How to Use the FFmpeg Dynaudnorm Filter
This article provides a practical guide on how to use the
dynaudnorm (Dynamic Audio Normalizer) filter in FFmpeg. You
will learn what the filter does, its basic syntax, key parameters you
can customize, and real-world command examples to normalize your audio
dynamically without losing quality or causing clipping.
The dynaudnorm filter is an advanced audio filter in
FFmpeg used for dynamic range compression and volume normalization.
Unlike standard normalization, which applies a single gain adjustment to
the entire file, dynaudnorm changes the volume dynamically
over time. This is highly useful for video and audio files with
inconsistent volume levels, such as movies where whispered dialogue is
too quiet and action scenes are too loud.
Basic Syntax
To apply the dynamic audio normalizer with its default settings, use
the -af (audio filter) flag followed by
dynaudnorm:
ffmpeg -i input.mp4 -af dynaudnorm output.mp4This command automatically analyzes the audio in real-time and adjusts the volume to a comfortable, balanced level throughout the duration of the file.
Key Parameters
You can fine-tune the behavior of dynaudnorm by passing
specific parameters. The syntax for passing parameters is
dynaudnorm=parameter1=value:parameter2=value.
f(Frame Length): Sets the frame length in milliseconds. The default is500. Smaller values make the filter react faster to volume changes, while larger values make the transitions smoother.g(Gaussian Filter Window Size): Sets the size of the sliding window used for local analysis. The default is31. It must be an odd number.p(Target Peak): Specifies the maximum peak threshold. The default is0.95(roughly -0.5 dB). This ensures the audio gets loud but never clips or distorts.m(Maximum Gain): Sets the maximum amplification factor. The default is10.0. If you have very quiet sections that you do not want to be amplified too much (like background hiss), you can lower this value (e.g., to5.0).s(Compress Factor): Controls the compression factor. The default is0.0(disabled). Setting this to a value between0.0and30.0helps to compress the dynamic range further.
Practical Examples
Example 1: Smooth Normalization for Movies If you
want a smoother transition between loud and quiet parts, increase the
frame length (f) and the window size (g):
ffmpeg -i input.mkv -af "dynaudnorm=f=1000:g=51" output.mkvExample 2: Restricting Maximum Gain To normalize a
podcast or voice recording without heavily amplifying background room
noise during silences, limit the maximum gain (m) to
3.0:
ffmpeg -i podcast.mp3 -af "dynaudnorm=m=3.0" output.mp3Example 3: Normalize Audio and Copy Video Stream If
you are processing a video file and only want to modify the audio
without re-encoding the video, use the -c:v copy option.
This saves a significant amount of processing time:
ffmpeg -i input.mp4 -af dynaudnorm -c:v copy output.mp4