I uploaded a
sample M4B file, from which I extracted the second track (the chapters, stored as subtitles) in various formats :
SRT,
TimedText (TTXT), and
raw.
The commands I used are easy :
MP4Box -srt 2 Zemixx119.m4b
MP4Box -ttxt 2 Zemixx119.m4b
MP4Box -raw 2 Zemixx119.m4b
The output is a file in the current directory.
To extract the audio track :
MP4Box -raw 1 Zemixx119.m4b
"1" or "2" indicates the track to extract. You can get a list of tracks (and other interesting information) like this :
MP4Box -info Zemixx119.m4b
Track 3 contains the pictures and track 4 has the URLS for the links displayed throughout the podcast.
To create a new MP4 file from the tracks I extracted, it's easy too :
MP4Box -add inputFile destinationFile
There can be several -add statements, i.e. :
MP4Box -add Zemixx119_track1.aac -add Zemixx119_2_text.ttxt Zemixx119.mp4
Maybe an MP4 file created like this (and maybe renamed to M4A or M4B) would display chapters in iTunes and an iPod, but I doubt it.
The full documentation for MP4Box can be found
here.
Also, I uploaded my tools to extract chapters from an iTunes M4B file and convert them to a cuesheet file for rockbox :
srt2cue.c and
m4btocue.sh.
To compile srt2cue.c, just type :
gcc srt2cue.c -o srt2cue
Then to use m4b2cue.sh you need to edit it so it knows the path to srt2cue and MP4Box, and then it's quite straightforward :
bash m4b2cue.sh [FILE1 [FILE2 ...]]
will output a cuesheet file of the same name for each MP4 file it finds (it will always try to extract the second track).