August 9, 2005

Tovid: Video authoring simplified

Author: Nathan Willis

Despite today's impressive array of media PCs, low-latency frameworks, and revolutionary gold-plated sound cards, most people still prefer to watch television and movies from the comfort of their living rooms rather than in front of a computer monitor. Thus, for computer-acquired video, conversion to a video disc is often the order of the day. That's a task for tovid, a free suite of open source tools to make that trip from the hard drive in one room to a DVD player in another completely painless.

Tovid started out as a VCD (VideoCD) creation tool, and still fully supports that format. VCD is a video disc format similar to DVD, but with a lower resolution and bitrate, so VCD-encoded files can be burned onto a regular 650MB CD-R disc. Many modern DVD players can read VCD and SVCD (Super VCD) formats. As a rule of thumb, if your DVD player can play MP3 CDs or JPEG-slideshow CDs, odds are that it can play VCDs as well. Due to the smaller capacity, VCDs generally hold about one hour's worth of video -- not enough for feature films, but plenty for homemade video or short material from the Internet.

Tovid began life in 2004 as a pet project of Eric Pierce, who found it hard to remember all the necessary options to convert different forms of video into strict VCD-compatible MPEGs. Pierce wrote a shell script to simplify the process, and later added a second script to generate DVD-compliant content and a third for SVCD. Today, tovid has evolved into a general-purpose script that can read almost any video type and write it to the proper output for disc authoring.

As with Pierce's original scripts, tovid works by calling on an array of powerful lower-level tools that can be more difficult to use. Tovid's documentation lists MPlayer, MJPEGtools, FFMPEG, normalize, ImageMagick, and SOX as requirements, and dvdauthor, vcdimager, transcode, libdvdcss, and lsdvd as options, depending on what types of discs you want to author.

You can download the latest release of tovid from SourceForge.net, as well as an in-development package called tovid-gui that supplies a Python-based graphical interface (discussed below). Since tovid is a collection of bash scripts, there is no compile step -- simply unpack the tarball and run the configure script, which checks for the required lower-level packages and installs the tovid scripts themselves.

In fact, gathering all the required dependencies is probably the most complicated thing about tovid. They are maintained by different teams of programmers, and you might have to track one or two of them down if your distribution doesn't supply them all.

Making a VCD

Creating a VCD with tovid takes four steps: encoding the video with tovid, creating a menu with makemenu, building the XML disc descriptor with makexml, and authoring the disc with either vcdimager or dvdauthor.

The tovid script will take any form of video readable by MPlayer and re-encode it to DVD or (S)VCD format. Some popular video file formats (such as AVI and QuickTime) can contain any of a number of video formats, so transcoding them the old-fashioned way into VCD-compliant clips would require poking inside the files to find the correct bitrates, frame-rates, resolutions, and video codecs. Tovid, however, does this for you by utilizing the wide selection of codecs MPlayer can read.

Tovid takes only a few options: The command tovid -ntsc -vcd -full Clip01.avi clip01-final will convert the file Clip01.avi and write the result in a file named clip01-final.mpg. The first flag specifies NTSC format; you can also use -pal for PAL output. The second flag specifies VCD resolution (352x240); the other options are -dvd (720x480), -half-dvd (352x480), -svcd (480x480), and -dvd-vcd(352x240).

The -full flag results in a "standard-definition" 4:3 aspect-ratio. Other choices are -wide (for 16:9) and -panavision (for 2.35:1). Tovid will automatically letterbox the video to fit into the aspect ratio you select, adding black bars at the top and bottom to a widescreen original destined for 4:3 output. Certainly, letterboxing a video wastes pixels drawing these black boxes, but if your target is a standard 4:3 television, the alternative is cropping the sides. Letterboxing the video manually would require a compositor and a lot of your own time.

With your video in VCD-compliant MPEG form, create a menu screen with makemenu. You pass it the desired format and resolution, followed by a list of the titles that are to be made menu items. For example, makemenu -ntsc -vcd "Uncle Earl Falls Down the Stairs" "Grandpa's Quake Movie" my-video-menu. Makemenu then creates a "menu movie" (really a single-frame MPEG) for your disc in NTSC format and VCD resolution. The menu will list two items: Uncle Earl Falls Down the Stairs and Grandpa's Quake Movie.

The menu movie is constructed with ImageMagick and mjpegtools. You can make artsy creations in this step by using an image for the menu background, adding an audio clip for background music, or changing the default font and text layout.

Step three uses makexml to build a disc descriptor file that details the order of the clips, the menu, and which menu items link to which clips. For example, we might use makexml -vcd clip01-final.mpg clip02-final.mpg -menu my-video-menu.mpg my-videocd. These options tell makexml to prepare a VCD descriptor, list our two video clips in order, and link to the menu movie created in the previous step.

Now we are ready to author and burn a VCD. Tovid recommends using vcdimager for VCD and SVCD authoring and dvdauthor for DVD authoring, but neither comes with the tovid package. The XML file produced is designed to work with vcdimager's vcdxbuild command, as in vcdxbuild my-videocd.xml. The resulting disc image can be burned to CD-R with your favorite CD-burning application.

Now that you know what to do, don't

If all that seems like a lot of typing, don't worry. The newest version of tovid introduces two things to speed up the process. First, you can make a configuration file in your home directory to specify command-line options (-ntsc, -vcd, etc.), saving you from retyping them every time.

Second, the tovid-gui package provides a graphical front end to the entire suite of scripts. It is currently an add-on module to the base tovid package. Although it's still under development, it may one day become the default interface. With tovid-gui, you can lay out your disc in its entirety, including the videos to be converted and menu design to be created, and let the entire process run in the background.

This is an improvement over the command-line system, since the video encoding process is a notorious CPU hog and can be quite time-consuming. Even VCD videos (the lowest-resolution option) can take longer to convert than they do to watch, depending on the speed of your system.

That's not all, folks

Even if the above was all tovid did, it would be worth writing home about. But there's more -- the base package includes several auxiliary scripts for the same low price. Idvid scans video files and prints out helpful information: running time, frame rate, resolution, and compatibility with the various disc formats supported by tovid. Postproc can help tweak videos that suffer from jitter or A/V synchronization problems. Dvrequant can re-quantize DVD format video to take up less space, while makeslides can convert a set of still images into a slideshow in VCD- or DVD-compatible MPEG format.

There are also many other options beyond basic tovid usage -- deinterlacing, subtitling, and various audio and video tweaking. Tovid can take great advantage of the advanced features of mencoder, ImageMagick, and SOX. I was impressed with how well tovid performs its tasks on its own without requiring the user to know and understand the advanced options.

A lot of time and hard work goes into making complex tools like these. Sometimes, though, a really complex, flexible tool ends up being a bit like a handle-less Swiss army knife: You can use it to do lots of complicated work, but you'll probably slice your hand up numerous times before you even get started. Part of the beauty of using free software is that it is written to scratch a personal itch. Eric Pierce first wrote tovid to make re-encoding videos simpler and faster for himself, and in doing so, he made the power of these lower-level utilities far more accessible to the rest of us.

Click Here!