'ffmpeg H264 - How to add user unregistered SEI Message while encoding stream

I'm working on an application where I need to insert some user unregistered SEI data in every frame before encoding it. I can't seem to find any API to add the SEI data. What I need to do is probably option 1 to the answer of this post; but I'm not sure on how to proceed.?

I've tried setting "sei" through the AvCodecContext priv_data, using av_opt_set as follows: (as well as changing the parameters quite a bit).

AVCodecContext* c;

char *sei_msg = (char *)malloc(lenData);   // just a sample usage of how...
memcpy(sei_msg, data, lenData);            // ...i have my sei_message

av_opt_set(c,"sei", sei_msg, 0)

Not sure if this is the correct direction for this?

How do I set the data that i'm adding is a Nal of type SEI (6) and that the SEI is of type User_Data_Unregistered (5). And then go about adding this data?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source