Browse Source

Added tolerance to trimaudio

itec78 3 years ago
parent
commit
666024dd99
1 changed files with 5 additions and 4 deletions
  1. 5 4
      trimaudio.sh

+ 5 - 4
trimaudio.sh

@@ -1,7 +1,8 @@
 #!/bin/sh
 
-secmax=240
-secfad=5
+secmax=240 #max length
+sectol=15 #tolerance
+secfad=10 #fade
 
 #wav is faster
 temp1=$(mktemp /tmp/playlistalo.XXXXXXXX.wav)
@@ -11,14 +12,14 @@ 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
+ffmpeg -i "$1" -to $(($secmax + $sectol + 30)) -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
 len=$(ffprobe -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 -v quiet $temp1)
 len=${len%.*}
 
-if [ $len -gt $secmax ];
+if [ $len -gt $(($secmax + $sectol)) ];
 then 
     ffmpeg -i $temp1 -to $secmax -af "afade=t=out:st=$(($secmax - $secfad)):d=$secfad" -v quiet -y $temp2
     rm $temp1