34 líneas
1.007 B
Bash
Archivo ejecutable
34 líneas
1.007 B
Bash
Archivo ejecutable
#!/bin/sh
|
|
|
|
secmax=240
|
|
secfad=5
|
|
|
|
#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
|
|
|
|
|
|
#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
|
|
rm $temp1
|
|
mv $temp2 $temp3
|
|
else
|
|
mv $temp1 $temp3
|
|
fi
|
|
|
|
#step3 normalizza
|
|
#ffmpeg -i $temp3 -af loudnorm $tempx
|
|
ffmpeg-normalize -q -f $temp3 -c:a aac -o $tempx
|
|
rm $temp3
|
|
mv $tempx "$2"
|