Configure FFmpeg mcompand Multiband Compressor
This article provides a comprehensive guide on how to configure the
compression parameters for each frequency band in the FFmpeg
mcompand (multiband compand) filter. You will learn the
exact syntax structure, how to define individual compression bands, and
how to configure key parameters such as attack/decay times, transfer
functions (points), soft-knee values, and crossover frequencies.
Understanding the
mcompand Syntax
The mcompand filter allows you to perform multiband
dynamic range compression. Unlike a standard compressor that processes
the entire audio spectrum equally, mcompand divides the
audio into multiple frequency bands and applies separate compression
settings to each.
The basic syntax for the filter is:
mcompand="band1 band2 band3 ..."Each band configuration is separated by a space. The overall filter parameters are enclosed in double quotes.
Configuration Parameters for a Single Band
For each band, you must define parameters in a specific order:
attacks,decays soft-knee points [gain [crossover-frequency]]
Here is a detailed breakdown of each parameter within a band definition:
1. Attacks and Decays
(attacks,decays)
This is a comma-separated list of time constants in seconds. *
Attack time: How quickly the compressor responds to an
increase in volume (e.g., 0.005 seconds). * Decay
time: How quickly the compressor stops compressing after the
volume drops below the threshold (e.g., 0.1 seconds). *
Note: If you are processing multi-channel audio, you can
specify multiple attack/decay pairs separated by commas.
2. Soft-Knee (soft-knee)
Defined in decibels (dB). This determines how sharp the transition is
into compression. * A value of 0 creates a hard knee
(instant compression at the threshold). * A higher value (e.g.,
6) softens the transition, making the compression sound
more natural.
3. Transfer Function
(points)
This defines the input-to-output volume mapping, which dictates the
compression ratio and threshold. It consists of a comma-separated list
of dB pairs: input_dB,output_dB. * An example mapping:
-60,-60,-40,-40,-20,-25,0,-15 * In this mapping, an input
of -20dB is compressed down to -25dB, and an
input of 0dB is compressed to -15dB.
4. Makeup Gain (gain)
Optional. The gain in dB applied to the band after
compression to restore lost volume. This is usually set to
0 if you do not want to boost the output of the band.
5. Crossover Frequency
(crossover-frequency)
Optional. This defines the upper frequency limit of the band in Hz. * The first band will cover from 0 Hz to this frequency. * The next band will cover from this frequency to its own specified crossover frequency. * Crucial rule: Do not specify a crossover frequency for the very last band. The last band automatically covers everything up to the Nyquist frequency (half the sampling rate).
Practical Example
Below is a standard command to apply a 3-band compressor using
mcompand.
ffmpeg -i input.wav -filter_complex "mcompand='0.005,0.1 6 -60,-60,-40,-40,-20,-20,0,-10 0 800 0.005,0.1 6 -60,-60,-40,-40,-20,-20,0,-10 0 3200 0.005,0.1 6 -60,-60,-40,-40,-20,-20,0,-10 0'" output.wavBreakdown of the Example:
- Low Band (0 Hz to 800 Hz):
0.005,0.1: 5ms attack, 100ms decay.6: 6 dB soft-knee.-60,-60,-40,-40,-20,-20,0,-10: Compression points.0: 0 dB makeup gain.800: Crossover frequency of 800 Hz.
- Mid Band (800 Hz to 3200 Hz):
0.005,0.1: Same envelope response.6: 6 dB soft-knee.-60,-60,-40,-40,-20,-20,0,-10: Compression points.0: 0 dB makeup gain.3200: Crossover frequency of 3200 Hz.
- High Band (3200 Hz to Nyquist limit):
0.005,0.1: Same envelope response.6: 6 dB soft-knee.-60,-60,-40,-40,-20,-20,0,-10: Compression points.0: 0 dB makeup gain.- (No frequency limit specified, as this is the final band)