Converts Audible aax audiobooks to m4a while keeping chapters and the cover image intact. The cover is added as a looped image so it is shown while playing on Plex Media Server
Also available as NodeJS package: https://github.com/r15ch13/audible-converter
> convert-aax-to-m4a.cmd <filename> <device> <debug>
<filename>
: is your aax file. duh!<device>
: is the number of the registry entry inHKLM\SOFTWARE\WOW6432Node\Audible\SWGIDMAP
.<debug>
: adddebug
as 3rd parameter to get moreffmpeg
output
Example:
> convert-aax-to-m4a.cmd AgenttotheStars_ep6_A1SZN9UBXNTEA2.aax
Using Device 0 (Activation Bytes: 74FF0506)
Reading audiobook information ...
John Scalzi - Agent to the Stars (Unabridged) [2010] (Duration: 8h44m)
Converting to m4a ...
size= 246321kB time=08:49:45.00 bitrate= 63.5kbits/s speed=7.09e+003x
Adding looped cover image audiobook
frame=31844 fps=645 q=17.0 Lsize= 256060kB time=08:49:45.00 bitrate= 66.0kbits/s speed= 644x
Done!
- Extract cover image:
ffmpeg -y -i audiobook.aax cover.png
- Decrypted and convert to m4a:
ffmpeg -y -activation_bytes 1CEB00DA -i audiobook.aax -c:a copy -vn audiobook-tmp.m4a
- Add looped cover image:
ffmpeg -y -r 1 -loop 1 -i cover.png -i audiobook-tmp.m4a -c:a copy -shortest audiobook.m4a
So I'll start by admitting I'm not too smart on all this. I created a GitHub account in order to comment here if that shows how new I am.
First, I couldn't run this from PowerShell--couldn't seem to find ffmpeg, even after adding to Path variable. This could just be my limited PowerShell knowledge, but I did get this to run in cmd. Maybe I have to restart PS for it to accept the updated Path variable. Also as a note on on the functionality of "where", when I downloaded jq, it was named jq-win64.exe by default, but your script didn't find it until I renamed it jq.exe. I'd suggest adding a comment that it might need to be renamed. I just guessed that might be what I needed to do.
Second, and my primary reason for wanting to comment, the script worked fine for a file with no spaces in the filename, but when I ran it on files with spaces, it gave me the error "[first word after space] was unexpected at this time." The filename was in double quotes when I ran the command, so I was surprised by this error. Have you encountered this? I don't know enough to fix this in the script for myself, so I'll just have to remove all space from the filenames.
Finally, would it be possible to add an option to bypass checking the registry key for a device and just input the activation_bytes manually? I think I can figure out how to comment all this out and just assign the activation bytes in the script. Not that this is a required function, I only noticed because the initial file I tested the script on was a book my mom had shared with me, and it wasn't from my audible account, so the activation_bytes were different. Additionally, I had already gone through the process of digging up my activation_bytes before I realized this script did it for me.
Thanks for the useful script.