aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/matroskaenc.c
diff options
context:
space:
mode:
authorJohn Stebbins <stebbins@jetheaddev.com>2013-09-03 10:53:34 -0700
committerAnton Khirnov <anton@khirnov.net>2013-09-04 20:30:43 +0200
commit26b241c0791bfeb9df7b873da4dc74cce0c06be3 (patch)
tree9dba310357d9bfdaa622d5f6e12bd3e20b196361 /libavformat/matroskaenc.c
parenta711a2cb473dc95708f371a82c85c97fe789b5c2 (diff)
downloadffmpeg-26b241c0791bfeb9df7b873da4dc74cce0c06be3.tar.gz
matroskaenc: Allow chapters to be written in trailer
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. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/matroskaenc.c')
-rw-r--r--libavformat/matroskaenc.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 825e92c82d..5edaa36c66 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) {