|
|
@ -2014,9 +2014,9 @@ static int transcode_init(OutputFile *output_files, |
|
|
|
codec->codec_type = icodec->codec_type; |
|
|
|
codec->codec_type = icodec->codec_type; |
|
|
|
|
|
|
|
|
|
|
|
if (!codec->codec_tag) { |
|
|
|
if (!codec->codec_tag) { |
|
|
|
if( !oc->oformat->codec_tag |
|
|
|
if (!oc->oformat->codec_tag || |
|
|
|
|| av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id |
|
|
|
av_codec_get_id (oc->oformat->codec_tag, icodec->codec_tag) == codec->codec_id || |
|
|
|
|| av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) |
|
|
|
av_codec_get_tag(oc->oformat->codec_tag, icodec->codec_id) <= 0) |
|
|
|
codec->codec_tag = icodec->codec_tag; |
|
|
|
codec->codec_tag = icodec->codec_tag; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -2029,13 +2029,16 @@ static int transcode_init(OutputFile *output_files, |
|
|
|
} |
|
|
|
} |
|
|
|
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); |
|
|
|
memcpy(codec->extradata, icodec->extradata, icodec->extradata_size); |
|
|
|
codec->extradata_size = icodec->extradata_size; |
|
|
|
codec->extradata_size = icodec->extradata_size; |
|
|
|
if(!copy_tb && av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && av_q2d(ist->st->time_base) < 1.0/500){ |
|
|
|
if (!copy_tb && |
|
|
|
|
|
|
|
av_q2d(icodec->time_base)*icodec->ticks_per_frame > av_q2d(ist->st->time_base) && |
|
|
|
|
|
|
|
av_q2d(ist->st->time_base) < 1.0/500) { |
|
|
|
codec->time_base = icodec->time_base; |
|
|
|
codec->time_base = icodec->time_base; |
|
|
|
codec->time_base.num *= icodec->ticks_per_frame; |
|
|
|
codec->time_base.num *= icodec->ticks_per_frame; |
|
|
|
av_reduce(&codec->time_base.num, &codec->time_base.den, |
|
|
|
av_reduce(&codec->time_base.num, &codec->time_base.den, |
|
|
|
codec->time_base.num, codec->time_base.den, INT_MAX); |
|
|
|
codec->time_base.num, codec->time_base.den, INT_MAX); |
|
|
|
} else |
|
|
|
} else |
|
|
|
codec->time_base = ist->st->time_base; |
|
|
|
codec->time_base = ist->st->time_base; |
|
|
|
|
|
|
|
|
|
|
|
switch(codec->codec_type) { |
|
|
|
switch(codec->codec_type) { |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
if(audio_volume != 256) { |
|
|
|
if(audio_volume != 256) { |
|
|
@ -2075,8 +2078,10 @@ static int transcode_init(OutputFile *output_files, |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!ost->enc) |
|
|
|
if (!ost->enc) |
|
|
|
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); |
|
|
|
ost->enc = avcodec_find_encoder(ost->st->codec->codec_id); |
|
|
|
|
|
|
|
|
|
|
|
ist->decoding_needed = 1; |
|
|
|
ist->decoding_needed = 1; |
|
|
|
ost->encoding_needed = 1; |
|
|
|
ost->encoding_needed = 1; |
|
|
|
|
|
|
|
|
|
|
|
switch(codec->codec_type) { |
|
|
|
switch(codec->codec_type) { |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
case AVMEDIA_TYPE_AUDIO: |
|
|
|
ost->fifo = av_fifo_alloc(1024); |
|
|
|
ost->fifo = av_fifo_alloc(1024); |
|
|
@ -2084,18 +2089,22 @@ static int transcode_init(OutputFile *output_files, |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
} |
|
|
|
} |
|
|
|
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); |
|
|
|
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); |
|
|
|
|
|
|
|
|
|
|
|
if (!codec->sample_rate) |
|
|
|
if (!codec->sample_rate) |
|
|
|
codec->sample_rate = icodec->sample_rate; |
|
|
|
codec->sample_rate = icodec->sample_rate; |
|
|
|
choose_sample_rate(ost->st, ost->enc); |
|
|
|
choose_sample_rate(ost->st, ost->enc); |
|
|
|
codec->time_base = (AVRational){1, codec->sample_rate}; |
|
|
|
codec->time_base = (AVRational){1, codec->sample_rate}; |
|
|
|
|
|
|
|
|
|
|
|
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) |
|
|
|
if (codec->sample_fmt == AV_SAMPLE_FMT_NONE) |
|
|
|
codec->sample_fmt = icodec->sample_fmt; |
|
|
|
codec->sample_fmt = icodec->sample_fmt; |
|
|
|
choose_sample_fmt(ost->st, ost->enc); |
|
|
|
choose_sample_fmt(ost->st, ost->enc); |
|
|
|
|
|
|
|
|
|
|
|
if (!codec->channels) |
|
|
|
if (!codec->channels) |
|
|
|
codec->channels = icodec->channels; |
|
|
|
codec->channels = icodec->channels; |
|
|
|
codec->channel_layout = icodec->channel_layout; |
|
|
|
codec->channel_layout = icodec->channel_layout; |
|
|
|
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) |
|
|
|
if (av_get_channel_layout_nb_channels(codec->channel_layout) != codec->channels) |
|
|
|
codec->channel_layout = 0; |
|
|
|
codec->channel_layout = 0; |
|
|
|
|
|
|
|
|
|
|
|
ost->audio_resample = codec-> sample_rate != icodec->sample_rate || audio_sync_method > 1; |
|
|
|
ost->audio_resample = codec-> sample_rate != icodec->sample_rate || audio_sync_method > 1; |
|
|
|
icodec->request_channels = codec-> channels; |
|
|
|
icodec->request_channels = codec-> channels; |
|
|
|
ost->resample_sample_fmt = icodec->sample_fmt; |
|
|
|
ost->resample_sample_fmt = icodec->sample_fmt; |
|
|
|