[MPlayer-dev-eng] mencoder problem

D Richard Felker III dalias at aerifal.cx
Fri May 17 16:47:36 CEST 2002


On Fri, May 17, 2002 at 01:48:22PM +0200, Michael Niedermayer wrote:
> > libavcodec is just too good ;)
> > so it simply cannot use all bits you give it as it don't need such many
> > bits to encode all that :)
> >
> > Michael: is it safe to set vqmin=1 by default?
> no :( and neither is vqmin=2 allways save :(((
> it depends on the used format though for mpeg4 vqmin=1 might be ok, but there 
> is little quality difference (no encoder uses qscale=1 afaik)
> 
> [...]
> > > -vpass 1 and -vpass 2  generate same files (diff show no differences)
> >
> > i doubt - unless all qscale is 3 or the stream is very linear, no low/high
> > motion scene changes, or it is too short to get advantage of long-term vbr
> i guess all frames are encoded with qscale=3

It seems there are several issues at hand. AFAIK, lavc always enforces
the qscale min/max unless the caller has specified fixed qscale, as
the second pass of mencoder's external 2pass (-pass 2) does. This
could be a good or a bad thing, but right now, lavc's handling of this
situation is broken.

For example, suppose I encode a file with lavc's internal 2pass and
request qmin=3, qmax=12, bitrate=1000. On the first pass, the file
comes out a lot smaller than it should, because lavc is "too good" and
doesn't need that many bits for qscale=3 in most frames. Then, when it
comes time for the second pass, lavc rescales the qscales to make more
efficient use of the available bits. BUT, when it scales down the
qscale for a frame below qmin, it seems to just truncate the scaledown
to qmin, rather than going lower, and it doesn't return the excess
bits gained by this truncation to be distributed over the more
complicated frames that could benefit from these extra bits!

At least in the meantime until lavc's 2pass code is improved to deal
with this situation, and perhaps in the longterm as well, it's
probably desirable NOT to use qmin/max in the second pass of encoding.
I propose the following possible solution, although I don't know if
it's the best or most intuitive:

In mencoder, have the default values for vqmin/vqmax be 0, which will
mean initialize defaults based on pass number. For vpass 1, it would
just initialize them with the old defaults that exist now. For vpass
2, it would initialize them to 1 and 31.

Would this be messy and confusing though? Perhaps the docs should just
tell users to set vqmin=1 and vqmax=31 on the second pass if they want
this behavior?

Rich





More information about the MPlayer-dev-eng mailing list