Friday, September 26, 2008

Command Line DVD Authoring: Part 4

This is part of a multi-part series on creating DVDs manually from the command line. It is not expected that regular users will generally be performing video editing or DVD authoring from the command line. Rather, this guide is intended for programmers who may be wishing to build a front-end for DVD authoring, and don't want to sift through miles of documentaion just to get the basics. This guide makes use of command-line utilities already freely available, but is not meant to be a complete set of documentation for any of these utilities. Instead, consider it a primer. The parts in this series are:

Part 1: Editing a Video File with MPlayer
Part 2: Converting a Video to DVD Format
Part 3: Making a DVD Menu
Part 3.1: Extracting Audio From A Video
Part 4: Building a DVD .iso File

It should be noted that while the programs themselves should remain relatively the same between Linux distros, the name of the packages themselves are likely to change. This tutorial was written using Ubuntu 8.04 as the reference OS, so if you use a different distro, your mileage may vary.

Part 4: Building a DVD .iso File

Part 3 dealt with building a menu for our DVD, using components assembled in Part 2 (and possibly in Part 3.1, depending on your needs). This part takes us the rest of the way, putting it all together into a DVD .iso file, suitable for burning.

Once we have our menu set up, we need to create an XML file that describes how it all fits together. We use the makexml command (part of the tovid package from Part 3) to do this. A typical command to go along with the previous makemenu command might look like:

/usr/share/tovid/makexml -dvd
-menu mydvd.mpg \
shownumber1.mpeg2 \
shownumber2.mpeg2 \
-out mydvd

This is pretty straight-forward. This program is designed to work with either DVDs or VCDs, so we tell it which one to use with the '-dvd' option. The '-menu' option tells it which video file to use for the menu (that's the one that we created in Part 3). We follow it with the actual video files that our DVD features, making sure they appear in the same order as we specified with the makemenu command. Lastly, we use the '-out' option to give it an outout filename (it will automatically append .xml to the end).

Once we have our XML file in place, you can tweak it to your heart's desire, but at this point we're ready to actually build the DVD file and directory structure. Again, the tovid package provides the perfect tool for this: makedvd. And as it turns out, this command is the simplest yet:

/usr/share/tovid/makedvd mydvd.xml

The xml file describes how the menu is laid out, which video files are used, where they appear on the disc, everything that makedvd needs to organize the files in the way they need to appear on the DVD. This is going to create a subdirectory with the name of the XML file, minus the .xml extension. Check it out, you'll see an AUDIO_TS and a VIDEO_TS directory, and the VIDEO_TS looks exactly the way you expect it to. But you can't just burn it off like this and hope that it's going to work. We have one more step.

The genisoimage package will provide us with the genisoimage command. This package sets up a symlink to that command called mkisofs, which you may already be familiar with, but it is a different package. Our command is pretty simple:

genisoimage -dvd-video -o mydvd.iso mydvd

The '-dvd-video' option is the important one here, it tells genisoimage to actually prepare a DVD video-compliant filesystem, with proper file sorting, padding, etc. Without this option, your DVD may not work so well as you'd think. The '-o' of course is the output file, and the last argument is the directory that we created with the makedvd command.

When you're finished, go ahead and clean up the directory that makedvd created, and you're good to go! You have an .iso file that can be burned off onto DVD using any major CD/DVD burning software. If you want to test it before burning it, just to make sure you're not wasting blank discs on DVDs that need tweaking, just mount it temporarily and test it in your favorite DVD viewing program:

mount -t iso9660 -o loop mydvd.iso /mnt

This will mount it in the /mnt directory, which is where you want to point your viewer. When you're finished, just umount it:

umount /mnt

...and if you liked what you see, go ahead and burn off a copy.

I hope this series of articles gave you a little more insight as to using various Linux utilities to create your own DVDs. Those of you comfortable using Perl, Python, Ruby or whatever to build GUIs may find these instructions invaluable in building your own frontends for whatever purpose you may have. As always, be sure to check the man pages and the project web sites for any addition documentation that I didn't cover (there's a lot). If you end up creating a front-end based on these instructions and wouldn't mind sharing it (and maybe the source code), let me know and I'll post a link here.

1 comment:

  1. Hi! if you don't want to use command lines you should better use this:


Comments for posts over 14 days are moderated

Note: Only a member of this blog may post a comment.