Authoring an SVCD with VCDImager

728

Author: Dave Fancella

So you’ve recorded the last six seasons of “Red Dwarf” off of PBS, and now you’d like to burn them onto a disc that you can watch on your TV? Most DVD players support two formats that you can burn onto a regular CD: Video Compact Disc (VCD) and Super Video Compact Disc (SVCD). This article will help you create your own videos on SVCD, the superior of the two formats.

An SVCD can hold 35 to 60 minutes of video data, supports MPEG-2 5+1 surround sound, menus, and more. You can create an SVCD with menus and multiple tracks that will look, for all intents and purposes, just like a DVD in your DVD player. The main differences are that the resolution will be lower, but not noticeably so, and there will be more encoding artifacts. Like DVD, SVCDs are encoded with MPEG-2 video. Unlike DVD, your only choice of audio is MPEG-1 (technically the audio is MPEG-1 layer II audio, but I’m calling it MPEG-1 audio for simplicity. It can also be referred to as MP2); DVDs also support PCM, MP2, AC3, and DTS audio. Supported video and audio bitrates for SVCDs are also lower than for DVDs. While DVD is perfect for feature films, SVCD is generally sufficient for burning anything you’ve recorded from a TV network.

There are at least three GUI-based utilities for authoring SVCDs of which I’m aware. I’ve tried Arson and K3b and was unable to get either to work for an SVCD. I have not tried qvcd, but for this application, you may find your only path to success is through the command line.

Video formats

To make an SVCD, you need a video track encoded as MPEG-2, multiplexed with an audio track encoded as MPEG-1. The multiplexing process takes some frames of audio and places them in the file with their matching frame of video. For NTSC televisions, which are used in the U.S., you need a resolution of 480×480, and for PAL, which is used in most of Europe (except France), you need 480×576. SVCDs support variable bitrate compression for both video and audio. For video, SVCDs can be any bitrate up to 2.6Mbps. For audio, any bitrate from 32 to 384Kbps is acceptable. Many SVCD burners support non-standard bitrates, but that makes a less portable SVCD.

If you need to convert your input from some arbitrary format to MPEG-2 and MPEG-1, I recommend using a program called transcode to make the conversion. You will also need the MJPEG tools to provide an MPEG2 video encoder and an MP2 audio encoder. The MJPEG tools also provide the mplex program for multiplexing the converted streams. You may need some extra libraries for transcode to understand the source format you’re using.

Regardless of the input file format, use this command to turn the input file into an MPEG-2 video file and an MP2 audio file:

transcode -i [filename] -V -y MPEG-2enc,mp2enc -F 4 -Z [480x480 or 480x576] -E 44100 -b -o [output]

Transcode will use the file [filename] and turn it into two files, [output].m2v and [output].mpa. If you don’t know what audio bitrate to use, you probably want to use 128, which provides decent sound that doesn’t take a lot of room. You can choose up to 384 for best sound if you prefer, but your final filesize will be much larger. Now you need to multiplex the two files:

mplex -f 4 -S 680 -o [output].mpg [output].m2v [output].mpa

When transcode and mplex finish working, I’ll have a file called [output].mpg that I can burn as an SVCD using VCDImager.

Authoring the SVCD with VCDImager

The quick and dirty command for burning a single MPEG video is:

vcdimager -t svcd [inputfile]

This creates two files, called videocd.cue and videocd.bin. Pass videocd.cue to Cdrdao to burn the SVCD.

Unfortunately, the quick and dirty solution doesn’t give us menus or much else. VCDImager is perfectly capable of authoring a really fancy SVCD with menus, submenus, and multiple tracks, so let’s do that!

Let’s burn the first two episodes “Red Dwarf.” I would like to have two menus; the first will let me choose Play, and the second menu will let me choose which episode I want to watch. From a usability standpoint that’s definitely too many menus for this disc, but it makes a nice simple example of how to build SVCDs with multiple menus.

Creating a nice introduction

I’m going to create an introductory MPG file that will play when the SVCD is started. I’m going to pull the title sequence from the very first episode of “Red Dwarf” using MEncoder, a component of MPlayer. I used slight variations of this command to figure out where the sequence ends:

mplayer -frames 1690 1x01.avi

1690 was the frame I came up with that marks the end of the intro sequence. You could also pass the -ss option to mplayer to specify a starting position, but for me the default starting position of 0 was acceptable. The command I need to pass to mencoder needs the end position expressed in seconds instead of frames, so I calculated the end position by dividing the number of frames by the frames per second of the input file, and came up with this command:

mencoder 1x01.avi -oac copy -ovc copy -ss 0 -endpos 56.38 -o intro.avi

The output file is still an AVI file, which we’ll process later with transcode to make the MPG that we’ll place on the SVCD.

If your input file is a lower quality MPG than the SVCD standard accepts, you probably want to make a VCD rather than an SVCD. Frequently, if you transcode an MPG file from a VCD-compliant MPG to an SVCD-compliant MPG, you wind up doubling or even tripling the size of the file and making it impossible to fit it on an SVCD. Since this isn’t always the case, you’ll need to experiment a bit to decide. It’s almost always better to just make a VCD anyway. Consider that your MPG is already encoded with a loss of information; encoding it a second time will cause you to lose more information. If your input file is an XviD AVI file, you don’t have a choice — you have to re-encode it. But it’s also of much higher quality, so any loss you notice is much more likely to be the result of the MPG encoding rather than the decode/encode cycle.

Anatomy of the XML description

To create a well-authored SVCD, you need to build an XML file to process with a tool called VCDxBuild that’s part of VCDImager. This XML file describes the SVCD you’re making and references files on your hard drive that will be used to build the SVCD. The XML description consists of a header and body, just like an HTML document. The header looks like this:

<?xml version="1.0"?>

<!DOCTYPE videocd PUBLIC "-//GNU//DTD VideoCD//EN" 
"http://www.gnu.org/software/vcdimager/videocd.dtd">

<videocd xmlns="http://www.gnu.org/software/vcdimager/1.0/"
class="svcd" version="1.0">

<info>
<album-id>Red Dwarf 1x01 1x04</album-id>
<volume-count>1</volume-count>
<volume-number>1</volume-number>
<restriction>0</restriction>
</info>

<pvd>
<volume-id>Red Dwarf 1x01 1x04</volume-id>
<system-id>CD-RTOS CD-BRIDGE</system-id>
<preparer-id/>
<publisher-id>Dave Fancella</publisher-id>
</pvd>

<segment-items>
<segment-item src="intro.mpg" id="seg-intro"/>
<segment-item src="menu.mpg" id="seg-mainmenu"/>
</segment-items>

<sequence-items>
<sequence-item src="1x01.mpg" id="seq-episode1"/>
<sequence-item src="1x04.mpg" id="seq-episode2"/>
</sequence-items>

The first two lines are standard XML. The third line is also standard, and represents the start of the SVCD description. Notice that there isn’t a formal header section; instead there are four sections that make up the header. The info tag represents meta data about the SVCD. It
contains the volume ID, a count of volumes in a series, the specific volume number of this disc, and the restriction tag. The restriction tag represents whether this SVCD should be able to be copied once, more than once, or unlimited times. Since I’m authoring this SVCD for personal use, I set it to unlimited.

Next is the pvd section. PVD stands for Primary Volume Description and is used to construct the ISO9660 portion of the SVCD. For consistency, I mirror the album-id from the info section in the volume-id tag. The system-id tag should be left as it is here. Preparer-id and publisher-id are used mostly for professional SVCDs, though you might also use specific values here if you were authoring home videos to distribute to family and friends.

In the next two sections, segment-items and sequence-items, you describe the actual MPG files that will be placed on the SVCD. A segment is generally a brief segment of video, such as the introduction I built earlier. Commercials, previews, and shorts are other types of segments. Sequences are actual content. A sequence corresponds to a track on an audio CD, and it’s quite common to refer to sequences on a video CD as tracks. Chapters on a DVD and whole episodes of a television program are types of video you would describe as sequences. Give each segment and sequence file a unique ID you can reference throughout the remainder of the XML description.

The rest of the XML file is the pbc section and the closing videocd tag that matches the opening tag we saw earlier. It looks something like this:

<pbc>

<playlist id="play-intro">
<prev ref="play-intro" />
<next ref="select-mainmenu" />
<play-item ref="seg-intro" />
</playlist>

<selection id="select-mainmenu">
<bsn>1</bsn>
<prev ref="select-mainmenu"/>
<next ref="play-episode1"/>
<return ref="select-mainmenu"/>
<timeout ref="select-mainmenu" />
<wait>60</wait>
<loop jump-timing="immediate">1</loop>
<play-item ref="seg-mainmenu" />
<select ref="play-episode1" />
<select ref="play-episode2" />
</selection>

<playlist id="play-episode1">
<prev ref="select-mainmenu"/>
<next ref="play-episode2"/>
<return ref="select-mainmenu"/>
<wait>2</wait>
<play-item ref="seq-episode1"/>
</playlist>

<playlist id="play-episode2">
<prev ref="play-episode1"/>
<next ref="select-mainmenu"/>
<return ref="select-mainmenu"/>
<wait>2</wait>
<play-item ref="seq-episode2"/>
</playlist>

</pbc>

</videocd>

The pbc section describes the actual video part of the SVCD. It’s the real meat of the production. From top to bottom the description in the pbc section will be written in the order described onto the disc. The first item that will play when you put the SVCD in your DVD player is the first sequence or segment referenced, and it will be played according to the rules you set in the pbc section.

There are two types of content you can put in the pbc section: A playlist is just a track to be played, and a selection is a menu. In both cases you can use the previous, next, and other buttons on your remote control to interact with the SVCD, but in a selection block you can also use the number buttons to select items. In each of these sections you describe what the SVCD player should do when the user presses any of these buttons while viewing the item.

Let’s take a look at the first playlist, which is the introduction I created earlier. I’ll use the ID of play-intro I gave it to refer to this playlist throughout the rest of the pbc. The next two tags, prev and next, represent actions the user might want to perform. Since it’s the beginning of the SVCD, I decided that when the user presses the Previous button the section should just start over. I also decided the user should be able to skip the introduction. For both of these tags, the ref attribute refers to an
identified playlist or selection. So naturally the prev tag refers to play-intro, the ID of the introduction, and the next tag refers to select-mainmenu. The last, and probably most important, item, play-item, refers to a previously defined segment or sequence — in this case the seg-intro. VCDxBuild will insert the MPG file described by seg-intro at this location on the SVCD.

Next, let’s look at the main menu. I gave it the ID that appears in the introduction playlist. The bsn tag represents the base selection number; in simple terms, the first select item will have this value, 1. The second select item will be
this value plus 1, or 2. If not given, bsn defaults to 1. In my example SVCD, the user will press 1 to watch the first episode on the disc and 2 to watch the second.

prev and next here serve the same purpose as in the playlist. I also added a return tag, referencing what happens when the user presses the Return button. The timeout tag means “if the menu displays for X amount of time, jump to this section.” I set it to select-mainmenu, which means it will stay on this menu until the user does something. wait specifies the timeout value in seconds. loop specifies how many times you should loop the video. The menu I used is an MPEG still picture,
and you always set the loop on an MPEG still as 1. play-item is the segment or sequence that should be played. In a menu, your segment should contain graphics telling the user what his choices are, or it can’t truly be considered a menu. The last two items are the actual select tags, which should refer to previously defined segments or sequences.

With the menu finished, let’s look at the first playlist of actual content. All of the tags should look familiar to you by now. You’ll notice that prev and return both take you back to the main menu. It would also make sense if prev just restarted this playlist since this playlist is technically the first track. I decided that was counterintuitive, but you can decide whatever you want for your SVCD. I gave a wait value, but since there’s no timeout action defined here the wait value is meaningless. However, since I will use this file as a template for other SVCDs, I’ll leave it, because I will author an SVCD someday that will use the wait tag.

Wrapping it up

Finally it’s time to build the SVCD using the VCDxBuild utility. It takes a number of useful options, but we don’t need any of them. We’ll just use:

vcdxbuild svcd.xml

When it’s done I have two files in my working directory: videocd.bin and videocd.cue. I then burn the video CD by calling cdrdao with the file videocd.cue:

cdrdao write --device ATAPI:0,1,0 --speed 2 videocd.cue

As with audio CDs, you should burn your SVCD at the slowest speed your burner is capable of burning for maximum hardware player compatibility. The --device flag will vary depending on where your burner is on your ATAPI bus.

Advanced authoring

This article is not the be-all, end-all of SVCD authoring with GNU VCDImager; there are many more wonderful things you can do. You can declare sections of video as chapters and automatically skip around them, which is useful when you don’t want to try to extract commercials from a show you recorded from your TV but you still don’t want to watch the commercials when you watch the show. You can declare visual hotspots in your menus, which can be used by a player that supports pointer devices as input, such as Xine. Sadly, many hardware players do not support pointer devices on SVCDs, even if they do support them for DVDs. You can also have alternate audio tracks.

All in all, SVCDs are a pretty neat way to make optical video media with an old CD burner. With the dropping prices of DVD burners I expect SVCDs will drop in popularity. They never got wildly popular to start with, because of the relatively small amount of data they can hold compared to a traditional VHS tape. I still expect that the SVCD format will continue to live and be supported by DVD players for years to come. Considering the price of the hardware and the price of the media, traditional CDs are still the most cost-effective way to store the TV programs you record onto your hard drive and are likely to remain that way for several years.