Skip to main content


Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: FLAC upsampling with ffmpeg and varying sample rates, 44.1 > 48 etc (Read 494 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

FLAC upsampling with ffmpeg and varying sample rates, 44.1 > 48 etc

This is one I am curious about more than anything else.

I came across this very educational avid thread, where nika, the person who wrote Digital Audio Explained:

pointed out something so obvious that I was embarrassed to not have realized it myself:
Chosen for multiple reasons. The ratio between these (44.1 and 48 KS/s) sample rates is 147:160, so the lowest common multiple is 7.056MS/s.
This is correct. Regardless of the source and destination rates the sample material is upsampled to a lowest common denominator of all of the rates available - this makes programming easier. Despite whether the sample rate is an even integer multiple or not they take them all up and back down again. The filtering mechanisms used are pretty much the same ones used in A/D and D/A conversion, so if a converter can do it right an SRC can do it right and versa visa.

In other words, the issue of resampling problems is largely irrelevant, if I understood that long thread right, in pro audio because they simply upsample any given sample rate until they get to the lowest common multiple, then down sample again to the desired end sample rate.

In other words, as indicated in the quote, the lowest common multiple of 44,100 and 48000 is 7056000, or 7.056 MS/s.

The perfectionist in me wants to know, how does ffmpeg do its resampling. Is there an option to force upsampling to lowest common multiple internally?

Since for example starting sample rate of 96000 S/s is evenly divided by 48000, that does not present any real issues.

But I'm curious how ffmpeg does this resampling, and if it does not up then downsample, if it can be forced to.

I'm suspecting no, because Nika iin that thread is talking about commercial level pro digital audio, but if I can make ffmpeg do that, it would be cool.

I believe I've managed to wrap my head around the dithering component of resampling, so that one seems clear enough how to handle.

Currently using something like this (ignoring dithering for this example since it's not really relevant to the core question I believe):

Code: [Select]
ffmpeg -i [input file] -sample_fmt s16 -ar 44100 [output file]

But the hacker/perfectionist in me wonders if this can be done with the upsampling then downsampling method. If I recall, ffmpeg/flac only supports sample rates up to I think 655 KS/s, so this would have to be done internally by the resampling logic without creating an intermediate upsampled flac.

I'm aware this is in the real world not really a major issue, this is just something I'd like to understand better, obviously if the pro audio tools can do this, it's a thing that is useful at some point in the process.

Any thoughts on this appreciated, or if you actually know how ffmpeg internally does a non even dividing resampling like 48000 > 44100, that would be great. ffmpeg documentation was not helpful, at least nothing I could find pointed in this direction.