-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch.sh
More file actions
executable file
·25 lines (20 loc) · 868 Bytes
/
batch.sh
File metadata and controls
executable file
·25 lines (20 loc) · 868 Bytes
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
#!/bin/zsh
# https://gist.github.com/valosekj/dce78453f232362201ac4f8229678bd4
# https://stackoverflow.com/questions/125281/how-do-i-remove-the-file-suffix-and-path-portion-from-a-path-string-in-bash
# https://trac.ffmpeg.org/wiki/Encode/MP3
for file in ./input/**/*(.); do
# if wav, encode as mp3 vbr0
if [[ "${file##*.}" == "wav" ]]; then
# ffmpeg -i $file -codec:a libmp3lame -b:a 320k ${file%.*}.mp3
ffmpeg -i $file -codec:a libmp3lame -q:a 0 ${file%.*}.mp3
fi
# swap "input" w/ "output" in file path; make subdir in "output" folder
new_path=${file/input/output}
mkdir -p $(dirname "${new_path}")
python3 mp3glitch.py ${file%.*}.mp3 ${new_path%.*}.mp3 -p 7 -M 6 -w 19
# convert glitched mp3 back to wav
ffmpeg -i ${new_path%.*}.mp3 $new_path
# remove both clean and glitched mp3s
rm ${file%.*}.mp3 ${new_path%.*}.mp3
# rm ${file%.*}.mp3
done