FFmpeg Dynaudnorm Frame Length and Filter Window
This article explains how to configure the dynamic range compression
and normalization behavior of the FFmpeg dynaudnorm
(Dynamic Audio Normalizer) filter. Specifically, we will look at the
parameters that control the frame length (framelen) and the
Gaussian filter window size (gaussSize), and how adjusting
these settings impacts your audio processing workflow.
The dynaudnorm filter in FFmpeg is an advanced tool used
to normalize audio dynamically without clipping. Unlike traditional
normalization, which applies a constant gain to the entire file, the
dynamic approach adjusts the volume on the fly. Two critical parameters
govern how responsive and smooth these adjustments are:
1. Frame Length (framelen
/ f)
The framelen parameter (shorthand
f) controls the frame length in
milliseconds.
- Default Value:
250(milliseconds) - Allowed Range:
10to8000(milliseconds)
This parameter defines the size of the individual analysis blocks. A smaller frame length makes the filter highly responsive to rapid volume changes, which is useful for highly dynamic content like dialogue mixed with sudden sound effects. However, setting this value too low can lead to distortion or an unnatural “pumping” effect. A larger frame length results in smoother transitions but may react too slowly to sudden spikes in volume.
2. Filter Window Size
(gaussSize / g)
The gaussSize parameter (shorthand
g) controls the size of the Gaussian
filter window.
- Default Value:
31 - Allowed Range:
3to301(must be an odd integer)
This parameter determines how many frames are used to perform the moving average for the volume envelope smoothing. The filter window ensures that the gain factor changes smoothly over time rather than abruptly between adjacent frames. A larger Gaussian window produces a broader, more natural-sounding compression over longer periods, while a smaller window forces the filter to adapt quickly to local variations at the risk of less cohesive overall audio.
Example FFmpeg Implementation
To customize these parameters in an FFmpeg command, you pass them as
key-value pairs inside the -af (audio filter) argument.
ffmpeg -i input.mp4 -af "dynaudnorm=framelen=150:gaussSize=25" output.mp4In this command, the frame length is shortened to 150
milliseconds to increase responsiveness, and the filter window is
reduced to 25 frames to match the quicker analysis
cycle.