Hello,
I have some 192 kHz / 24 bit Vinyl-Rips in FLAC and want them to downsample to 44.1 kHz / 16 bit for my iPhone.
I would like to do that with FFmpeg + SoX.
So is that line correct?
ffmpeg -i input.flac -af aresample=resampler=soxr -acodec alac -ar 44100 -sample_fmt s16p output.m4a
I read about dither with downsampling.
But that is done with SoX by default?
Best regards,
Felix
Code works.
I didn't find that SoX do dithering by default.
https://ffmpeg.org/ffmpeg-resampler.html
I am using this one (swr):
ffmpeg -i "input.wav" -af aresample=resampler=swr ^
-acodec alac -ac 2 -ar 44100 -sample_fmt s16p output.alac
From http://sox.sourceforge.net/sox.html:
Specifically, by default, SoX automatically adds TPDF dither when the output bit-depth is less than 24 and any of the following are true
What do you do with -ac 2?
And why you convert to alac? Isn't it m4a?
Specifically, by default, SoX automatically adds TPDF dither when the output bit-depth is less than 24 and any of the following are true
This is true for SoX commandline tool. But you aren't using it.
If you use ffmpeg, it will NOT dither by default. You need to set dither manually.
-af "aresample=44100:resampler=soxr:precision=33:
osf=s16:dither_method=shibata" (if using this command you also can ommit -ar 44100 -sample_fmt s16p)
More dither methods are available, see https://ffmpeg.org/ffmpeg-resampler.html
From http://sox.sourceforge.net/sox.html:
Specifically, by default, SoX automatically adds TPDF dither when the output bit-depth is less than 24 and any of the following are true
What do you do with -ac 2?
And why you convert to alac? Isn't it m4a?
You read Rollin :))
And, as he also mentioned, you can omit ac 2 and some other stuffs... ac 2 (stereo) is my simple bug: I like to write everything. In your case, without ac 2. FFMPEG will guess that it is stereo and will do well too. But it will write in the log some info about all of that...
Thank you for the answers.
My command looks like this now:
ffmpeg -i input.flac -af "aresample=44100:resampler=soxr:precision=33:osf=s16:dither_method=shibata" -acodec alac output.m4a
Still two questions:
1. dither_method: Why shibata? What are advantages and disadvantages of the others?
2. precision: What does it do? More precisions means bigger file size? And according to FFmpeg Resampler Documentation a value of 28 gives SoX’s ’Very High Quality’, so 28 is max or not? Why a value of 33?
dither_method: Why shibata? What are advantages and disadvantages of the others?
shibata moves dither noise from most audible range to high frequencies. You can see difference between dither/noise shaping algorithms here - http://sox.sourceforge.net/SoX/NoiseShaping
precision: What does it do? More precisions means bigger file size? And according to FFmpeg Resampler Documentation a value of 28 gives SoX’s ’Very High Quality’, so 28 is max or not? Why a value of 33?
Quality of resampling algorithm. It not affects file size directly. 28 is not max. 33 is max. But, yes, 33 is overkill.
Also, notice, that sometimes resampling can result in audible clicks between tracks - https://hydrogenaud.io/index.php/topic,114960.msg947760.html#msg947760 I don't know if this can be avoided with ffmpeg, but this can be avoided with foobar2000.
Okay, thank you for the explanation.
So here I have my to batch-files. For CD to ALAC only, without resampling and for Vinyl 24 Bit to 16 Bit.
16 Bit:
FOR %%A IN (*.flac) DO ffmpeg -i "%%A" -map_metadata -1 -acodec alac "%%A.m4a" 2>> ffmpeg.log
24 Bit:
FOR %%A IN (*.flac) DO ffmpeg -i "%%A" -map_metadata -1 -af "aresample=44100:resampler=soxr:precision=33:osf=s16:dither_method=shibata" -acodec alac "%%A.m4a" 2>> ffmpeg.log
(-map_metadata -1 because I want to clean tags completly with TuneUp.)
16 Bit Input:
Audio: FLAC (framed) 44100Hz stereo 1411kbps [A: flac, 44100 Hz, stereo, s16]
16 Bit Output
Audio: ALAC 44100Hz stereo 1059kbps [A: SoundHandler (alac, 44100 Hz, stereo, s16, 1059 kb/s)]
24 Bit Input:
Audio: FLAC (framed) 96000Hz stereo 4608kbps [A: flac, 96000 Hz, stereo, s24]
24 Bit Output
Audio: ALAC 44100Hz stereo 811kbps [A: SoundHandler (alac, 44100 Hz, stereo, s16, 811 kb/s)]
Why are the 16 Bit Outputs always much higher bitrate than the 24 Bit Outputs?
From the log-file:
What does the 128 kb/s mean?
Stream #0:0: Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16p, 128 kb/s
And what is that overhead?
overhead: 0.044341%
I will test the files for clicks.
Hopefully there are none.
Thank you for your help.
Why are the 16 Bit Outputs always much higher bitrate than the 24 Bit Outputs?
Hm... what do u talking about? :))
First of all, for all conversions of that type, I am using WAV only. That's much more correct imho. So
4096 is native fixed bitrate for sample rate of 96000Hz 2 channels.
1411 is Red Book standard for CDs (Sample rate 44100 HZ).
FLAC will always decrease bitrate and you should not pay any attention on that. But you DO!
This 1059kbps and this 811kbps are nocense (imho).
Take out from FLAC your WAV file and do your testing with it and do not write about FLAC but about WAV only. Makes much more sense imho.
Rollin wrote
dont know if this can be avoided with ffmpeg
I am using foobar for fast unpacking too but this case I tested with ffmpeg: no clicks, no nothing. Checked full GD Tracks album from Lara Fabian. Usually, for serious down-sampling etc. Adobe Audition is my favorite.
Specifically, by default, SoX automatically adds TPDF dither when the output bit-depth is less than 24 and any of the following are true
This is true for SoX commandline tool. But you aren't using it.
If you use ffmpeg, it will NOT dither by default. You need to set dither manually.
-af "aresample=44100:resampler=soxr:precision=33:osf=s16:dither_method=shibata" (if using this command you also can ommit -ar 44100 -sample_fmt s16p)
More dither methods are available, see https://ffmpeg.org/ffmpeg-resampler.html
Which dither_method be used usually for downsampling to 44.1K?
I think it's much safer, simpler and easier solution to just use SoX CMD instead of FFmpeg CMD.
I think it's much safer, simpler and easier solution to just use SoX CMD instead of FFmpeg CMD.
where can i download the lastest version sox.exe....i can't find...
I think it's much safer, simpler and easier solution to just use SoX CMD instead of FFmpeg CMD.
where can i download the lastest version sox.exe....i can't find...
Here. (https://sourceforge.net/projects/sox/files/sox/14.4.2/) Choose your OS (Windows) and version (32 or 64 bit).
A very recent compile can be found here https://audiodigitale.eu/repo/sox/
A very recent compile can be found here https://audiodigitale.eu/repo/sox/
The most recent compile is on the official site.
The most recent compile is on the official site.
14.4.2 from 2015 is at the page you linked. There where changes since regarding DSD support, Ultra for resampling and maybe others in the 2017 compile i link above.
Edit: This is more a compile of the recent Fork done by Mans Rullgard https://github.com/mansr/sox
The same Rullgard does some things at https://sourceforge.net/p/sox/code/ci/master/tree/ and here https://sourceforge.net/p/sox/mailman/message/34464900/
I did my own compile a while back and use it since without any problems.
And what is that overhead?
overhead: 0.044341%
That is muxing overhead, how much muxing into some format increases size compared to saving into raw.
Also sox is obsolete and abandoned and not much developed these days.
A very recent compile can be found here https://audiodigitale.eu/repo/sox/
Thank you, sir. I like this package is almost static instead of plethora of dlls.