Skip to content

Instantly share code, notes, and snippets.

@rraallvv
Last active March 2, 2022 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rraallvv/5370204282eb9b3dcd0cb56bed28a75c to your computer and use it in GitHub Desktop.
Save rraallvv/5370204282eb9b3dcd0cb56bed28a75c to your computer and use it in GitHub Desktop.
FFMPEG mp3 normalization
#!/bin/bash
find . -type f -not -name ".*" -print0 | while read -d $'\0' file; do
echo $file
level=$(ffmpeg -y -nostdin -i $file -af "volumedetect" -vn -sn -dn -f null /dev/null 2>&1 | grep max_volume | sed -n 's/.*max_volume: \([^ ]*\) .*/\1/p')
gain=$(bc -l <<< "-($level)")
echo "${gain}dB"
ffmpeg -y -nostdin -loglevel panic -i $file -af "volume=${gain}dB" temp.mp3
rm $file
mv temp.mp3 $file
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment