summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-21 10:59:02 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-21 11:00:26 +0200
commita76390d100ec85f88a7d48ddad476c4a685008f9 (patch)
tree7ccbaef8bdecc03a34df517d62466d4f059a5f1b /libavformat
parent8d63aaed1efe58d951c312bad01d38277518fa36 (diff)
parent6c786765cd5eb794dedd4a0970dfe689b16dfeeb (diff)
Merge commit '6c786765cd5eb794dedd4a0970dfe689b16dfeeb'
* commit '6c786765cd5eb794dedd4a0970dfe689b16dfeeb': movenc: Allow chapters to be written in trailer Conflicts: libavformat/movenc.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 4dae71309c..8525e57ef9 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3628,7 +3628,9 @@ static int mov_write_header(AVFormatContext *s)
mov->nb_streams += mov->nb_meta_tmcd;
}
- mov->tracks = av_mallocz(mov->nb_streams * sizeof(*mov->tracks));
+ // Reserve an extra stream for chapters for the case where chapters
+ // are written in the trailer
+ mov->tracks = av_mallocz((mov->nb_streams + 1) * sizeof(*mov->tracks));
if (!mov->tracks)
return AVERROR(ENOMEM);
@@ -3897,9 +3899,9 @@ static int mov_write_trailer(AVFormatContext *s)
{
MOVMuxContext *mov = s->priv_data;
AVIOContext *pb = s->pb;
- int64_t moov_pos;
int res = 0;
int i;
+ int64_t moov_pos;
/*
* Before actually writing the trailer, make sure that there are no
@@ -3914,6 +3916,16 @@ static int mov_write_trailer(AVFormatContext *s)
}
}
+ // If there were no chapters when the header was written, but there
+ // are chapters now, write them in the trailer. This only works
+ // when we are not doing fragments.
+ if (!mov->chapter_track && !(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
+ if (mov->mode & (MODE_MP4|MODE_MOV|MODE_IPOD) && s->nb_chapters) {
+ mov->chapter_track = mov->nb_streams++;
+ mov_create_chapter_track(s, mov->chapter_track);
+ }
+ }
+
moov_pos = avio_tell(pb);
if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {