Making Linux and Your iPod Play Nice with Audiobooks

Written by:  • Edited by: Lamar Stonecypher
Updated Sep 30, 2011
• Related Guides: iPod | Linux

Linux user who owns an Apple iPod? Tired of having to settle for a MP3 version of your audiobook? Well, look no further! In this article I will show you how to convert those MP3 audiobooks to M4B!

Introduction

I admit it. I'm an audiobook fanatic. I have to have a audiobook in my ears at all times; when I work, when I exercise, and when I sleep! No exceptions! In this guide I will show you how to rip your audiobook CD, combine the MP3 files, convert the MP3 files to PCM and finally convert the PCM files to M4B. The best part about this? We will do it all from the command line! You may be wondering "Why from the command line!". The answer to that is simple, because we can! Lets get started.

Tools You Will Need

For the purposes of this guide you will need a number of readily available packages installed. In this guide I will assume you are using Ubuntu Linux but all distributions should offer these tools through their package manager.

sudo apt-get install cdparanoia lame mp3wrap mplayer faac

This will make sure you have all the tools we need installed so we can move on to the next section, "Ripping Your Audiobook CD".

Ripping Your Audiobook CD

cdparanoia
click to enlarge
The first step in creating your iPod compatible M4B file on Linux is to rip your audiobook CD. We will use a handy little Linux command line tool called cdparanoia to accomplish this. Insert your audiobook CD into your optical drive and issue the following command:

sudo cdparanoia -B

This will rip your audiobook CD, into the current directory, splitting each track into it's own WAV file.

Now that we have the tracks ripped to the current directory lets convert them to MP3.

Convert WAV to MP3

In order to convert our WAV files, created by cdparanoia, we will use the LAME mp3 encoder. To begin converting your files from WAV to MP3 you will issue the following command:

lame -b 64 <input file.wav> <output file.mp3>

This will convert your WAV files into MP3 files with a CBR (Constant BitRate) of 64kbps.

Combining the MP3 Files

mp3wrap
click to enlarge
Here we are going to use the Linux command line tool mp3wrap to combine our multiple MP3 tracks into one large MP3 track. To do this, still in the same directory, issue the command:

mp3wrap <output file.mp3> *.mp3

One very important thing to keep in mind is that the multiple tracks must be named sequentially. This should not be an issue if you used cdparanoia to rip your audiobook CD, however, if you already had the tracks ripped and they are not named sequentially be sure to rename them before trying to combine them. For example, track01.mp3, track02,.mp3, track03.mp3, and so on.

We now have the one large MP3 file that we want. Lets convert this file to PCM.

Convert to PCM

The next step will require a fair amount of space. Make sure you have roughly 7 times the disk space of the MP3 you created in the last section available to you. To convert our MP3 file to PCM we will use mplayer from the command line, issuing the following command:

mplayer -vc null -vo null -ao pcm:nowaveheader:fast:file=<output file.pcm> <input file_MP3WRAP.mp3>

This command will take a fair amount of time to complete so be patient. Once it completes we will have the PCM file we need and can move onto the last step, converting the PCM file to a iPod compatible M4B file.

Convert to M4B

The final step of this process is to convert our PCM file to an iPod compatible M4B file. To do this we will use the Linux command line tool faac:

faac -R 44100 -B 16 -C 2 -X -w -q 80 --artist "authorname" --album "audiobookname" --track "1" --genre "Audiobooks" --year "year" -o <output file.m4b> <input file.pcm>

That's it! This audiobook should show up in the Audiobooks section and be fully iPod compatible. Until next time, keep it Open Source!

References

  • Author's own experience.

Comments

Showing all 8 comments
 
Michael Dougherty Feb 18, 2011 10:21 AM
RE: Making Linux and Your iPod Play Nice with Audiobooks
Michael, Have you tried gtkpod? It's a Linux based iPod manager that I've had good success with.

http://www.gtkpod.org/wiki/Home
Michael Neath Feb 18, 2011 4:32 AM
Getting it on to the ipod
How do you then get the audiobooks on to an ipod? I've had no luck with Banshee or Amarok.
Adrien Beaucreux Dec 23, 2010 12:50 AM
Chapters
The only missing thing here are the chapters. you can get them by using MP4Box and mp4chaps.
MP4Box is available in Ubuntu in the package gpac, mp4chaps I had to compile.

To generate the chapter file, I used the following code as create_chapters_files.py:
---------8<------------------------
import mad
import glob

timeacc=0
flist=glob.glob("track*.mp3")
flist.sort()

for index, filename in enumerate(flist):
hours = int(timeacc/3600000)
rest = timeacc - hours*3600000
minutes = int(rest/60000)
rest = rest - minutes*60000
seconds = int(rest/1000)
milliseconds = rest-seconds*1000

print "CHAPTER%s=%02d:%02d:%02d.%03d"%(index+1,
hours,
minutes,
seconds,
milliseconds)
print "CHAPTER%sNAME=%s"%(index+1, filename)

timeacc += mad.MadFile(filename).total_time()
---------8<------------------------
and start it with:
# python create_chapters_file.py > chapters_file.chapters
then edit the resulting file to get the titles.

Now you can add your chapters to the audiobook:
# MP4Box -add <input file.m4b> -chap <chapters file.chapters> <output file.m4b>
And convert these chapters from nero format to QuickTime:
# mp4chaps -c -Q <input file.m4b>

You now have an audiobook with chapters.

Source: http://froebe.net/blog/2009/12/24/how-to-create-an-itunesipod-compatible-audiobook-mpeg4-m4b-on-linux-using-mp4box-and-mp4v2-v1-9-1-it-can-be-done/
Michael Dougherty Aug 1, 2010 1:50 AM
RE: Making Linux and Your iPod Play Nice with Audiobooks
@Jeff - As you discovered on your own removing the input file options (even when using the defaults) isn't an option. Depending on your input file you may have to mix and match when it comes to the input file PCM sample rate. Nice catch on having to change the input file sample rate when appropriate. I'll see what I can do about adding this tip to the article.
Jeff Windsor Jul 30, 2010 11:35 AM
faac options, again.
So much for my question. I removed the options and it didn't work. One change, however: in order to get the resulting to file to play at standard speed I had to change the -R to 22050 rather than 44100
Jeff Windsor Jul 30, 2010 10:23 AM
faac options?
Excellent tutorial for using open source tools for a task most people relegate to proprietary gui-wrapped ones. I learned a bunch. One question: in faac why are you specifying the -R -B and -C options when you're just using the default? Am I missing why this might be useful?
Michael Dougherty Jul 25, 2010 7:08 PM
RE: Making Linux and Your iPod Play Nice with Audiobooks
The extra encoding step allows you to combine the multiple files.
KIlian Lackhove Jul 25, 2010 4:27 PM
unneccessary transcoding
cdda > mp3 > wav > m4a
should be
cdda > wav > m4a
 
blog comments powered by Disqus
Email to a friend