1234567891011121314151617181920212223242526 |
- #!/bin/sh
- 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
- #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
- 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"
- rm $temp1
- else
- mv $temp1 "$2"
- fi
|