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.


How Crossover Frequencies Work

When you chain multiple bands together, the crossover frequencies are determined sequentially:

  1. Band 1 covers frequencies from 0 Hz to its specified top-frequency.
  2. Band 2 covers frequencies from the first band’s top-frequency to its own specified top-frequency.
  3. Band N (Last Band) covers frequencies from the previous band’s top-frequency to 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:

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.wav

Parameter Breakdown for the Bands:

  1. Band 1 (Bass): Ends with 150. This targets frequencies up to 150 Hz.
  2. Band 2 (Mids): Ends with 4000. This targets frequencies from 150 Hz to 4,000 Hz.
  3. 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.