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

Verified: FFmpeg 8.1 on Windows — all 5 commands in this article were executed by the verification script and passed (2026-09-06). 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. Once the voice is clean, you can layer background music with the amix BGM workflow to finish a narrated video.


Basic Command

Apply a Noise Gate

ffmpeg -i input.mp3 -af "agate=threshold=0.02:attack=5:release=100:range=0.0" output.mp3
Parameter Value Description
threshold 0.02 Level at which the gate opens (0.0–1.0)
attack 5 Time to fully open the gate (ms)
release 100 Time to fully close the gate (ms)
range 0.0 Attenuation when gated (0.0 = full mute, 1.0 = no change)

Parameter Reference

Parameter Description Default Range
level_in Input gain (multiplier) 1 0.015625–64
mode Gate mode downward downward / upward
range Minimum ratio when the gate is closed 0.06125 0.0–1.0
threshold Level above which the gate opens 0.125 0.0–1.0
ratio Compression ratio (interacts with range) 2 1–9000
attack Attack time (ms) 20 0.01–9000
release Release time (ms) 250 0.01–9000
makeup Makeup gain 1 1–64
knee Knee width (dB) 2.828 1–8
detection Detection method rms peak / rms
link Stereo linking average average / 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. For a fuller breakdown of RMS, peak, and other metrics, see measuring audio statistics with astats.

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

Filter Behavior Best for
agate Attenuates audio during silence (does not remove it) Real-time processing, natural finish
silenceremove Physically removes silent sections Post-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.