Last active
March 2, 2022 07:56
-
-
Save rraallvv/5370204282eb9b3dcd0cb56bed28a75c to your computer and use it in GitHub Desktop.
FFMPEG mp3 normalization
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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