[FFmpeg-devel] [PATCH] lavf/matroska: Export codecdelay and seekpreroll as metadata tags

Vignesh Venkatasubramanian vigneshv at google.com
Tue Sep 17 23:34:05 CEST 2013


On Tue, Sep 17, 2013 at 2:13 PM, Hendrik Leppkes <h.leppkes at gmail.com> wrote:
>
> On Tue, Sep 17, 2013 at 9:36 PM, Vignesh Venkatasubramanian <
> vigneshv at google.com> wrote:
>
> > This patch exports the values of Codec Delay and Seek Preroll
> > container elements as metadata tags.
> >
> > Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> > ---
> >  libavformat/matroskadec.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> >
> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> > index 76c610b..dc82bbd 100644
> > --- a/libavformat/matroskadec.c
> > +++ b/libavformat/matroskadec.c
> > @@ -163,6 +163,8 @@ typedef struct {
> >      uint64_t default_duration;
> >      uint64_t flag_default;
> >      uint64_t flag_forced;
> > +    uint64_t codec_delay;
> > +    uint64_t seek_preroll;
> >      MatroskaTrackVideo video;
> >      MatroskaTrackAudio audio;
> >      MatroskaTrackOperation operation;
> > @@ -410,6 +412,8 @@ static EbmlSyntax matroska_track[] = {
> >      { MATROSKA_ID_TRACKOPERATION,       EBML_NEST, 0,
> > offsetof(MatroskaTrack,operation), {.n=matroska_track_operation} },
> >      { MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0,
> > {.n=matroska_track_encodings} },
> >      { MATROSKA_ID_TRACKMAXBLKADDID,     EBML_UINT, 0,
> > offsetof(MatroskaTrack,max_block_additional_id) },
> > +    { MATROSKA_ID_CODECDELAY,           EBML_UINT, 0,
> > offsetof(MatroskaTrack,codec_delay) },
> > +    { MATROSKA_ID_SEEKPREROLL,          EBML_UINT, 0,
> > offsetof(MatroskaTrack,seek_preroll) },
> >      { MATROSKA_ID_TRACKFLAGENABLED,     EBML_NONE },
> >      { MATROSKA_ID_TRACKFLAGLACING,      EBML_NONE },
> >      { MATROSKA_ID_CODECNAME,            EBML_NONE },
> > @@ -1821,6 +1825,21 @@ static int matroska_read_header(AVFormatContext *s)
> >              }
> >          }
> >
> > +        /* export codec delay and seek preroll as metadata tags */
> > +        if (track->codec_delay > 0) {
> > +            char codec_delay[25];
> > +            snprintf(codec_delay, sizeof(codec_delay), "%lu",
> > +                     track->codec_delay);
> > +            av_dict_set(&st->metadata, "codec_delay", codec_delay, 0);
> > +        }
> > +
> > +        if (track->seek_preroll > 0) {
> > +            char seek_preroll[25];
> > +            snprintf(seek_preroll, sizeof(seek_preroll), "%lu",
> > +                     track->seek_preroll);
> > +            av_dict_set(&st->metadata, "seek_preroll", seek_preroll, 0);
> > +        }
> > +
> >          if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
> >              MatroskaTrackPlane *planes =
> > track->operation.combine_planes.elem;
> >
> > --
> > 1.8.4
> >
> >
> The way i understood the new codec delay element, isn't this something the
> demuxer can completely take care of internally (ie. adjust timestamps), and
> the info wouldn't be needed externally?

Codec delay it the number of samples (represented in matroska as
nanoseconds) that the decoder has to discard from the beginning of the file
before the decoded data is considered valid. So, the demuxer cannot take
care of it internally.

> I guess you could still want it as metadata, but just wondering?

I am exporting this as metadata so that programs outside of libav* can make
use of these values (I am doing this specifically with chromium in mind).

>
> - Hendrik
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


More information about the ffmpeg-devel mailing list