[FFmpeg-devel] [PATCH v5 1/6] libavcodec: Add generic metadata injection using AV_PKT_DATA_METADATA_UPDATE
Romain Beauxis
romain.beauxis at gmail.com
Mon Feb 17 21:18:41 EET 2025
Le lun. 17 févr. 2025 à 13:10, Lynne <dev at lynne.ee> a écrit :
>
> On 17/02/2025 17:19, Romain Beauxis wrote:
> > libavcodec/decode.c: intercept `AV_PKT_DATA_METADATA_UPDATE` packet extra data,
> > attach them to the next decoded frame.
> >
> > The metadata needs to be cached because there is no guarantee that each packet
> > will generate a decoded frame immediately.
> >
> > `AV_PKT_DATA_METADATA_UPDATE` does not seem used in `libavcodec` at the moment
> > so regression risks seem low.
> >
> > This generic mechanism could be reused to support more in-band metadata update
> > in the future.
>
> Much cleaner than before, thanks.
Thanks for the guidance!
> Which packets will not generate a decoded frame immediately? When it
> comes to audio, all of them should output something immediately.
> The code is correct, metadata updates could occur on B-frames in video.
> Just wondering.
I was working from memory about ogg/flac but got it wrong: flac frames
map to ogg packets BUT they can span page boundaries:
> * Native FLAC audio frames appear as subsequent packets in the stream. Each packet corresponds to one FLAC audio frame. The first byte of each packet serves as the packet type. >. Since audio packets are native FLAC frames, this first byte will be always 0xFF according to the native FLAC format specification.
> * The last page is marked 'end of stream' in the page flags.
> * FLAC packets may span page boundaries.
Source: https://xiph.org/flac/ogg_mapping.html
This is a bit confusing, though.
At any rate, however, in the current implementation, flac ogg packet
headers are still exported by the demuxer and later ignored by the
decoder.
These packets would not generate an audio frame.
I'm happy to work on further improvement on this as discussed. Then we
could consider un-caching the metadata.
-- Romain
More information about the ffmpeg-devel
mailing list