Monday, November 06, 2006

Burning a DVD on Tiger

So, I have an unencrypted VIDEO_TS folder (a non-commercial video project) obtained via download. I know this is a valid set of files because Apple's DVD Player application can open the VIDEO_TS folder and play it like a DVD. I've got a Mac Mini (G4, not Intel processor) with a SuperDrive. I've got a few blank DVD-R discs. So how do I burn it?

Allegedly, you can make a disk image containing this folder using Apple's disk utility. But if you don't do it right, you'll have an HFS image, not a UDF image. Allegedly, to do it right you tell Disk Utility to make a file system that is a "DVD/CD Master." This results in a .cdr file instead of a .img file. Allegedly, you can then burn that to make your DVD.

There's only one problem: this process doesn't work. I burned 4 coasters before I gave up. What I'm getting is an HFS file system on a burned DVD-R. The Mac can read it, but my DVD player can't, and neither can my PC. By comparison, if I put a commercial DVD in the Mac, the Finder's "Get Info" shows the file system type as UDF.

So, how do I get a usable UDF file system burned? Preferably, with no, or at least little in the way of extra software?

It's surprisingly hard to find a coherent explanation online. Apple provides some command-line utilities (hdiutil and drutil). The hdiutil command can do a huge variety of things. The drutil command seems more targeted around burning to and providing information from CD and DVD writers. The GUI Disk Utility seems to be mainly built on top of hdiutil. The descriptions of these command-line tools make it sound as if, between them, they ought to be able to do everything you need.

There's only one problem -- as far as I can tell, they can't!

There are two parts to the problem.

The first part of the problem is that I need to get a real UDF file system written. The GUI Disk Utility does not do this when I tell it to burn a .cdr file. It seems like perhaps hdiutil or drutil ought to be able to do it, although each of these has such a plethora of command-line options that it is not exactly obvious at first glance how to do this. When I say a plethora, I mean a plethora. And how often do you get to use the word "plethora" in a sentence and mean it?

The second part of the problem is that even if I can get a UDF file system written, apparently set-top DVD players aren't capable of playing just any old UDF file system. The file system has to use 8.3 uppercase filenames. And, apparently, the .VOB and other files have to be laid out in a specific order, in contiguous sectors, and possibly with padding. I don't know (and don't want to know) all the grisly details, but it appears that the players really just get a starting sector from the filesystem and then play video data from contiguous sectors. I suppose this makes some sense when you consider that you don't want the DVD player to have to seek to a new point on the disk in the middle of a chapter.

So, to build a UDF file system image which obeys these rules, it appears that the only option, besides using Toast or some other commercial tool, is to use a tool called mkisofs, passing it the -dvd-video option. You start with a directory containing your VIDEO_TS directory (and optional AUDIO_TS and JACKET_P directories and perhaps extra files) and use the tool like this:

mkisofs -dvd-video -o test.iso test/

However, this tool is not bundled with MacOS X 10.4, like the hdiutil and drutil tools are.

So, you can just download a binary, right?

Well, mkisofs doesn't seem to be available as a binary for Tiger on PowerPC through either DarwinPorts or Fink, although a source build looks feasible. It also seems like you can't get mkisofs by itself. Instead, it comes as part of a package called cdrtools. Or, you might see it as part of the port of xcdroast. I've used xcdroast under Linux, and it works fine, but I don't want to have to build or install that whole toolchain to get that one command-line tool. My Mac Mini is a bit lacking on both hard drive space and processing power. Although I've used them before, I have not yet installed either the developer tools, DarwinPorts, or Fink onto my Mac Mini. So I decided to try another approach.

I thought maybe I could use the mkisofs tool under Linux, since I already have the VIDEO_TS directory in question on a FAT32 partition on my PC. My PC is configured to dual boot Windows 2000 and Fedora. Allegedly I could mount the FAT32 file system under Fedora and run mkisofs to build the image file, then send it to my Mac, right?

Well, that got me nowhere. The mkisofs tool failed with a generic error message: "Unable to make a DVD-Video image." It might also have something to do with the way filename case is handled; under Windows 2000 the filenames are all uppercase, but when mounted under Fedora, the ls command shows the filenames as all lowercase. There's probably a solution to this, but again I was just trying to get something done, so I decided to look for another way.

After many Google searches I came across a little application called DVD Imager for MacOS X, available here:

http://lonestar.utsa.edu/llee/applescript/dvdimager.html

This application is basically an AppleScript UI wrapped around a binary of the mkisofs tool. (I am not sure whether it is a universal binary which would run on Intel-based Macs or not). You can drag and drop your VIDEO_TS directory onto the UI and then tell the tool where to put the resulting image file. The tool produced an .img file (not .dmg), which the Finder calls an NDIF disk image. What happened when I mounted it? It showed up as a UDF file system. That looked promising, so I burned it to a DVD-R using the Apple Disk Utility.

It appears to work fine on my Sony DVD player, so now I have my disk image file!

However, I didn't _really_ want a GUI with limited options; I'm accustomed to working with command line tools. The GUI tool created its own temp directory for assembling the file system and didn't pick up the JACKET_P directory next to the VIDEO_TS directory I dragged onto it. Can't I tell it exactly what I want?

Yes! The little .app package actually contains the mkisofs tool. You can right-click on it and choose "Show Package Contents." Inside the package, under Contents/Resources, is the mkisofs executable file. You can copy it and paste it elsewhere. For now I just put the mkisofs tool in my working directory, rather than with other Apple-supplied command-line tools. I ran it like this:

./mkisofs -dvd-video -udf -V PROJECT -o project.iso ./PROJECT

(where PROJECT is the name I want for the DVD filesystem, and ./PROJECT is the directory containing the VIDEO_TS and JACKET_P directories), and project.iso is the name of the image I want to generate.

It looks like it worked! It created another mountable file system image file, which the Finder will happily mount. The next thing to do was to try burning the DVD from the command line as well:

drutil burn -udf ./project.iso

And, it worked as well! So there you are. Note that I didn't have to give it any special options; it just did the right thing. If you have an external DVD burner or more than one drive you might have to provide some more options to tell drutil exactly what you want to do. If you want to add more special content to your DVD to be available on MacOS X or Windows or both, you might have to look into making some kind of hybrid file system. I'm sure that's all possible but I'm not going to go there for now!

I hope this information has saved you a little bit of time and effort!

4 comments:

Unknown said...

Thanks for this. I've been looking for an easy way to burn Jacket files for some time! Your method was simple and easy to follow. Thanks again!

Spaceboy said...

And what about this?

drutil burn -nofs -udf PROJECT

This will burn the folder PROJECT in UDF disc format. The disc is named as PROJECT

Paul R. Potts said...

Spaceboy, sorry, it has been a long time (and many MacOS X updates) since I have looked at this.

Do drutil's -udf and -nofs options really produce a contiguous file system that will play on a typical DVD player, directly from the folder?

I don't know, but I will try it when I next get a chance. Also, for all I know, Disk Utility may do a better job now.

Paul R. Potts said...

I have not yet tried the drutil options mentioned, but note that I have a new solution for commercial encrypted DVDs, using VLC, Fairmount, and Apple's Disk Utility (no command-line tools required) for Mac OS X 10.5.7. See this new post.

Since Disk Utility is mostly a wrapper on Apple's command-line tools, it should certainly be possible to use the command line tool instead of the Disk Utility GUI to do the same thing, but you'd still need VLC and FairMount.