How to Use FFmpeg sidechaingate Filter

This guide explains how to use the sidechaingate filter in FFmpeg to apply sidechain gating to your audio files. You will learn the basic syntax, the primary parameters that control the gate’s behavior (such as threshold, attack, and release), and see practical command-line examples for controlling one audio track’s volume using the level of another.

Understanding Sidechain Gating in FFmpeg

A noise gate reduces the volume of an audio signal when it falls below a certain threshold. In sidechain gating, the gate on the main audio channel is opened or closed based on the volume level of a second, separate audio channel (the sidechain/detection signal).

The FFmpeg sidechaingate filter (also accessible via the alias asgated) requires two audio inputs: 1. First input: The audio signal you want to gate (the primary audio). 2. Second input: The control signal (the sidechain audio).

Key Parameters

You can customize the filter using several parameters formatted as key=value pairs separated by colons:

Basic Command Syntax

To use the filter, you must use -filter_complex because the filter requires two distinct input streams.

Here is the template command:

ffmpeg -i main_audio.wav -i sidechain_audio.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.15:attack=10:release=150[outa]" -map "[outa]" output.wav

Command Breakdown:

Practical Example: Gating Synth Pads with a Kick Drum

A common music production technique is to gate a sustaining synthesizer pad using a transient kick drum. This creates a rhythmic, pumping effect where the synth is only heard when the kick drum hits.

ffmpeg -i pad.wav -i kick.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.2:range=0.01:attack=5:release=100[out]" -map "[out]" rhythmic_pad.wav

In this setup: * range=0.01 ensures that when the kick drum is silent, the pad is almost completely muted. * attack=5 makes the gate open almost instantly when the kick strikes. * release=100 allows the pad sound to fade out quickly but smoothly after each kick hit.