movenc: Make chapter track QuickTime compatible
QuickTime requires that the stsd.text box be completely filled in. Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
parent
f8ef91ff3d
commit
fe5d5a8ffc
@ -2980,18 +2980,25 @@ static int mov_write_packet(AVFormatContext *s, AVPacket *pkt)
|
|||||||
|
|
||||||
// QuickTime chapters involve an additional text track with the chapter names
|
// 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.
|
// 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)
|
||||||
{
|
{
|
||||||
MOVMuxContext *mov = s->priv_data;
|
MOVMuxContext *mov = s->priv_data;
|
||||||
MOVTrack *track = &mov->tracks[tracknum];
|
MOVTrack *track = &mov->tracks[tracknum];
|
||||||
AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
|
AVPacket pkt = { .stream_index = tracknum, .flags = AV_PKT_FLAG_KEY };
|
||||||
int i, len;
|
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->mode = mov->mode;
|
||||||
track->tag = MKTAG('t','e','x','t');
|
track->tag = MKTAG('t','e','x','t');
|
||||||
track->timescale = MOV_TIMESCALE;
|
track->timescale = MOV_TIMESCALE;
|
||||||
track->enc = avcodec_alloc_context3(NULL);
|
track->enc = avcodec_alloc_context3(NULL);
|
||||||
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
track->enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
|
||||||
|
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));
|
||||||
|
|
||||||
for (i = 0; i < s->nb_chapters; i++) {
|
for (i = 0; i < s->nb_chapters; i++) {
|
||||||
AVChapter *c = s->chapters[i];
|
AVChapter *c = s->chapters[i];
|
||||||
@ -3011,6 +3018,8 @@ static void mov_create_chapter_track(AVFormatContext *s, int tracknum)
|
|||||||
av_freep(&pkt.data);
|
av_freep(&pkt.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mov_write_header(AVFormatContext *s)
|
static int mov_write_header(AVFormatContext *s)
|
||||||
@ -3379,8 +3388,10 @@ static int mov_write_trailer(AVFormatContext *s)
|
|||||||
mov_write_mfra_tag(pb, mov);
|
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);
|
av_freep(&mov->tracks[mov->chapter_track].enc);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; i < mov->nb_streams; i++) {
|
for (i = 0; i < mov->nb_streams; i++) {
|
||||||
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
|
if (mov->tracks[i].tag == MKTAG('r','t','p',' '))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user