Configure sidechaingate Threshold and Range in FFmpeg
This article provides a straightforward guide on how to configure the
threshold and range parameters in the FFmpeg sidechaingate
audio filter. You will learn the exact syntax, the practical meaning of
these parameters, and see real-world command-line examples to control
your audio dynamics effectively using sidechain gating.
Understanding the sidechaingate Filter
The sidechaingate filter uses the audio level of a
second audio stream (the sidechain input) to control a gate on the first
audio stream (the main input). When the sidechain signal rises above a
specified threshold, the gate opens and allows the main audio to pass
through. When the sidechain signal falls below the threshold, the gate
closes, attenuating the main audio.
To use the filter, you must pass two audio inputs to
-filter_complex in the following order:
[main_audio][sidechain_audio]sidechaingate=parameter1=value1:parameter2=value2[output_audio]
Configuring Threshold
The threshold parameter determines the audio level of the sidechain signal required to open the gate.
- Option Name:
threshold(orlevel_in) - Value Type: Double (decibels or linear amplitude)
- Default Value:
0.125 - Range:
0.00003to1.0
How to set it:
If you want the gate to open only when the sidechain audio is relatively loud, set a higher threshold. If you want it to open even with quiet sidechain signals, set a lower threshold.
Example of setting threshold to 0.05:
sidechaingate=threshold=0.05Configuring Range
The range parameter determines the amount of gain reduction (attenuation) applied to the main audio signal when the gate is closed.
- Option Name:
range - Value Type: Double (linear amplitude reduction factor)
- Default Value:
0.03125(approximately -30 dB) - Range:
0.00003to1.0
How to set it:
A lower range value means more attenuation (a quieter background when
the gate is closed). Setting the range to 0.0 would
completely mute the main signal when the gate is closed, while setting
it to 1.0 would result in no attenuation at all.
Example of setting the range to 0.01 (for heavy
attenuation):
sidechaingate=range=0.01Practical FFmpeg Command Example
In the following example, we have a main audio track
(main.wav) and a sidechain trigger track
(trigger.wav). We configure the gate to open when the
trigger signal crosses 0.1 amplitude, and we restrict the
closed gate volume to 0.05 of the original signal:
ffmpeg -i main.wav -i trigger.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.1:range=0.05[out]" -map "[out]" output.wavAdditional Useful Parameters
To fine-tune how the gate opens and closes, you can combine
threshold and range with these time-based
parameters:
- attack: The time in milliseconds it takes for the
gate to fully open once the threshold is crossed (default is
20). - release: The time in milliseconds it takes for the
gate to fully close after the signal falls below the threshold (default
is
250). - makeup: The amount of signal boost applied to the
output (default is
1.0).
Example with custom attack, release, threshold, and range:
ffmpeg -i main.wav -i trigger.wav -filter_complex "[0:a][1:a]sidechaingate=threshold=0.08:range=0.02:attack=10:release=150[out]" -map "[out]" output.wav