[Libav-user] maxhap: Set SEI unregistered user message using H264MetadataContext
sw at jkqxz.net
Thu Dec 20 22:56:04 EET 2018
On 19/12/2018 16:21, Max Ashton wrote:
> Hi all and thanks for reading!
> I'm trying to set the SEI unregistered user message on a per video frame basis. I notice that libav has a H264MetadataContext structure which contains a const char *sei_user_data field. This seems to be exactly what I'm looking for. After poking around in the ffmpeg code I notice this structure is wrapped within the private data of the AVBSFContext. My knowledge is extremely limited so at this point I'm looking for an example or explanation on how to correctly access the H264MetadataContext structure. I presume I need a bit stream filter (based on the naming), but can't find any examples of setting the H264MetadataContext.
> Can anyone help me with an explanation, code snippet or point me to an example I might have missed/overlooked?
> Any general advice would also be appreciated. I have checked the few similar questions on stackoverflow, they don't seem to have any solid answers or explanations though (maybe due to my lack of understanding).
You're looking at internal code inside the h264_metadata BSF. It only supports inserting the same thing on all IRAP access units - the intended use-case is adding global metadata (such as fixing up odd bugs like the x264 4:4:4 8x8 problem). If you only want to use it for that, then you can make an instance of the h264_metadata BSF, set the sei_user_data option on it, and pass packets through it with the external BSF API.
If you want something more, there isn't any external API to do it. The internal CBS API does offer complete decomposition of the coded bitstream, including the SEI user data, and can be used to implement whatever you like there (indeed, the h264_metadata BSF uses it). That would require editing the FFmpeg source, though, and there is no guarantee of API stability for internals like that. If you want to go that way then the easiest approach is probably to hack something in to the h264_metadata BSF, though making another BSF or just adding new external API calls are equally possible.
More information about the Libav-user