Normalize Audio Dynamically with FFmpeg
This guide explains how to normalize audio levels dynamically using
FFmpeg. While the standard volume filter is ideal for
static gain adjustments and peak normalization, true dynamic
normalization—adjusting quiet and loud parts on the fly—is best achieved
using FFmpeg’s specialized dynamic volume filters,
dynaudnorm and loudnorm. Below, you will find
the exact commands and parameters needed to apply both peak and dynamic
audio normalization to your media files.
Method 1:
Peak Normalization using the volume Filter
Peak normalization adjusts the volume of the entire file by a constant factor so that the loudest peak reaches a target level (usually 0 dB). This prevents clipping but does not change the dynamic range.
To do this with the volume filter, you must use a
two-step process:
Step 1: Analyze the Audio
Run the volumedetect filter to find the current maximum
volume of your input file:
ffmpeg -i input.mp3 -filter:a volumedetect -f null -Look at the terminal output for the max_volume line. For
example:
[parsed_volumedetect_0 @ 0x...] max_volume: -6.1 dB
Step 2: Apply the
volume Filter
To bring the peak volume up to 0 dB, apply the inverse of your
max_volume value using the volume filter:
ffmpeg -i input.mp3 -filter:a "volume=6.1dB" output.mp3Method
2: Dynamic Normalization using the dynaudnorm Filter
If your audio has very quiet whispering and very loud explosions,
peak normalization will not help the quiet parts. To dynamically adjust
the volume throughout the playback, use the dynaudnorm
(Dynamic Audio Normalizer) filter. This filter acts as a continuous
intelligent volume controller.
Run the following command for standard dynamic normalization:
ffmpeg -i input.mp3 -filter:a dynaudnorm output.mp3Key Customization
Parameters for dynaudnorm:
f(Frame Length): Sets the frame length in milliseconds (default is 1022). Lower values react faster to volume changes.g(Gauss Size): The smoothing filter size (default is 15). Must be an odd number. Higher values result in smoother transitions.m(Maximum Gain): The maximum amplification factor (default is 10.0).
Example with custom parameters:
ffmpeg -i input.mp3 -filter:a "dynaudnorm=f=500:g=31:m=15.0" output.mp3Method
3: Standardized Dynamic Normalization using loudnorm
For broadcast-ready dynamic normalization, the loudnorm
filter is recommended. It conforms to the EBU R128 loudness standard,
dynamically compressing the dynamic range to meet a targeted integrated
loudness.
Run this command for a quick, single-pass dynamic normalization:
ffmpeg -i input.mp3 -filter:a "loudnorm=I=-16:TP=-1.5:LRA=11" output.mp3I(Integrated Loudness): The target loudness in LUFS (default is -24. For web/podcasts, -16 is common).TP(True Peak): The maximum peak level in dBTP (default is -2.0).LRA(Loudness Range): The targeted dynamic range in LU (default is 7.0).