Added tolerance to trimaudio

This commit is contained in:
itec78 2020-08-25 12:59:43 +02:00
parent 70b5d259cb
commit 666024dd99

View file

@ -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