FFmpeg speechnormalizer: Ratio and Gate Threshold
This guide explains how to configure the compression ratio and gate
threshold parameters using FFmpeg's speechnormalizer audio
filter. By adjusting these two settings, you can control the dynamic
range compression of spoken dialogue while preventing unwanted
background noise from being amplified during pauses in speech.
Understanding the Parameters
The speechnormalizer filter processes speech signals by
boosting quiet passages and attenuating louder sections. The two key
parameters controlling this behavior are:
ratio(orr): Controls the compression ratio. This determines how aggressively the audio dynamic range is compressed. The default value is2.0, and values can range from1.0(no compression) up to10.0(heavy compression). Higher ratios make quiet and loud voices closer in volume.threshold(ort): Sets the gate threshold for speech detection. It functions as a noise gate, defining the input signal level below which the normalizer treats the audio as background noise rather than active speech. It accepts values from0.0to1.0(default is0.0). Increasing this value prevents the filter from raising ambient room tone or hiss during speech pauses.
Basic Command Syntax
To specify the ratio and threshold, pass the r and
t options into the -af (audio filter)
argument:
ffmpeg -i input.mp4 -af "speechnormalizer=r=3.0:t=0.05" -c:v copy output.mp4In this command:
r=3.0increases the compression ratio above the default to further even out speech levels.t=0.05sets the gate threshold to ignore very quiet background noise during pauses.-c:v copycopies the video stream without re-encoding to save time and preserve video quality.
Full Example with Peak Targeting
In typical usage, you will also want to set the target peak level
(p or peak) along with the ratio and threshold
to avoid digital clipping:
ffmpeg -i input.wav -af "speechnormalizer=p=0.95:r=2.5:t=0.03" output.wavp=0.95: Limits the maximum output amplitude to 95% (-0.45 dBFS) to leave head room.r=2.5: Applies moderate dialogue compression.t=0.03: Keeps the expansion active for weak voice signals while cutting out faint microphone hiss.
Tips for Tuning
- If quiet phrases are still too soft: Increase the
ratio (
r) to3.5–5.0. - If background hiss pumps during silence: Increase
the threshold (
t) incrementally (e.g.,0.02,0.05,0.1). Settingttoo high will cause quieter words or the ends of sentences to cut out abruptly. - If audio sounds over-compressed or unnatural: Lower
the ratio (
r) closer to1.5–2.0.