Howto:ivtv for dvdauthor
From IVTV
Contents |
Introduction
This is a page about how to generate MPEG material from IVTV in such a way that it can be fed directly into dvdauthor (the most widely used free tool for producing DVDs under Linux and other *NIX operating systems).
Our goal is to avoid the need to re-multiplex the audio and video. This is widely believed to be necessary but can in fact be avoided - saving a lot of time, hassle and subsequent problems with A/V sync.
I am using a CX23416 based video capture and encoding card (Adaptec VideOh! AVC-2010), version 1.1.0 of the ivtv driver and Linux 2.6.24.7-92.fc8. I believe the method described should however work with other CX2341x based cards.
I live in the UK so my TV standard is PAL-I (720x576, 25fps) and I'm capturing in widescreen (16:9) via the Composite-1 input for video and the line-in input for audio. Make the necessary changes relevant to your locale and setup.
There are two things you need to do in order to feed IVTV streams successfully direct into dvdauthor:
(1) set IVTV to produce the correct format; and
(2) apply some patches to dvdauthor.
History
In 2005 I developed an 'ivtv' patch against version 0.6.11 of dvdauthor. This subsequently worked well for me for a number of years. In May '08 I updated the patch to work with the current version of dvdauthor (0.6.14) and posted it to this site. As of June '08 I posted an updated version of my patch for 0.6.14 that fixes a few shortcomings in the original. All three patches are available from the links below.
Part 1: IVTV Settings
We need to set the driver to produce something similar to the following format:
ivtv0: Stream: MPEG-2 DVD-compatible Stream ivtv0: VBI Format: No VBI ivtv0: Video: 720x576, 25 fps ivtv0: Video: MPEG-2, 16x9, Variable Bitrate, 2750000, Peak 5000000 ivtv0: Video: GOP Size 15, 2 B-Frames, GOP Closure ivtv0: Audio: 48 kHz, Layer II, 256 kbps, Stereo, No Emphasis, No CRC
Note: do NOT insert additional navigation packets using v4l2-ctl -c insert_navigation_packets=1 as the resulting stream will crash dvdauthor. For info on mpeg streams, B-frames etc, see [1] .
So from a clean restart do something like this:
v4l2-ctl -i 1
v4l2-ctl -s pal-I
v4l2-ctl -c stream_type=3
v4l2-ctl -c insert_navigation_packets=0
v4l2-ctl -c stream_vbi_format=0
v4l2-ctl -c video_aspect=2
v4l2-ctl -c video_bitrate=2750000
v4l2-ctl -c video_peak_bitrate=5000000
v4l2-ctl -c video_gop_size=15
v4l2-ctl -c video_b_frames=2
v4l2-ctl -c video_gop_closure=1
v4l2-ctl -c audio_sampling_frequency=1
v4l2-ctl -c audio_encoding_layer=1
v4l2-ctl -c audio_layer_ii_bitrate=11
v4l2-ctl -c audio_stereo_mode=0
v4l2-ctl -c audio_emphasis=0
v4l2-ctl -c audio_crc=0
For explanation of these options use "v4l2-ctl --list-ctrls-menus" and "v4l2-ctl --help". Many settings such as the aspect ratio and the bitrates are non critical and can be tuned to our requirements, within the constraints of the DVD standard (e.g. see [2] ).
Now review your configuration using "v4l2-ctl --log-status". Carefully compare the output to the one at the top of this section.
Now capture some video:
cd ~
mkdir test
cd test
cp /dev/video0 ivtv.mpg
[ after 30secs or so, hit 'ctrl-c' ]
Test the file with a reliable application (personally I use xine or mplayer) to make sure the capture was successful.
Part 2 : Patching dvdauthor
As I mentioned above, the latest release of the ivtv patch is against version 0.6.14 of dvdauthor. The patch has been submitted to the dvdauthor developers and requested for inclusion in the next release.
Start by downloading a clean copy of the 0.6.14 source tarball. You can get this from sourceforge: the link is currently [3] .
Unpack the source tarball somewhere convenient:
tar -xzf dvdauthor-0.6.14.tar.gz
Note that you may need to install a couple of dependencies to get a successful configure (e.g. libdvdread). I assume you can work that one out for yourself.
Now apply my patch named "dvdauthor-0.6.14-ivtv-patch-0.2.txt". You can get a copy of this and previous versions from here. The older patch against version 0.6.11 of dvdauthor is available here.
cd dvdauthor-0.6.14
patch -p0 < dvdauthor-0.6.14-ivtv-patch-0.2.txt
You should see:
patching file src/dvdvob.c
Now configure and build the package
cd dvdauthor-0.6.14
./configure
make
sudo make install
It is normal to get a few compiler warnings during the make but nothing fatal. If you get problems check that you did the ./configure correctly and also that you fixed any missing dependencies (libdvdread etc) before attempting to call make.
Part 3: Trying it out
We should now be able to use the patched version of dvdauthor to encode the sample video that we captured in part 1.
First we need to create a minimal XML configuration file. Using your favorite editor (allegedly some people can't handle the raw power of 'vi') create a new file as ~/test/config.xml and paste in the following lines:
<dvdauthor dest="DVD">
<vmgm />
<titleset>
<titles>
<pgc>
<vob file="ivtv.mpg" />
</pgc>
</titles>
</titleset>
</dvdauthor>
Note that the patch has now been updated to allow dvdauthor to auto-detect the video and audio standards and formats correctly from the MPEG-2 stream.
Now it is time for the moment of truth:
cd ~/test
rm -rf ./DVD
dvdauthor -x config.xml
Dvdauthor may spit out a warning about an unclosed gop, nonetheless if all went well you should now have a DVD file structure in ~/test/DVD.
You can test the DVD with xine:
cd ~/test
xine dvd:`pwd`/DVD/VIDEO_TS/
Convert the files in the DVD directory into an ISO9660 image suitable for commercial dvd players:
mkisofs -dvd-video -o dvdimage.iso DVD
Use your favorite tool to burn the .iso image onto a blank DVD
Note: it is often convenient to skip the step of creating an intermediate ISO image and just burn straight to disk. You may be able to do this by specifying '-o /dev/dvd' to mkisofs, or you can do it using growisofs (see http://freshmeat.net/projects/dvdrw-tools/ ):
sudo pkill hald # if your system runs hald then complete this step BEFORE inserting the blank DVD
cd ~/test
growisofs -Z /dev/dvd -dvd-video DVD
Et voila! I hope it worked for you, and that this helps a few people out. For the sake of completeness I also attach here a record of some pertinent details about my system configuration (kernel version etc), and here a personal aide memoir that I use to remind myself how to do nice anti-aliased menus and buttons with spumux/dvdauthor using gimp.
