[MEncoder-users] mencoder apparently not obeying video bitrate settings

Eric Anopolsky erpo41 at gmail.com
Mon Jul 21 11:57:28 CEST 2008


On Sun, 2008-07-20 at 22:45 -0700, RC wrote:
> On Sun, 20 Jul 2008 23:21:58 -0600
> "Eric A" <erpo41 at gmail.com> wrote:
> 
> > the full file would have been around 2300MB, far too small considering
> > the video bitrate was set to 8000kbps.
> 
> You're upscaling a tiny, low-bitrate video, and trying to encode it with
> a huge bitrate (the maximum acceptible for DVD). 

I think perhaps I miscommunicated. Since one of the problems I'm having
is that my video bitrate settings don't seem to have an effect on the
output (in particular, the video bitrate of the output is too low) I
picked a large video bitrate setting to underscore the incongruity.
Originally, I had picked a lower bitrate so that the video would fit on
a single layer DVD-R properly.

> What do you expect
> MEncoder to do with the extra bits after it's reached the point
> where it has encoded the video perfectly(*)? Pad the file with zeros?

Since MPEG2 is lossy, I expect the encoder to reproduce the input as
accurately as it can at the given bitrate. The subjective quality of the
input shouldn't affect the encoder's ability to do this, should it?

> (*) Well... up to the maximum quality possible, given lavc's quant
> settings as well as the user options specified.  You can encode a
> video with vqscale=2, and then look at the bitrate used, to see if this
> is in fact the case.

When I use vqscale=2, here's what I get:

//////////////////////
$ /usr/bin/mencoder -oac lavc -ovc lavc -of mpeg -mpegopts
format=dvd:tsaf -ofps 24000/1001 -vf
expand=576:324:0:10,scale=720:480,harddup -lavcopts
vcodec=mpeg2video:trell:mbd=2:sc_threshold=1000000000:cgop:vstrict=0:vrc_maxrate=8476:vrc_buf_size=1835:vbitrate=8000:keyint=15:acodec=ac3:abitrate=224:aspect=16/9:vqscale=2 -o /home/eric/movie_01_01.mpg input.avi

MEncoder 2:1.0~rc2-0ubuntu13 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU     T9300  @ 2.50GHz (Family: 6, Model:
23, Stepping: 6)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x2bb6b000
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [XVID]  576x304  24bpp  23.976 fps  765.9 kbps (93.5 kbyte/s)
[V] filefmt:3  fourcc:0x44495658  size:576x304  fps:23.98  ftime:=0.0417
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
PACKET SIZE: 2048 bytes, deltascr: 43885
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [harddup]
Opening video filter: [scale w=720 h=480]
Opening video filter: [expand w=576 h=324 x=0 y=10]
Expand: 576 x 324, 0 ; 10, osd: 0, aspect: 0.000000, round: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Limiting audio preload to 0.4s.
Increasing audio density to 4.
VDec: vo config request - 576 x 304 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.89:1 - prescaling to correct movie aspect.
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
[swscaler @ 0xdd9330]SwScaler: BICUBIC scaler, from yuv420p to yuv420p
using MMX2
[swscaler @ 0xdd9330]SwScaler: using 4-tap MMX scaler for horizontal
luminance scaling
[swscaler @ 0xdd9330]SwScaler: using 4-tap MMX scaler for horizontal
chrominance scaling
[swscaler @ 0xdd9330]SwScaler: using n-tap MMX scaler for vertical
scaling (YV12 like)
[swscaler @ 0xdd9330]SwScaler: 576x324 -> 720x480
videocodec: libavcodec (720x480 fourcc=3267706d [mpg2])
[VE_LAVC] High quality encoding selected (non-realtime)!
[VE_LAVC] Using constant qscale = 2.000000 (VBR).
Full DR not possible, trying SLICES instead!
Writing header...
INITV: 0.200, 0.158, fps: 23.976
Full DR not possible, trying SLICES instead!min   0mb  A-V:0.000 [0:0]
Pos: 539.0s  12923f (10%) 56.39fps Trem:  33min 2272mb  A-V:0.049
[3340:224]
Flushing video frames.
Writing index...

Overhead: 2.331% (5598988 / 240163060)
Writing header...

Video stream: 3340.625 kbit/s  (417578 B/s)  size: 225073300 bytes
538.997 secs  12923 frames

Audio stream:  224.000 kbit/s  (28000 B/s)  size: 15102080 bytes
539.360 secs
////////////////////

I let it get to 10% and the file generated was 235MB (or an estimated
final file size of 2350MB), so no significant change there.

Additionally, check out this output:

///////////////////////
$ /usr/bin/mencoder -oac lavc -ovc lavc -of mpeg -mpegopts
format=dvd:tsaf -ofps 24000/1001 -vf
expand=576:324:0:10,scale=720:480,harddup -lavcopts
vcodec=mpeg2video:trell:mbd=2:sc_threshold=1000000000:cgop:vstrict=0:vrc_maxrate=8476:vrc_buf_size=1835:vbitrate=8000:keyint=15:acodec=ac3:abitrate=224:aspect=16/9:vqmin=1:vqmax=1 -o /home/eric/movie_01_01.mpg input.avi

MEncoder 2:1.0~rc2-0ubuntu13 (C) 2000-2007 MPlayer Team
CPU: Intel(R) Core(TM)2 Duo CPU     T9300  @ 2.50GHz (Family: 6, Model:
23, Stepping: 6)
CPUflags: Type: 6 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
success: format: 0  data: 0x0 - 0x2bb6b000
AVI file format detected.
[aviheader] Video stream found, -vid 0
[aviheader] Audio stream found, -aid 1
VIDEO:  [XVID]  576x304  24bpp  23.976 fps  765.9 kbps (93.5 kbyte/s)
[V] filefmt:3  fourcc:0x44495658  size:576x304  fps:23.98  ftime:=0.0417
==========================================================================
Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
AUDIO: 48000 Hz, 2 ch, s16le, 128.0 kbit/8.33% (ratio: 16000->192000)
Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
==========================================================================
PACKET SIZE: 2048 bytes, deltascr: 43885
Opening video filter: [expand osd=1]
Expand: -1 x -1, -1 ; -1, osd: 1, aspect: 0.000000, round: 1
Opening video filter: [harddup]
Opening video filter: [scale w=720 h=480]
Opening video filter: [expand w=576 h=324 x=0 y=10]
Expand: 576 x 324, 0 ; 10, osd: 0, aspect: 0.000000, round: 1
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffodivx] vfm: ffmpeg (FFmpeg MPEG-4)
==========================================================================
Limiting audio preload to 0.4s.
Increasing audio density to 4.
VDec: vo config request - 576 x 304 (preferred colorspace: Planar YV12)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.89:1 - prescaling to correct movie aspect.
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: reducing / aligning filtersize 5 -> 4
[swscaler @ 0xdd9330]SwScaler: BICUBIC scaler, from yuv420p to yuv420p
using MMX2
[swscaler @ 0xdd9330]SwScaler: using 4-tap MMX scaler for horizontal
luminance scaling
[swscaler @ 0xdd9330]SwScaler: using 4-tap MMX scaler for horizontal
chrominance scaling
[swscaler @ 0xdd9330]SwScaler: using n-tap MMX scaler for vertical
scaling (YV12 like)
[swscaler @ 0xdd9330]SwScaler: 576x324 -> 720x480
videocodec: libavcodec (720x480 fourcc=3267706d [mpg2])
[VE_LAVC] High quality encoding selected (non-realtime)!
Full DR not possible, trying SLICES instead!
Writing header...
INITV: 0.200, 0.158, fps: 23.976
Full DR not possible, trying SLICES instead!min   0mb  A-V:0.000 [0:0]
Pos: 895.4s  21467f (14%) 37.20fps Trem:  54min 2558mb  A-V:0.050
[3271:224]
Flushing video frames.
Writing index...

Overhead: 2.339% (9150646 / 391204682)
Writing header...

Video stream: 3271.450 kbit/s  (408931 B/s)  size: 366137738 bytes
895.353 secs  21467 frames

Audio stream:  224.000 kbit/s  (28000 B/s)  size: 25079936 bytes
895.712 secs
/////////////////////////////

Note that both vqmin and vqmax are set to 1. Surely this should generate
a huge file, but after getting to 14%, the file size was only 383MB for
an estimated final file size of only 2736MB.

The video is about an hour and 45 minutes, so even if that 2736MB were
entirely video with no audio or overhead, the video bitrate would only
be about 3.47mbps, less than half of the requested 8mbps and a truly
small file for an enforced quantizer of 1. But again, I'm new to
mencoder so I may just be using it incorrectly.

> Secondly, single-pass isn't really guaranteed to maintain a given
> bitrate. You should use 2-pass encoding if you care about that.

Based on my results, I think something else may be going wrong.

Cheers,
Eric





More information about the MEncoder-users mailing list