In my line of work transcoding videos for dr.dk/pirattv i use FFmpeg extensively. I have written a tool in C# that automates this task and in doing so, i discovered that FFmpeg is not a good choice for downsampling audio. The downsampling does not suffer from aliasing because the signal is properly attenuated at the Nyquist frequency – but the quality of this lowpass filter is terrible. The problem lies with the lowpass filter which is by no means steep enough so it unnecessarily cuts a lot of high frequencies fairly far from the Nyquist frequency. The only good thing about the filter, is that the resampling is really fast. I have not found a setting in FFmpeg that forces it to use a better filter so i wanted to find a better way:
This is the same sweep downsampled to 44.1 kHz using FFmpeg.
Notice the server attentuation already at 17-18 kHz
Here the same downsampling is done using SSRC. The filter is extremely steep as we want it to be. In fact so steep that you can”t even see the attentuation right before Nyquist – but it’s there!
Notice that the y-axis is different than that on the FFmpeg version.
Update: I ended up using SoX, because I needed more than just great resampling. SSRC is in theory slightly better but the difference is inaudible to me and SoX provides me with an array of additional possibilities.
Update II – FFmpeg now includes the SoX resampler – but only utilizes it if you tells it to – the default resampler is still the simple one with its limitations.
To use the better resampler from SoX, eg resampling to 44.1 kHz, add the following to your command line: