Audio Volume Manipulation
Changing volume
To change the audio volume, you may use FFmpeg's volume audio filter.
If we want our volume to be half of the input volume:
ffmpeg -i input.wav -filter:a "volume=0.5" output.wav
150% of current volume:
ffmpeg -i input.wav -filter:a "volume=1.5" output.wav
You can also use decibel measures. To increase the volume by 10dB:
ffmpeg -i input.wav -filter:a "volume=10dB" output.wav
To reduce the volume, use a negative value:
ffmpeg -i input.wav -filter:a "volume=-5dB" output.wav
Note that the volume
filter only adjusts the volume. It does not set the volume. To set or otherwise normalize the volume of a stream, see the sections below.
Peak and RMS Normalization
To normalize the volume to a given peak or RMS level, the file first has to be analyzed using the volumedetect
filter:
ffmpeg -i input.wav -filter:a volumedetect -f null /dev/null
Read the output values from the command line log:
[Parsed_volumedetect_0 @ 0x7f8ba1c121a0] mean_volume: -16.0 dB [Parsed_volumedetect_0 @ 0x7f8ba1c121a0] max_volume: -5.0 dB ...
... then calculate the required offset, and use the volume
filter as shown above.
Loudness Normalization
If you want to normalize the (perceived) loudness of the file, use the loudnorm filter, which implements the EBU R128 algorithm:
ffmpeg -i input.wav -filter:a loudnorm output.wav
This is recommended for most applications, as it will lead to a more uniform loudness level compared to simple peak-based normalization. However, it is recommended to run the normalization with two passes, extracting the measured values from the first run, then using the values in a second run with linear normalization enabled. See the loudnorm filter documentation for more.
Automatization with ffmpeg-normalize
To automate the normalization processes with ffmpeg without having to manually perform two passes, and run normalization on multiple files (including video), you can also use the ffmpeg-normalize Python program via pip install ffmpeg-normalize
.
The script defaults to EBU R128 normalization with two passes, but peak and RMS normalization are also supported.
For details, run ffmpeg-normalize -h
or see the README file.