Some thoughts on DVD authoring (original) (raw)
| Introduction The tools for the job Necessary hardware Necessary software The stages of processing Downloading from the camera Composing the movie Converting and saving DVD Menus Examples of DVD authoring Authoring basics Example 1 Example 2 Writing the disk Playing the DVD Acknowledgements | Updates21/Apr/03 - Original.22/Apr/03 - Various suggestions from Scott Smith, Andy Polyakov and Dan Dennedy applied.24/Apr/03 - Improved explanation of .sub file format and menus.5/May/03 - Updated to dvdauthor 0.5.314-15/May/03 - Clarifications17/May/03 - More clarifications.22/Sep/03 - Added alternative to jpeg2yuv.31/Dec/03 - Updated authoring section to dvdauthor version 0.6.x3/Jan/04 - Added a second example and some comments on bitrates.21/Jan/04 - Corrected allowed contents of vmgm block and added a table of contents.24/Jan/04 - Minor tweaks. |
|---|
What this page is.
This document offers a few clarifications and thoughts on writing DVDs and in particular DVD videos under Linux. I shall concentrate on the processes that I personally use, rather than attempting to write a fully general guide. So the emphasis will be on converting digital video recordings and transferring them to DVD.
Standard Disclaimer: Take all you read with a generous pinch of salt mixed with scepticism. What appears here seems to work for me. It may work for you, it might not, it could even be harmful. Stay alert, and if things look bad bail out. To a very great extent this document was written to help me to remember what to do and to help me find the bits I didn't understand.
Most of what is here is in the web pages of the software packages I mention, or their mailing-list archives. All I've really done is to try to make it a little easier to find. I welcome suggestions, clarifications etc. (especially on the sections in red), I'm still feeling my way in this.
Tools
Hardware
Obviously if you are going to make DVD videos you need a number of hardware tools.
A DVD writer
There are several different formats available, and this is the cause of many headaches.
- DVD+R &DVD+RW:
- DVD-R & DVD-RW:
- DVD-RAM: This format is not suitable for DVD-video, and so will not be considered further here.
Some writers on the market support more than one format for writing. Unless your writer does, you need to make sure you use the correct media for the writer.
Note that not all DVD-ROM drives and DVD players can read rewritable media (as is the case with CD media). Of the 4 DVD-ROM drives to which I have easy access one (the oldest of them) is unable to recognise DVD+RW disks but does handle both DVD+R and DVD-R (I don't have any DVD-RW media with which to test it); my hardware player handles DVD+R and +RW without any problems. www.dvdplusrw.org has some listings of compatibility. As with all media compatibility issues your mileage may vary, if a device is marginal, then different machines of the same model may not give the same results. If you do have problems, it's always worth cleaning the lens.
It is also worth noting at this point that the 4.7GB typically listed as the capacity are salesman's GB (i.e. 109 bytes rather than 230 bytes) you can actually get about 4.4GB onto a disk.
A DV camera
If you are going to make you own videos, you will need a digital video camera. As far as I can tell most seem to interface with Linux systems as the interfaces are pretty standard. Look for one with DV IN/OUT and full AV/C support. (It's probably possible to do something with an analogue camera and a TV card, but I don't know.)
A Firewire (IEEE1394) Card
The interface of most (all? I've never seen a USB video camera) digital video cameras is Firewire (also known as iLink, DV or IEEE1394). Most Firewire cards work under Linux but there is one major chipset that is not supported, check out The Linux IEEE1394 page for the latest information on support, there are also notes on supported/unsupported cameras and other devices there. (My camera also has a serial interface, but I'm not aware of any Linux software that can use it, and I'm not sure why anyone would want to.)
Loads of Disk Space
A full 1 hour DV tape will typically use about 13 GB of disk space when first downloaded, then you'll need room for the translated stuff and for the DVD mastering.
A Fast CPU
The conversion from DV to DVD video formats seems to be pretty slow, I get about 250 frames/minute conversion rate with a 1.2GHz Athlon.
Software
The larger distributions (e.g. SuSE and Debian) probably have most of the software needed, but unless you are running Debian Unstable they may be old versions that only support a limited subset of the capabilities of current versions. This field is evolving rather quickly, which is part of the reason why documentation is in short supply, it also means that by the time I've finished writing this it will probably be out of date.
Kernel
It is possible that your distribution's stock kernels don't support Firewire, although I think most do now (check for /lib/modules/<_version_>/kernel/drivers/ieee1394, if that directory exists and contains raw1394.o and video1394.o you may not need to do anything special here -- however if you have problems with the interface it may be worth trying a newer version).
If you need to build you own kernel, it is almost certainly worth getting the latest ieee1394 drivers for 2.4 from The Linux IEEE1394 page before building, however be aware that the latest versions are not compatible with the 2.4.20 pre-emptive kernel patch. To get at the IEEE1394 drivers you need to enable prompting for development drivers, other than that it's pretty much the standard routine.
You probably won't use these directly very often (apart from creating menus), but kino and dvdauthor both use them.
Kino is able to control the transfer of the video stream from the camera to the computer. Kino is also a solid basic video editor that allows you to split and join scenes, export to various formats and most of the other stuff you need to get your raw video into a useable form. This an essential tool.
There is now a titling tool dvtitler available for kino version 0.7 which can be downloaded from the same site. The capabilities are fairly basic, but it will do the job.
A set of tools for mastering DVD videos. These programs can take the output from kino and convert them to the required directory structure for a DVD video. There are also tools for creating menus (and other subtitles). These tools are all command-line utilities. All the descriptions here refer to dvdauthor-alpha-773, although most of the 0.6.x versions should be similar, the 0.5.x versions were however very different.
These are command line tools for writing DVD±R(W) media. (Originally only DVD+R(W), but current versions also support DVD-R(W)). DVD-R(W) can also be written using the ProDVD extensions tocdrecord, or dvdrecord (which is another cdrecord extension).
mkisofs is part of the cdrtools package, along with cdrecord. For DVD-Video support you need to have at least version 2.0.
Processing
Getting the basic movies ready
Obviously firstly you need to record something! Suggestions on subject matter, video techniques etc. are WAY beyond the scope of this page.
Transferring the material to your hard drive
Kino is the tool for this job.
Connect the camera to a firewire port and switch it into "Playback" mode, then start kino. You will probably need to configure kino to default to putting things in sensible places, and to use sensible default formats (in particular, I recommend setting the default save format to DV2 as that can be played by xine). As an interesting aside, the Windows software that comes with my camera only supports downloading stills (or so the manual says), but kino does the full works.
To get data off the tape, go to the "Capture" tab of kino. This allows you to set up the options and transfer movies to your hard disk. By default A/VC (Audio/Video Control) is disabled--enable it, otherwise kino will not be able to start and stop the camera. You can now manoeuvre around the tape with the navigation buttons and control capture with the capture buttons. When transferring video, kino automatically inserts scene breaks each time the camera was stopped and restarted (I think it also occasionally inserts breaks it shouldn't, but I'm not absolutely certain there). As a guide, a full DV tape needs about 13-14GB of disk space.
I don't know anything about cameras that use memory sticks.
Composing your movie
Again this is a job that can be done with kino. I've not tried it, but it looks as if avidemux also has similar editing capabilities.
Basically all you need do is read in the files you saved earlier, put them into a sensible order and cut the bits you don't need. There are some more advanced editing features as well, but I've not done much with them. The editing capabilities of kino are pretty self-explanatory. Get familiar with the timeline tool as a means of coarse navigation, it will save you a lot of time looking for cut points.
Saving your movie
In order for DVD players (whether software or hardware) to be able to play your movie it has to be in a suitable format. The easiest way to do this if you are using kino is to go to kino's export tab. There you need to find the mpeg export tab, which is hidden until you start to move along the export types (it's the last one).
- Select an export path and select type=8 (DVD)
- Add a -r 48000 option to the mp2enc settings. If you don't do this, then you will get a 44.1kHz sampled audio track which is non-standard and may give hardware players problems. (This appears to be fixed in kino version 0.7).
- By default mpeg2enc encodes DVD format with a maximum bit rate of 7500kbits/second. This will typically allow you to get about an hour and a half onto a DVD. This is a resonable mid-range setting, but DVD's can have higher or lower bit rate with a trade-off between quality and quantity. Unfortunately I've mislaid the URL that gives the permitted range but I think it was 4000-10,000. At 4000kb/s on a good monitor with xine I can see significant pixelation of a blue sky, but on a normal television it's still very watchable. To adjust the bit rate add a -boption to the mpeg2enc line (e.g. -b 4000 for 4000kb/s). 4000kb/s can give about two and a half hours on a disc.
- If you want each scene in kino to be one chapter in the DVD, then enable the "split scenes" option. If you want just one long chapter or want to set your chapter boundaries in dvdauthor, then don't.
- Other than that, just ensure export frames is set to "all", and export it, the default settings for the conversion routines seem well chosen. This is quite a slow process, my 1.2GHz Athlon can only manage about 220-250 frames/minute.
Menus
One of the big advantages of DVD over video is that it is a random-access medium which means that it is possible to have menus which allow you to to select what you want to see, rather than having to scan to roughly where you want which is both time-consuming and inaccurate (at least on my VCR).
To understand menus (and in particular the limits of what can be done with dvdauthor) you need a basic understanding of the hierarchy of structure within a video DVD.
TitleSet
This is the highest level of structure within a video DVD. Every DVD has at least 1 titleset. All the files associated with a given titleset start with VTS_ _nn_where nn is the titleset number (starting from 1).
Title
Each titleset contains 1 or more titles. Each title is effectively a standalone movie. If you start xine and just tell it to play a dvd, and that dvd doesn't have a top-level menu, then it will just play the first title of the first titleset and then stop.
Chapter
Titles are subdivided into chapters. Chapters provide entry points to the movie, but when the player reaches the end of a chapter it will continue to the next chapter.
Menus can be associated with either the whole disk (VMGM) or with a titleset (VTSM), there can be more than one menu of either type. The simplest use of menus is to navigate within the disk. There are some limitations on the targets of navigation menus:
- A VMGM menu can only jump to:
- Another VMGM menu
- The first VTSM of a titleset
- The start of a titleset
- A VTSM menu can only jump to
- Another VTSM in the same titleset.
- A title or chapter within the titleset.
- The first VMGM of the disk
- There are a number of other useful targets for menus (use dvdauthor --help for a list).
The basic process of creating a menu is described in the documentmenu.txt in the current version of dvdauthor, however there are a few extras to bear in mind.
- The menu is actually implemented as an mpeg movie with subtitles.
- It appears to be necessary to add a (possibly silent) sound file into the mpeg for it to work.
- Button coordinates are measured from top-left (which is conveniently the same as the gimp's coordinate system), however if you use the recipe here, you do not need to give explicit button coordinates.
Examples of authoring a DVD
This example creates a DVD with a main menu, 4 titlesets each containing a menu and a single title. The titles are all made from multiple input files and each input file is one chapter. Of course there are many other permutations possible, it's just that this format is convenient for the kind of material I normally work with; the documentation that comes with dvdauthor should be sufficient to allow you to go from this example to the format you want.
I shall assume that the individual chapters of the DVD have been saved as mpeg-2 files from kino as described above.
Making the menu
Menus are just an mpeg file with subtitles. The basic mpeg is the background and the subtitles produce the menu buttons. The background can either be a short movie or a still image converted to an mpeg, in the example here we use the latter.
This example assumes reasonable familiarity with the gimp.
There are probably many other ways to do this, but this is a route with which I am comfortable.
The background.
This is just a short (even single-framed) mpeg-2 file. It appears to need a sound track even if it is just silence. If you are working from a scanned image or an image from a still camera, you need to be aware that DVDs have non-square pixels, this can be handled either with the DPI in gimp or the aspect settings in the mpec encoding process (generally I use the latter for no better reason than I figured the correct settings there first).
Create your background image this should also contain any text that is part of the buttons (in this case it's just a title on the gimp's waves pattern. For PAL this image should be 720x576 pixels, for NTSC it should be 720x480 (SECAM I don't know). It is recommended to save this image in JPEG format.
The sound track can be made by recording a short (couple of seconds) sample from a sound card with nothing connected, and then converting it to an mp2 format with mp2enc. This shold be done at 48kHz sampling rather than the more common (for CDs) 44.1kHz.
If you are going to use a short movie clip, the you don't have to make a background image, just use the clip as the argument of spumux after following the procedure described here to make the subtitle images.
The subtitles.
Create your subtitle images. There are in fact 3 of them: the basic subtitles image which is used to show buttons in their "quiet" state, the highlight image which shows when a button is under the cursor, and the selected image which shows after the button has been clicked until its action has begun. If you are going to use automatic button identification (and why not it's a lot easier) you need to have transparent space between the locations in all the images. It will also make life easier if you put your buttons in nice rows and columns (the menu generator can handle either row-major or column-major layouts). I suggest using the guide bars in gimp to make a nice grid. It is recommended to save these images in PNG format. I shall not attempt to give a gimp tutorial here, there are many on the web, most of them far better than I could manage.
There are a number of important points to note:
- There may be no more than 4 colours in any image.
- Therefore you should disable all antialiasing (text tool and selections).
- Saving in indexed mode with a colour table of size 3 helps to force this (transparent is a colour in subtitle menus but not in gimp colour tables). RGB mode images are accepted but they won't check that you haven't got too many colours.
In the example here, the basic image (main6.png)is just the button texts in black, the selected image (main6s.png) is the same thing but with red text, while the highlight image (main6h.png) adds a background to the buttons (and will thus be the one that defines the sizes). If you make use of the gimp's save as option and do the images in that order, you won't need to retype the text with the consequent worries about alignment. I like to have a systematic naming convention for the images as that allows a simple shell script to make the menu mpeg files.
The control file
spumux, the subtitler in current versions of dvdauthor uses an XML control file to define how the subtitles are created. The example here is just about as basic as it can be:
force="yes"
This tells spumux that the subtitles are to be displayed irrespective of the player options. This is required for menus.
start="00:00:00.00"
Start the display of the subtitles at the start of the movie. There is also an end= attribute but this is not needed for menus.
image="main6.png" (etc.)
These 3 lines specify the files for the three states of the buttons.
autooutline="infer"
Tells spumux to work out where the buttons should be. The alternative is to have tags after the tag to specify where the buttons are.
outlinewidth="6"
Tells spumux that there must be 6 pixels of space between features in the images for them to be treated as different buttons (N.B. space means that all three images are transparent).
autoorder="rows"
Tells spumux that the buttons are numbered across the screen first and then downwards.
Putting it together
You have now reached the stage where you have all the pieces needed to build the menu mpeg.
#!/bin/sh
rm -f ${1}.mpg
jpegtopnm Background.jpg | ppmtoy4m -n 1 -F25:1 -I t -A 59:54 -L | mpeg2enc -f 8 -n p -o ${1}.m2v mplex -f 8 -o /dev/stdout 1.m2vsilent.mp2∣spumux−v2{1}.m2v silent.mp2 | spumux -v 2 1.m2vsilent.mp2∣spumux−v2{1}.xml > ${1}.mpg
With the examples above, if the xml files was saved as main6.xml, then calling this script with the argument main6 will convert the images to an mpeg file that can be included in a DVD as a menu. Notes:
- -F25:1 this is the frame rate, this is appropriate for PAL, for NTSC it should be30000:1001
- -A 59:54 Sets the aspect ratio, again this is the PAL value, for NTSC it should be10:11
- -f 8 is DVD format (suitable for dvdauthor) in both mpeg2enc and mplex.
- -n p specifies PAL output, for NTSC the code is n.
- If you wanted to, you could of course generate the XML in the script as well.
Authoring the DVD
This is the job of dvdauthor. This description refers to the alpha version of dvdauthor-0.6.8. The interface of 0.6.x versions is totally different from 0.5.x and earlier, so this won't work for old versions.
Example 1: Several titlesets, 1 menu & title per set.
Like spumux, dvdautor now uses an XML control file that specifies the structure of the DVD being authored. The contruction of a suitable XML file is the greatest challenge for the newcomer to dvdauthor. In the example here I shall deconstruct a particular XML file and comment on its important features.
This is the overall top-level tag. The attibute tells dvdauthor the directory in which to put the VIDEO_TS (and AUDIO_TS) directories.
jump titleset 1 menu; jump titleset 2 menu; jump titleset 3 menu; jump titleset 4 menu; exit;- The vmgm tag describes the title sequence. In this case just a single menu.
- The menus tag defines a menu. In a vmgm, tag there may only be one menus tag, however it can contain several pgc elements. To make an introductory sequence that plays before the main menu, you can add a pgc element that doesn't have any buttons.
- The video tag is probably not needed as dvdauthour should be able to infer this from the streams.
- The pgc tag defines a menu or title. Here the entry="title" attribute tells dvdauthor that this is a top-level menu.
- The vob tag specifies the source file for the menu. (This is the one we created earlier).
- The button tag specify what to do when each button is selected. A top-level menu can only jump to the menu or beginning of a title. Titlesets are numbered from 1. All these entries jump to the menu of the appropriate titleset. To access a particular title of a titleset use title <_n_>instead of menu (title number also count from 1).
- The exit command returns you to the xine logo or the default page of your player.
- If you have amoving background to your menu and want it to loop, then add a post tag at the end of the pgc with the action jump menu 1;, see below for a bit more about post tags.
- This block defines the first titleset of the disc.
- Like the vmgm, the titleset contains menus and titles, however unlike a vmgm it can contain several of each, although on this disc it does not do so.
- Here the button targets are given by title number and chapter number (it is not necessary to have a button pointing to every chapter if this is not appropriate).
- The titles tag defines the contents of a title.
- In the titles tag, if there are multiple files and none of the vob tags have a chapters attribute, then each input file is a single chapter.
- The post tag specifies what is to happen at the end of the title. In this case, return to the main disc menu. Note that here we must use call rather than jump(I'm not fully sure about when jump must be used and when call must be used).
The remaining three titlesets are very similar to the first, each has one menu and one title, but with differing numbers of chapters.
If this file is saved as dvd.xml in the same directory as all the mpeg files, then the command:
dvdauthor -x dvd.xml
should produce a dvd image in the directory /data6/video/Sheffield6.
Example 2: Several menus and titles per set
This is a slightly more complex example which shows how to have several menus in one titleset and also several titles in the titleset. Repetitive passages have been compressed to save space.
jump titleset 1 menu; jump titleset 2 menu; exit;The top-level or title menu here is very similar to the previous example.
jump menu 2; jump menu 3; jump menu 4; jump menu 5; jump menu 6; jump vmgm menu; jump title 1 chapter 1; jump title 1 chapter 2; jump title 1 chapter 4; jump title 1 chapter 6; jump title 1 chapter 8; jump menu 1; . . . jump title 5 chapter 1; jump title 5 chapter 2; jump title 5 chapter 3; jump title 5 chapter 5; jump title 5 chapter 6; jump menu 1;- The first menu just jumps to the others.
- Note that each menu is defined by a pgc tag, but all the menus are contained within a single menus tag.
- Only one menu has the entry="root" attribute. This is the one that will be displayed if you press the "Menu" button on your remote or hit Escape in xine.
- In this example we have jumps to titles other than number 1.
- As with the menus, all the titles are bracketed by the titles tag, and each title is defined by a pgc tag.
- The call menu; command in the post tag returns to the root menu of the titleset. (Rather than the title menu as in the first example).
- If you want to continue from one title straight into the next, then the post command should be jump title2 chapter 1 etc. instead of call menu
Obviously your needs will differ from mine, however I hope that these examples will help clarify the basics so that you will be able to adapt it to your needs with the aid of the dvdauthor and spumux manuals.
Writing it
Before you commit your DVD to disc, it's probaly worth testing it from the hard drive. This can be done with xine by using the command:
xine dvd:/data6/video/Sheffield6/VIDEO_TS/
N.B. the final / is required. This will allow you to check that your menus look reasonable and that they send you where you expect. It is very easy to miss out a file or to include a junk file that should have been omitted, and that will throw out all the rest of the titleset targets.
This section has been tried by me with DVD+R(W) media. It should work with DVD-R(W), but I don't have one to try. There are some notes onusing dvd+rw-tools for dvd-r(w) media.
The tools used here are part of the dvd+rw-tools package.
I shall assume thoughout that you have your drive set up to use ide-scsi emulation, as that is needed to write CD media on it (DVD writing does not need this, but since every DVD writer I've ever seen also writes CDs you will probably have it set that way unless you are using the 2.6 kernel). Furthermore I'll assume that it's the only SCSI cd drive on the system, so the device will be /dev/scd0 (if it is somewhere else, just change the device name thoughout).
If you are using ±RW media then format the blank disk (unlike CD's DVD+RW media need to be formatted, for -RW media this is only needed if you wish to change recording mode):
dvd+rw-format /dev/scd0
This is not needed for ±R media.
Now use growisofs to create the DVD (so with the directory used above), we have:
cd /data6/video growisofs -Z /dev/scd0 -V SHEFF03 -dvd-video Sheffield6
For more general information on writing data to DVD+RW, refer to thedvd+rw-tools web page.
For those using cdrecord.prodvd on DVD-R(W) media, the following is reported to be the appropriate command lines:
mkisofs -o /tmp/image.raw -dvd-video /data6/video/Sheffield6 cdrecord.prodvd -v dev=0,1,0 -useinfo driveropts=burnfree -pad -dao /tmp/image.raw
Playing
DVDs thus generated should play on any device that can handle the media. I've had success with xine on my Linux box (if xine exits with messages about encrypted streams, these are bogus and the problem is fixed in xine-lib beta-12 and later) and with Apple's DVD player on my iBook and on a hardware DVD player.
With my dvd writer I have had problems with cheap (store's own-brand) DVD+R media, tyically this shows up a very slow response times to the menus and pauses in playback in the later part of the disk (these problems manifest on both the PC and the Mac, but not on the hardware player); name-brand blanks on the other hand have never shown these problems. Possibly the el-cheapo disks stretch too much when spun up (the later chapters and the top-level menus are at the outside of the disc)?
Acknowledgements
Without the work of all those developers who have contributed to the tools described here Linux users would still not be able to write their own DVDs.
Mail comments
James Tappin, 24 Apr 2003.

