-
Notifications
You must be signed in to change notification settings - Fork 0
/
mysox.sh
executable file
·50 lines (46 loc) · 1.29 KB
/
mysox.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/env bash
# seq start step end
startHz=1
step=50
endHz=500
width=15h
Hz=($(seq $startHz $step $endHz))
after=soxOutput
before=soxInput
outExt=mp4
progressbar=##
echo -ne "\n=============Converting================\n${progressbar}\r"
ffmpeg -y -i "${1}" soxNoisered.wav > /dev/null 2>&1
# sox in.ext out.ext trim {start: s.ms} {duration: s.ms}
sox soxNoisered.wav noise-audio.wav trim 0 0.400
progressbar+=##
# generate noise profile
echo -ne "${progressbar}\r"
sox noise-audio.wav -n noiseprof noise.prof
progressbar+=###
# remove noise
echo -ne "${progressbar}\r"
sox soxNoisered.wav soxInput.wav noisered noise.prof 0.3
progressbar+=##
# remove noisy audio
echo -ne "${progressbar}\r"
rm soxNoisered.wav
rm noise-audio.wav
rm noise.prof
progressbar+=#
echo -ne "${progressbar}\r"
progressbar+=#
echo -ne "${progressbar}\r"
for i in "${Hz[@]}"
do
progressbar+=##
sox "${before}.wav" "${after}${i}.wav" bandreject ${i} ${width} && rm "${before}.wav" > /dev/null 2>&1
# echo -e "${before}.wav" "${after}${i}.wav \n"
before="${after}${i}"
echo -ne "${progressbar}\r"
done
progressbar+=##
ffmpeg -y -i "$1" -i ${after}*.wav -map 0:v -map 1:a -c:v copy -c:a aac -b:a 128k Cleared"${1}".${outExt} > /dev/null 2>&1
rm ${after}*.wav
progressbar+=##
echo -e "${progressbar}\r\nFinished 100%"