-
Notifications
You must be signed in to change notification settings - Fork 1
/
aax2ogg.sh
45 lines (37 loc) · 1.22 KB
/
aax2ogg.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
#!/bin/bash
# Convert aax to oog
#
# This script converts aax-files to ogg-files.
#
# Parameter: <none> ... convert all aax-files in current directory
# Parameter: <filename.aax> ... convert only filename.aax
FFMPEG=/usr/bin/ffmpeg
FFPROBE=/usr/bin/ffprobe
# next add your own activation-code
# You can extract it with the followin tool: https://github.com/inAudible-NG/audible-activator
ACTIVATION_BYTES="xxxxxxxx"
function convert {
# extract some meta data from the input file
TITLE=`$FFPROBE -show_format "$1" 2>/dev/null | grep TAG:title | cut -d '=' -f 2 | sed 's/:/ -/g'`
ARTIST=`$FFPROBE -show_format "$1" 2>/dev/null | grep TAG:artist | cut -d '=' -f 2`
if [[ ! -d "$ARTIST" ]]; then
mkdir "$ARTIST"
fi
# skip convertion if file already exists
if [[ ! -e "$ARTIST/$TITLE.ogg" ]]; then
echo "Converting $TITLE ..."
time $FFMPEG -v error -stats -activation_bytes $ACTIVATION_BYTES -i "$1" -vn -qscale:a 4 "$ARTIST/$TITLE.ogg" -n
else
echo "File "$ARTIST/$TITLE.ogg" already exists!"
fi
}
if [[ -z "$1" ]]; then
# if there is no parameter then convert all aax-files
for f in `find -type f -iname "*.aax"`
do
convert "$f"
done
else
# only convert one file
convert "$1"
fi