[Gllug] DVD audio

damion.yates at gmail.com damion.yates at gmail.com
Sun Oct 22 00:53:32 UTC 2006


On Sat, 14 Oct 2006, Adrian McMenamin wrote:

> I am trying to burn a DVD - essentially using the mechanisms
> descibed here:  http://www.linux.com/article.pl?sid=06/04/17/2058219
> 
> But I am having trouble as the audio seems to lag the video by about
> a second (it doesn't on the original file, this is some artifact of
> transcoding). Now, I can play back on the PC just using the -delay
> option on mplayer, but cannot seem to get that into the DVD.
> 
> Presumably I have to take separate audio and video tracks and fuse
> them together to get that to happen, or is there an easier way?

As John Winters suggests you can sort this by re multiplexing the
audio and video with an audio offset.

You should install the transcode package tools which comes with
tcextract, you run this against the mpeg you've created to extract the
audio and video separately (actually you can faff around with named
pipes and do it all in one go if you want to play like that).  You may
have ac3 (common with PAL) or mp2 audio, so use something like this:

tcextract -i video.avi -x ac3 >audio.ac3
tcextract -i video.avi -x mpeg2 >video.mpv
tcextract -i video.avi -x mp2 >audio.mp2

A simple ls -l aud* vid*
should show reasonable results, video without any audio should be
slightly smaller than the src, the audio file will be about 10% the
size.  If you get 0 length or full filesize in the output it's failed.

You can then either multiplex back together with mjpegtool's (old and
stable known good mpeg2 encoding tool) mplex:
mplex -f 8 -O 900 -o output.mpg audio.mp2 video.mpv
(I've assumed 900ms audio sync offset)

Or transcode's tcmplex:
tcmplex -m d -i video.mpv -p audio.mp2 -D 0,900 -o output.mpg

This has worked for me in the past, especially for cleaning mpeg input
that was not in DVD format (PS vs TS for example (Programme Stream vs
Transport Stream)).  Once remuxed dvdauthor was MUCH happier, or in
fact worked at all, rather than just complained for hours and ended
with 0 sized dvd output.

For audio sync problems though it's not ideal, it's slow and you have
to judge it yourself by ear while watching via xine or something on
the dvd output.  I've had better success transcoding via other methods
to remove the loss of sync, typically if something has gone wrong in
transcoding to lose sync, it may have slipped further later in the
file so re-mplex on split a/v will not fix the whole movie.

If you don't have transcode there are other tools to do the the
audio/video splitting, mplayer(/mencoder)* and ffmpeg can both split
out the video only and audio only in copy modes.

However it would probably make sense if you're compiling ffmpeg and
sorting all the dependancies and theirs**, to just use ffmpeg to do
the transcoding to DVD, something like this:

ffmpeg -i video.avi -async 1 -target pal-dvd output.mpg

The mencoder line seems quite complex and I suspect is the cause of
the audio sync problem.  FFmpeg uses sensible defaults and if you use
multiple pass encoding (google for how) should be about as good as
you'll expect from any general downloaded movie***.

Once you've got a DVD ready mpeg2, I recommend getting hold of the
dvdwizard shellscripts.  You can point the main script at an mpeg2 and
after a few minutes you have a fully menu featured DVD structure to
write to DVD.  It's very clever, setting chapter points every 5mins
(unless you check first and specify sensible chapter marks yourself as
a comma separated list) then extracting single images out around those
places picking the largest (simple ls -S in the shell code :) ) which
typically contains the most interesting image (if you've selected your
own breaks and picked points with scene changes, there are typically
blank screens for a moment, this avoids picking them) for the
thumbnail in the chapter selection menu.  You can play with the shell
code as it's all very simple stuff.

Anyway, I hope this is of some use.

Damion

*Actually I believe it used to use different code, but now mplayer
uses a snapshot of ffmpeg as VLC has done for a while (VLC would be
just like using ffmpeg but with a pretty gui for helping you select
how to transcode).  I don't know if anyone uses anything other than
ffmpeg these days.

**I recommend not using binary packages for ffmpeg.  It changes and
improves frequently.  But I have also recently had poor experiences
with various peoples attempts at rpm and deb packages.  It's hard to
get a nice fully featured ffmpeg together with supporting
dependancies/libs which each have their own fully featured compile
options, but it's worth the effort to roll it by hand.  Especially
when you spot that although none of the configure outputs mention it,
simply having libid3 dev headers and libs adds proper multiformat file
tagging support.

Binary package maintainers could well have lacked compile time options
you may want, or added some that complicate encoding, like
--enable-amr_if2 which seems to break normal (mobile phone) amr
decoding, or using faad2 which breaks aac decoding.  Or they may have
omitted or added flags based on the licencing involved, possibly for
very noble reasons, but leads to a crap featureless binary.

***You didn't say where the src was from, but if it's your own DV
footage and you have the raw DV, then you'll want to use mjpegtools
and mplex with mode 8 (DVD) to create the cleanest best compressed
mpeg2 video for DVD playback.  You'll probably want to read about
yuvdescaler to sort interlacing issues and probably use Kino to do all
the editing and exporting via mjpegtools anyway as it's a nice tool.

If you're dealing with mobile phone (mp4 and 3gp) or downloads (divx
and random) then ffmpeg will be best.

-- 
Damion Yates - damion.yates at gmail.com
mobile: +44 (0) 7801 741582
-------------- next part --------------
-- 
Gllug mailing list  -  Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug


More information about the GLLUG mailing list