[MEncoder-users] Re: Encoding video for old DVD players
Trent Piepho
xyzzy at speakeasy.org
Fri Sep 1 15:40:06 CEST 2006
On Fri, 1 Sep 2006 Staffan Hamala <sh at ltu.se> wrote:
> Hi,
>
> I have a problem with encoding video so that older DVD players will play it
> correctly.
>
> I have used commands similar to these:
>
> mencoder -oac lavc -ovc lavc -of mpeg -mpegopts format=dvd -vf
> scale=720:576,harddup -srate 48000 -af lavcresample=48000 -lavcopts
> vcodec=mpeg2video:vrc_buf_size=1835:vrc_maxrate=8000:vbitrate=5000:keyint=15:acodec=ac3:abitrate=224:aspect=4/3 -ofps
> 25 -o out.mpeg2 in.avi
I've found that mencoder seems produce better AV sync if I use -mc 0.
There are two problems with lavc I've had when making DVDs or SVCDs for
hardware players.
One problem is the scene detection code. It creates an "I" frame when it
detect a scene change. If there is lots of motion, it will detect and
scene change on every frame, causing multiple I frames in a row. This is
not allowed on DVDs, there is a minimum spacing between I frames. My DVD
player will have problems when the I frames get too close together.
mpeg2enc from mjpegtools has options for minimum and maximum gop length,
but lavc has only maximum gop length (the keyint parameter).
You can fix this by turning off scene detection. I fixed it in a better
way by adding a keyint_min parameter to mencoder and lavc's mpeg-1/2
encoder.
The other problem I have not found a fix for is lavc's rate control. You
specify a maximum bitrate with vrc_maxrate, but lavc *does not honor it*!
My DVD player has a option to put up an onscreen display with bitrate. I
can encode a DVD with the vrc_maxrate limited to 9.6 mbits, but when I play
it back I see that the bitrate goes up to over 20 mbits. My player is ok
up to about 18 mbits, but above that it starts to skip.
It's not just my player that says the bitrate is too high. mencoder's mpeg
muxer will produce errors like:
BUFFER UNDEFLOW at stream 0, raising muxrate to 17088 kb/s, delta_scr: 39896
The muxer is rasing the bitrate well above DVD spec because lavc isn't
staying within vrc_maxrate.
If I produce a mpeg2 ES with mencoder and try to mux it with mjpegtool's
mplex problem, there is the same problem: mplex complains that the bitrate
is too high.
I have found something that helps with this problem is to _not_ use 2-pass
encoding. It seems when you use 2-pass lavc will spike the bitrate way up
on the hard parts of the encode because it knows it can make it up later on
the easy parts and still meet the overall bitrate for the whole encode. In
1-pass mode it won't spike the bitrate as much on the hard parts.
mpeg2enc has an option to disable dual-prime motion estimation because some
hardware players have a problem with it. I don't know if lavc supports
dual-prime or not.
I've heard that some hardware players a problem if there are not 2 "B"
frames between each "P" frame. I think lavc has an option to enforce a
strict number of B frames.
If you can't get mencoder to work, you might try using mjpegtools.
mpeg2enc from that package has a better reputation for producing output
that works with hardware players. I can get working DVDs from mencoder
(usually), but for SVCDs which are limited to a much lower bitrate than
DVDs, only mpeg2enc will work for my hardware players.
More information about the MEncoder-users
mailing list