[Home]Outdated DV To DVD HOWTO

No diff available--this is the first major revision. (no other diffs)
Florin Andrei's (Somewhat Outdated) DV-to-DVD-HOWTO

    v1.0, 2004/01/05, Florin Andrei <florin@andrei.myip.org>

Here are some suggestions on how to convert Digital Video material (DV) to DVD. This document is focused on material that's shot with DV camcorders. See the end of the document for helper scripts.

1. About DV

Digital Video is a format used by most of the modern digital camcorders, both in the proffesional arena and in the amateur range. The compression used is kind of similar to MJPEG; each image is compressed independently of the others (unlike MPEG1/2/4) so DV is "editing-friendly".

Usually, NTSC DV has a resolution of 720x480 and the pixels are non-square; the aspect ratio is usually either 4:3 or 16:9; the framerate is 29.97 fps and the image is interlaced, with the bottom field first.

PAL is similar, but the resolution is 720x576 and the framerate is 25 fps.

Variations are possible on non-standard and/or expensive equipment (24 fps, progressive, etc.) but are rare.

Using the normal parameters above, 60 minutes of movie get compressed by normal DV gear into approximately 10GB to 15GB of video data files.

2. About DVD

Very popular digital media, it's using MPEG2 encoding for video and a variety of encodings for sound (MP2, AC3, DTS, PCM). There are several resolutions permitted by the standard, 720x480 (NTSC) and 720x576 (PAL) being the most popular.

The sum of the bitrates of the video track and of the current audio track must not be higher than 10.08 Mbit/s, not even for a fraction of a second; failure to comply generates DVDs that are unplayable on most standalone DVD players. Usually, professional DVDs have their video tracks encoded at a peak bitrate of 9800 kbps, hence leaving some room for an audio track. The average video bitrate varies greatly, but it's usually between 2000 kbps and 7000 kbps.

3. Capturing DV

You need a FireWire card and the Linux utility "dvgrab" version 1.4 or newer. SuSE 9.0 only has version 1.2 of dvgrab, dvgrab-1.2-162.i586.rpm. Download and build the latest sources from http://kino.schirmacher.de, 1.5 is now released:

Run the grab.sh script (see Appendix B below), then start the camcorder. The script grab.sh is designed so that it will create a new file for each new scene on the tape (a new scene begins whenever you paused or stopped the camcorder while shooting). If the entire tape was shot as one big scene, only one file will be created.

The utility dvgrab can create OpenDML AVI files, so don't worry about file size, OpenDML stuff can be as big as necessary. At the end, stop the camcorder if it doesn't stop by itself, then interrupt the script (using Ctrl-C).

The order of the operations is important.

4. Optional processing

You can preview the captured DV/AVI files using a media player. Currently, Xine seems to be the only one supporting OpenDML. If you don't want a scene, you can simply delete the corresponding file. If you want to make changes inside a scene, you must use a video editor that understands DV and OpenDML; Kino seems to work fine for this.

5. Transcoding to DVD

You need a recent transcode version, such as 0.6.11. You need a new mjpegtools version as well, at least (plain 1.6.1 won't work), or 1.6.2 when it will get released.

The homepage for mjpegtools is: http://mjpeg.sourceforge.net/

For an overview of mjpegtools, see: http://linuxmafia.com/faq/Apps/AV/mjpegtools_overview.html You also need a fairly recent dvdauthor version, such as 0.6.8. The script that does the job is conv-dvd.sh, (see Appendix A below). It is designed to work with a capture project directory created by the script grab.sh.

Let's discuss the conv-dvd.sh script:

The $flags variable contains the parameters passed to mpeg2enc. You have to choose one version and uncomment it; the first two are for high-quality encoding, the last two are intended to reduce output file size.

Explanation of the parameters:

 -c means "all GOPs are closed"; this generates an MPEG2 stream
    that is more compatible with various apps and players

 -q sets the quantization factor; 6 is a reasonable value for
    DV material converted to DVD; decrease it for higher quality,
    but be aware that you might create video tracks that are not
    accepted by the multiplexer; increase it for smaller file
    sizes at the expense of image quality

 -4 2 -2 1 controls the motion estimation; an even better
    (quality-wise) value would be "-4 1" but the quality
    increase is almost imperceptible while the encoding speed
    decreases a lot; just leave it like it is.

 -K defines the encoder matrix; this script uses a matrix
    devised by Steven Schultz to maximize the image quality,
    or the tmpgenc matrix for a more efficient compression
    (at the expense of image quality)

 -N is a very gentle low-pass filter that reduces the bitrate
    usage tremenduosly while not affecting the image too much

 -E tells the encoder to simply discard bits that are hard to
    encode yet do not contribute to the image too much

 -R controls the B frames; encoding with 0 B frames is unusual
    and some truly broken players may get upset, although it is
    perfectly legal from the DVD standard point of view; encoding
    with 2 B frames is normal for proffesional DVDs but it slows
    down encoding a lot (by 60%) and it makes the compression
    slightly less efficient for amateur DV stuff (material that's
    less than perfect_). If you're like me and don't care about
    encoding speed (I let the script run overnight), then encode
    with 2 B-frames; if you're in a rush or want to obtain better
    compression (your space on the DVD is limited) then encode
    with 0 B-frames, but be aware of the broken players.

The $asr variable controls the aspect ratio. Uncomment the appropriate value, depending on how your camcorder was configured. An aspect ration of 4:3 would be for a normal TV screen, 16:9 would be for HDTV. You cannot use one of them if your camcorder was configured with the other.

The $bitr variable controls the MPEG2 bitrate used for the DVD. WARNING: Do not increase it above 8500 regardless of what you've been told.

I know that proffesional DVDs are encoded at a peak value of 9800 kbps, I know that various pieces of documentation recommend 9800 as "One Value To Rule Them All". Just ignore them. Trust me. If you do otherwise, sooner or later you'll create a DVD that will not be playable on some standalone players. I learned that the hard way. You have been warned. Moreover, you don't truly need very high values. I did many evaluations, and the results are pretty surprising: many scenes that I shot do not take the peak bitrate above 7000 kbps, and the average is at 2000 or something! Only very rarely you'll need such high bitrates.

Down below in the script you'll find the transcode command. Let's discuss some command-line parameters:

 "-x ffmpeg" tells transcode to use ffmpeg as the DV decoder
             instead of the default Quasar codec.
             This way you'll obtain a compression which is
             10% better, or thereabouts.

 "--encode_fields b" tells transcode that the DV material is
                     "bottom field first". For some reason,
                     that's true for any DV camcorder in the

Commented out in the script, you'll find some parameters for generating AC3 sound for your DVD instead of MP2. While AC3 is more popular, for some reason there are audio/video sync issues if you use it. I'm still investigating the bug, meanwhile MP2 should be perfectly fine, you can use it with no problems.

After transcoding, the script will multiplex the audio and video files using mplex. The results are a bunch of VOB files. You can test each one of them individually with a media player, since they're essentially MPEG2 files on steroids.

After multiplexing everything, the VOBs are transformed into a DVD image on the hard-drive with the help of dvdauthor. The DVD is created so that each scene on the DV tape is translated into a chapter on the DVD. I believe this makes a lot of sense and allows for a simple way to jump to a specific scene while playing the DVD. This whole chapter affair is accomplished through the XML file that's built while transcoding, which instructs dvdauthor to set chapter marks at the beginning of each scene. Of course, you can change all that, see dvdauthor documentation.

At the end, there are a few chown/chmod commands, to normalize file ownership and permissions. I am not sure if this is really required, I just put them there just in case. Remove them if they annoy you.

6. Test the DVD image

You can test the newly created DVD image with xine like this:

    xine dvd:///full/path/to/the/dvd/image/

The trailing slash is important. xine will play the image just as though it were a true DVD, with chapters and all.

7. Burn the DVD

You need a fairly new version of dvd+rw-tools. SuSE 9.0 has dvd+rw-tools-, which seems to be recent enough. dvd+rw-tools contains the "growisofs" utility, which is a combined mkisofs frontend and DVD-recording program.

    growisofs -speed=4 -Z /dev/scd0 -V "$label" -dvd-video $dvd-image

$label is the ISO label you desire. Usually, labels are all caps and do not contain spaces. Example: MY_COOL_MOVIE

$dvd-image is the directory containing the DVD image.

Of course, you can change the speed and the DVD-Writer device to suit your existing hardware.

Appendix A - the script conv-dvd.sh


if [ $# -ne "1" ]; then
  echo "Usage: $0 dirname"

pushd $name

# high quality, 80 min / DVD
# fast encoding, slightly unusual MPEG2 (no B frames)
flags="-c -q 6 -4 2 -2 1 -K file=matrix.txt -R 0"
# slower encoding, classic MPEG2
#flags="-c -q 6 -4 2 -2 1 -K file=matrix.txt -R 2"

# ok quality, 120 min / DVD
# fast encoding, slightly unusual MPEG2 (no B frames)
#flags="-c -q 6 -4 2 -2 1 -N 0.5 -E -10 -K tmpgenc -R 0"
# slower encoding, classic MPEG2
#flags="-c -q 6 -4 2 -2 1 -N 0.5 -E -10 -K tmpgenc -R 2"

# Aspect ratio of the original DV tape
# 4:3
asr="--export_asr 2"
# 16:9
#asr="--export_asr 3"


# Steven Schultz's combined HQ matrix
cat - > matrix.txt << MATRIX
# High resolution INTRA table

rm -f $xmlf
# dvdauthor XML config head
cat - >> $xmlf << XMLHEAD
<vmgm />

for inp in `ls dv`; do
out=`basename $inp .avi`
transcode -i dv/$inp -x ffmpeg \
	-V -w $bitr \
	--encode_fields b \
	${asr} \
	-F 8,"${flags}" \
	-y mpeg2enc,mp2enc -b 224 -m $out \
	-o $out \
	--print_status 10
# stuff to copy/paste in the transcode parameters
# use this if DV sound is not sampled at 48kHz
# (it almost ALWAYS is 48kHz!)
#	-E 48000,16,2 -J resample \
# AC3 sound
# (has A/V sync bugs, don't use it yet, still investigating...)
#	-y mpeg2enc,raw -N 0x2000 -b 192 -m $out.ac3 \
# MP2 sound
#	-y mpeg2enc,mp2enc -b 224 -m $out \

# use this with MP2
mplex -r 10000 -f 8 -S 4400 $out.m2v $out.mpa -o $out.vob
# use this with AC3
#mplex -r 10000 -f 8 -S 4400 $out.m2v $out.ac3 -o $out.vob
echo "<vob file=\"$out.vob\" />" >> $xmlf

# dvdauthor XML config tail
cat - >> $xmlf << XMLTAIL

dvdauthor -o $name -x $xmlf

# the next commands require the following line in visudo:
# yourusername ALL = NOPASSWD: ALL
sudo chown -R root:root $name
sudo chmod -R 0755 $name
sudo chmod 0644 $name/*_TS/*

Appendix B - the script grab.sh


if [ ! $1 ]; then
  echo "Usage: $0 dirname"

mkdir -v ${name} || exit
pushd ${name}
mkdir -v dv || exit
pushd dv

dvgrab --autosplit --size 0 --format dv2 --opendml \
  --noavc --buffers 200 ${name}-

Transcode Wiki | Recent Changes | Preferences
Password required to edit | View other revisions
Last edited January 3, 2006 9:08 pm by Achurch (diff)