[MPlayer-users] [BUG] in mencoder handling of FFmpeg vbitrate flag

George Hawkins george_hawkins at yahoo.com
Tue Apr 16 18:21:01 CEST 2002


I'll start off with a (very) minor mencoder bug - there's actually a
more important (at least to me :-) question following on from this
further down.

[ Referenced code was checked out of CVS last Saturday. ]

According to cfg-mencoder.h bitrate for the Project Mayo encoder and
vbitrate for the FFmpeg encoders take the same range of values, i.e.
4 to 24000000.

cfg-mencoder.h:
>
> {"br", &divx4_param.bitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
>
> ...
>
> {"vbitrate", &lavc_param_vbitrate, CONF_TYPE_INT, CONF_RANGE, 4, 24000000, NULL},
>

And according to the mencoder man page (see quoted text below) values in
these ranges are interpreted in the same way, i.e. 4 to 16000 are
interpreted as kilobit rate values and 16001 to 24000000 are interpreted
as straight bit rate values.

As can be seen in mencoder.c this is true for the Project Mayo encoder
(well almost - it's actually values 1 to 16000 that are interpreted as
kilobit values).

But it's not true for the FFmpeg encoders - here if a value is supplied
it is always multiplied by 1000 (otherwise the bit rate defaults to
800000, as also happens with the Project Mayo bit rate).

mencoder.c:
>
> if(!divx4_param.bitrate) divx4_param.bitrate=800000;
> else if(divx4_param.bitrate<=16000) divx4_param.bitrate*=1000;
> 
> ...
>
> if (lavc_param_vbitrate >= 0) /* != -1 */
>     lavc_venc_context.bit_rate = lavc_param_vbitrate*1000;
> else
>     lavc_venc_context.bit_rate = 800000; /* default */
>

So this is a bug - if only a very minor one - an inconsistency between
documentation and implementation. I dislike the kilobit and non-kilobit
ranges idea anyway - if there's nothing to distinguish kilobit and
non-kilobit arguments (like say a 'k' after the number) its confusing.
If I'm encoding something at 16Mbit I use vbitrate=16000, if I then
decide to bump up the bit rate 1Mbit using vbitrate=17000 I will
actually cause the bit rate to plung to 17Kbit - slightly counter
intuitive I think. Forcing users to type the full bit rate (i.e.
appending an extra 3 zeroes some cases) is not too much of a hard ship.

Anyway that's all pretty minor - mplayer is a great product and I'm very
impressed by it. The reason I started looking closely at the vbitrate
option is as follows. I decided to look at what effect changing the
bit rate had on the size of the result of encoding a particular DVD.
Just to start off I encoded the first two minutes at various bit rates
for a quick start. I was rather surprised at the results. I used
mencoder as follows (replacing X with different bitrates).

$ ./mencoder -dvd 1 -dvd-device /dev/dvd -aid 128 \
	-endpos 120 \
	-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=X \
	-o movie-Y.avi

Y is the actuall bit rate (i.e. the value of X multiplied by 1000).

The results for various values of X were as follows (size in KB):

$ ls -s | cat
total 359192
 2408 mencoder
 34680 movie-1000.avi *
 34680 movie-2000.avi *
 34680 movie-4000.avi
 72360 movie-4000000.avi
 72360 movie-16000000.avi
 72360 movie-16001000.avi
 35664 movie-default.avi (i.e. 800000 - no vbitrate specified)

The size of the resulting files seems to jump rather than go up in a
smooth fashion depending on the bitrate - 1000, 2000 and 4000 bits
all come in at the same size, the size doubles as we step up a thousand
fold to 4000000. All very odd - am I confused in using vbitrate to
try and alter the size of the resulting file? And the values look odd,
I'd've thought a bit rate of 1000 would produce an unviewable clip but
I end up with a viewable clip that's 34MB long (rather big for 120
seconds). Have I got things all wrong?

[ * Note: to get the 1000 and 2000 bit rate values I had to go into
  mencoder.c and comment out the multiply by a thousand that's done
  to the vbitrate value. ]

Thanks for any advice - I'll much appreciated.

Keep up the good work guys - yours,


George.

PS is it just me and my Comp. Sci. background or do other people find
kilobit meaning a thousand bits odd - being more used to 1024?

PPS I'd like to stick with the FFmpeg encoders - FFmpeg looks a much
more convincing open source project than Project Mayo. Project Mayo
looks about as far as you can get from the open source ideal as you
can get (sorry if I've taken there Web site up wrong).

------------------------------------------------------------------------

Extract from mencoder.1 man page:

>
> -divx4opts
>        If encoding to DivX4, you can specify its parameters here, like:
>
>          -divx4opts br=1800:deinterlace:key=250
>
>        Available options:
>
>          help           get help
>          br=XXX         specify bitrate in
>                         kbit <4-16000> or
>                         bit  <16001-24000000>
>
>  ...
>
> -lavcopts
>        If encoding with a codec from libavcodec, you can specify its parameters here, like:
>
>          -lavcopts vcodec=msmpeg4:vbitrate=1800:vhq:keyint=250
>
>        Available options:
>
>          help           get help
>          vcodec=XXX     use the specified codec
>                         (for full list, see html doc!)
>          vbitrate=XXX   specify bitrate in
>                         kbit <4-16000> or
>                         bit  <16001-24000000>
>

__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/




More information about the MPlayer-users mailing list