mirror of
https://github.com/xenia-project/FFmpeg.git
synced 2024-11-25 12:40:01 +00:00
move track timescale/sampleDuration init to write_header and return error if not set
Originally committed as revision 6167 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
5c07cf535f
commit
ffb512e349
@ -1299,14 +1299,6 @@ static int mov_write_moov_tag(ByteIOContext *pb, MOVContext *mov,
|
|||||||
for (i=0; i<mov->nb_streams; i++) {
|
for (i=0; i<mov->nb_streams; i++) {
|
||||||
if(mov->tracks[i].entry <= 0) continue;
|
if(mov->tracks[i].entry <= 0) continue;
|
||||||
|
|
||||||
if(mov->tracks[i].enc->codec_type == CODEC_TYPE_VIDEO) {
|
|
||||||
mov->tracks[i].timescale = mov->tracks[i].enc->time_base.den;
|
|
||||||
mov->tracks[i].sampleDuration = mov->tracks[i].enc->time_base.num;
|
|
||||||
} else if(mov->tracks[i].enc->codec_type == CODEC_TYPE_AUDIO) {
|
|
||||||
mov->tracks[i].timescale = mov->tracks[i].enc->sample_rate;
|
|
||||||
mov->tracks[i].sampleDuration = mov->tracks[i].enc->frame_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
mov->tracks[i].trackDuration =
|
mov->tracks[i].trackDuration =
|
||||||
(int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
|
(int64_t)mov->tracks[i].sampleCount * mov->tracks[i].sampleDuration;
|
||||||
mov->tracks[i].time = mov->time;
|
mov->tracks[i].time = mov->time;
|
||||||
@ -1468,12 +1460,20 @@ static int mov_write_header(AVFormatContext *s)
|
|||||||
track->mode = mov->mode;
|
track->mode = mov->mode;
|
||||||
if(st->codec->codec_type == CODEC_TYPE_VIDEO){
|
if(st->codec->codec_type == CODEC_TYPE_VIDEO){
|
||||||
track->tag = mov_find_video_codec_tag(s, track);
|
track->tag = mov_find_video_codec_tag(s, track);
|
||||||
|
track->timescale = st->codec->time_base.den;
|
||||||
|
track->sampleDuration = st->codec->time_base.num;
|
||||||
av_set_pts_info(st, 64, 1, st->codec->time_base.den);
|
av_set_pts_info(st, 64, 1, st->codec->time_base.den);
|
||||||
}else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
|
}else if(st->codec->codec_type == CODEC_TYPE_AUDIO){
|
||||||
track->tag = mov_find_audio_codec_tag(s, track);
|
track->tag = mov_find_audio_codec_tag(s, track);
|
||||||
|
track->timescale = st->codec->sample_rate;
|
||||||
|
track->sampleDuration = st->codec->frame_size;
|
||||||
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
|
||||||
track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
|
track->sampleSize = (av_get_bits_per_sample(st->codec->codec_id) >> 3) * st->codec->channels;
|
||||||
}
|
}
|
||||||
|
if (!track->sampleDuration) {
|
||||||
|
av_log(s, AV_LOG_ERROR, "track %d: sample duration is not set\n", i);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mov_write_mdat_tag(pb, mov);
|
mov_write_mdat_tag(pb, mov);
|
||||||
|
Loading…
Reference in New Issue
Block a user