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

Hendrik Leppkes h.leppkes at gmail.com
Tue Sep 17 23:13:01 CEST 2013


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?
I guess you could still want it as metadata, but just wondering?

- Hendrik


More information about the ffmpeg-devel mailing list