Configure FFmpeg dynaudnorm Filter Parameters
The FFmpeg dynaudnorm (Dynamic Audio Normalizer) filter
is a powerful tool used to level out audio volume dynamically without
causing clipping or losing perceived dynamic range. This article
provides a straightforward guide on how to configure its three most
critical parameters: frame length, filter window size, and target peak.
By adjusting these settings, you can customize the normalization process
to suit different audio types, from podcasts with spoken dialogue to
highly dynamic movie soundtracks.
The dynaudnorm filter operates by analyzing audio in
small segments and applying a spatially smooth gain factor. Here is how
to configure the key parameters to control this behavior.
1. Frame Length (f or
framelen)
The frame length parameter defines the size of each individual audio segment (in milliseconds) that the filter analyzes and processes at one time.
- Syntax:
f=valueorframelen=value - Default:
1022ms - Allowed Range:
10to8000ms - How it works: A shorter frame length allows the filter to react very quickly to sudden changes in volume, which is ideal for highly erratic audio. However, setting this value too low can introduce audible distortion or a “pumping” effect. A longer frame length results in a smoother, more natural-sounding adjustment but may miss rapid volume spikes.
2. Filter Window Size
(g or gaussSize)
The filter window size determines the number of neighboring frames used to calculate the Gaussian smoothing filter. This smoothing prevents abrupt volume changes between adjacent frames.
- Syntax:
g=valueorgaussSize=value - Default:
31 - Allowed Range: Any odd integer from
3to301 - How it works: The window size directly influences
how gradually the volume adjustments occur. A larger window size (e.g.,
51or101) creates a wider, smoother transition of volume changes over time, preserving more of the original audio dynamics. A smaller window size makes the volume leveling more aggressive and immediate.
3. Target Peak (p or
peak)
The target peak parameter sets the maximum peak amplitude for the output audio signal.
- Syntax:
p=valueorpeak=value - Default:
0.95(which corresponds to roughly -0.45 dB) - Allowed Range:
0.0to1.0 - How it works: This value represents a linear scale
where
1.0is the absolute maximum digital ceiling (0 dBFS). Setting the peak to0.95is highly recommended because it leaves a small amount of headroom to prevent clipping during digital-to-analog conversion on playback devices.
Command Line Examples
To apply these parameters in FFmpeg, you chain them inside the
-af (audio filter) argument using colons to separate each
option.
Example 1: Standard Balanced Normalization
This configuration uses default-like values suitable for general movies and TV shows, ensuring smooth transitions and safe peak levels.
ffmpeg -i input.mp4 -af "dynaudnorm=f=1022:g=31:p=0.95" output.mp4Example 2: Aggressive Normalization for Speech/Podcasts
For speech, you want fast adaptations to keep quiet voices audible and loud voices reigned in. This setup uses a shorter frame length and smaller window size.
ffmpeg -i podcast_input.wav -af "dynaudnorm=f=500:g=15:p=0.98" podcast_output.wavExample 3: Ultra-Smooth Normalization for Classical Music
To preserve the natural crescendo and decrescendo of music while gently leveling the overall volume, use a larger frame size and a wider Gaussian window.
ffmpeg -i music_input.wav -af "dynaudnorm=f=2000:g=101:p=0.90" music_output.wav