Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: M4B to MP3 (chapter separation) (Read 100002 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

M4B to MP3 (chapter separation)

Hello
I have been searching on the forum but haven't found anything. Basicly what I'm looking for is a program that will input a M4B file and output several MP3 files (1 MP3 per chapter in the M4B file).
I have been using Free M4B to MP3 Converter, but unfortunately, all it does is extract a single MP3 from the M4B.

Anyone knows any other programs for this job?

Thank you

M4B to MP3 (chapter separation)

Reply #1
NOTE - I've never seen an M4B file, so maybe someone else can give you a better answer.

Do you need to do it automatically?  I don't know how to do it automatically, but with any audio editor you can cut-out sections and save the separate sections in a variety of formats.   (That  assumes the audio editor can open the M4B files.)  If you don't already have an audio editor, Audacity is FREE!!! (open source).

Or, MP3DirectCut[/u] (FREE!!!) can take the one-big MP3 file and chop it into little files (manually).

M4B to MP3 (chapter separation)

Reply #2
Would you point me to a link with such file (m4b with chapters), for test purposes? Maybe you can upload some?

M4B to MP3 (chapter separation)

Reply #3
Have you tried foobar2000?
It can handle m4a/m4b with chapters and should be able to convert to individual mp3 files.
You'll need lame.exe for converting to mp3, though.

M4B to MP3 (chapter separation)

Reply #4
Hello
Thanks to everyone with their fast replies...

NOTE - I've never seen an M4B file, so maybe someone else can give you a better answer.

Do you need to do it automatically?  I don't know how to do it automatically, but with any audio editor you can cut-out sections and save the separate sections in a variety of formats.   (That  assumes the audio editor can open the M4B files.)  If you don't already have an audio editor, Audacity is FREE!!! (open source).

Or, MP3DirectCut[/u] (FREE!!!) can take the one-big MP3 file and chop it into little files (manually).


Thanks, I know such programs. Actually, I'm a frequent user of audacity and use another program called gtk mp3splitter that automatically detects silences in mp3 and splits them accordingly. However, I was thinking that since the M4B file when played in the ipod, the ipod recognizes it's chapters (similar to different tracks). Therefore, I guess the M4B file must contain some kind of information related to the chapter separation inside. I was therefore looking for some program that would use this info and split the M4B file accordingly.




Would you point me to a link with such file (m4b with chapters), for test purposes? Maybe you can upload some?


The file I currently want to split is nearly 200mb long, I'm looking for a smaller M4B file to upload. Thanks!



Have you tried foobar2000?
It can handle m4a/m4b with chapters and should be able to convert to individual mp3 files.
You'll need lame.exe for converting to mp3, though.



I have just tried using foobar2000, it opens the M4B file but when converting it I tried using the option "Convert each track to an individual file" and "generate multi-track files". Unfortunately, both just produced one single MP3 file


We'll keep investigating, thanks for the help!

M4B to MP3 (chapter separation)

Reply #5
Is there any particular reason you need to transcode from AAC to MP3, rather than just splitting the file into multiple AAC (.m4a) files?

M4B to MP3 (chapter separation)

Reply #6
Is there any particular reason you need to transcode from AAC to MP3, rather than just splitting the file into multiple AAC (.m4a) files?


Hello Zarggg,
No, there is no particular reason. Splitting to AAC is ok as long as it keeps the same structure of chapters as in the ipod and it is done automatically. I can always convert it back to MP3. Any ideas?


Thanks.

M4B to MP3 (chapter separation)

Reply #7
Is there any particular reason you need to transcode from AAC to MP3, rather than just splitting the file into multiple AAC (.m4a) files?


Hello Zarggg,
No, there is no particular reason. Splitting to AAC is ok as long as it keeps the same structure of chapters as in the ipod and it is done automatically. I can always convert it back to MP3. Any ideas?


Thanks.


Did you have any luck with this. I also want to do this and my reason - my Cowon Q5W will not play .m4b files so I have to convert to mp3, ogg, flac ect. The files I want to convert are approx 8hrs long and made up of several chapters.

M4B to MP3 (chapter separation)

Reply #8
If you don't have (lossless) sources, and you're willing to run the risk of artifacts, just transcode at a similar bitrate/comparable quality setting. There's really not much other choice if your media player cannot read the formats you're using.

M4B to MP3 (chapter separation)

Reply #9
My idea was to first convert the complete M4b files(10 x 8Hrs) into mp3 files which I did with dBpoweramp with good results. Now I want to chop up these large mp3 files into their revelant chapters. Using Qtime player on the .m4b files I was able to determine the exact time frame and size of each chapter(00:00:00 - 00:28:56, 00:28:58 - 01:06:08 and so on). I did try Cool Edit Pro to cut the files up into the revelant chapters but this re-converts the lame mp3's into mp3 pro files, not what I want. I will try the mp3 direct cut app DVDdoug linked to and see how that works but I suspect that also re-encodes the file, maybe not. My fear is that I will spend a week doing this and only then find out there was a much faster, easier and automatic method to achieve the same result.  There are over 200 chapters in all.

M4B to MP3 (chapter separation)

Reply #10
Have you tried using Audacity? I've had pretty good luck with that program when I needed to chop up audio files in the past.

M4B to MP3 (chapter separation)

Reply #11
Jamie11,
Did you ever find a solution?  I am looking for the same thing, and several months later, I am not having too much success.  Did you find solution for "a program that will input a M4B file and output several MP3 files (1 MP3 per chapter in the M4B file)"?
Thanks

M4B to MP3 (chapter separation)

Reply #12
If anyone is still interested I wrote a little python script to do this. You can find the git repository here: https://github.com/valekhz/m4b-converter. If you don't use git you can just download the python file here: https://github.com/valekhz/m4b-converter/raw/master/m4b.py.

You'll need python (only tested with 2.7 so far) and ffmpeg. Place the m4b.py somewhere and drag your *.m4b file onto m4b.py, or use the command line. There's a README in the git repository for more info on how to use it. I haven't been able to test that many .m4b files yet but those I've tried have worked great. I've tested it on Windows 7 and Ubuntu.

Basically it works by parsing the output of ffmpeg -i file.m4b to get the chapter data, encodes the audio and splits it based on the data from ffmpeg. Sorry if the code is a bit messy, haven't been coding in python for a while.

M4B to MP3 (chapter separation)

Reply #13
If anyone is still interested I wrote a little python script to do this. You can find the git repository here: https://github.com/valekhz/m4b-converter. If you don't use git you can just download the python file here: https://github.com/valekhz/m4b-converter/raw/master/m4b.py.

You'll need python (only tested with 2.7 so far) and ffmpeg. Place the m4b.py somewhere and drag your *.m4b file onto m4b.py, or use the command line. There's a README in the git repository for more info on how to use it. I haven't been able to test that many .m4b files yet but those I've tried have worked great. I've tested it on Windows 7 and Ubuntu.

Basically it works by parsing the output of ffmpeg -i file.m4b to get the chapter data, encodes the audio and splits it based on the data from ffmpeg. Sorry if the code is a bit messy, haven't been coding in python for a while.


Thank you,  I also have been looking for this for weeks!
Now my problem: I get the message "no chapter information found", although iTunes shows them and ffmpeg parses a 'subtitle' stream... What can I do?
File-Info:
m4b_Info.txt


By the way, for other newbies in Python - like me - here a few (Windows-)hints:
1. DL Python 2.7 and install to directory of your choice.
2. The 'PATH' means the directory, where the Python-executable is stored (in my case it was the 'Python 2.7' dir created on HDD during install).
3. Download 'ffmpeg.exe' from here (for example, other sites exist) and put it in the same dir, as the Python-executable, i.e. the 'PATH'.
4. Put m4b.py into any directory, which has enough space for the .mp3-output files (of course, as valekhz points out you may change the output-dir by editing the .py file, but I wouldn't dare, never having come close to coding such things...)
5. Drag&drop m4b file onto the .py-file, wait (depending on CPU-power), find the new file(s) in a new subdirectory, called the same as the m4b...

Thanks again, valekhz!
Should you be able to help me on my above stated issue, I' be extremely grateful!!

M4B to MP3 (chapter separation)

Reply #14
Thank you for writing the guide, nbarzgar.

Thank you,  I also have been looking for this for weeks!
Now my problem: I get the message "no chapter information found", although iTunes shows them and ffmpeg parses a 'subtitle' stream... What can I do?
File-Info:
m4b_Info.txt

If you could post the output of ffmpeg.exe -i myfile.m4b I may be able to help. This particular error message shows up when the script couldn't find/parse chapter data from the output. The current implementation of getting the chapter data is very ugly and if anyone knows of a library that can read the chapters directly I could improve the script.

4. Put m4b.py into any directory, which has enough space for the .mp3-output files (of course, as valekhz points out you may change the output-dir by editing the .py file, but I wouldn't dare, never having come close to coding such things...)

There's a command line option to change the output directory: python m4b.py --output-dir C:\Some\Other\Folder myfile.m4b. You can find the other command line options by running: python m4b.py -h.

M4B to MP3 (chapter separation)

Reply #15
Thank you for writing the guide, nbarzgar.

welcome...

If you could post the output of ffmpeg.exe -i myfile.m4b I may be able to help. This particular error message shows up when the script couldn't find/parse chapter data from the output. The current implementation of getting the chapter data is very ugly and if anyone knows of a library that can read the chapters directly I could improve the script.


I put the output here.

Thanks for trying to help and being so fast about it! 

M4B to MP3 (chapter separation)

Reply #16
I put the output here.

Thanks for trying to help and being so fast about it! 

It's possible that Apple have their own implementation of mp4 chapters which ffmpeg can't read. There are a few options available:
  • Play the .m4b file in VLC and see if the chapters appear in the menu (Playback -> Chapter)
  • MP4Box should be able to read the chapters
  • mp4chaps should also be able to read them

You'll be able to test #1 easily and this is the solution I'd prefer. #2 and #3 will not be possible right now since I don't have access to one of those .m4b files. You could try #2 and #3 if you feel like it and feel comfortable enough with the command line. If we're lucky VLC can read it, otherwise there's not much I can do right now.

M4B to MP3 (chapter separation)

Reply #17
VLC shows the chapters!!
So now what would I do? I know that VLC allows converting, but how would I go about it in this case? Or did you mean yet another solution?

M4B to MP3 (chapter separation)

Reply #18
VLC shows the chapters!!
So now what would I do? I know that VLC allows converting, but how would I go about it in this case? Or did you mean yet another solution?

Awesome. I will remove the old chapter code and use VLC's API to get them instead. This will be a lot more reliable than parsing command output. There should be a new version out tomorrow.

M4B to MP3 (chapter separation)

Reply #19
Awesome. I will remove the old chapter code and use VLC's API to get them instead. This will be a lot more reliable than parsing command output. There should be a new version out tomorrow.


This is wonderful news! Thanks for all the help.

M4B to MP3 (chapter separation)

Reply #20
I finally got the time to finish the script. Unfortunately it's not possible to retrieve chapter times through VLC's API so I had to find another solution. libmp4v2 should be able to read both chapter formats but I haven't been able to test both. If it doesn't work it'll have to wait until I have access to one of those m4b files.

Installation is pretty simple:
  • Download the new script and extract all files to a folder of your choice.
  • Place ffmpeg.exe either in the same dir as m4b.py or in your PATH.
  • Download libmp4v2.dll and place it in the same dir as m4b.py. I couldn't find any pre-compiled dlls so I compiled one myself. You can get it here. If you feel more comfortable compiling yourself check the README for instructions.
I compiled the dll with Visual Studio 2010 so you may need the Microsoft Visual C++ 2010 Redistributable Package if you get dll errors when running the script. You can download it from Microsoft's website. Sorry about all these extra dependencies.

If anyone rather want to use the old script (without support for both chapter types) it's still available here.

M4B to MP3 (chapter separation)

Reply #21
I finally got the time to finish the script.


Just downloaded, followed the steps - and ended up after about 45 min (83 chapters, 15 hrs runtime) with the correctly splitted files!!! (In the course of the process I already had got the message "83 chapter(s) found"...)
This is great work, thank you so much!!


M4B to MP3 (chapter separation)

Reply #22
valekhz,

Thank you so much for writing this script!  You are doing great work!  I have been looking for a way to do this for some time, and I'm thrilled to see that someone with the right skills has taken an interest.  I didn't visit the site for a couple weeks - and it looks like I missed alot!

While it is *almost* working for my m4b files, unfortunately, it is not quite there just yet.

For background...When I run the original script (from Dec 4), it must be close to being able to parse the chapters, because as it works, I can see the chapter names scrolling by, but it only creates a single mp3 file.  I suspect the problem might be related to the characters in the chapter names, because as it works, I can see that some of the characters (both western, but non-English characters, like "ñ, ǐ, ǚ, á, è, ß" as well as Asian, like "你好") look corrupted.

When I ran the new script from Dec 10 (I think I'm following the instructions right), I simply get an error message "This application has failed to start because MSVCP100.dll was not found. Reinstalling the application may fix this problem."  The first few letters do suggest that the dll you compiled may be creating a need for other components of Microsoft Visual Studio, so I downloaded and installed it.  Now, it does run, and does create multiple mp3's from one m4b.  However, it creates far fewer mp3s than there are chapters.  I also notice that some of the mp3 file names are not the same as the m4b chapter names...again, I suspect it is related to non-English characters.  Do you think there is any way to get chapter names / file names using other character sets?  I will send you a couple of my m4B files as a samples via email in the hope that you are willing to give it a try

Again - I am so happy that you have both the knowledge to deal with this topic and the interest to do so.  Thank you so much!

M4B to MP3 (chapter separation)

Reply #23
Unfortunately there's no Unicode support right now that's why you get those issues. Unicode support is essential so I'll see what I can do. A few samples of those m4b files would be very helpful so check your inbox.

When I ran the new script from Dec 10 (I think I'm following the instructions right), I simply get an error message "This application has failed to start because MSVCP100.dll was not found. Reinstalling the application may fix this problem."  The first few letters do suggest that the dll you compiled may be creating a need for other components of Microsoft Visual Studio, so I downloaded and installed it.

That's correct. If anyone else is having the same issue you may need to download the Microsoft Visual C++ 2010 Redistributable Package from Microsoft's website. This is also included in the installation instructions above.

M4B to MP3 (chapter separation)

Reply #24
I ran into a couple of problems:

1)  It was saying that the library and/or DLL was not a valid windows dll.  The problem was I was using the supplied DLL, which is a 32-bit and I was using 64-bit python.  Those don't mix, so I installed and used the 32-bit version of python and it worked great.  So, if anyone has that problem, hopefully this will help them.

2)  The other "problem" I have is not really a problem, but more of a request I guess.  The script works well, however, when it extracts the chapters and names to mp3, I have no idea of what order they should have be in.  Could there be an internal counter or something so that you would get something like "Chapter 1 - " prepended to the chapter title?  Otherwise, the only way I see to figure out the order is to listen to each one and hope it starts with the chapter number...