[FFmpeg-user] HOW TO APPLY LOUDNESS R128 PROFILE

Moritz Barsnick barsnick at gmx.net
Wed Sep 23 15:42:35 EEST 2020


On Wed, Sep 23, 2020 at 14:16:31 +0200, Marco Mircoli wrote:
> Just bought a php script that use ffmpeg.

I hope it's worth it. ;)

> this is the line
> $shell     = shell_exec("$ffmpeg_b -i $audio_file_full_path -map 0:a:0 -b:a
> 96k $audio_output_mp3 2>&1");
>
> I'm wondering if it is possible to include in the conversion the audio
> level normalization to R128 loudness profile.
> I think it is possible, but I don't know how to do it :-(

Sure. You just need to insert a filter to the command line. The R128
filter is even described here:

https://trac.ffmpeg.org/wiki/AudioVolume#LoudnessNormalization

> $shell     = shell_exec("$ffmpeg_b -i $audio_file_full_path -map 0:a:0 -b:a 96k $audio_output_mp3 2>&1");

Just add the loudnorm filter:

$shell     = shell_exec("$ffmpeg_b -i $audio_file_full_path -map 0:a:0 -af loudnorm -b:a 96k $audio_output_mp3 2>&1");

To fine tune the filter's behavior, check ffmpeg's filters
documentation, or

$ ffmpeg -h filter=loudnorm

Good luck,
Moritz


More information about the ffmpeg-user mailing list