How to Use the FFmpeg sidechaingate Filter

This article provides a practical guide on how to use the sidechaingate filter in FFmpeg to control one audio signal using the level of another. You will learn the basic syntax, the key parameters that control the gating effect, and a practical command-line example to help you implement sidechain gating in your audio processing workflows.

What is Sidechain Gating?

A sidechain gate is an audio dynamics processor that acts as a gate on a primary audio channel, but determines whether to open or close that gate based on the volume level of a secondary “sidechain” audio channel. When the volume of the sidechain signal rises above a specified threshold, the gate opens, allowing the primary audio signal to pass through. When the sidechain signal falls below the threshold, the gate closes, silencing or reducing the volume of the primary audio.

Key Parameters of the sidechaingate Filter

The sidechaingate filter accepts several parameters to fine-tune the gating behavior. Here are the most commonly used options:

Practical Command Example

To use the sidechaingate filter, you must pass two audio streams into the filter using FFmpeg’s filter_complex. The first input is the primary audio you want to gate, and the second input is the sidechain trigger.

Here is a standard command template:

ffmpeg -i primary_audio.wav -i trigger_audio.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.05:attack=10:release=150[outa]" -map "[outa]" output.wav

How the Command Works

  1. -i primary_audio.wav -i trigger_audio.wav: This inputs both audio files. The primary track (index 0) is the one that will be muted or unmuted, while the trigger track (index 1) acts as the control key.
  2. [0:a][1:a]: This feeds the audio from the first input and the audio from the second input into the filter.
  3. sidechaingate=threshold=0.05:attack=10:release=150: This applies the filter. The gate will open quickly (10 milliseconds) whenever the trigger audio rises above the 0.05 threshold, and it will close smoothly over 150 milliseconds when the trigger audio goes quiet.
  4. [outa]: This labels the resulting processed audio stream.
  5. -map "[outa]": This tells FFmpeg to write the processed audio stream to the final output file, output.wav.