How to Configure FFmpeg Compand Delay and Gain

This article explains how to configure the delay and gain parameters within the FFmpeg compand (compressor/expander) filter. You will learn the exact command syntax, how the post-processing gain and lookahead delay parameters function, and how to apply them to your audio files using practical command-line examples.

Understanding the Compand Filter Syntax

The compand filter in FFmpeg is used to adjust the dynamic range of audio. The basic syntax for the filter is:

compand=attacks,decays:points:soft-knee:gain:volume:delay

To configure the gain and delay parameters, you must navigate this specific order of arguments, as they are positional.

Configuring the Gain Parameter

In the compand filter, “gain” refers to the overall post-compression gain (often called makeup gain) applied to the output signal. It is used to boost the overall volume of the audio after the dynamic range has been compressed.

Input/Output Gain Points

In addition to the final makeup gain, you also configure gain behavior using the points parameter (the 2nd argument). Points define the transfer function using input/output dB pairs separated by a pipe (|).

For example, points=-90/-90|-20/-10|0/-3 means: * An input of -90 dB remains -90 dB. * An input of -20 dB is boosted to -10 dB (a gain of +10 dB). * An input of 0 dB is compressed to -3 dB (a reduction of -3 dB).

Configuring the Delay Parameter

The delay parameter acts as a “lookahead” buffer. It delays the main audio signal relative to the volume detector. This allows the compressor to detect sudden volume spikes and adjust the gain before the spike actually reaches the output, preventing momentary clipping.

Practical Example Command

The following command demonstrates how to apply a compand filter with specific gain and delay settings:

ffmpeg -i input.wav -filter:a "compand=attacks=0.3:decays=0.8:points=-90/-90|-20/-10|0/0:soft-knee=6:gain=5:volume=-90:delay=0.3" output.wav

Breakdown of the Configuration: