QuickTime Chapters in iDVD 5

Chapter support was added to iDVD in Version 3, but for those of us who don't use iMovie, it has never quite worked right...

UPDATE: This entire document is about to become little more than an academic exercise. QuickTime developer Noah "Bantha" Sorscher has added support for the magic iDVD metadata to the forthcoming version of his amazingly useful Metadata Hootenanny. Chapter tracks created with Versions 1.1.5 and later should be recognized by iDVD. That version isn't quite ready for release, but you can find the intermediate pre-release beta version HERE.

WARNING: This is complicated. It involves making extremely-low-level changes to your QuickTime movies. It requires hexadecimal arithmetic, and if you do it wrong you can easily render a movie unplayable. Perform all edits on reference copies of your QuickTime movies!

iDVD is tightly tied to iMovie, and with some apparent reluctance, Apple has added some iDVD support to Final Cut Pro and Final Cut Express. But where does that leave those of us who use non-Apple tools, or who produce neat content in QuickTime Pro? Sometimes I think I should consider myself fortunate that iDVD will import my QuickTime movies at all. But when I bought iDVD 3, I was told that it would generate chapter markers from QuickTime chapter tracks. I could never get it to work. I've been able to add chapters to QuickTime movies, but iDVD could never seem to "see" them. Then in iDVD 5, it seems that the ability to import QuickTime chapters was either removed entirely or at least scrubbed from Apple's documentation.

Now this doesn't seem to make sense. If you set a chapter marker in iMovie, then share the movie to iDVD, a QuickTime reference movie is created in the iMovie package. If you open that movie in QuickTime Player, it has a working chapter track, and if you take that movie out of the iMovie project package and import it into iDVD, iDVD will see the chapter markers. What this means is that everything you need to create chapter markers that iDVD can see must be included in the QuickTime reference movie. So, I reasoned, if iMovie can do it, why can't I??

I started experimenting. Using QuickTime Pro, I broke the iMovie-exported movie into its component parts using the "Extract Tracks" feature. I left the audio and video together, but I separated off the two text tracks and the tween track. Then I tried assembling the movie myself using the audio/video movie and the chapter movie. I added the chapter movie to the video, set it as a chapter track, and imported into iDVD. That worked. That also told me that I could safely ignore both the "Tween Track" and the "iDVD Compression Marker Track".

Next, I used QuickTime Pro to export the working chapter track to a text file, then imported that text to a new chapter track and applied it to the audio/video track, made sure it worked in QuickTime, then tried to import that into iDVD. Sure enough, I got no chapter markers. Clearly there is something different between the chapter track I'm working with and the text version of the chapter track that got exported by QuickTime Pro. So I decided to take the two QuickTime chapter movies: the working one from iMovie, and the one I had just created from a text file of the other movie...and compare them.

diff told me that they were different. Yeah, I think I knew that. Next, I used HexEdit to compare the files and I found that they were VERY different. A closer examination revealed, though, that the two chapter tracks were on different time scales (the iMovie chapter track was based on 29.97 FPS while the exported/imported chapter track was based on 1000 FPS). Since all the internal data was at least consistent, I didn't worry about that...after all, the non-iMovie chapter track had worked with my QuickTime movie in spite of the weird timebase. Slightly more disturbing to me was the fact that the iMovie chapter track was longer than the exported one. What I was able to conclude from this was that when you export a chapter track as a text file from QuickTime Pro, what you get is not a dump of the chapter track data, but rather a complete reinterpretation of the chapter track data. That's potentially useful information, though it doesn't seem to explain why the QuickTime chapters don't work in iDVD.

Next, I employed the services of a little utility called Dumpster, available from Apple's QuickTime Tools page. Dumpster examines QuickTime movies on a slightly higher level than HexEdit. QuickTime movies are set up much like XML files, where the file is made up of a series of heirarchial nodes. Each node can contain either more nodes, or data. In QuickTime, these nodes are called "atoms". The file starts with a "moov" atom which identifies the start of a QuickTime file. This is followed by the top-level structure called a "trak", which contains all the information necessary to build a QuickTime track, including any necessary media references. I opened the two chapter movies side-by-side in Dumpster and looked for differences. I found differences in the data, but I was able to explain almost all of them by noting the difference in timebase between the files. As it turns out, the most obvious difference between the files was right in front of my nose, as it is visible in the track structure. Here, take a look...

Dump of chapter track movie created with iMovie

Dump of chapter track movie created with QT Pro:


There, do you see it, sticking out like a sore thumb? Clear down in the bottom of the trak structure. On the iMovie side, there are three atoms that are missing on the QuickTime side, down in the udta atom: name, chap and kgit. As it turns out, the contents of those atoms are constants:

name - 'Chapter Track'
chap - 'chap'
kgit - 'chap'

My guess is that this is how iDVD gets around a potentially hairy problem: QuickTime is so flexible that it can have multiple chapter tracks. A QuickTime movie could have multiple audio tracks (multiple languages, for instance) and a separate chapter track for each, so that the chapter names would come up in the appropriate language. This isn't allowed in the DVD standard (or at least iDVD doesn't handle it), so adding these three atoms to the chapter track seems to indicate to iDVD that this is the One True Chapter Track in the QuickTime movie.

It follows, then, that adding these three atoms to the trak structure for a QuickTime movie's chapter track would cause the chapter track to be recognized by iDVD. Further experimentation revealed that indeed, it is the presence of those atoms (specifically the kgit atom) that causes iDVD to create the chapter menu when it imports the movie. That's literally all there is to it.

Not so fast...

The fix is really simple. The problem is, there is no good way to do it. In a week of searching, I was not able to find a single utility on the Web that could arbitrarily add user data atoms to a QuickTime chapter track. The closest I could come was Metadata Hootenanny which is designed to add user data to the moov structure. Then I tried digging into the QuickTime API, where I learned that the Java API may or may not work, and the C API is opaque enough that for someone like me who doesn't speak C, it makes for a frustrating experience. Finally I decided against trying to do it myself programmatically. If someone wants to write a utility to add these atoms to a QuickTime movie, I'll link to it from this page. But since such a utility doesn't seem to exist, I decided it would be quicker and easier to use HexEdit to manually add the atoms to the file.

This is going to get really involved, so I'm splitting it up. Proceed to the next page for some Atomic Theory.

1. Introduction - 2. Atomic Theory - 3. Atomic Fusion - -->

--Dave Althoff, Jr.

Back to davealthoff.com...

Revised 01/04/2006

Revised 01/02/2006

Created 01/01/2006