Multi-Band Compression in FFmpeg Using mcompand

This article provides a practical guide on how to use the mcompand (multi-band compander) filter in FFmpeg to process audio streams. You will learn the structure of the filter’s syntax, how to define frequency crossover points, and how to configure attack, release, and volume threshold parameters for different audio bands to achieve a balanced and professional sound.


Understanding the mcompand Filter Syntax

The mcompand filter divides an audio signal into multiple frequency bands and applies compression or expansion to each band individually. The basic syntax for the filter requires defining the parameters for each band, separated by spaces, wrapped in single quotes:

ffmpeg -i input.wav -af "mcompand='band1 band2 band3'" output.wav

Each band is defined using the following sequence of parameters:

attacks releases [delay] points [crossover_frequency]

Step-by-Step Implementation

To apply a 3-band compressor (Low, Mid, and High frequencies), you must construct three separate band definitions within the filter.

1. Define the Low-Frequency Band (Bass)

For the low frequencies (0 Hz to 200 Hz), we want a fast attack to catch heavy transients and moderate compression:

2. Define the Mid-Frequency Band (Vocals/Instruments)

For mid-range frequencies (200 Hz to 3000 Hz), we use a slightly slower attack to keep vocals sounding natural:

3. Define the High-Frequency Band (Treble/Air)

For the high frequencies (3000 Hz and above), we use very fast settings to control sibilance:


Complete FFmpeg Command

Combining these three band definitions into a single FFmpeg command yields the following:

ffmpeg -i input.wav -af "mcompand='0.005,0.005 0.1,0.1 -60,-60,-20,-16,0,-10 200 0.01,0.01 0.15,0.15 -60,-60,-20,-18,0,-12 3000 0.003,0.003 0.08,0.08 -60,-60,-20,-15,0,-10'" output.wav

Key Considerations for Tuning