Hack69.Create a VCD


Hack 69. Create a VCD

Use the tovid scripts to automate the conversion of many video formats to VCD and SVCD.

Before DVD burners and media were relatively inexpensive, creating your own video DVDs was a daunting prospect. Many people (both professionally and personally) used VCDs (or Video CDs) instead, as the media and hardware were much cheaper. VCDs allow you to put a video on one or more CDs and watch them either in your computer or in VCD-compatible DVD players (most modern DVD players support VCD playback, if not SVCD playback). Even with DVD burners and media coming down in price, VCDs are still a popular format in a number of countries. This hack tells you how to convert your own video files into a VCD or SVCD.

3.24.1. Choose VCD or SVCD

There are a number of standards for video on CD. These standards include VCD, XVCD, SVCD, XSVCD, and others. Some of these formats aren't even official standards (i.e., they may not even play in a commercial DVD player) but are instead variations on a standard. For the purposes of this hack, I will use the two more widely used formatsthat will most likely work in your DVD playerVCD and SVCD.

The primary differences between VCD and SVCD, on a basic level, are video and audio quality and compression. The VCD standard was created based on MPEG1 video with CBR (constant bit rate) audio. The VCD 2.0 standard supports MPEG1 videos at a 352 x 240 resolution at 29.97 fps (NTSC) or 352 x 288 at 25 fps (PAL).

SVCD is based on MPEG2 video with VBR (variable bit rate) encoding for audio. The result is a higher resolution for the video stream in the same space requirements. SVCD supports MPEG2 videos at 480 x 480 at 29.97 fps (NTSC) or 480 x 576 at 25 fps (PAL).

It may seem like the decision between the two formats is simplego for the higher resolution SVCD format. If you are creating the (S)VCD primarily for your own use, and your DVD player supports SVCD (or you plan to play it on your computer) then yes, go for the higher resolution. However, if you plan on distributing your video to a number of people, you might want to go with the VCD format simply because it has much wider support in hardware DVD players.

Whatever format you choose, you need the VCDImager suite of tools to create the (S)VCD file structures to burn to CD. Even if you use a GUI tool such as K3b to burn the CD, these libraries and tools are used underneath.

To get VCDImager, either download precompiled binary packages from the official site at http://www.vcdimager.org or, if you use Debian, run apt-get install vcdimager. If precompiled binary packages aren't available for your distribution, download the latest source tarball from the official site and compile it according to the installation instructions.

3.24.2. Create (S)VCD-Compatible Video

So you have a video (or a number of videos) that you want to convert into a VCD. The first step is to convert that video into a format compatible with the VCD standard. Although you could use mencoder or transcode directly to perform this conversion, the number of options involved can quickly get complicated and confusing. Luckily a great tool, tovid, has been created to solve this problem. The tovid suite is a series of scripts, which automate the process of converting a video into a VCD. The scripts involved have basic easy-to-understand arguments and, because the output shows you the commands that are being executed, you can also use the scripts to learn more about the underlying process.

To install tovid, download the latest release from the official project page at http://tovid.sourceforge.net. The main tool in the suite is called tovid and uses mplayer, mjpegtools, ffmpeg, and normalize to perform the video conversion so you will need to have these packages installed beforehand. Once these requirements are met, download the latest release and untar it:

 $ tar -xzvf  tovid_0.18b.tar.gz  

Now become root, enter the tovid source directory that tar created, and then run the configure script inside. This script automates the process of installing tovid on your system and once it completes, you are ready to start.

 # cd  tovid_0.18b  # ./configure  

With tovid installed, now it's time to convert the video. The tovid arguments are pretty basic. The only wrinkle is that you need to decide whether to use NTSC or PAL formats and which aspect ratio to use for the video so tovid knows how to properly resize the video. Whether to use NTSC or PAL formats depends on where you live (or more specifically, what your TV uses). If you live in the United States, use NTSC. If you live in Europe or Japan, use PAL.

tovid supports full-screen (4:3), wide-screen (16:9) and theatrical widescreen (2.35:1) aspect ratios through the -full, -wide, and -panavision options, respectively. Generally speaking, if you are creating a VCD of a home video or TV show, you will probably use -full (and this is what tovid uses by default if you don't specify the option). If the video source is from a movie, you will use -wide or -panavisiondepending on how wide the video is. If you are unsure, run the idvid utility that comes with the tovid suite on the video file to output the width and height of the video, and then divide the width by the height:

 $ idvid  sample.avi  --------------------------------- idvid video identification script Version 0.18b Written in 2004 by Eric Pierce http://tovid.sourceforge.net/ --------------------------------- Gathering video information. This may take several minutes, so please be patient… ===================================================== File: sample.avi    Width: 640 pixels   Height: 288 pixels … $ 

In this example the video aspect ratio is 640/288 or, basically, 2.35:1.

With all this figured out, now run tovid on the input video. In this example, I will create a NTSC VCD out of sample.avi with a panavision aspect ratio:

 $ tovid -vcd -ntsc -panavision  sample.avi output  

This example would create a new VCD-compatible video called output.mpg in the same directory. As tovid runs, it outputs the various commands it is running and gives you a general idea on how long it will take to complete the task. On my 1.2 GHz CPU it takes between an hour and two hours to convert a video. To create an SVCD instead, simply use the -svcd argument instead of -vcd. If you have a video that is too long to fit on a single CD, tovid will automatically split the video along CD-sized boundaries for you.

If you have more than one video you would like to convert, you can use the tovid-batch command instead. tovid-batch takes the same arguments as tovid, except that you don't specify an output filenametovid-batch will determine the output filename based on the input filename. So if you had a directory of full-screen .avi files that you wanted to convert to SVCD, you would run:

 $ tovid-batch -svcd -ntsc *.avi 

Notice I didn't specify -full. That's because -full is set by default in both tovid and tovid-batch. When tovid-batch completes, your directory will be full of VCD-compatible .mpgfiles.

3.24.3. Create the (S)VCD XML File

With your video in the proper format, you can create the (S)VCD file structure to burn to CD. (You can skip this entire step if you use K3b to burn the CD.) Just launch K3b, click File New Project New Video CD project. Drag and drop your video file(s) onto the bottom pane and then click Burn to start the process. At this moment K3b does not perform any video conversion or validation on its ownall it will do is create the proper file structure for the video file and burn it to the CD along with the video you created.

If you don't want to use K3b and instead want to stick to the command line or use another burning tool, the next step is to create the VCD XML file. This file describes the structure of the VCD and is used by vcdimager to create the actual VCD image and includes any menus you might want to have in the VCD as well. tovid includes the makexml script to help automate this process. To create the XML file for the video in the previous example, type:

 $ makexml -vcd  output.mpg output  --------------------------------------- makexml A script to generate XML for authoring a VCD, SVCD, or DVD. Part of the tovid suite, version 0.18b Written in 2004 by Eric Pierce http://tovid.sourceforge.net/ --------------------------------------- Adding title: output.mpg as title number 1 ========================================== Done. The resulting XML was written to output.xml. You can create the (S)VCD .bin and .cue files by running the command: vcdxbuild output.xml Thanks for using makexml! $ 

To create an SVCD-compatible XML file, replace -vcd with -svcd. The makexml script supports other options as well, and Table 3-4 goes over some. These options come into play if you want to add a menu system to the VCD, but if you just want to play back the video you don't need them.

Table 3-4. makexml command-line arguments

Argument

Function

-menu VIDEO

Use video file VIDEO as a menu from which you can jump to each of the listed video files. If you have multiple menus, include a top menu so they are reachable.

-topmenu VIDEO [-menu VIDEO ]

[-menu VIDEO ]…

Use video file VIDEO for the top-level (VMGM) menu. The top menu will jump to each of the subsequent [-menu] videos listed. Use this only if you have multiple sub-menus to jump to. You can only have one top menu.

-slides

Create a slide show of still images.


3.24.4. tCreate the BIN and CUE Files

As you might have noticed in the makexml output, the next command to run is nvcdxbuild. This script actually generates the .cue and .bin files that make up the VCD image you will burn to CD (the cue file contains the file structure for the VCD and the bin file contains the actual video). The syntax is pretty simple, just pass vcdxbuild the name of your .xml file. makexml is nice enough to tell you the command to use, and in the case of my example I would type:

 $ vcdxbuild  output.xml  

I noticed on my VCD .xml file that the makexml script added an SVCD-only option tag:

 <option name="update scan offsets" value="true"/> 

When I ran vcdxbuild the first time, it complained "parameter not applicable for vcd type." If you run into this problem, compare the XML file to the examples at http://www.videohelp.com/~vitualis/general_xml_structure.html and make sure the options are valid for VCDs or SVCDs, depending on what you are making. I deleted the offending line and was able to run vcdxbuild at that point.


When vcdxbuild finishes, it will create a videocd.bin and videocd.cue file by default (change these with the -b and -c options, respectively). Now you are ready to burn to a CD.

3.24.5. Burn to a CD

The .cue file is actually a special set of instructions as to the structure of your VCD. A CD recording utility like cdrecord doesn't automatically know how to handle such a structure, so you need to use cdrdao, which can perform DAO (disk at once) recording, instead of TAO (track at once) like you might use with cdrecord. cdrdao is used by many other applications, so it might already be installed on your system, otherwise it is likely already prepackaged, so use your distribution's package manager to install it.

The cdrdao syntax is much like cdrecord. Tell cdrdao the device to use like you would with cdrecord or, on Linux, you can even specify the actual device (such as /dev/sr0 for instance). My system has a CD burner on /dev/ hdc, so to burn the VCD in the example, I type:

 $ cdrdao write --device  /dev/hdc videocd.cue  Cdrdao version 1.1.9 - (C) Andreas Mueller … Burning entire 79 mins disc. Starting write at speed 8… Pausing 10 seconds - hit CTRL-C to abort. Process can be aborted with QUIT signal (usually CTRL-\). WARNING: No super user permission to setup real time scheduling. Turning BURN-Proof on … Writing track 01 (mode MODE2_RAW/MODE2_RAW )… Writing track 02 (mode MODE2_RAW/MODE2_RAW )… Wrote 615 of 615 MB (Buffers 100% 98%). Wrote 274259 blocks. Buffer fill min 87%/max 100%. Flushing cache… Writing finished successfully. $ 

Now pop your new CD into your DVD player and enjoy.




Linux Multimedia Hacks
Linux Multimedia Hacks
ISBN: 596100760
EAN: N/A
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net