|
|
|
@@ -1600,7 +1600,9 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVTrack *track, AVStream *st) |
|
|
|
(version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */ |
|
|
|
ffio_wfourcc(pb, "tkhd"); |
|
|
|
avio_w8(pb, version); |
|
|
|
avio_wb24(pb, track->secondary ? 0x2 : 0xf); /* flags (first track enabled) */ |
|
|
|
avio_wb24(pb, (track->flags & MOV_TRACK_ENABLED) ? |
|
|
|
MOV_TKHD_FLAG_ENABLED | MOV_TKHD_FLAG_IN_MOVIE : |
|
|
|
MOV_TKHD_FLAG_IN_MOVIE); |
|
|
|
if (version == 1) { |
|
|
|
avio_wb64(pb, track->time); |
|
|
|
avio_wb64(pb, track->time); |
|
|
|
@@ -2331,7 +2333,6 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int64_t pos = avio_tell(pb); |
|
|
|
int not_first[AVMEDIA_TYPE_NB]={0}; |
|
|
|
avio_wb32(pb, 0); /* size placeholder*/ |
|
|
|
ffio_wfourcc(pb, "moov"); |
|
|
|
|
|
|
|
@@ -2372,13 +2373,6 @@ static int mov_write_moov_tag(AVIOContext *pb, MOVMuxContext *mov, |
|
|
|
mov_write_iods_tag(pb, mov); |
|
|
|
for (i = 0; i < mov->nb_streams; i++) { |
|
|
|
if (mov->tracks[i].entry > 0 || mov->flags & FF_MOV_FLAG_FRAGMENT) { |
|
|
|
if (i < s->nb_streams){ |
|
|
|
int codec_type= s->streams[i]->codec->codec_type; |
|
|
|
if (codec_type==AVMEDIA_TYPE_AUDIO || codec_type==AVMEDIA_TYPE_SUBTITLE){ |
|
|
|
mov->tracks[i].secondary= not_first[codec_type]; |
|
|
|
not_first[codec_type]= 1; |
|
|
|
} |
|
|
|
} |
|
|
|
mov_write_trak_tag(pb, mov, &(mov->tracks[i]), i < s->nb_streams ? s->streams[i] : NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -3510,6 +3504,56 @@ static int mov_create_timecode_track(AVFormatContext *s, int index, int src_inde |
|
|
|
return ret; |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* st->disposition controls the "enabled" flag in the tkhd tag. |
|
|
|
* QuickTime will not play a track if it is not enabled. So make sure |
|
|
|
* that one track of each type (audio, video, subtitle) is enabled. |
|
|
|
* |
|
|
|
* Subtitles are special. For audio and video, setting "enabled" also |
|
|
|
* makes the track "default" (i.e. it is rendered when played). For |
|
|
|
* subtitles, an "enabled" subtitle is not rendered by default, but |
|
|
|
* if no subtitle is enabled, the subtitle menu in QuickTime will be |
|
|
|
* empty! |
|
|
|
*/ |
|
|
|
static void enable_tracks(AVFormatContext *s) |
|
|
|
{ |
|
|
|
MOVMuxContext *mov = s->priv_data; |
|
|
|
int i; |
|
|
|
uint8_t enabled[AVMEDIA_TYPE_NB]; |
|
|
|
int first[AVMEDIA_TYPE_NB]; |
|
|
|
|
|
|
|
for (i = 0; i < AVMEDIA_TYPE_NB; i++) { |
|
|
|
enabled[i] = 0; |
|
|
|
first[i] = -1; |
|
|
|
} |
|
|
|
|
|
|
|
for (i = 0; i < s->nb_streams; i++) { |
|
|
|
AVStream *st = s->streams[i]; |
|
|
|
|
|
|
|
if (st->codec->codec_type <= AVMEDIA_TYPE_UNKNOWN || |
|
|
|
st->codec->codec_type >= AVMEDIA_TYPE_NB) |
|
|
|
continue; |
|
|
|
|
|
|
|
if (first[st->codec->codec_type] < 0) |
|
|
|
first[st->codec->codec_type] = i; |
|
|
|
if (st->disposition & AV_DISPOSITION_DEFAULT) { |
|
|
|
mov->tracks[i].flags |= MOV_TRACK_ENABLED; |
|
|
|
enabled[st->codec->codec_type] = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (i = 0; i < AVMEDIA_TYPE_NB; i++) { |
|
|
|
switch (i) { |
|
|
|
case AVMEDIA_TYPE_VIDEO: |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
case AVMEDIA_TYPE_SUBTITLE: |
|
|
|
if (!enabled[i] && first[i] >= 0) |
|
|
|
mov->tracks[first[i]].flags |= MOV_TRACK_ENABLED; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
static int mov_write_header(AVFormatContext *s) |
|
|
|
{ |
|
|
|
AVIOContext *pb = s->pb; |
|
|
|
@@ -3720,6 +3764,8 @@ static int mov_write_header(AVFormatContext *s) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
enable_tracks(s); |
|
|
|
|
|
|
|
if (mov->mode == MODE_ISM) { |
|
|
|
/* If no fragmentation options have been set, set a default. */ |
|
|
|
if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME | |
|
|
|
|