<div dir="ltr"><blockquote dir="ltr" class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I am interested in storing custom metadata on a per frame level in a mov or mp4 file. It looks like using <span>user
data unregistered (UDU) supplemental enhancement information (SEI) may
be a suitable approach for this. I am however struggling to get this to
work as I am always reading back the custom message I used for the first
frame.</span></blockquote><div><br></div><div>Turns out I was wrongly assuming from the API that there can be only one item of <span><span>AV_FRAME_DATA_SEI_UNREGISTERED. I was accumulating messages in a single frame and only displaying the first one.</span></span></div><div><span><span><br></span></span></div><div><span><span>This is now fixed in my gist by calling `</span></span>av_frame_remove_side_data<span><span>`:</span></span></div><div><a href="https://gist.github.com/tvercaut/94c68e46d0d0321a2c83b88024d9cd69">https://gist.github.com/tvercaut/94c68e46d0d0321a2c83b88024d9cd69</a></div><div><br></div><div>It seems a bit unclear to me though why `av_frame_get_side_data` only returns the first item rather than a list of items.<br></div><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div dir="auto">> I am however struggling to get this to work as I am always reading back the custom message I used for the first frame.<br><br>You can't, at least using FFmpeg Tools. I am not sure if there is an libavXXX function which would allow you to, but FFMpeg tools themselves cannot. Looking at the FFmpeg patches for Apple's ambient viewing brightness, and from Discussions in the FFmpeg IRC, I understand that to extract that data you need to register a UUID for your usecase in libavcodec to be able to pull information, which means modifying libavcodec. Don't know how accurate my understanding is though.<br><br>You can follow <<a href="https://stackoverflow.com/questions/67283568" target="_blank">https://stackoverflow.com/questions/67283568</a> to get FFMpeg to announce the presence of an unrecognized custom SEI Message, but there is no function to actually display it.<br><br>In my project I resorted to reading the H264 Stream binary as a whole, scanning for the UUID / Magic Number of the SEI Message and extracting the JSON Data that way. Performance wise this was actually really good, as I could export nice Charts of my Data without interfacing with FFmpeg, but that is really more of a hackye workaround.<br><br>I think injecting custom data through SEI messages is really cool, as you can Livestream sensor data in tandem with video, without sync issues. Hope this workflow can become more elegant and less hacky.<br></div></div></blockquote><div><br></div>Thanks. I found a way with libav as mentioned above but would still be interested in being able to extract that SEI from the ffmpeg command line.<br></div></div>