Configure FFmpeg Compand Transfer Function dB Curve
This article explains how to configure the transfer function (dB
curve) in the FFmpeg compand filter to customize audio
compression and expansion. You will learn the syntax of the
points parameter, how input and output decibel (dB) levels
map to each other, and how to construct custom curves for different
audio processing needs.
Understanding the Compand Filter Syntax
The FFmpeg compand filter uses the following basic
syntax:
compand=attacks:decays:points:[soft-threshold]:[makeup]:[delay]
The transfer function (dB curve) is configured entirely within the
third parameter: points. This parameter
defines a list of coordinate pairs that dictate how the input volume (on
the X-axis) maps to the output volume (on the Y-axis).
The Points Parameter Syntax
The points parameter is a space-separated list of
transfer points. Each point is defined as input/output in
decibels (dB):
input1/output1 input2/output2 input3/output3 ...
- Input values (X-axis): The volume of the incoming audio signal.
- Output values (Y-axis): The volume of the outgoing audio signal after processing.
- 0 dB represents the maximum digital volume (0 dBFS).
- Negative values (e.g.,
-20,-40) represent quieter signals. - A value of
-900is typically used to represent absolute silence (negative infinity dB).
FFmpeg performs linear interpolation in the dB domain between the points you define to create a continuous curve.
Common dB Curve Configurations
1. Linear (No Compression)
To pass audio through without changing its volume dynamics, the input must match the output exactly:
-900/-900 0/0
This maps silence to silence, and maximum volume to maximum volume, resulting in a straight diagonal line.
2. Standard Compressor (2:1 Ratio Above -20 dB)
To compress loud sounds, you can set a threshold (e.g., -20 dB) where the volume increases at a slower rate:
-900/-900 -20/-20 0/-10
- Signals below
-20 dBremain untouched (e.g.,-20 dBinput outputs at-20 dB). - Signals above
-20 dBare compressed. An input of0 dB(a 20 dB increase from the threshold) outputs at-10 dB(only a 10 dB increase), resulting in a 2:1 compression ratio.
3. Noise Gate / Downward Expander
To reduce background noise, you can configure the curve to drop sharply below a certain threshold (e.g., -50 dB):
-900/-120 -50/-50 0/0
- Signals above
-50 dBremain unaffected. - Signals below
-50 dBare pushed down toward-120 dB(near silence), effectively silencing low-level background hiss.
4. Limiter (Infinite Compression Above -10 dB)
To prevent audio from exceeding a strict ceiling (e.g., -10 dB):
-900/-900 -10/-10 0/-10
- Audio behaves normally up to
-10 dB. - Any increase in input volume beyond
-10 dBis completely flattened, keeping the output capped at-10 dB.
Applying the Curve in FFmpeg
To use your transfer function in an FFmpeg command, insert the points into the filter chain.
For example, to apply a compressor with a 2:1 ratio above -20 dB, fast attack/decay times, and a 6 dB soft-threshold (to round the curve’s corners for a smoother transition):
ffmpeg -i input.wav -filter:a "compand=attacks=0.3:decays=0.8:points=-900/-900 -20/-20 0/-10:soft-threshold=6" output.wav