-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconcat-mp3
More file actions
executable file
·55 lines (42 loc) · 1.01 KB
/
concat-mp3
File metadata and controls
executable file
·55 lines (42 loc) · 1.01 KB
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
50
51
52
53
54
55
#!/usr/bin/env bash
set -xeuo pipefail
if termux-battery-low; then
echo "Battery is too low to concat files"
exit 1
fi
deleteList=()
name=''
tmpSilenceDir=$(mktemp concat-mp3.XXXXXX --directory --tmpdir)
tmpWavSilenceFile="$tmpSilenceDir/silence.wav"
tmpMp3SilenceFile="$tmpSilenceDir/silence.mp3"
function cleanup()
{
rm -f "$tmpWavSilenceFile" "$tmpMp3SilenceFile"
if [ -d "$tmpSilenceDir" ]; then
rmdir "$tmpSilenceDir"
fi
}
trap cleanup EXIT
files=("$@")
[[ $# -eq 0 ]] && files=( *.mp3 )
for x in "${files[@]}"; do
if [ -z "$name" ]; then
name=$(basename "$x" .mp3)
if contains "$name" "MP3WRAP"; then
exit 2
fi
# make a silent file
sox -n -r 44100 -c 2 "$tmpWavSilenceFile" trim 0.0 0.0
lame "$tmpWavSilenceFile" "$tmpMp3SilenceFile"
nice -n 15 mp3wrap "$name" "$x" "$tmpMp3SilenceFile"
else
nice -n 15 mp3wrap -a "${name}_MP3WRAP.mp3" "$x"
mv -v "temp_MP3WRAP.mp3" "${name}_MP3WRAP.mp3"
fi
deleteList+=("$x")
done
cleanup
for mp3 in "${deleteList[@]}"; do
s3-trash "$mp3"
done
exit 0