Optimized trimaudio

This commit is contained in:
itec78 2020-06-21 12:26:04 +02:00
parent 16c80efc40
commit a70905d5f9

View file

@ -3,9 +3,12 @@
secmax=240
secfad=5
temp1=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
temp2=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
temp3=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
#wav is faster
temp1=$(mktemp /tmp/playlistalo.XXXXXXXX.wav)
temp2=$(mktemp /tmp/playlistalo.XXXXXXXX.wav)
temp3=$(mktemp /tmp/playlistalo.XXXXXXXX.wav)
tempx=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
#step 1 rimuove il silenzio
ffmpeg -i "$1" -to $(($secmax + 15)) -af "silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse,silenceremove=start_periods=1:start_duration=1:start_threshold=-60dB:detection=peak,aformat=dblp,areverse" -v quiet -y $temp1
@ -18,11 +21,14 @@ len=${len%.*}
if [ $len -gt $secmax ];
then
ffmpeg -i $temp1 -to $secmax -af "afade=t=out:st=$(($secmax - $secfad)):d=$secfad" -v quiet -y $temp2
mv $temp2 $temp3
rm $temp1
mv $temp2 $temp3
else
mv $temp1 $temp3
fi
#step3 normalizza
ffmpeg-normalize -q -f $temp3 -c:a aac -o "$2"
#ffmpeg -i $temp3 -af loudnorm $tempx
ffmpeg-normalize -q -f $temp3 -c:a aac -o $tempx
rm $temp3
mv $tempx "$2"