Making Audiobooks for iPhone (in Linux/MacOS)

If you have audiobooks on CD that you want to have on your iPod or iPhone, here are some rough steps to turn them into iDevice-compatible files. Along the way, I’ll show you what I learned about how those files are constructed, i.e. what works and doesn’t.

The first step, of course, is to rip the CD to audio files. I prefer to rip using abcde to FLAC files. This preserves the full fidelity of the audio file (for now, anyway–we will compress the audio later).

$ abcde -o flac /dev/disk2

In my case above, the disc drive is /dev/disk2, but if you don’t know which one yours is, you can use drutil to check, as per the instructions here.

The next step is to combine the audio files into one file. For whatever reason, the option in abcde to rip a CD as one file isn’t working for me and I haven’t had time to dive into why. So, instead, I use sox to concatenate the files into one audio stream. You can do this by running sox and passing in as the first parameters the input files, in order. The last parameter is the output file.

sox 01.flac 02.flac 03.flac 04.flac 05.flac Disc1.flac

The next step is to update the metadata on the FLAC files that were the Discs. The reason for this is that we want the metadata to be up-to-date before we convert the file to the format that the iDevice is expecting. The metadata will be carried into the new file, so it is important to get it right at this stage.

  1. The ARTIST tag should be the book’s author, and should be consistent across all files
  2. The TRACKTOTAL should be the number of discs
  3. The TRACKNUMBER should be the disc number for each file
  4. The TITLE should be descriptive, I use “Disc x”, replacing x with each disc number
  5. The ALBUM should be the name of the book, and should be consistent across all files

Below is an example of me editing one disc file. I start by listing the information (I’ve trimmed a lot of the output), then I use metaflac --remove-tag to remove each tag and metaflac --set-tag to replace it with a new tag. I do this for each disc in the collection.

metaflac --list Disc4.flac
...
METADATA block #2
  type: 4 (VORBIS_COMMENT)
  is last: true
  length: 177
  vendor string: reference libFLAC 1.3.3 20190804
  comments: 7
    comment[0]: ARTIST=Brené Brown
    comment[1]: ALBUM=Rising Strong [Disc 4]
    comment[2]: TITLE=Track 1
    comment[3]: DATE=2015
    comment[4]: TRACKNUMBER=01
    comment[5]: TRACKTOTAL=13
    comment[6]: CDDB=b011fb0d
$ metaflac --remove-tag=ALBUM Disc4.flac 
$ metaflac --set-tag=ALBUM="Rising Strong" Disc4.flac 
$ metaflac --remove-tag=TITLE Disc4.flac 
$ metaflac --set-tag=TITLE="Disc 4" Disc4.flac 
$ metaflac --remove-tag=TRACKNUMBER Disc4.flac 
$ metaflac --set-tag=TRACKNUMBER=04 Disc4.flac 
$ metaflac --remove-tag=TRACKTOTAL Disc4.flac 
$ metaflac --set-tag=TRACKTOTAL=07 Disc4.flac 

Once the metadata is set, it’s time to convert the files so that the iDevice can read them. Here are the important points:

  1. The file must be MPEG-4 audio. I use the AAC format and that seems to work fine
  2. The filename extension MUST be .m4b which stands for “MP4 Book” (it won’t work otherwise)

I use ffmpeg to convert the audio files.

$ ffmpeg -i Disc1.flac -c:a aac Disc1.m4b

Once the files are all converted, place them into one directory. Then, open the Books app on your Mac, import the directory (File > Add to Library), and you should see a new book in the collection.

You can sync the book to your iDevice through the Finder app once your iDevice is connected to your Mac via USB.

  1. Follow the prompts on your Mac and/or your iDevice to establish “Trust” between the devices
  2. Open the Finder
  3. Click on the iDevice
  4. Click “Audiobooks” in the top row of options
  5. Select “Sync audiobooks onto <devicename>”
  6. Choose what books (or all books) you would like to sync
  7. Apply