Tool To Make iDVD Recognize QuickTime Chapter Tracks

Tool To Make iDVD Recognize QuickTime Chapter Tracks

Having trouble getting iDVD to recognize the chapter markers in a movie you edited in something other than iMovie? Have we got the solution for you.

The Story So Far

First, a little background...I'm working on a DVD project for someone in the family. I have a three year old Powerbook (867MHz/640MB RAM) and a custom built PC (2.6GHz/1.5GB RAM) to work with.

Since my laptop doesn't have enough horsepower to edit video and render effects as smoothly as I'd like, and its native resolution is 1024x768, I've gotten into the habit of doing the majority of my editing in Vegas Video on my PC, and then building the DVD with iDVD on my Powerbook.

At first this seemed like a great match. Vegas is actually a joy to work with on the PC, and makes short work of projects like this. DVD Architect 4 that comes with Vegas Video is a very competent DVD authoring solution as well, but it just can't hold a candle to the ready-made, high production value templates that come w/iDVD on the Mac.

When you have some video and want to publish a great looking DVD with excellent looking animated menus and the like, and want to get it done while you're young, iDVD along with its themes and drop zones are the hands down winner.

Unfortunately, iDVD's strengths also form its weaknesses, especially when you want to do something low-level, and not included with the default themes. This first showed up when I wanted to include a chapter menu for my video.

According to the iDVD manual, it will automatically recognize any chapter markers present in imported video and offer to build a chapter/scene menu for you.

You could imagine my surprise then, when I marked out my eighteen or so chapter markers in Vegas Video, exported it to a DV .mov file with the option selected to include markers in the exported video, imported the file into iDVD and was greeted with a single video clip...no menu, no offer to create a menu, no indication that iDVD even noticed there were chapters in my .mov file.

The Research

So, I do a little research and and find out that whatever Vegas Video is doing during the export, it's not adding a chapter track to the movie file. Alright, so iDVD isn't to blame.

I continue researching to see if there's a way to do this manually with QuickTime Pro. I read Apple's documentation that shows how to add a specially formatted text track to a movie file so that QuickTime will recognize chapter markers. (How I generated that text track from within Vegas is a topic for another time, but it involves some C# code)

I follow Apple's documentation, add my text track containing chapter names and timecodes to the movie and save the updated file. According to what I read, if everything worked correctly, when the movie was opened in the QuickTime player, I would be able to see a chapter drop down.

Sure enough, it seemed to work. When the movie was opened in QuickTime, a chapter drop down appeared in the movie controller.

Not So Fast...

If you've been reading this far, and are interested in me hurrying up and getting to the solution, I'm sure you know that this is where the real problems begin.

Everything I read about iDVD states that it will automatically recognize chapter tracks in imported movie files. It will then offer to build chapter menus. This is all well and good, except for the fact that it doesn't work at all.

It turns out that just because you have a chapter track in a movie file, doesn't mean iDVD will recognize it. Hats off to David at Capital University who found the difference between a movie file containing chapters exported from iMovie, and a movie containing chapters created the manual way or with a tool other than iMovie.

If you look at the structure of the two files in a tool like Apple's Dumpster, the chapter track in the iMovie file contains three extra entries of user data that aren't contained in the non-iMovie file. David's article explains about the QuickTime file structure and shows how to use a hex editor to add these entries to your movie file. I must say, I was impressed by his article, but at the same time, scared to death to try it myself.

Enter The Programmer

It was then that I decided to see how hard it would be to automate David's process--to simply add three special entries to the user data of a chapter track. (Specifically, "chap", "name" and "kgit" atoms)

First I looked into QTKit, (since this is a Cocoa community site, and we're in desperate need of some quality content) but it doesn't seem to have the necessary classes or methods to edit the individual atoms of a movie file. For low-level access like this, it provides you a handle to the C structures that you can use with the C QuickTime API.

Next, I looked at the QuickTime Java API, because I was comfortable with Java, and didn't want to get caught up in the memory management, pointers, handles, etc...that were undoubtedly going to show up when using the C API--debugging any actual code was going to be trouble enough, I didn't want the memory management hassle on top of it.

The Solution

So I fired up Eclipse, and thirty minutes later, had a working Java utility that automatically adds (or removes) the three "magic" atoms to the user data of a chapter track in a movie file. Once these entries are in the file, iDVD will recognize the chapter track and offer to make a scene menu for you!

The utility, which you'll find a link to at the end of this post, is provided as a single Java jar file. Since this is a Cocoa site, I don't expect anyone to know what to do with it, so let me explain.

NOTE: This utility will modify the specified movie file in place, so make a back up of the movie first.

The jar file is nothing more than a zip file with a .jar extension that contains the compiled Java code and can be run from the command line like so:

Show usage information:
java -jar FixChapterTrack.jar

Patch/enable the chapter track in a movie file:
java -jar FixChapterTrack.jar Test.mov

Unpatch/disable the chapter track in a movie file:
java -jar FixChapterTrack.jar -remove Test.mov

(These examples assume the jar file and the Test.mov file are in the same folder. If that's not the case, you'll need to specify full pathnames to the jar and movie files)

Not that anyone here would care, but this utility is completely cross platform, and should work on that other OS too. Of course, you might need to specify the full path to the java command if it's not already in your path like it will be on OSX. Oh, and you need to make sure QuickTime for Java is installed like it already will be on OSX. (I don't know if the QuickTime installer for Windows does that automatically or if it's an option you can select)

The source code is included in the jar file as well if you're interested. To extract the .java source file from the terminal:

jar fx FixChapterTrack.jar *.java

(That command will only work on Windows if you have the full JDK installed, and not merely the Java runtime. You can also just unzip the jar file with any unzip tool.)

To satify your curiosity and to really make you wonder if this is truly a Cocoa community site like I keep saying, here's the crux of the Java code:

/**
 * Adds the "magic" atoms to a QuickTime Text track so that iDVD sees it as
 * a chapter track and will build scene menus for a movie file.
 * 
 * @param track the chapter/text Track to add the magic atoms to
 * @throws QTException
 */
private static boolean patchTrack(Track track) throws QTException
{
	System.out.println("Examining track for existing atoms...");

	if (isTrackPatched(track))
	{
		System.out.println("Text/chapter track contains 'kgit' atom--"
			+ "iDVD should recognize this chapter track already.");

		return false;
	}

	System.out.println("Patching track's user data to include 'name', 'chap' and 'kgit' atoms");
	UserData userData = track.getUserData();
	QTHandle nameData = new QTHandle(NAME_DATA);
	QTHandle chapData = new QTHandle(CHAP_DATA);
	QTHandle kgitData = new QTHandle(KGIT_DATA);

	userData.addData(nameData, NAME_ATOM);
	userData.addData(chapData, CHAP_ATOM);
	userData.addData(kgitData, KGIT_ATOM);

	System.out.println("User data of chapter track successfully patched to include "
		+ "'name', 'chap' and 'kgit' atoms");

	return true;
}

Enough Dirty Talk

In the interest of putting all this Java and Windows talk behind us and getting on with the task of starting this new Cocoa community site, I'm going to take this Java code and convert it over to an easy to use Cocoa utility. I'll be documenting the results within the next week.

As usual, if you've found this content useful, please spread the word to your friends and colleagues. It's painfully obvious that Regal Media is just starting up, and we can use all the feedback and community generated content we can get our hands on.

AttachmentSize
FixChapterTrack.jar6.42 KB

Comments

javascript

I am download java code and install the porsonal computer.this is a nice code and give more information this website.contractors insuranceThanks.>>>>jay12401