Configure FFmpeg speechnormalizer Ratio and Threshold

This article provides a straightforward guide on how to configure the compression behavior and noise gate threshold of the speechnormalizer filter in FFmpeg. You will learn the specific parameters required to control speech volume envelope adjustments, prevent background noise amplification, and apply these settings using practical command-line examples.

The speechnormalizer filter in FFmpeg is an audio filter designed to automatically adjust the volume of speech to a consistent level. Unlike standard compressors, it uses a speech-profile-based approach. To control its compression strength and noise gating, you must configure its key parameters: threshold, max_gain, and peak.

1. Configuring the Gate Threshold

The noise gate threshold prevents the filter from amplifying quiet background noise during silent intervals. In the speechnormalizer filter, this is controlled by the threshold (or t) option.

  • Parameter: threshold
  • Value Range: 0.0 to 1.0 (Default is 0.22)
  • How it works: Any audio signal below this threshold is treated as noise or silence, meaning the filter will not apply gain to it.
  • Adjustment:
    • Increase this value (e.g., 0.35) if you have a noisy background and notice the filter is boosting hiss or hum during pauses.
    • Decrease this value (e.g., 0.10) if quiet speech is being cut off or ignored by the normalizer.

2. Configuring the Compression Ratio (Intensity)

The speechnormalizer does not use a traditional static compression ratio (like 4:1). Instead, it acts as an Automatic Gain Control (AGC). You control the compression range and output level using the max_gain and peak parameters.

  • max_gain (or g): Sets the maximum digital gain in dB that the filter can apply to quiet speech. The default is 15.0.
    • Lower values (e.g., 5.0 to 8.0) result in a gentler, more natural compression (lower ratio effect).
    • Higher values (e.g., 20.0) squeeze the dynamic range heavily, making quiet voices match loud voices almost completely (high compression ratio effect).
  • peak (or p): Sets the target peak amplitude of the output audio. The default is 0.9. Setting this closer to 1.0 maximizes the output volume without clipping.

3. Practical FFmpeg Command Example

To apply these configurations, chain the parameters within the -af (audio filter) flag using the parameter=value syntax separated by colons.

Here is a command that sets a moderate compression maximum gain of 10 dB, a target peak of 0.95, and a strict noise gate threshold of 0.30 to block background hiss:

ffmpeg -i input.mp3 -af "speechnormalizer=peak=0.95:max_gain=10:threshold=0.30" output.mp3

Parameter Breakdown:

  • peak=0.95: The output audio will peak at 95% of maximum digital volume.
  • max_gain=10: Restricts the normalizer from boosting any quiet speech by more than 10 dB, preserving some natural dynamics.
  • threshold=0.30: Audio below 30% of the detection threshold is ignored, keeping background noise quiet during pauses.