[MEncoder-users] H.264 compression

Diogo Franco diogomfranco at gmail.com
Wed May 14 18:23:06 CEST 2008


Em Qua, 2008-05-14 às 10:07 +0100, Mark Himsley escreveu:
> Hi,
> 
> For 6 months or so I've been using the lavcopts in the command below to 
> make rather nice quality H.264 video. Recently, after the update from 
> Ubuntu Gusty to Hardy broke mencoder, I recompiled libx264 and 
> mplayer/mencoder and the files produced are about half the size that 
> they used to be.
> 
> Previously mencoder produced H.264 at about 760 Mbps, now it creates 
> H.264 at about 360 Mbps. To my eyes I feel that the quality has reduced, 
> but I thought that setting vq* to 2 should give me a constant quality.
> 
> It might be that, since I know the files are smaller I think the quality 
> is worse - us humans are odd like that - but I'm wondering if I've 
> overlooked a change in the last few months that would mean my lavcopts 
> less than optimal.
> 
> The full command I am using is (please excuse the line wrapping):
> 
>   mencoder -v \
>    "$i" \
>    -o "$d" \
>    -aspect 1050:576 \
>    -ofps 25.00 \
>    -noskip \
>    -mc 0 \
>    -vfm ffmpeg \
>    -vf kerndeint=18:0:0:1:0,crop=688:568:16:4,scale=480:272,harddup \
>    -ovc lavc \
>    -oac lavc \
>    -lavcopts 
> vglobal=1:vcodec=libx264:vqscale=2:vqmin=2:level=30:mbd=2:trell:v4mv:last_pred=2:dia=-1:vmax_b_frames=0:cmp=3:subcmp=3:autoaspect:aglobal=1:acodec=libfaac:abitrate=128 
> \
>    -of lavf \
>    -lavfopts format=ipod
> 
> 
> And here is the typical output (I pressed ^C after a couple of seconds 
> of encoding)
> 
> 
> MEncoder dev-SVN-r26759-4.2.3 (C) 2000-2008 MPlayer Team
> CPU: Intel(R) Pentium(R) 4 CPU 3.20GHz (Family: 15, Model: 2, Stepping: 9)
> CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 0 3DNow2: 0 SSE: 1 SSE2: 1
> Compiled for x86 CPU with extensions: MMX MMX2 SSE SSE2
> 
> Configuration: --enable-gui --enable-menu
> init_freetype
> get_path('font/font.desc') -> '/home/mdsh/.mplayer/font/font.desc'
> font: can't open file: /home/mdsh/.mplayer/font/font.desc
> font: can't open file: /usr/local/share/mplayer/font/font.desc
> Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay
> [file] File size is 1558312960 bytes
> STREAM: [file] input.mpg
> STREAM: Description: File
> STREAM: Author: Albeu
> STREAM: Comment: based on the code from ??? (probably Arpi)
> success: format: 0  data: 0x0 - 0x5ce1f800
> LAVF_check: MPEG PS format
> Checking for YUV4MPEG2
> ASF_check: not ASF guid!
> Checking for NuppelVideo
> Checking for REAL
> Checking for SMJPEG
> Searching demuxer type for filename input.mpg ext: .mpg
> Checking for Nullsoft Streaming Video
> Checking for MOV
> Checking for VIVO
> header block 1 size: 0
> AVS: avs_check_file - attempting to open file input.mpg
> AVS: File is too big, aborting...
> Checking for PVA
> Checking for MPEG-TS...
> TRIED UP TO POSITION 86857, FOUND 47, packet_size= 0, SEEMS A TS? 0
> Checking for LMLM4 Stream Format
> Invalid packet in LMLM4 stream: ch=0 size=1140851708
> LMLM4 Stream Format not found
> system stream synced at 0xD (13)!
> ==> Found video stream: 0
> ==> Found audio stream: 0
> MPEG-PS file format detected.
> Searching for sequence header... OK!
> VIDEO:  MPEG2  720x576  (aspect 3)  25.000 fps  4350.0 kbps (543.8 kbyte/s)
> [V] filefmt:2  fourcc:0x10000002  size:720x576  fps:25.000  ftime:=0.0400
> ==========================================================================
> Opening audio decoder: [mp3lib] MPEG layer-2, layer-3
> dec_audio: Allocating 4608 + 65536 = 70144 bytes for output buffer.
> mp3lib: using SSE optimized decore!
> MP3lib: init layer2&3 finished, tables done
> MPEG 1.0, Layer II, 48000 Hz 256 kbit Stereo, BPF: 768
> Channels: 2, copyright: No, original: No, CRC: Yes, emphasis: 0
> AUDIO: 48000 Hz, 2 ch, s16le, 256.0 kbit/16.67% (ratio: 32000->192000)
> Selected audio codec: [mp3] afm: mp3lib (mp3lib MPEG layer-2, layer-3)
> ==========================================================================
> [file] File size is 0 bytes
> STREAM: [file] input.mp4
> STREAM: Description: File
> STREAM: Author: Albeu
> STREAM: Comment: based on the code from ??? (probably Arpi)
> ** MUXER_LAVF 
> *****************************************************************
> REMEMBER: MEncoder's libavformat muxing is presently broken and can generate
> INCORRECT files in the presence of B-frames. Moreover, due to bugs MPlayer
> will play these INCORRECT files as if nothing were wrong!
> *******************************************************************************
> OK, exit.
> ALLOCATED STREAM N. 1, type=0
> 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=480 h=272]
> SwScale params: 480 x 272 (-1=no scaling)
> Opening video filter: [crop w=688 h=568 x=16 y=4]
> Crop: 688 x 568, 16 ; 4
> Opening video filter: [kerndeint=18:0:0:1:0]
> ==========================================================================
> Trying to force video codec driver family ffmpeg...
> Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
> INFO: libavcodec init OK!
> Selected video codec: [ffmpeg2] vfm: ffmpeg (FFmpeg MPEG-2)
> ==========================================================================
> ALLOCATED STREAM N. 2, type=1
> Building audio filter chain for 48000Hz/2ch/s16le -> 0Hz/0ch/??...
> [libaf] Adding filter dummy
> [dummy] Was reinitialized: 48000Hz/2ch/s16le
> [libaf] Adding filter format
> [format] Changing sample format from little-endian 16-bit signed int to 
> big-endian 8-bit signed int
> [dummy] Was reinitialized: 48000Hz/2ch/s16le
> [format] Changing sample format from little-endian 16-bit signed int to 
> big-endian 8-bit signed int
> Building audio filter chain for 48000Hz/2ch/s16le -> 48000Hz/2ch/s16le...
> [dummy] Was reinitialized: 48000Hz/2ch/s16le
> [format] Changing sample format from little-endian 16-bit signed int to 
> big-endian 8-bit signed int
> [libaf] Removing filter format
> [dummy] Was reinitialized: 48000Hz/2ch/s16le
> Increasing filtered audio buffer size from 0 to 4224
> [ffmpeg] aspect_ratio: 1.777778
> VDec: vo config request - 720 x 576 (preferred colorspace: Planar YV12)
> Trying filter chain: kerndeint crop scale harddup expand lavc
> VDec: using Planar YV12 as output csp (no 0)
> Movie-Aspect is 1.82:1 - prescaling to correct movie aspect.
> VO Config (720x576->1050x576,flags=0,'MPlayer',0x32315659)
> REQ: flags=0x441  req=0x0
> REQ: flags=0x441  req=0x400
> SwScaler: reducing / aligning filtersize 7 -> 8
> SwScaler: reducing / aligning filtersize 7 -> 8
> SwScaler: reducing / aligning filtersize 10 -> 9
> SwScaler: reducing / aligning filtersize 10 -> 9
> [swscaler @ 0x876bb98]BICUBIC scaler, from yuv420p to yuv420p using MMX2
> [swscaler @ 0x876bb98]using 8-tap MMX scaler for horizontal luminance 
> scaling
> [swscaler @ 0x876bb98]using 8-tap MMX scaler for horizontal chrominance 
> scaling
> [swscaler @ 0x876bb98]using n-tap MMX scaler for vertical scaling (YV12 
> like)
> [swscaler @ 0x876bb98]688x568 -> 480x272
> REQ: flags=0x401  req=0x0
> REQ: flags=0x401  req=0x0
> REQ: flags=0x401  req=0x0
> videocodec: libavcodec (480x272 fourcc=34363268 [h264])
> [VE_LAVC] High quality encoding selected (non-realtime)!
> [VE_LAVC] Using constant qscale = 2.000000 (VBR).
> [libx264 @ 0x87833f0]using SAR=1/1
> [libx264 @ 0x87833f0]using cpu capabilities: MMX MMX2 SSE SSE2 Cache64
> *** [kerndeint] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 
> bytes
> *** [kerndeint] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 
> bytes5 D/B/S 0/1/0
> *** [crop] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 bytes
> *** [crop] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 bytes
> *** [scale] Exporting mp_image_t, 688x568x12bpp YUV planar, 586176 bytes
> *** [harddup] Allocating mp_image_t, 480x272x12bpp YUV planar, 195840 bytes
> *** [expand] Exporting mp_image_t, 480x272x12bpp YUV planar, 195840 bytes
> *** [lavc] Allocating mp_image_t, 480x272x12bpp YUV planar, 195840 bytes
> get_path('subfont.ttf') -> '/home/mdsh/.mplayer/subfont.ttf'
> Unicode font: 255 glyphs.
> get_path('subfont.ttf') -> '/home/mdsh/.mplayer/subfont.ttf'
> Unicode font: 255 glyphs.
> Muxer frame buffer sending 25 frame(s) to the muxer.
> VIDEO CODEC ID: 28
> AUDIO CODEC ID: 15002, TAG: 0
> MUXER_LAVF(audio stream) frame_size: 1024, scale: 1024, sps: 48000, 
> rate: 48000, ctx->block_align = stream->wf->nBlockAlign; 0=1 
> stream->wf->nAvgBytesPerSec:13078
> Writing header...
> *** [kerndeint] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 
> bytes25 D/B/S 0/1/0
> *** [crop] Allocating mp_image_t, 720x576x12bpp YUV planar, 622080 bytes
> Pos:   3.8s     96f ( 0%)  32fps Trem:  30min  57mb  A-V:0.000 [82:127] 
> A/Vms 2/26 D/B/S 0/1/0
> Flushing video frames.
> Writing index...
> 
> Video stream:   82.345 kbit/s  (10293 B/s)  size: 39114 bytes  3.800 
> secs  96 frames
> 
> Audio stream:  127.423 kbit/s  (15927 B/s)  size: 67959 bytes  4.267 secs
> Uninit audio filters...
> [libaf] Removing filter dummy
> Uninit audio: mp3lib
> Uninit video: ffmpeg
> [libx264 @ 0x87833f0]slice I:1     Avg QP:25.00  size:   432
> [libx264 @ 0x87833f0]slice P:94    Avg QP:28.54  size:   412
> [libx264 @ 0x87833f0]mb I  I16..4: 100.0%  0.0%  0.0%
> [libx264 @ 0x87833f0]mb P  I16..4:  4.3%  0.0%  0.0%  P16..4: 22.0% 
> 0.0%  0.0%  0.0%  0.0%    skip:73.7%
> [libx264 @ 0x87833f0]final ratefactor: -12.14
> [libx264 @ 0x87833f0]SSIM Mean Y:0.9772701
> [libx264 @ 0x87833f0]kb/s:82.3
> 
> 
> Thanks
> 
x264 ratecontrol on FFmpeg (libavcodec) is broken for some time now, for
some weird reason it always use the maximum quantizer. You have to use
x264 directly with mencoder.




More information about the MEncoder-users mailing list