PDA

View Full Version : x264 vs mpeg2video


ramprasad85
12th January 2009, 12:36
Hi All
Please have a look at the following


E:\std_yuv_files>ffmpeg -s 720x480 -i universe_720x480.yuv -b 512000 -vcodec mpeg2video universe_720x480_mpeg.mp4
FFmpeg version SVN-r15986, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --extra-cflags=-fno-common --enable-memalign-hack --enable-pthreads --enable-libmp3
lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --ena
ble-libgsm --enable-libx264 --enable-libschroedinger --enable-avisynth --enable-swscale --enable-gpl

libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 6. 0 / 52. 6. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
built on Dec 3 2008 01:59:37, gcc: 4.2.4
Input #0, rawvideo, from 'universe_720x480.yuv':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 720x480, 25.00 tb(r)
Output #0, mp4, to 'universe_720x480_mpeg.mp4':
Stream #0.0: Video: mpeg2video, yuv420p, 720x480, q=2-31, 512 kb/s, 25.00 tb(c)
Stream mapping:
Stream #0.0 -> #0.0
Press [q] to stop encoding
frame= 113 fps= 93 q=31.0 Lsize= 720kB time=4.48 bitrate=1317.2kbits/s
video:719kB audio:0kB global headers:0kB muxing overhead 0.228011%

E:\std_yuv_files>ffmpeg -s 720x480 -i universe_720x480.yuv -b 512000 -vcodec libx264 universe_720x480_x264.mp4
FFmpeg version SVN-r15986, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --extra-cflags=-fno-common --enable-memalign-hack --enable-pthreads --enable-libmp3
lame --enable-libxvid --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libfaac --ena
ble-libgsm --enable-libx264 --enable-libschroedinger --enable-avisynth --enable-swscale --enable-gpl

libavutil 49.12. 0 / 49.12. 0
libavcodec 52. 6. 0 / 52. 6. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
built on Dec 3 2008 01:59:37, gcc: 4.2.4
Input #0, rawvideo, from 'universe_720x480.yuv':
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0.0: Video: rawvideo, yuv420p, 720x480, 25.00 tb(r)
Output #0, mp4, to 'universe_720x480_x264.mp4':
Stream #0.0: Video: libx264, yuv420p, 720x480, q=2-31, 512 kb/s, 25.00 tb(c)
Stream mapping:
Stream #0.0 -> #0.0
[libx264 @ 0x1105930]using cpu capabilities: MMX2 SSE2 SSE3 Cache64
[libx264 @ 0x1105930]profile Baseline, level 3.0
Press [q] to stop encoding
frame= 113 fps= 7 q=2288895.0 Lsize= 1431kB time=4.52 bitrate=2593.2kbits/s
video:1429kB audio:0kB global headers:1kB muxing overhead 0.074927%
[libx264 @ 0x1105930]slice I:10 Avg QP:28.79 size: 24008
[libx264 @ 0x1105930]slice P:103 Avg QP:30.03 size: 11879
[libx264 @ 0x1105930]mb I I16..4: 24.5% 0.0% 75.5%
[libx264 @ 0x1105930]mb P I16..4: 12.8% 0.0% 0.0% P16..4: 74.2% 0.0% 0.0% 0.0% 0.0% skip:12.9%
[libx264 @ 0x1105930]final ratefactor: 38.71
[libx264 @ 0x1105930]SSIM Mean Y:0.9223630
[libx264 @ 0x1105930]kb/s:2590.4

E:\std_yuv_files>dir
Volume in drive E is sairam
Volume Serial Number is 648F-9439

Directory of E:\std_yuv_files

01/12/2009 05:09 PM <DIR> .
01/12/2009 05:09 PM <DIR> ..
12/02/2008 08:19 PM 58,579,200 universe_720x480.yuv
01/12/2009 04:55 PM 737,606 universe_720x480_mpeg.mp4
01/12/2009 05:09 PM 1,465,179 universe_720x480_x264.mp4
3 File(s) 60,781,985 bytes
2 Dir(s) 4,730,077,184 bytes free


"Bitrate * number of seconds in the sequence = compressed file size in bits" that is my understanding of bitrate
So when i specify bitrate 512 to 2 encoders i expect the file sizes to be same while the quality different.
But here the results are unexpected. Is my understanding of bitrate wrong or have i made any mistake in the command line arguments.
In other words: how do i instruct two encoders to compress at a specified quality so that i can compare the resultant file sizes.
:thanks:

akupenguin
12th January 2009, 12:51
Note that both encodes told you they failed to get the target bitrate, so don't assume your math is wrong.
mpeg2, because even at the worst possible quality (q=31), it was still too big.
And I'm not sure why x264 failed, but it might have to do with the video being only 113 frames. Try 2 or 3 pass.

There is no quality metric you can give to two different encoders. Even if they each have quality-based ratecontrol modes, they won't be equivalent.

Also, never use x264 in ffmpeg without "-vpre hq".