This site runs best with JavaScript enabled.

Audible to Plex


How and why I migrated all my Audible audiobooks to my Plex server and how I consume them.

Why

Before doing this you might ask, "Why? What is the point?" Yes, the audible player is great. But, there are a few reasons why I prefer to move them to Plex.

  1. With Plex I can stream the audios to my iPhone with the great Prologue app. This way I can listen to audiobooks without having to download them (but I can download them if I want). This saves a lot of storage on my phone and I don't have to wait for a book to download before I start listening.
  2. This makes my books more easily available to my family. My wife once accidentally purchased an audiobook on her account. It was such a pain to try to figure out how to share it with me on Audible. Now my wife and kids all have access to the audiobooks I buy through their Plex account.
  3. There is just something gratifying about buying an audiobook and FEELING like you actually own it.
  4. Sometimes I purchase audiobooks that are not on Audible. This allows me to keep them all in one place so I don't have to have multiple audiobook apps on my phone.

Downloading Audiobooks

Go to Audible.com and then browse to your library. This will show all the books you have purchased. There is a download button next to each title to download the book in .aax format.

Convert the book to M4B

I am just going to point you to the AAXtoMP3 project on Github. Follow instructions there to get the tool set up.

This is the command I run to convert books to the format I want.

1bash AAXtoMP3 --aac -e:m4b AUDIOBOOK.aax

Clip file (optional)

Since I'm not listening on Audible, like to remove the beginning and ending of the clips that says "This is Audible" and "Audible hopes you have enjoyed this program".

This is a little more tricky and requires a few tools to do so, so if you don't want to go to the work of all this, just skip this step.

You'll need to install ffmpeg to clip the file and mp4art from the mp4v2 package to put the cover art back on since FFmpeg doesn't support cover art.

On the mac, both can be installed with brew.

1brew install ffmpeg mp4v2

I have the following script that will do strip the intro and outro and keep the cover art intact.

1# get cover art
2ffmpeg -i "$1" -an -codec:v copy cover.jpg
3
4# calculate duration to trim audible end clip
5dur=$(ffprobe -i "$1" -show_entries format=duration -v quiet -of csv="p=0")
6dur=$(echo $dur | cut -d "." -f 1 | cut -d "," -f 1)
7trim=$((dur - 6))
8
9# main work to copy and trim
10ffmpeg -hide_banner -i "$1" -ss 2 -t $trim -map 0:a -c copy output.m4b
11
12# add the cover art back on
13mp4art -q --add cover.jpg output.m4b
14
15# housekeeping
16rm cover.jpg
17rm "$1"
18mv output.m4b "$1"

You would just pass the name of the m4b file to this script like so:

1clip.sh AUDIOBOOK.m4b

Serve from Plex

Now, just move this audiobook file to your plex server. I recommend this guide for configuring your Audiobook library on Plex.

Automate

Here is a script I wrote that will do all of the above. You would just run aax2m4b ebookfilename.aax:

1# Remove DRM and clip Audible intro and outro
2function aax2m4b() {
3 local PLEX_DIR=/Volumes/Media/Audiobooks
4 local AAXtoMP3_DIR=~/src/p/AAXtoMP3
5 local TARGET_DIR=~/Downloads/m4b
6 local AUTHCODE=`cat $AAXtoMP3_DIR/.authcode`
7 rm -rf $TARGET_DIR
8 mkdir -p $TARGET_DIR
9
10 # Remove DRM
11 $AAXtoMP3_DIR/AAXtoMP3 --aac -e:m4b --authcode $AUTHCODE --target_dir $TARGET_DIR -D 'converted' -F '$title by $artist' "$1"
12
13 local NEWFILE=`ls $TARGET_DIR/converted/*.m4b`
14 local BASENAME=`basename -a $TARGET_DIR/converted/*.m4b`
15 echo $NEWFILE
16
17 # Cut Audible intro/outro
18 # calculate duration to trim audible end clip
19 dur=$(ffprobe -i "$NEWFILE" -show_entries format=duration -v quiet -of csv="p=0")
20 dur=$(echo $dur | cut -d "." -f 1 | cut -d "," -f 1)
21 trim=$((dur - 6))
22
23 # main work to copy and trim
24 ffmpeg -hide_banner -i "$NEWFILE" -ss 2 -t $trim -map 0:a -c copy output.m4b
25
26 # add the cover art back on
27 mp4art -q --add $TARGET_DIR/converted/cover.jpg output.m4b
28
29 # move file
30 mv output.m4b "$BASENAME"
31 cp "$BASENAME" "$PLEX_DIR"
32 echo "Copied to $PLEX_DIR"
33}

I have all this automated with Hazel so the only step I really need to do is download the .aax file and automation takes care of the rest of it! But I won't go into the details here. That would make for a much longer tutorial.

Discuss on TwitterEdit post on GitHub

Share article
Dustin Davis

Dustin Davis is a software engineer, people manager, hacker, and entreprenuer. He loves to develop systems and automation. He lives with his wife and five kids in Utah.

Join the Newsletter



Dustin Davis