Bulk Converting M4B files to MP3 with Chapters

Bulk Converting M4B files to MP3 with Chapters

My car only plays MP3 files, and it's not that easy to skip around inside of a file if you need to. In order to listen to larger audiobooks that means I have a couple of restrictions:

MP3 Format

For starters, my files must be in MP3 format. My car is a bit older so it doesn't do bluetooh linking to your phone for audio, or I might just play them from my phone. Instead I need to convert to MP3 and put them on a USB stick.

It's not very picky on the MP3 format, though I've found certain formats (VBR?) will start a song back over at the beginning after the car has been turned off.

Separate Chapters

If I'm listening to a 4 hour audiobook file and I accidentally switch the car to a different file, it's impossible to find your location. It's easier to break it up into chapters in case you need to manually find your location again later.

Enter m4b-converter:

I found a great little Python script that will work with ffmpeg and mp4v2 to not only convert an m4b file to MP3, but at the same time split it into multiple chapter files.


A few issues

I stumbled on a few issues with this script that required I edit the sourcecode. I'm not sure if it's just old and not updated or if something was weird with my particular install. First I had to manually change the library filename to "libmp4v2.so.2" at the top of the libmp4v2.py file. It was looking for libmp4v2.so.0 which doesn't exist on my system. Alternatively I could have symlinked it, but I elected to edit the source.

Additionally the ffmpeg command specified "-acodec copy" on the input stream, but you can't use copy as a decoder. So I just removed the "-acodec copy" portion from the m4b.py script, leaving the rest of that line intact.

Posted by Tony on Mar 28, 2016 | Desktop Linux, Linux Tricks