Converting mp3 to ipod-ready audio books

DISCLAIMER: The below technique works about half of the time: For no readily discernible reason, some of the files come out in chipmunk mode. It appears, from what I've been able to determine so far, that mpg123 is playing the original mp3 file at the wrong speed.

-----------------

As a fan of Librivox, it's frustrating to me that the iPod doesn't recognize audio books in mp3 format as audio books. It wants them in aac format. Converting them is a hassle, mostly because I always forget how. So, here's a little Perl script I whipped up for the purpose.

The same thing is necessary if you rip an audiobook from CD.

Share and enjoy:

#!/usr/bin/perl

opendir F,".";
my @files = readdir(F);
closedir F;

foreach my $chapter (@files) {
    next unless $chapter =~ m/\.mp3$/i;

    my $filename = $chapter;
    $filename =~ s/\.mp3$//;
    $filename = $filename . '.m4b';

    `mpg123 -s "$chapter" | faac -b 80 -P -X -w -o "$filename" -`;
}

Note that while this retains the track name, it seems to lose the album name and author, so you may need to add that back. Presumably faac has command-line arguments for this, too, but I haven't found them yet. Haven't looked, either.


4 Responses to Converting mp3 to ipod-ready audio books

  1. 46121 Nathaniel McCallum 2009-01-09 09:10:03

    You should be aware that while faac generally works, its a pretty crappy encoder and can generate invalid aac files. YMMV

  2. 46124 skippy 2009-01-09 09:39:41

    Excellent! Thanks for this trick. It's unfortunate that the iPod doesn't recognize the plain MP3 files as audiobooks.

    I don't expect LibriVox to encode to aac format, since they want everything to remain in the public domain. Still, it would be nice if LibriVox could get into the iTunes Music Store somehow, so that you could access audiobooks through that interface directly to your iPod or iPhone.

  3. 46129 phydeaux 2009-01-09 11:12:42

    Tres groové. I'm too deep into my current Libravox reading to rework that one but I've got 4 others already downloaded and ready to go. I'm gonna try it out on the next one.

  4. 46131 rbowen 2009-01-09 12:23:28

    Nathaniel,

    Could you elaborate on "crappy" and "invalid"? What do those words mean in practical terms?

Leave a Reply



About

Here dies another day during which I have had eyes, ears, hands and the great world round me; And with tomorrow begins another. Why am I allowed two? (Evening, by Chesterton)