FFmpeg Dynamic Range Compression with dynaudnorm

This article explains how to use the dynaudnorm (Dynamic Audio Normalizer) filter in FFmpeg to apply dynamic range compression to your audio files. You will learn the basic command syntax, understand the key parameters for fine-tuning the filter, and see practical examples of how to balance loud and quiet sections of your audio without introducing clipping or distortion.

Understanding the dynaudnorm Filter

The dynaudnorm filter is an advanced tool in FFmpeg designed for dynamic range compression and audio normalization. Unlike standard peak normalization, which applies a single gain factor to the entire file, dynaudnorm analyzes the audio in small, overlapping windows (frames) and applies a changing amount of gain over time. This boosts quiet passages (like whispered dialogue) and tames loud spikes (like explosions) to create a more consistent and comfortable listening volume.

Basic Usage

To apply the Dynamic Audio Normalizer with its default settings, use the -af (audio filter) flag in your FFmpeg command:

ffmpeg -i input.mp3 -af dynaudnorm output.mp3

This default command is highly effective for most general audio files, podcasts, and video soundtracks.

Key Parameters for Fine-Tuning

You can customize the behavior of the dynaudnorm filter by passing specific parameters in a key-value format: dynaudnorm=parameter1=value1:parameter2=value2.

Practical Examples

1. Gentle Compression for Music

For music, you want to avoid abrupt changes in volume to preserve the artistic dynamics of the track. A larger window size and lower maximum gain work best:

ffmpeg -i music.wav -af "dynaudnorm=g=51:m=5:p=0.98" output.wav

2. Aggressive Compression for Dialogue and Podcasts

If you are processing a podcast or movie dialogue where some speakers are very quiet and others are very loud, you can use a smaller window and higher gain limit to level out the voices:

ffmpeg -i podcast.mp3 -af "dynaudnorm=f=150:g=15:m=15" output.mp3

3. Preventing Background Noise Boost

If your audio has silent gaps where you do not want background hiss or room tone to be amplified, reduce the maximum gain parameter (m):

ffmpeg -i interview.wav -af "dynaudnorm=m=3.0" output.wav