FFmpeg: Measure the average loudness of an audio file
If you need to calculate the average volume or loudness of a file you can use FFmpeg with the volumedetect filter:
ffmpeg -i input.mp3 -af volumedetect -f null /dev/null 2>&1 | grep -P '(mean|max)_volume'
This will report the average (mean) and the maximum volume. This information is useful when comparing two files to see if their "loudness" (or quietness) is comparable.
[Parsed_volumedetect_0 @ 0x698a300] mean_volume: -19.7 dB
[Parsed_volumedetect_0 @ 0x698a300] max_volume: -1.0 dB