Convert Audible aax-files

How to convert the proprietary aax-audiobook format from Audible to mp3

inAudible-NG/tables Github Repo
https://github.com/inAudible-NG/tables.git

aax2mp3 Bitbucket Repo
https://bitbucket.org/kleberj/aax2mp3.git

First time setup

To convert your aax-files, you'll need your personal authentification token.
To obtain it, first download an audiobook from your Audible library.
Now clone the inAudible-NG/tables repository and enter the directory:

git clone https://github.com/inAudible-NG/tables.git
cd tables

Next calculate the checksum of your aax-file with ffmpeg and use rcrack.sh from the tables repository to get the authentification token:

ffprobe -i /path/to/your/file.aax 2>&1 | awk '/checksum/{print $NF}' 
# you get something like 999a6ab8...
./rcrack . -h 999a6ab8...
# statistics
# -------------------------------------------------------
# plaintext found:                              1 of 1
# total time:                                   13.98 s
# [...]
# result
# ----------------------------------------------------------------
# 999a6ab8...  \xa5\xd0Y1  hex:CAFED00D

Your personal authentification token can be found after "hex:", so in the above example CAFED00D.
Store this token in your *rc.file as export AAX2MP3_AUTHCODE=CAFED00D (or when using fish with set -Ux AAX2MP3_AUTHCODE CAFED00D).

As the last preparation step, clone the aax2mp3 Bitbucket repository and copy the binary to your .local/bin directory:

cd /tmp
git clone https://bitbucket.org/kleberj/aax2mp3.git
cd aax2mp3
cp aax2mp3 ~/.local/bin/aax2mp3
chmod u+x ~/.local/bin/aax2mp3

Logout and login again, to make the binary available.

Convert your audiobooks

aax2mp3 -i /path/to/your/file.aax

This converts the given file in the current directory and splits the chapters in single files.
To create a single mp3 file instead, use:

aax2mp3 -S -i test.aax 

Extract cover and add it to the files (optional)

To add the cover to the files, you'll need a tool like eyeD3, so make sure to install it first.

First enter the regarding audiobook directory and extract the cover from the first file using ffmpeg:

cd /path/to/the/converted/audiobook
ffmpeg -i chapter1.mp3 Cover.jpg

Now add it to the remaining chapter files with eyeD3:

eyeD3 *.mp3 --add-image=Cover.jpg:FRONT_COVER