-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathopus2mp3.sh
executable file
·47 lines (41 loc) · 1.05 KB
/
opus2mp3.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
#!/bin/bash
# @author Fred Brooker <[email protected]>
if [ $# -eq 0 ]; then
echo -e "\nConvert OPUS files to MP3 recursively.\n\nSyntax: $(basename $0) <folder>\n"
exit 1
fi
which ffmpeg >/dev/null 2>&1 || (echo "Installing ffmpeg" && sudo apt-get install -yqq ffmpeg)
which ffmpeg >/dev/null 2>&1 || (echo "ERROR: ffmpeg is not installed" && exit 1)
which lame >/dev/null 2>&1 || (echo "Installing lame" && sudo apt-get install -yqq lame)
which lame >/dev/null 2>&1 || (echo "ERROR: lame is not installed" && exit 1)
if [ -n "$1" ]; then
if [ -d "$1" ]; then
cd "$1"
else
echo "Invalid folder: $1"
exit 1
fi
fi
for i in *
do
if [ -d "$i" ]; then
echo "Recursing into directory: $i"
$0 "$i"
fi
done
for i in *.opus
do
if [ -f "$i" ]; then
echo "Converting: $i"
j="${i%.opus}"
ffmpeg -i "$i" -vn "$j.wav"
lame -h --preset extreme "$j.wav" "$j.mp3"
if [ $? -eq 0 ]; then
echo "Successfully converted: $i"
rm -f "$i" "$j.wav"
else
echo "Failed to convert: $i"
fi
fi
done
echo -e "Done.\n"