zambelli
7th December 2021, 04:54
I'm writing a batch processing script for a workflow which requires all audio sources to be converted to 48 kHz stereo before transcoding, with one caveat: if the source sample rate is < 48 kHz, I don't want to upsample it to 48 kHz, I'd like to pass it through at its native sample rate.
So if the source sample rate is > 48000 Hz, I'd like the command line to be something like this:
ffmpeg -i "%sourcefile%" -af "aresample=resampler=soxr:precision=33:osr=48000:osf=flt:ocl=stereo:matrix_encoding=dplii" -acodec pcm_f32le -f wav
but if the source sample rate is <= 48000 Hz, I'd like the command line to be something like this:
ffmpeg -i "%sourcefile%" -af "aresample=resampler=soxr:precision=33:osf=flt:ocl=stereo:matrix_encoding=dplii" -acodec pcm_f32le -f wav
Is there a way to do this with just a single FFmpeg command line that conditionally inserts osr=48000 into the filter parameters based on the source sample rate? I think I'm looking for a solution analogous to using in_w and in_h constants in video scaler filter, but as far as I can tell there is no in_sample_rate equivalent I could use with the aresample filter.
So if the source sample rate is > 48000 Hz, I'd like the command line to be something like this:
ffmpeg -i "%sourcefile%" -af "aresample=resampler=soxr:precision=33:osr=48000:osf=flt:ocl=stereo:matrix_encoding=dplii" -acodec pcm_f32le -f wav
but if the source sample rate is <= 48000 Hz, I'd like the command line to be something like this:
ffmpeg -i "%sourcefile%" -af "aresample=resampler=soxr:precision=33:osf=flt:ocl=stereo:matrix_encoding=dplii" -acodec pcm_f32le -f wav
Is there a way to do this with just a single FFmpeg command line that conditionally inserts osr=48000 into the filter parameters based on the source sample rate? I think I'm looking for a solution analogous to using in_w and in_h constants in video scaler filter, but as far as I can tell there is no in_sample_rate equivalent I could use with the aresample filter.