HDV to DVD in Linux
One way to create a standard definition DVD from an
HDV tape is to set the firewire output to DV on the camcorder.
This causes the camcorder to appear as a standard definition DV
camcorder to the computer and the resulting workflow becomes
the same as the
DV Video Workflow in Linux.
This obtains good results and allows you to keep the DV workflow
that you might be already have.
If you are interested in progressive frames, chroma keying or
slow motion better quality can be obtained.
The workflow described here
creates mjpeg Quicktime source files that use the 4:2:2 color space.
We obtain high resolution slow motion,
progressive and interlaced files simultaneously.
Moreover, the progressive and slow motion
video obtained is higher resolution than
could be obtained from a DV source.
Starting with HDV input we use frame-rate doubling
deinterlacing followed by rescaling to obtain 480p60 video.
From this we can obtain
- 480i,
- 480p30, and
- 480p30 slow motion.
We use jpeg Quicktime for our intermediate video format because
this is the most stable format to edit with Cinelerra.
Note that the developers of Cinelerra originally wrote the
Quicktime for Linux library.
Cinelerra will edit jpeg avi almost as well.
Needed Software
This method relies on the following open source software.
- mjpegtools
- mplayer
- sox
- ffmpeg
- dvgrab
- ProjectX
Capture
First, capture the HDV source.
Use the option -s512 to tell dvgrab to break the input into
files with a size of 512K.
This is important because when we double the frame rate to
obtain slow motion we want to keep the files less than 2GB.
$ mkdir capture
$ cd capture
$ dvgrab -fhdv -s512 -noavc src
Demultiplex each m2t file with ProjectX and then remultiplex with
$ mplex -f3 src001.m2v src001.mp2 -r 28000 -b 800 -o src001.mpg
to avoid audio video desynchronization.
Another way of capturing is to download the whole mpeg2
transport stream as one m2t file with the option -s0 and then cut
it into small enough pieces using ProjectX as part of the
demultiplexing step. This has the advantage that you can be
more selective in what scenes are contained in each file.
Creating the Quicktime Files
There is nothing to be gained in using a motion compensating
deinterlacer, because the 540 lines of resolution in a single field
of high-definition video is already more than the 480 lines in a
standard definition frame.
Therefore, we use the video filter -vf tfields=1:0,boxblur=1:1 in
mplayer and select -vo yuv4mpeg as the video output device.
The -nosound option avoids playing the sound track back
in real time and greatly speeds things up.
We split the yuv4mpeg stream after it is rescaled and
simultaneously encode interlaced, progressive and slow motion video.
This is done by the script
hdvto480.
Note three things about the script.
First, yuvfps tags the video stream at 29.97 fps
before yuvscaler so that yuvscaler doesn't try
to change the frame rate.
Second, the yuv2lav encoder is forced into
progressive mode with -I0 even for interlaced input
so that Cinelerra can read the files.
Third, if your version of mjpegtools doesn't have
Quicktime support, the script may be modified by replacing
.mov with .avi in the lines containing yuv2lav.
Now, create three Quicktime files
srcYYYi.mov, srcYYYp.mov and srcYYYs.mov for each srcYYY.mpg
file using the commands
$ ./hdvto480 src001.mpg
$ ./hdvto480 src002.mpg
...
The output files are
- srcYYYi.mov for top first interlaced 480i video,
- srcYYYp.mov for progressive 480p30 video, and
- srcYYYs.mov for slow motion 480p30 video.
For some reason vlc will not play the Quicktime files created above.
These files play fine in mplayer and also load into
Cinelerra without difficulties.
Editing In Cinelerra
You may now mix and match the .mov files on the Cinelerra
time line. Cinelerra is quite happy editing jpeg Quicktime
and will use smart copy for frames that are not changed when
rendering the project to jpeg Quicktime output.
Set the render options as
Smart copy also works when rendering your project
using jpeg avi files.
Suppose that the file rendered by Cinelerra is named fin2jpeg.mov.
Unfortunately, the frames encoded by Cinelerra use the 4:2:0 color
space whereas the frames that were smart copied use 4:2:2.
Therefore, fin2jpeg.mov contains a
mixture of frames encoded with different color spaces.
This file can be decoded by mplayer, mencoder, ffmpeg and lav2yuv;
however, Cinelerra can't load it back onto the timeline nor
can vlc play it.
Encoding to DVD
Convert the Quicktime or avi file to DVD
compliant video stream using mjpegtools as
described in DVD Compliant mpeg2
on Linux. Don't use ffmpeg or mencoder.
If the video is interlaced, the interlacing mode needs to
be explicitly specified with yuvcorrect when transcoding.
This is because the original source was encoded by
yuv2lav with the -I0 option.
Conclusions
If there is no need to produce a high-definition Blu-ray or
HD-DVD disk, then it is it is easier to convert HDV to standard
definition before editing.
As a more flexible alternative to importing the HDV tape
as DV footage from the camcorder, import the source as HDV
and convert it to standard definition 4:2:2 jpeg Quicktime
with yuv2lav.
Note that that this Quicktime format appears to have more
mosquito noise than DV.
An added benefit of this work flow is that you can go back and
create a high-definition version of the edited video with no
additional work.
Simply substitute the original high definition source files
into Cinelerra and rerender the project in high definition.
To do this
replace the srcYYYi.mov files with the srcYYY.mpg originals
and the words "Quicktime for Linux" with "MPEG"
in the xml Cinelerra project save file.
If you used slow motion, you will need to create high
definition slow motion files as described in Slow
Motion Video in Linux and insert them into the xml file as well.
Load the modified xml project file into Cinelerra, adjust the format
settings, resize the tracks and render a high definition version
of the project though a YUV4MPG Stream using one of the
scripts contained in HD Video Workflow in Linux
or H264 HD Video Workflow.
Evidence that mjpeg is not a good intermediate codec
is presented by Eugenia Loli-Queru in
Intermediate Codecs: the face-off where she states
We also see that MJPEG sucks as an intermediate format
(and I am writing this because many users under Linux use
that same MJPEG codec for intermediate needs).
Adam Wilt explains
in his page DV vs
MJPEG compression
that
The DV specification allows every macroblock to have its own quantization
value. This means that a DV frame has 1350 quantization values which
can be defined, vs. the 1 quantization value for an MJPEG frame. This
is why DV is a lot better than MJPEG for the same data rate; DV allows
fine tuning of individual parts of the frame.
Since we are editing on Linux, we follow the tradition of
using mjpeg as our intermediate codec.
Change the quality flag to -q95 or -q97 in the yuv2lav encoder to
reduce the mosquito noise.
It would be nice if Cinelerra could read and smart render lossless
huffyuv encoded intermediate files.
Last Updated: Sun Mar 27 22:14:27 PDT 2011