On Tue, 3 Sep 2013 10:53:34 -0700, John Stebbins <[email protected]> wrote: > This allows creation of frame accurate chapter marks from sources like > DVD and BD where the precise chapter location is not known until the > chapter mark has been reached during reading. > --- > libavformat/avformat.h | 11 +++++++++++ > libavformat/matroskaenc.c | 10 +++++++++- > 2 files changed, 20 insertions(+), 1 deletion(-) > > diff --git a/libavformat/avformat.h b/libavformat/avformat.h > index 1399de0..12462c8 100644 > --- a/libavformat/avformat.h > +++ b/libavformat/avformat.h > @@ -948,6 +948,17 @@ typedef struct AVFormatContext { > */ > unsigned int max_picture_buffer; > > + /** > + * Number of chapters in AVChapter array. > + * When muxing, chapters are normally written in the file header, > + * so nb_chapters should normally be initialized before write_header > + * is called. Some muxers (e.g. mov and mkv) can also write chapters > + * in the trailer. To write chapters in the trailer, nb_chapters > + * must be zero when write_header is called and non-zero when > + * write_trailer is called. > + * muxing : set by user > + * demuxing: set by libavformat > + */ > unsigned int nb_chapters; > AVChapter **chapters; > > diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c > index 825e92c..5edaa36 100644 > --- a/libavformat/matroskaenc.c > +++ b/libavformat/matroskaenc.c > @@ -103,6 +103,7 @@ typedef struct MatroskaMuxContext { > int cluster_size_limit; > int64_t cues_pos; > int64_t cluster_time_limit; > + int wrote_chapters; > } MatroskaMuxContext; > > > @@ -710,7 +711,7 @@ static int mkv_write_chapters(AVFormatContext *s) > AVRational scale = {1, 1E9}; > int i, ret; > > - if (!s->nb_chapters) > + if (!s->nb_chapters || mkv->wrote_chapters) > return 0; > > ret = mkv_add_seekhead_entry(mkv->main_seekhead, MATROSKA_ID_CHAPTERS, > avio_tell(pb)); > @@ -743,6 +744,8 @@ static int mkv_write_chapters(AVFormatContext *s) > } > end_ebml_master(pb, editionentry); > end_ebml_master(pb, chapters); > + > + mkv->wrote_chapters = 1; > return 0; > } > > @@ -1391,6 +1394,11 @@ static int mkv_write_trailer(AVFormatContext *s) > end_ebml_master(pb, mkv->cluster); > } > > + if (mkv->mode != MODE_WEBM) { > + ret = mkv_write_chapters(s); > + if (ret < 0) return ret; > + } > + > if (pb->seekable) { > if (mkv->cues->num_entries) { > if (mkv->reserve_cues_space) { > -- > 1.8.3.1 >
Ok, pushed -- Anton Khirnov _______________________________________________ libav-devel mailing list [email protected] https://lists.libav.org/mailman/listinfo/libav-devel
