It's broken with multiple files or audio streams.
This removes the default samplerate of 44100 for raw input, hence all
the FATE changes.
| ... | ... |
@@ -163,7 +163,7 @@ static char *vfilters = NULL; |
| 163 | 163 |
#endif |
| 164 | 164 |
|
| 165 | 165 |
static int intra_only = 0; |
| 166 |
-static int audio_sample_rate = 44100; |
|
| 166 |
+static int audio_sample_rate = 0; |
|
| 167 | 167 |
static int64_t channel_layout = 0; |
| 168 | 168 |
#define QSCALE_NONE -99999 |
| 169 | 169 |
static float audio_qscale = QSCALE_NONE; |
| ... | ... |
@@ -2170,6 +2170,13 @@ static int transcode(AVFormatContext **output_files, |
| 2170 | 2170 |
if(!ost->fifo) |
| 2171 | 2171 |
goto fail; |
| 2172 | 2172 |
ost->reformat_pair = MAKE_SFMT_PAIR(AV_SAMPLE_FMT_NONE,AV_SAMPLE_FMT_NONE); |
| 2173 |
+ if (!codec->sample_rate) {
|
|
| 2174 |
+ codec->sample_rate = icodec->sample_rate; |
|
| 2175 |
+ if (icodec->lowres) |
|
| 2176 |
+ codec->sample_rate >>= icodec->lowres; |
|
| 2177 |
+ } |
|
| 2178 |
+ choose_sample_rate(ost->st, codec->codec); |
|
| 2179 |
+ codec->time_base = (AVRational){1, codec->sample_rate};
|
|
| 2173 | 2180 |
ost->audio_resample = codec->sample_rate != icodec->sample_rate || audio_sync_method > 1; |
| 2174 | 2181 |
icodec->request_channels = codec->channels; |
| 2175 | 2182 |
ist->decoding_needed = 1; |
| ... | ... |
@@ -3268,15 +3275,9 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3268 | 3268 |
set_context_opts(dec, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_DECODING_PARAM, input_codecs[nb_input_codecs-1]); |
| 3269 | 3269 |
channel_layout = dec->channel_layout; |
| 3270 | 3270 |
audio_channels = dec->channels; |
| 3271 |
- audio_sample_rate = dec->sample_rate; |
|
| 3272 | 3271 |
audio_sample_fmt = dec->sample_fmt; |
| 3273 | 3272 |
if(audio_disable) |
| 3274 | 3273 |
st->discard= AVDISCARD_ALL; |
| 3275 |
- /* Note that av_find_stream_info can add more streams, and we |
|
| 3276 |
- * currently have no chance of setting up lowres decoding |
|
| 3277 |
- * early enough for them. */ |
|
| 3278 |
- if (dec->lowres) |
|
| 3279 |
- audio_sample_rate >>= dec->lowres; |
|
| 3280 | 3274 |
break; |
| 3281 | 3275 |
case AVMEDIA_TYPE_VIDEO: |
| 3282 | 3276 |
input_codecs[nb_input_codecs-1] = avcodec_find_decoder_by_name(video_codec_name); |
| ... | ... |
@@ -3338,6 +3339,7 @@ static int opt_input_file(const char *opt, const char *filename) |
| 3338 | 3338 |
input_files[nb_input_files - 1].ist_index = nb_input_streams - ic->nb_streams; |
| 3339 | 3339 |
|
| 3340 | 3340 |
video_channel = 0; |
| 3341 |
+ audio_sample_rate = 0; |
|
| 3341 | 3342 |
|
| 3342 | 3343 |
av_freep(&video_codec_name); |
| 3343 | 3344 |
av_freep(&audio_codec_name); |
| ... | ... |
@@ -3585,7 +3587,6 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) |
| 3585 | 3585 |
if (audio_stream_copy) {
|
| 3586 | 3586 |
st->stream_copy = 1; |
| 3587 | 3587 |
audio_enc->channels = audio_channels; |
| 3588 |
- audio_enc->sample_rate = audio_sample_rate; |
|
| 3589 | 3588 |
} else {
|
| 3590 | 3589 |
audio_enc->codec_id = codec_id; |
| 3591 | 3590 |
set_context_opts(audio_enc, avcodec_opts[AVMEDIA_TYPE_AUDIO], AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM, codec); |
| ... | ... |
@@ -3596,14 +3597,13 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) |
| 3596 | 3596 |
} |
| 3597 | 3597 |
audio_enc->channels = audio_channels; |
| 3598 | 3598 |
audio_enc->sample_fmt = audio_sample_fmt; |
| 3599 |
- audio_enc->sample_rate = audio_sample_rate; |
|
| 3599 |
+ if (audio_sample_rate) |
|
| 3600 |
+ audio_enc->sample_rate = audio_sample_rate; |
|
| 3600 | 3601 |
audio_enc->channel_layout = channel_layout; |
| 3601 | 3602 |
if (av_get_channel_layout_nb_channels(channel_layout) != audio_channels) |
| 3602 | 3603 |
audio_enc->channel_layout = 0; |
| 3603 | 3604 |
choose_sample_fmt(st, codec); |
| 3604 |
- choose_sample_rate(st, codec); |
|
| 3605 | 3605 |
} |
| 3606 |
- audio_enc->time_base= (AVRational){1, audio_sample_rate};
|
|
| 3607 | 3606 |
if (audio_language) {
|
| 3608 | 3607 |
av_dict_set(&st->metadata, "language", audio_language, 0); |
| 3609 | 3608 |
av_freep(&audio_language); |
| ... | ... |
@@ -3889,6 +3889,8 @@ static void opt_output_file(const char *filename) |
| 3889 | 3889 |
|
| 3890 | 3890 |
set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL); |
| 3891 | 3891 |
|
| 3892 |
+ audio_sample_rate = 0; |
|
| 3893 |
+ |
|
| 3892 | 3894 |
av_freep(&forced_key_frames); |
| 3893 | 3895 |
uninit_opts(); |
| 3894 | 3896 |
init_opts(); |
| ... | ... |
@@ -165,7 +165,7 @@ fate-wmapro-2ch: CMP = oneoff |
| 165 | 165 |
fate-wmapro-2ch: REF = $(SAMPLES)/wmapro/Beethovens_9th-1_small.pcm |
| 166 | 166 |
|
| 167 | 167 |
FATE_TESTS += fate-ansi |
| 168 |
-fate-ansi: CMD = framecrc -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 |
|
| 168 |
+fate-ansi: CMD = framecrc -ar 44100 -i $(SAMPLES)/ansi/TRE-IOM5.ANS -pix_fmt rgb24 |
|
| 169 | 169 |
|
| 170 | 170 |
FATE_TESTS += fate-wmv8-drm |
| 171 | 171 |
# discard last packet to avoid fails due to overread of VC-1 decoder |
| ... | ... |
@@ -14,7 +14,7 @@ eval do_$test=y |
| 14 | 14 |
do_lavf() |
| 15 | 15 |
{
|
| 16 | 16 |
file=${outfile}lavf.$1
|
| 17 |
- do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 |
|
| 17 |
+ do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2 |
|
| 18 | 18 |
do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3 |
| 19 | 19 |
} |
| 20 | 20 |
|
| ... | ... |
@@ -39,8 +39,8 @@ do_image_formats() |
| 39 | 39 |
do_audio_only() |
| 40 | 40 |
{
|
| 41 | 41 |
file=${outfile}lavf.$1
|
| 42 |
- do_ffmpeg $file $DEC_OPTS $2 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $3 |
|
| 43 |
- do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file |
|
| 42 |
+ do_ffmpeg $file $DEC_OPTS $2 -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $3 |
|
| 43 |
+ do_ffmpeg_crc $file $DEC_OPTS $4 -i $target_path/$file |
|
| 44 | 44 |
} |
| 45 | 45 |
|
| 46 | 46 |
rm -f "$logfile" |
| ... | ... |
@@ -55,7 +55,7 @@ fi |
| 55 | 55 |
|
| 56 | 56 |
if [ -n "$do_rm" ] ; then |
| 57 | 57 |
file=${outfile}lavf.rm
|
| 58 |
-do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed |
|
| 58 |
+do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -ar 44100 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed |
|
| 59 | 59 |
# broken |
| 60 | 60 |
#do_ffmpeg_crc $file -i $target_path/$file |
| 61 | 61 |
fi |
| ... | ... |
@@ -181,11 +181,11 @@ do_audio_only wav |
| 181 | 181 |
fi |
| 182 | 182 |
|
| 183 | 183 |
if [ -n "$do_alaw" ] ; then |
| 184 |
-do_audio_only al |
|
| 184 |
+do_audio_only al "" "" "-ar 44100" |
|
| 185 | 185 |
fi |
| 186 | 186 |
|
| 187 | 187 |
if [ -n "$do_mulaw" ] ; then |
| 188 |
-do_audio_only ul |
|
| 188 |
+do_audio_only ul "" "" "-ar 44100" |
|
| 189 | 189 |
fi |
| 190 | 190 |
|
| 191 | 191 |
if [ -n "$do_au" ] ; then |
| ... | ... |
@@ -114,7 +114,7 @@ do_video_encoding() |
| 114 | 114 |
do_audio_encoding() |
| 115 | 115 |
{
|
| 116 | 116 |
file=${outfile}$1
|
| 117 |
- do_ffmpeg $file $DEC_OPTS -ac 2 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2 |
|
| 117 |
+ do_ffmpeg $file $DEC_OPTS -ac 2 -ar 44100 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2 |
|
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 | 120 |
do_audio_decoding() |