What is a Noise Gate?

A noise gate turns audio down, or mutes it, when its level falls below a threshold.

  • While someone speaks or an instrument plays, the sound passes through (the gate is open).
  • During silence or quiet noise, the gate closes and turns the sound down or off.

This turns down steady background noise, such as microphone hiss or air-conditioning hum, in the pauses between words. Noise underneath the voice itself stays. Once the pauses are clean, you can add background music with amix 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 Limit on how far the gate turns the signal down (1.0 = no change, 0.0 = no limit)

Parameter Reference

Parameter Description Default Range
level_in Input gain (multiplier) 1 0.015625–64
mode Gate mode downward downward / upward
range Lowest gain 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 Ratio by which the signal below the threshold is reduced 2 1–9000
attack Attack time (ms) 20 0.01–9000
release Release time (ms) 250 0.01–9000
makeup Makeup gain: extra gain on the output (multiplier) 1 1–64
knee Softens the transition around the threshold (a factor, not dB) 2.828 1–8
detection How the level is measured rms peak / rms
link How the channels are combined for detection 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
  • threshold=0.015: adjust it to your voice. Try 0.01 for a quiet voice and 0.025 for a loud one.
  • attack=5: the gate opens in 5 ms. A longer attack opens it late and cuts off the start of each syllable.
  • release=200: the gate takes 200 ms to close after a word ends, so words fade out naturally.
  • range=0.0: no limit on the reduction. How far quiet sounds drop depends on ratio (default 2) and on how far below the threshold they are.

Measure the Noise Floor Before Setting Threshold

To choose a threshold, first measure the noise level in the silent parts. For what RMS, peak and the other values mean, see measuring audio levels 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

The command prints one RMS level (in dBFS) per audio frame. The values during the pauses are the noise floor. Choose a threshold between the noise floor and the voice level. threshold is a linear value, so convert the dBFS number first (see Caveats).

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 multiplies the input level by 1.5 before the gate. Use it for recordings where the microphone was too quiet.

Choosing Between agate and silenceremove

Filter Behavior Best for
agate Turns silent parts down but keeps them Real-time processing, a natural sound
silenceremove Cuts silent parts out of the file Trimming after editing, shortening podcasts

Use agate to keep the pauses and the natural flow of speech or music. Use silenceremove to cut the pauses out.

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

The gate first lowers the noise between phrases. loudnorm then brings the overall level to the target.

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 keeps the video as it is, without re-encoding. Only the audio is processed.

Caveats

  • threshold is a linear value from 0.0 to 1.0, not dB. To convert from dBFS, use threshold = 10^(dBFS/20). For example, -40 dBFS is about 0.01.
  • If attack is too long, the gate opens late and cuts off sharp consonants such as s and t. 5–20 ms works well.
  • If release is too short, the natural fade at the end of words is cut off. 100–300 ms is typical.
  • range=0.0 does not fully mute: sounds just below the threshold are turned down only a little. For a hard mute, raise ratio (for example ratio=9000). If the result sounds unnatural, try a value around range=0.02. That limits the reduction to about 34 dB.