Skip to main content
Topic: Downsampling Vinyl-Rips to CD (Read 973 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Downsampling Vinyl-Rips to CD

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?

Code: [Select]
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

Re: Downsampling Vinyl-Rips to CD

Reply #1
Code works.

I didn't find that SoX do dithering by default.
https://ffmpeg.org/ffmpeg-resampler.html

I am using this one (swr):
Code: [Select]
ffmpeg -i "input.wav" -af aresample=resampler=swr ^
-acodec alac -ac 2 -ar 44100 -sample_fmt s16p output.alac

Re: Downsampling Vinyl-Rips to CD

Reply #2
From http://sox.sourceforge.net/sox.html:
Code: [Select]
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?


Re: Downsampling Vinyl-Rips to CD

Reply #3
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

Re: Downsampling Vinyl-Rips to CD

Reply #4
From http://sox.sourceforge.net/sox.html:
Code: [Select]
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...

 

Re: Downsampling Vinyl-Rips to CD

Reply #5
Thank you for the answers.
My command looks like this now:

Code: [Select]
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?


Re: Downsampling Vinyl-Rips to CD

Reply #6
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.

Re: Downsampling Vinyl-Rips to CD

Reply #7
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:
Code: [Select]
FOR %%A IN (*.flac) DO ffmpeg -i "%%A" -map_metadata -1 -acodec alac "%%A.m4a" 2>> ffmpeg.log

24 Bit:
Code: [Select]
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:
Code: [Select]
Audio: FLAC (framed) 44100Hz stereo 1411kbps [A: flac, 44100 Hz, stereo, s16]
16 Bit Output
Code: [Select]
Audio: ALAC 44100Hz stereo 1059kbps [A: SoundHandler (alac, 44100 Hz, stereo, s16, 1059 kb/s)]

24 Bit Input:
Code: [Select]
Audio: FLAC (framed) 96000Hz stereo 4608kbps [A: flac, 96000 Hz, stereo, s24]
24 Bit Output
Code: [Select]
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?
Code: [Select]
Stream #0:0: Audio: alac (alac / 0x63616C61), 44100 Hz, stereo, s16p, 128 kb/s

And what is that overhead?
Code: [Select]
overhead: 0.044341%


I will test the files for clicks.
Hopefully there are none.


Thank you for your help.

Re: Downsampling Vinyl-Rips to CD

Reply #8
Code: [Select]
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
Code: [Select]
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.

Re: Downsampling Vinyl-Rips to CD

Reply #9
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?

Re: Downsampling Vinyl-Rips to CD

Reply #10
I think it's much safer, simpler and easier solution to just use SoX CMD instead of FFmpeg CMD.
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

Re: Downsampling Vinyl-Rips to CD

Reply #11
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...

Re: Downsampling Vinyl-Rips to CD

Reply #12
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. Choose your OS (Windows) and version (32 or 64 bit).
sox -e float -b 32 -V4 -D gain -3 rate -v 48000 norm -1
opusenc --bitrate 128

Re: Downsampling Vinyl-Rips to CD

Reply #13
A very recent compile can be found here https://audiodigitale.eu/repo/sox/
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!


Re: Downsampling Vinyl-Rips to CD

Reply #15
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.
Is troll-adiposity coming from feederism?
With 24bit music you can listen to silence much louder!

Re: Downsampling Vinyl-Rips to CD

Reply #16
And what is that overhead?
Code: [Select]
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.

 
SimplePortal 1.0.0 RC1 © 2008-2018