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 (or r): Controls the compression ratio. This determines how aggressively the audio dynamic range is compressed. The default value is 2.0, and values can range from 1.0 (no compression) up to 10.0 (heavy compression). Higher ratios make quiet and loud voices closer in volume.
  • threshold (or t): 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 from 0.0 to 1.0 (default is 0.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.mp4

In this command:

  • r=3.0 increases the compression ratio above the default to further even out speech levels.
  • t=0.05 sets the gate threshold to ignore very quiet background noise during pauses.
  • -c:v copy copies 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.wav
  • p=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

  1. If quiet phrases are still too soft: Increase the ratio (r) to 3.5–5.0.
  2. If background hiss pumps during silence: Increase the threshold (t) incrementally (e.g., 0.02, 0.05, 0.1). Setting t too high will cause quieter words or the ends of sentences to cut out abruptly.
  3. If audio sounds over-compressed or unnatural: Lower the ratio (r) closer to 1.5–2.0.