View Single Post

   
  #8 (permalink)  
Old 01-18-2008, 07:17 AM
decourl@cs.sunyit.edu
 
Posts: n/a
Default Re: Problems with dvdauthor - please help.

George (and others),

About a week ago I started to look into mastering video
DVDs using Linux. I have some thoughts to contribute which
are different than those which are already widely disseminated.
Also, I will repeat some well-understood and widely-made
statements which are (IMHO) worth repeating. This article is
somewhat verbose - I hope you will find my observations
useful and (to some extent) original.

Much of the audio-visual stuff floating around the net
is encoded and encapsulated in modern space-efficient formats
which are a little more attractive (for that purpose) than the
slightly dated MPEG2 format which is used in DVDs.

The basic steps required are as follows:

1) demultiplex the source into audio and video streams

2) decode those source streams into raw formats

3) encode those raw data using DVD-supported mechanisms

4) remultiplex

5) master the DVD filesystem

6) burn to DVD

As for demultiplexing and decoding the source, these steps can
be tricky as they require knowledge and tools specific to the
source format.

We follow the basic UNIX idiom of generating a "filter chain"
from one format to another. One suprisingly simple way to accomplish
these tasks is to simply use mplayer!

mplayer -ao pcm -noframedrop -vo yuv4mpeg [source_file]

mplayer can handle virtually any audio or video format that
you can throw at it. Note that all we are asking mplayer to
do is decode the source. It will give us a WAV file for the audio
and a YUV file for the video. This is great because unlike some tools,
mplayer is always able to infer necessary information w.r.t. the
source.

As for step three, encoding into supported formats, this is also
easy.
First, let's look at the video. Here is a command line that I am using
currently (for my specific situation):

cat stream.yuv | yuvfps -r 30000:1001 | yuvscaler -M WIDE2STD -O DVD \
| mpeg2enc -n n -f 8 -F 4 -o video_out.m2v
# all are
mjpegtools

In this pipeline, we alter the stream's frame rate and resolution.
Then, we use mpeg2enc to encode our video using MPEG2.

I strongly recommend these mjpegtools. They simply work better
than
the other tools.

Next the audio. I recommend using AC3 (aka Dolby Digital) encoding
for DVDs. The tool to get is ffmpeg.

ffmpeg -ab 224 -ac 2 -ar 48000 -i audiodump.wav audio_out.ac3

Another option is MP2 audio. Use a tool called toolame to
encode it.

Remultiplexing the video is simple.

mplex -f 8 -o output.mpg input.m2v input.ac3

Mastering the DVD filesystem is easy - just use dvdauthor.
I will not discuss dvdauthor since it is the single ubiquitous
tool for the job and is well-described elsewhere.

Should you desire a dvdauthor GUI, I strongly recommend qdvdauthor.
It only supports the automatic generation of simple menus, and it may
fail by attempting to call underlying tools with incorrect syntax or
without regard to shell pre-processing of the command line.

The qdvdauthor GUI is excellent because (like all good GUIs) it
shows you exactly what commands it intends to execute, the order it
intends to execute them, and what purpose they have. You can even
modify those calls prior to their invocation and choose which to
actually
execute.

It can take some time to get DVD menuing correct. The tool to
use is spumux. Let's say you want a moving video main menu which
allows
for the selection of one of two main feature films on a DVD.

Here is some spumux XML that I am using for a particular
application.

<subpictures>
<stream>
<spu start="00:00:36.0" end="00:00:00.0"
highlight="highlight.png"
select="highlight.png"
force="yes">
<button y0="90" y1="230" x0="110" name="1" x1="460" />
<button y0="250" y1="390" x0="110" name="2" x1="460" />
</spu>
</stream>
</subpictures>

Although I don't intend to treat dvdauthor usage, it is appropriate
for me to include an example XML file as there are some elements
related to menuing:

<dvdauthor dest="/opt/generic_tv_show/first_two_episodes" jumppad="yes"
>

<vmgm>
<menus>
<video format="ntsc" resolution="720x480" />
<pgc entry="title" >
<vob file="/home/decourl/menu-muxed.mpg" pause="inf" />
<button name="1" >jump title 1 chapter 1; </button>
<button name="2" >jump title 2 chapter 1; </button>
</pgc>
</menus>
</vmgm>
<titleset>
<menus/>
<titles>
<pgc>
<vob file="/home/decourl/title1.mpg" />
<post> call vmgm menu 1; </post>
</pgc>
<pgc>
<vob file="/home/decourl/title2.mpg" />
<post> call vmgm menu 1; </post>
</pgc>
</titles>
</titleset>
</dvdauthor>

So, this is the anatomy of our menu. The actual image of
the buttons is in the background video! Do not be fooled by
the "image", "highlight", or "select" images discussed by spumux
as these are simply mask images.

So, in generating the menu.mpg discussed above - put
pictures of buttons - ie: "Episode 1" and "Episode 2" - in
the movie. Cause the locations of these buttons to correspond
the the coordinates (top-left and bottom-right) described in the
spumux XML.

Okay, so about the mask images. These are slightly tricky
so here is a simple example. You really only need one image -
the "highlight" image.

Open gimp. File -> New. Enter same dimensions for "Image Size"
as the target DVD resolution (in my case 720x480 however YMMV).
Leave "Image Type" as "RGB" and set "Fill Type" to "Transparent".

Now, choose a color and flood fill the entire canvas. Then, use the
rectangle select tool to select the region that corresponds to the
location of (the pictures of) your buttons in the background video.

Then go to Select->Border, choose say 5 pixels, and Edit->Cut that
selection. Repeat for the other button location. The bit about
Select->Border causes you to select only the edges of the rectangle
and not its interior. Cutting that selection removes the color from
that region and thus that portion of the image is returned to
transparency.

Hence the entire image is filled in except for a "frame". Now, go to
Image->Mode->Indexed->Generate Optimum Palette->OK and finally
File->Save highlight.png.

The tricky thing conceptually is this: where the mask image is
transparent, the resulting DVD menu display will not be allowed
through the mask. You will instead see a "(likely) black box".
Where the mask image is filled in, the resulting DVD menu display
will shine through unadultered. Of course, this may seem counter-
intuitive but it is in fact how masks generally work.

Okay, a few ideas about how to generate a menu background video.

What we need is a single jpeg image for each frame of the moving video.

jpeg2yuv -I p -f 29.97 -j /home/decourl/menu_images/frame%0004d \
| mpeg2enc -n n -f 8 -o menu.m2v

The trick is setting up all the different jpegs. Let's say that you
have ten pictures that you want to display in the movie menu for
varying amounts of time (ie: a picture of co-star A, a picture of
co-star B, and then a picture of co-stars A and B together, etc.).

I would simply put these jpegs in /home/decourl/menu_images/01.jpeg,
02.jpeg, ..., 10.jpeg. Then create a file called flist (for frame
list) that describes the order and duration of the frames which is
intended.

Ie:
01.jpeg
01.jpeg
01.jpeg (n times)
..
..
..
02.jpeg
02.jpeg (m times)
..
..
..
etc.

Then use a (Bourne-family) script like this:

export CURR=0000
cat flist | while read file
do
ln -s $file frame$CURR
export CURR=`echo $CURR + 1 | bc | sed 's/^\(.\)$/0\1/' \
| sed 's/^\(..\)$/0\1/' \
| sed 's/^\(...\)$/0\1/'`
done

This way you only need a single (actual) copy of each image -
but the links exist so that jpeg2yuv will treat each image as
some number (ie: n or m) different consecutive frames.

Also, you will want an easy way to put the images of the buttons
in the menu video. I will use snapshots from the episode as well
as text for my example.

cat menulist | while read file
do
composite -geometry +120+113 episode_1snap.jpeg ${file}.orig
temp1.jpg
composite -geometry +120+273 episode_2snap.jpeg temp1.jpg temp2.jpg

convert -font helvetica -fill white -pointsize 32 \
-draw 'text 320,140 "Episode 1"' temp2.jpg temp1.jpg
convert -font helvetica -fill white -pointsize 30 \
-draw 'text 320,210 "In-laws visit unexpectedly"' temp1.jpg
temp2.jpg

convert -font helvetica -fill white -pointsize 32 \
-draw 'text 320,300 "Episode Two"' temp2.jpg temp1.jpg
convert -font helvetica -fill white -pointsize 30 \
-draw 'text 320,370 "Heavy boozing at office party"'
temp1.jpg $file
done

Note that for this to work you will create ??.jpeg.orig files so that
the
original images are unmodified and can be reused for other episodes.

Don't forget to execute spumux (see example XML above):

spumux menu.xml < menu.mpg > menu-muxed.mpg # (do this after
mplex but before dvdauthor).

Finally, after dvdauthor, preview your work:
xine dvd:/opt/generic_tv_show/first_two_episodes/

To burn the dvd, I personally recommend (as opposed to
mkisofs and cdrecord):
growisofs -Z /dev/dvd -dvd-video
/opt/generic_tv_show/first_two_episodes/

Anyhow, in recap, my main points are this:

1) it is best to fully decode A/V streams before making
the resolution and frame-rate modifications. Some information
is already lost because your source is encoded and some more
must be lost because you need to recode in a different format.

2) mjpegtools are the best tools for performing the adjustments.
In the case of video they are also the best tools for recoding the
stream. The proper "raw" video format (even for NTSC) is the YUV
format because it is treated natively by mjpegtools.

3) Since mplayer can infer everything necessary to play almost any
A/V input, and since it can be caused to dump decoded output, it is
a simple task to burn any format to DVD that mplayer can handle.
Using named pipes, it can be this simple:


infile
|
|
\ /
mplayer ---> video (YUV) -> yuvfps -> yuvscaler -> mpeg2enc -> (m2v)
| |
|-> audio (WAV) -> ffmpeg -> (ac3) -----------> mplex <-------|
|
|-> mpg


That resulting mpg is ready to be used as a title by dvdauthor!
This can be simply scripted and will definitely work no matter what
input you have. And, it is a high-quality solution.

Hope this helps!

Lincoln


George wrote:
> Hi,
>
> Has anyone been able to author DVD's in Linux? I've been trying

to
> do it for quite some time and am on the verge of giving up!
>

[...]
> Any help would be greatly appreciated!
>
> Thanks!
> George


Reply With Quote