How to Use FFmpeg Dynaudnorm for Audio Normalization
This article provides a quick overview and practical guide on how to
use the dynaudnorm (Dynamic Audio Normalizer) filter in
FFmpeg. You will learn the difference between dynamic and peak
normalization, understand the key parameters of the filter, and see
command-line examples to easily level out the volume of your audio and
video files.
What is the
dynaudnorm Filter?
The dynaudnorm filter in FFmpeg is a dynamic audio
normalizer. Unlike standard peak normalization—which increases the
volume of the entire file uniformly based on the single loudest
peak—dynamic normalization adjusts the volume of the audio dynamically
over time.
This means quieter sections (like whispers) are boosted, and louder sections (like explosions) are kept at a safe level, resulting in a more consistent and comfortable listening experience. It is especially useful for podcasts, movies, and speech recordings where volume levels fluctuate significantly.
Basic Usage
To apply dynamic audio normalization with the default settings, use the following basic FFmpeg command:
ffmpeg -i input.mp3 -filter:a "dynaudnorm" output.mp3If you are working with a video file and want to normalize the audio while keeping the video stream untouched (without re-encoding), use:
ffmpeg -i input.mp4 -c:v copy -filter:a "dynaudnorm" output.mp4Essential Parameters
The dynaudnorm filter offers several parameters to
fine-tune how the audio is processed. You can apply these parameters
using the syntax
dynaudnorm=parameter1=value:parameter2=value.
1. Target Peak (p)
Sets the target peak level of the output audio. The value ranges from
0.0 to 1.0. The default is 0.95.
* Example: To set the peak level to 0.9 (90% of maximum
volume):
bash ffmpeg -i input.wav -af "dynaudnorm=p=0.9" output.wav
2. Maximum Gain (m)
Sets the maximum amplification factor that can be applied to the
audio. The default is 10.0 (which allows for significant
boosting of quiet sections). * Example: To limit the maximum
amplification to 5.0 to prevent too much background noise
from being boosted:
bash ffmpeg -i input.wav -af "dynaudnorm=m=5.0" output.wav
3. Frame Length (f)
Defines the analysis window size in milliseconds. The range is from
10 to 8000 ms, with a default of
500 ms. A shorter frame length reacts faster to volume
changes, while a longer frame length provides smoother transitions. *
Example: To set a shorter response time of 250
milliseconds:
bash ffmpeg -i input.wav -af "dynaudnorm=f=250" output.wav
4. Compress Factor (s)
Applies extra compression to the audio. A value of 0.0
(default) disables compression. Higher values (up to 30.0)
will compress the dynamic range further, making the quietest and loudest
parts even closer in volume. * Example: To apply a moderate compression
factor of 15.0:
bash ffmpeg -i input.wav -af "dynaudnorm=s=15.0" output.wav
Advanced Configuration Example
You can combine multiple parameters to customize the normalization process for your specific needs. For example, to normalize a movie audio track with a fast reaction time, limited maximum gain, and a conservative target peak, you can run:
ffmpeg -i input.mkv -c:v copy -af "dynaudnorm=p=0.9:m=4.0:f=300:s=5.0" output.mkv