Removing encryption from an Audible aax file

See https://github.com/inAudible-NG/audible-activator.

First run the commands below. Run sudo -v first if you paste them all at once to a shell and you have not made sudo not require a password, or just remove the second line if you have already installed pip.

brew install chromedriver ffmpeg
sudo easy_install pip
pip install selenium requests
git clone https://github.com/inAudible-NG/audible-activator
cd audible-activator
sed -i '' 's,chromedriver_path = "./chromedriver",chromedriver_path = "/usr/local/bin/chromedriver",' audible-activator.py
./audible-activator.py

Then enter your Audible username and password and wait for a while for the eight character activation key to be printed.

If you do not run the sed command that changes the value of the chromedriver_path variable, ./audible-activator.py results in an error like 'chromedriver' executable needs to be in PATH even if a chromedriver executable is on the path or in the audible-activator directory.

After that run a command like this:

ffmpeg -activation_bytes youractivationkey -i input.aax -vn -c:a copy output.m4a;mv output.m4{a,b}

If you try to use the ffmpeg command with an aa file instead of an aax file, it results in an error like Option activation_bytes not found. To download a book from Audible as aax instead of aa, choose "Enhanced" from the "Audio Quality" dropdown in the view for downloading a book.

aax files are encrypted mp4 / m4a / m4b files so the ffmpeg command does not re-encode audio and it preserves metadata such as chapters. mp4, m4a, and m4b are alternative filename extensions for the MPEG-4 Part 14 container format. One difference between the m4a and m4b extensions is that the option to remember the previous playback position in iTunes is enabled by default for files with an m4b extension but not for files with an m4a extension. iTunes also displays files with an m4b extension under audiobooks by default. The UTI for the m4b extension is com.apple.protected-mpeg-4-audio and Finder shows the kind of all m4b files as "protected MPEG-4 audio" even though m4b all files do not have copy protection.