I have been trying to figure this out myself, and it is kinda frustrating because I am so close, yet so far from the goal.
For the .m4v files iTMS sells, the chapter tracks are MPEG-4 Timed Text tracks. You can actually extract the raw track using mp4box, and I am trying to see exactly how close to the MPEG-4 Timed Text track spec Apple's tracks follow.
The problem is that mp4box imports Text Tracks using a subtype that Apple doesn't recognize in Quicktime, even though the data looks (almost) identical. Worse still, is that since libmp4v2 has no code to support MPEG-4 Timed Text tracks, support in Handbrake also means writing/submitting a patch to the MPEG4IP team for decent Timed Text track support.
EDIT: I just broke through the nasty part... I successfully dumped a chapter track from a purchased iTMS movie using mp4box. Here is the great news: It is just a standard MPEG-4 Timed Text Track. Nothing shifty here at all other than the 'different' subtype of "text" as the fourcc instead of "3gtx" that mp4box forces.
That said, it still means that libmp4v2 needs to be updated to support MPEG-4 Timed Text Tracks before Handbrake can add chapters to MP4 files. And someone still needs to figure out how to connect a sound track to a chapter track... which atom needs to be set/added, and where. I suppose I could look at it if I have the time.
A 'good' side-effect of knowing how to do chapter tracks, is that text track subtitles are also possible using the same method (once you get around the nastiness that is character recognition).
