-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathencodeTo.sh
executable file
·56 lines (49 loc) · 981 Bytes
/
encodeTo.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
50
51
52
53
54
55
56
#!/bin/sh
# First create a new directory (aac ac3 mp3)
# Example for aac:
# rsync -a --exclude .git voices.ogg/ voices.aac
# cd voices.aac
# ./encodeTo.sh
if [ $# -ne 1 ]
then
echo "Usage $(basename $0) aac|ac3|mp3"
exit 1
fi
if [ ! -d af ]
then
echo "ERROR: move to the voice directory first"
exit 1
fi
format=$1
if [ $format = "aac" ]
then
codec="libvo_aacenc"
elif [ $format = "ac3" ]
then
codec="ac3"
elif [ $format = "mp3" ]
then
codec="libmp3lame"
else
echo "Error, unsupported format $1"
exit 1
fi
echo "Transcode ogg files to $format"
for f in $(find . -type f -name \*.ogg)
do
#echo "Processing $f"
avconv -v warning -i $f -acodec $codec ${f%.*}.${format}
if [ $? -ne 0 ]
then
echo "ERROR: Failed to convert $f"
fi
rm -f $f
done
echo "Fix symlinks"
for f in $(find . -type l -name \*.ogg)
do
#echo "Processing $f"
target=$(readlink -f $f)
rm $f
ln -s -r ${target%.*}.${format} ${f%.*}.${format}
done