summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-08-22 13:42:47 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-08-22 13:58:23 +0200
commit606a30c5a11522130658e0807b340ce922a390a6 (patch)
treedc512be593b28a155b554eb7c709f481c43c4256
parentd68adbd666cbc1180380034324d86cb31f1f77ae (diff)
parentfe5d5a8ffcafdc14c0d26eaea6464c89e120cc9e (diff)
Merge commit 'fe5d5a8ffcafdc14c0d26eaea6464c89e120cc9e'
* commit 'fe5d5a8ffcafdc14c0d26eaea6464c89e120cc9e': movenc: Make chapter track QuickTime compatible Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/movenc.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 1af2d1dbf4..b31338858d 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -3382,7 +3382,7 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
// QuickTime chapters involve an additional text track with the chapter names
// as samples, and a tref pointing from the other tracks to the chapter one.
-static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
+static int mov_create_chapter_track(AVFormatContext *s, int tracknum)
{
AVIOContext *pb;
@@ -3390,13 +3390,21 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
MOVTrack *track = &mov->tracks[tracknum];
AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
int i, len;
+ // These properties are required to make QT recognize the chapter track
+ uint8_t chapter_properties[43] = { 0, 0, 0, 0, 0, 0, 0, 1, };
track->mode = mov->mode;
track->tag = MKTAG('t','e','x','t');
track->timescale = MOV_TIMESCALE;
track->enc = avcodec_alloc_context3(NULL);
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
-
+#if 0
+ track->enc->extradata = av_malloc(sizeof(chapter_properties));
+ if (track->enc->extradata == NULL)
+ return AVERROR(ENOMEM);
+ track->enc->extradata_size = sizeof(chapter_properties);
+ memcpy(track->enc->extradata, chapter_properties, sizeof(chapter_properties));
+#else
if (avio_open_dyn_buf(&pb) >= 0) {
int size;
uint8_t *buf;
@@ -3440,6 +3448,7 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
av_free(&buf);
}
}
+#endif
for (i = 0; i < s->nb_chapters; i++) {
AVChapter *c = s->chapters[i];
@@ -3459,6 +3468,8 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
av_freep(&pkt.data);
}
}
+
+ return 0;
}
static int mov_create_timecode_track(AVFormatContext *s, int index, int src_index, const char *tcstr)
@@ -3978,8 +3989,10 @@ static int mov_write_trailer(AVFormatContext *s)
mov_write_mfra_tag(pb, mov);
}
- if (mov->chapter_track)
+ if (mov->chapter_track) {
+ av_free(mov->tracks[mov->chapter_track].enc->extradata);
av_freep(&mov->tracks[mov->chapter_track].enc);
+ }
for (i = 0; i < mov->nb_streams; i++) {
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))