-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertToMP3
executable file
·37 lines (32 loc) · 1021 Bytes
/
convertToMP3
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
#!/bin/bash
## -------------------------------------------------------------------
## Sound file to MP3 converter 1.0.0
##
## This is free software: you are free to change and redistribute it.
## There is NO WARRANTY, to the extent permitted by law.
## -------------------------------------------------------------------
### Converts all files with a given extension to mp3 files.
### Usage: convertToMP3 [options] <extension>
###
### -h, --help Show help options.
### -v, --version Print program version.
help=$(grep "^### " "$0" | cut -c 5-)
version=$(grep "^## " "$0" | cut -c 4-)
eval "$(docopts -A args -h "$help" -V "$version" : "$@")"
ext=${args[<extension>]}
for i in *.$ext
do
if [ -f "$i" ]; then
rm -f "$i.wav"
mkfifo "$i.wav"
mplayer \
-quiet \
-vo null \
-vc dummy \
-af volume=0,resample=44100:0:1 \
-ao pcm:waveheader:file="$i.wav" "$i" &
dest=`echo "$i"|sed -e "s/$ext$/mp3/"`
lame -V0 -h -b 160 --vbr-new "$i.wav" "$dest"
rm -f "$i.wav" "$i"
fi
done