[FFmpeg-devel] [PATCH 3/3] lavf/matroskadec: export chained segment chapter metadata.

wm4 nfxjfg at googlemail.com
Fri Feb 27 20:07:23 CET 2015


On Fri, 27 Feb 2015 16:50:30 +0100
Nicolas George <george at nsup.org> wrote:

> Signed-off-by: Nicolas George <george at nsup.org>
> ---
>  libavformat/matroska.h    | 1 +
>  libavformat/matroskadec.c | 6 +++++-
>  2 files changed, 6 insertions(+), 1 deletion(-)
> 
> 
> This is not real support for chained Matroska files, but at least
> applications using only lavf will have the relevant information to implement
> playback.

This isn't enough information to implement ordered chapters.

> 
> diff --git a/libavformat/matroska.h b/libavformat/matroska.h
> index 391c56c..1506307 100644
> --- a/libavformat/matroska.h
> +++ b/libavformat/matroska.h
> @@ -226,6 +226,7 @@
>  #define MATROSKA_ID_CHAPTERFLAGHIDDEN   0x98
>  #define MATROSKA_ID_CHAPTERFLAGENABLED  0x4598
>  #define MATROSKA_ID_CHAPTERPHYSEQUIV    0x63C3
> +#define MATROSKA_ID_CHAPTERSEGMENTUID   0x6E67
>  
>  typedef enum {
>    MATROSKA_TRACK_TYPE_NONE     = 0x0,
> diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
> index f8519b7..07cf194 100644
> --- a/libavformat/matroskadec.c
> +++ b/libavformat/matroskadec.c
> @@ -203,6 +203,7 @@ typedef struct MatroskaChapter {
>      uint64_t end;
>      uint64_t uid;
>      char    *title;
> +    EbmlBin segment_uid;
>  
>      AVChapter *chapter;
>  } MatroskaChapter;
> @@ -479,6 +480,7 @@ static EbmlSyntax matroska_chapter_entry[] = {
>      { MATROSKA_ID_CHAPTERTIMESTART,   EBML_UINT, 0, offsetof(MatroskaChapter, start), { .u = AV_NOPTS_VALUE } },
>      { MATROSKA_ID_CHAPTERTIMEEND,     EBML_UINT, 0, offsetof(MatroskaChapter, end),   { .u = AV_NOPTS_VALUE } },
>      { MATROSKA_ID_CHAPTERUID,         EBML_UINT, 0, offsetof(MatroskaChapter, uid) },
> +    { MATROSKA_ID_CHAPTERSEGMENTUID,  EBML_BIN,  0, offsetof(MatroskaChapter, segment_uid) },
>      { MATROSKA_ID_CHAPTERDISPLAY,     EBML_NEST, 0,                        0,         { .n = matroska_chapter_display } },
>      { MATROSKA_ID_CHAPTERFLAGHIDDEN,  EBML_NONE },
>      { MATROSKA_ID_CHAPTERFLAGENABLED, EBML_NONE },
> @@ -2185,7 +2187,7 @@ static int matroska_read_header(AVFormatContext *s)
>      chapters = chapters_list->elem;
>      for (i = 0; i < chapters_list->nb_elem; i++)
>          if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid &&
> -            (max_start == 0 || chapters[i].start > max_start)) {
> +            (max_start == 0 || chapters[i].start > max_start || chapters[i].segment_uid.size)) {
>              chapters[i].chapter =
>                  avpriv_new_chapter(s, chapters[i].uid,
>                                     (AVRational) { 1, 1000000000 },
> @@ -2194,6 +2196,8 @@ static int matroska_read_header(AVFormatContext *s)
>              if (chapters[i].chapter) {
>                  av_dict_set(&chapters[i].chapter->metadata,
>                              "title", chapters[i].title, 0);
> +                matroska_metadata_uid(s, &chapters[i].chapter->metadata,
> +                                      &chapters[i].segment_uid);
>              }
>              max_start = chapters[i].start;
>          }



More information about the ffmpeg-devel mailing list