Search code examples
ffmpeglowpass-filter

ffmpeg lowpass filter increase roll off


I have converted one of my old SACD's to 352kHz FLAC, but due to the nature of DSD, a lot of noise is added to the higher frequencies, which are outside the audible range, but consume quite some disk space.

352kHz FLAC - no lowpass filter

So I thought I'd use the simple lowpass filter to get rid of it, like this:

ffmpeg -i input.dsf -af "lowpass=26000" output.flac

However, the result is that the noise is still there, but only lowered in volume:

352kHz FLAC - with lowpass applied

Is there a way to increase the roll-off of the filter or another way to get up to -140 dB at ~48 kHz?


Solution

  • TL,DR:

    Use sox instead:

    ffmpeg -i input.dsf -f wav -acodec pcm_s24le pipe:1 | sox -S -t wav --ignore-length - --compression 8 output.flac sinc -32k -t 16k
    

    ...will get rid of all the high frequency distortion and reduce file size dramatically (bringing it back close to DSD):

    • DSD64 (SACD): ~162 MiB
    • FLAC (352.8kHz - no filters): ~396 MiB
    • FLAC (352.8kHz - lowpass): ~189 MiB

    Long Read

    OK, I found out, that one can simple chain the filters and by using slightly different roll-off frequencies. For the following, I simply converted the DSD files without any filter to FLAC (hence, in the following commands we have input.flac instead of input.dsf).

    Using the following command:

    ffmpeg -i input.flac -af "lowpass=24000,lowpass=28000,lowpass=30000,lowpass=32000" output.flac
    

    ...resulted in: enter image description here

    Which looked really nice.

    I then checked how close it still was to the original in the lower (audible) frequencies:

    sox -S -m -v 1 input.flac -v -1 output.flac -n spectrogram -x 640 -y 200 -Z -30 -o "lowpass.ffmpeg.diff.png"
    

    ...result: enter image description here

    So, no way I can keep that in my library. As I was searching for alternatives, I came across this nice informative read:

    So, based on that new information, I fired up sox instead:

    sox -S input.flac --compression 8 output.flac sinc -32k -t 16k
    

    ...which result in: enter image description here

    ...and confirmed via diff, that audible frequencies remain untouched: enter image description here