What You’ll Learn

  • How to apply a noise gate with the agate filter
  • The meaning and tuning of threshold, attack, release, and range
  • Practical settings for podcasts and voice-over work
  • When to use agate versus silenceremove

Tested with: FFmpeg 6.1 (ubuntu-latest / CI verified)
Platform: Windows / macOS / Linux


What is a Noise Gate?

A noise gate automatically reduces (or mutes) audio when its level falls below a threshold.

  • While speech or instruments are audible → the signal passes through (gate open)
  • During silence or quiet noise → the gate closes, muting or attenuating the signal

It is especially effective at removing constant background sounds like microphone hiss, HVAC noise, or venue ambience.


Basic Command

Apply a Noise Gate

ffmpeg -i input.mp3 -af "agate=threshold=0.02:attack=5:release=100:range=0.0" output.mp3
ParameterValueDescription
threshold0.02Level at which the gate opens (0.0–1.0)
attack5Time to fully open the gate (ms)
release100Time to fully close the gate (ms)
range0.0Attenuation when gated (0.0 = full mute, 1.0 = no change)

Parameter Reference

ParameterDescriptionDefaultRange
level_inInput gain (multiplier)10.015625–64
modeGate modedownwarddownward / upward
rangeMinimum ratio when the gate is closed0.061250.0–1.0
thresholdLevel above which the gate opens0.1250.0–1.0
ratioCompression ratio (interacts with range)21–9000
attackAttack time (ms)200.01–9000
releaseRelease time (ms)2500.01–9000
makeupMakeup gain11–64
kneeKnee width (dB)2.8281–8
detectionDetection methodrmspeak / rms
linkStereo linkingaverageaverage / maximum

Settings for Podcasts and Voice-Over

ffmpeg -i voice_recording.mp3 \
  -af "agate=threshold=0.015:attack=5:release=200:range=0.0" \
  output_clean.mp3

Notes:

  • threshold=0.015 — Adjust to match your voice level (try 0.01 for quieter voices, 0.025 for louder ones)
  • attack=5 — 5ms to open; too short and syllable onsets get clipped
  • release=200 — Close 200ms after the tail of a word for a natural feel
  • range=0.0 — Full mute when gated

Measure the Noise Floor Before Setting Threshold

To pick an optimal threshold, first measure the noise level during the silent sections.

ffmpeg -i input.mp3 -af "astats=metadata=1:reset=1,ametadata=print:key=lavfi.astats.Overall.RMS_level" -f null - 2>&1 | grep RMS

Review the reported RMS level (dBFS) and choose a threshold that sits between the noise floor and the voice level.


Combine with Input Gain

ffmpeg -i input.mp3 \
  -af "agate=threshold=0.02:attack=5:release=150:range=0.0:level_in=1.5" \
  output.mp3

level_in=1.5 boosts the input by 1.5× before the gate processes it. This helps with quiet microphone recordings.


Choosing Between agate and silenceremove

FilterBehaviorBest for
agateAttenuates audio during silence (does not remove it)Real-time processing, natural finish
silenceremovePhysically removes silent sectionsPost-edit trimming, podcast shortening

Use agate when you want to preserve the flow of conversation or music, and silenceremove when you need to strip silence entirely.


Chaining with Other Filters

Gate → Loudness Normalization Pipeline

ffmpeg -i input.mp3 \
  -af "agate=threshold=0.02:attack=5:release=150:range=0.0, \
       loudnorm=I=-16:TP=-1.5:LRA=11" \
  output.mp3

Remove background noise with the gate, then bring the level up to target with loudnorm.


Apply to the Audio Track of a Video

ffmpeg -i input.mp4 \
  -af "agate=threshold=0.02:attack=5:release=150:range=0.0" \
  -c:v copy \
  output.mp4

-c:v copy preserves the video stream unchanged while only the audio is processed.


Caveats

  • threshold is a linear value (0.0–1.0). To convert from dBFS: threshold = 10^(dBFS/20). For example, -40 dBFS is about 0.01.
  • If attack is too short, sharp consonants (s, t, etc.) get clipped. 5–20 ms works well.
  • If release is too short, natural word decay is removed. 100–300 ms is typical.
  • range=0.0 is full mute. If the resulting silence sounds unnatural, try range=0.02 or so.