<div dir="ltr"><div dir="ltr"><br></div><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">
> In such a case, am I right in assuming that using a stream of type<br>
> AV_MEDIA_TYPE_DATA that uses codec AV_CODEC_ID_SMPTE_KLV is a good way to<br>
> go? Something similar to how it is suggested here?<br>
> <a href="https://stackoverflow.com/q/68304330/17261462" rel="noreferrer" target="_blank">https://stackoverflow.com/q/68304330/17261462</a><br>
Its hard to say, since I'm not sure what your functional need is. If the <br>
content isn't KLV (see below), then saying AV_CODEC_ID_SMPTE_KLV isn't <br>
correct.<br>
That SO post looks to be more transport stream oriented. YMMV with ffmpeg and <br>
EMSG.<br>
<br>
> Now, for the message itself, is there a recommended MISB compliant KLV<br>
> library or is it OK to "hack" it by say using protobuf for serialising the<br>
> metadata (similar to <a href="https://github.com/Parrot-Developers/libvideo-metadata" rel="noreferrer" target="_blank">https://github.com/Parrot-Developers/libvideo-metadata</a><br>
> )?<br>
Depends on interoperability need. If you want to do something MISB compliant, <br>
then protobuf is not OK.  If its just for you, then you can package it to meet <br>
your needs.<br></blockquote><div><br></div><div><div>Thanks for the feedback. In terms of functional needs, I am interested in storing some 
frame-level metadata in a fragmented mp4 file. The resulting video 
should be readable in a standard media player. If the metadata stream is
 compliant with an existing standard (e.g. <span class="gmail-im">MISB or ISOBMFF</span>), that would be best but otherwise, I
 am fine with a non-standard-compliant metadata stream that I am able to write and read back with libav.</div><div><br></div><div>The reason I was referring to that SO post is that is while it focuses on streaming, it seems to have the most detailed sample code for setting up a KLV stream with ffmpeg / libav.</div><div><br></div><div>I tried adding a KLV track within the muxing.c example code from ffmpeg</div><div><a href="https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/examples/muxing.c">https://github.com/FFmpeg/FFmpeg/blob/release/5.0/doc/examples/muxing.c</a></div><div>but haven't managed to do so yet. My initial attempts lead to the following error message:</div><div>"Could not find tag for codec klv in stream #2, codec not currently supported in container"</div><div><br></div><div>This led me to taking a step back and try from the ffmpeg command line. Unfortunately ffmpeg is also throwing an error when trying to copy a (suposedly) valid KLV stream (from the library of ffmpeg sample files) to an mp4 or mpg file (despite the original file with KLV data being an mpg file). Calling<br></div><div>ffmpeg -i <a href="https://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg">https://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg</a> -c copy -map 0 test.mp4</div><div>indeed also leads to</div><div>"Could not find tag for codec klv in stream #1, codec not currently supported in container"</div><div><br></div><div>It works with a ts file though. <br></div><div>ffmpeg -i <a href="https://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg">https://samples.ffmpeg.org/MPEG2/mpegts-klv/Day%20Flight.mpg</a> -c copy -map 0 test.ts</div><div><br></div><div>Does this mean that muxing a KLV stream in an mp4 is not yet supported by libav or is there a workaround for this? If the former, would muxing a datastream with a different codec be supported in an mp4?</div><div><br></div><div>It would be great if the muxing.c example could be expanded to include a data stream.<br></div><div><br> </div></div></div></div>