How to Configure ffmpeg mcompand Frequency Bands
The FFmpeg mcompand (multiband compand) filter is a
powerful tool for dynamic range compression and expansion across
different audio frequency bands. This article provides a straightforward
guide on how to configure these frequency bands, explaining the syntax,
crossover points, and providing practical examples to help you optimize
your audio processing.
Understanding the Band Syntax
The mcompand filter works by splitting the audio into
multiple frequency bands and applying independent compression/expansion
to each. You define these bands in a single string, separating each
band’s configuration with a comma.
The configuration for each individual band follows this syntax:
attacks,decays points [soft-threshold [gain]] [top-frequency]
To configure the frequency bands specifically, you must focus on the
final, optional parameter:
top-frequency.
top-frequency: This defines the upper limit of the current frequency band in Hertz (Hz).- The Last Band: The very last band in your
configuration must omit the
top-frequencyparameter. It automatically acts as the “high” band, covering everything from the previous band’s limit up to the Nyquist frequency (half of your audio’s sample rate).
How Crossover Frequencies Work
When you chain multiple bands together, the crossover frequencies are determined sequentially:
- Band 1 covers frequencies from 0
Hz to its specified
top-frequency. - Band 2 covers frequencies from the first band’s
top-frequencyto its own specifiedtop-frequency. - Band N (Last Band) covers frequencies from the
previous band’s
top-frequencyto the maximum sample rate limit.
Practical Example: A 3-Band Compressor
Here is an example of a 3-band configuration. We will split the audio into Low, Mid, and High frequencies.
Frequency Splits:
- Low Band: 0 Hz to 150 Hz (ideal for bass)
- Mid Band: 150 Hz to 4,000 Hz (ideal for vocals and instruments)
- High Band: 4,000 Hz to maximum frequency (ideal for treble and sibilance)
The FFmpeg Command:
ffmpeg -i input.wav -af "mcompand=\
0.005,0.1 6 -60,-60,-40,-40,-20,-20,0,-20 0.1 -10 150,\
0.003,0.05 6 -60,-60,-40,-40,-20,-10,0,-10 0.1 -10 4000,\
0.0001,0.025 6 -60,-60,-40,-40,-20,-10,0,-10 0.1 -10" \
output.wavParameter Breakdown for the Bands:
- Band 1 (Bass): Ends with
150. This targets frequencies up to 150 Hz. - Band 2 (Mids): Ends with
4000. This targets frequencies from 150 Hz to 4,000 Hz. - Band 3 (Treble): Has no frequency number at the end of its parameters. This targets everything above 4,000 Hz.
By adjusting the numbers at the end of each comma-separated block, you can customize the crossover points to fit the specific needs of your audio source.