Browse Source

Added audio normalization

itec78 4 years ago
parent
commit
16c80efc40
1 changed files with 8 additions and 6 deletions
  1. 8 6
      trimaudio.sh

+ 8 - 6
trimaudio.sh

@@ -3,24 +3,26 @@
 secmax=240
 secfad=5
 
-temp1=/tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1).m4a
-temp2=/tmp/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1).m4a
+temp1=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
+temp2=$(mktemp /tmp/playlistalo.XXXXXXXX.m4a)
+temp3=$(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
 
 
-# step 2 tronca e sfuma
+#step 2 tronca e sfuma
 len=$(ffprobe -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 -v quiet $temp1)
 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 "$2"
+    mv $temp2 $temp3
     rm $temp1
 else
-    mv $temp1 "$2"
+    mv $temp1 $temp3
 fi
 
-
+#step3 normalizza
+ffmpeg-normalize -q -f $temp3 -c:a aac -o "$2"