How to Use FFmpeg Compand Filter for Audio Compression

In this guide, you will learn how to apply a classic dynamic range compression effect to an audio file using FFmpeg’s powerful compand (compressor/expander) filter. We will break down the filter’s complex syntax, explain its key parameters like attack, release, transfer function, and makeup gain, and provide a practical, ready-to-use command to balance your audio levels.

The FFmpeg Audio Compression Command

To apply a classic compressor effect to an audio file, run the following command in your terminal:

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

This command takes your input audio, processes it through a configured compressor curve, and saves the output.


Breakdown of the Compand Parameters

The compand filter uses a specific syntax where arguments are separated by colons (:). Here is what each segment of the command does:

1. Attack and Release (attacks=0.3|releases=0.8)

2. The Transfer Function (points=-80/-80|-20/-12|0/-6)

This is the most critical part of the compressor, defining the input-to-output volume mapping in decibels (dB): * -80/-80: Audio at -80 dB (near silence) remains unchanged at -80 dB. * -20/-12: Audio at -20 dB is boosted to -12 dB. * 0/-6: Loud peaks at 0 dB are compressed down to -6 dB. * This mapping compresses the dynamic range by bringing quiet sounds up and pulling loud peaks down.

3. Soft Knee (soft-knee=6)

4. Makeup Gain (gain=0)

5. Initial Volume (volume=-90)

6. Lookahead Delay (delay=0.2)