Converting MP3 Into iPod M4B Audiobook Format
Back a couple of weeks before Christmas, an unfortunate series of events resulted in my 4GB iPod nano going through the washing machine. And, as is the case with many such incidents, it rendered the device entirely non-functional.
I bit the bullet and picked up a replacement because it's fairly critical to my mental well-being. I need to be able to throw on a bit of music or a podcast when I'm driving or need to drown out the outside world. So, I ordered a new 4GB nano video.
Then, a couple of days after getting that nano and using it, the consulting company that I'm subcontracting through gave all of the consultants on my project a 30GB Zune.
That, of course, caused a quick re-org of my portable media strategy. I ended up making the nano a purely podcast and audiobook device and moved all of my music (and hopefully some video when I get it cooperating) to the Zune.
Unfortunately, revisiting nearly any process in one's life can quickly shine a light on previously ignored problems and make you re-question your solution. Such was the case with my podcasting listening. When I switched over to the nano, I missed the ability to listen at faster-than-normal speeds for spoken word podcasts. However, the other benefits outweighed that downside, so I moved on.
However, last night, I wondered if I couldn't just convert some of those podcasts into iPod audiobooks (the ones with .m4b as the extension). Several of the podcasts already distribute in that format and you get things like bookmarking of where you were in the audio as well as the ability to speed things up.
I'll leave it as an exercise for the reader to guess what I think about a device that allows only the speeding up of a specific class of audio files to the exclusion of other classes of audio files.
Regardless, I checked if the Swiss Army knife of audio/video: ffmpeg would be able to handle it and was happy to see it would. So, I wrote a really simple C# console app to convert these .mp3 files into .m4b files. The workflow is still a bit lacking as it doesn't easily tie in to the iPod/iTunes functionality of putting "the 1 latest unplayed" podcast from each feed on the device, but I can quit hoping that the people speaking would just hurry the hell up.
There were a couple of oddities that needed to be coded around. Most noteable is the proper quoting of file paths (which still might not work in all cases) and the fact that you need to actually convert from MP3 to M4A and then rename that M4A to M4B in order to be done.
At any rate, the code is below the fold if you would like to mess with it yourself. You call it by running
MP3toMB.exe input.mp3 128
It also works if you just drag an MP3 onto the exe by assuming a 96kbps bitrate. Obviously, this is coded for Windows, but the same principle could easily be accomplished on Mac with Applescript or Linux with shell scripting or just batch files on Windows given a commandline copy of ffmpeg.
I've also got a Windows app that combines lots of MP3's into a single audiobook file, but I wanted something that I could use to automate and run on a more nightly basis to convert stuff, which this gives me.
Read the rest of this entry »



