Log in

View Full Version : x264 vs DivX. Compressability same source


DJ Alik
7th May 2009, 16:54
I have been re-encoding videos to DivX forever and decided to try out x264 to see if I can get better compressibility at the same or better quality.

I encoded the same source using DivX 1 Pass Quality based with Target Quantizer set to 2 and with x264 using const. quantizer mode set to 2 as well.

The file encoded in DivX had the compression of about 86% which is not bad considering I encoded at the best quality.

The file encoded in x264 actually made the video 457% larger! than the source.

I don't understand how that is happening and what am I doing wrong. Please help!

Here is the details on the source and resulting files:

Source:

Complete name : Lady GaGa - Poker Face.VOB
Format : MPEG-PS
ID : 224 (0xE0)
Format : MPEG Video
Format version : Version 2
Format profile : Main@Main
Format settings, Matrix : Default
Duration : 3mn 34s
Bit rate mode : Variable
Bit rate : 5 533 Kbps
Nominal bit rate : 8 000 Kbps
Width : 720 pixels
Height : 480 pixels
Display aspect ratio : 4/3
Frame rate : 29.970 fps
Standard : NTSC
Colorimetry : 4:2:0
Scan type : Interlaced
Scan order : Top Field First
Bits/(Pixel*Frame) : 0.534

AVS:

DGDecode_mpeg2source("Lady GaGa - Poker Face.d2v", cpu=4, info=3)
ColorMatrix(hints=true, interlaced=true, threads=0)
tfm(order=1).tdecimate(hybrid=1)
crop( 14, 10, -14, -8)
LanczosResize(640,464)
Undot()

Output DivX:
File size : 125 MiB
Overall bit rate : 4 902 Kbps
Format : MPEG-4 Visual
Format settings, BVOP : Yes
Format settings, QPel : No
Format settings, GMC : No warppoints
Format settings, Matrix : Default (H.263)
Muxing mode : Packed bitstream
Codec ID : DX50
Codec ID/Hint : DivX 5
Duration : 3mn 34s
Bit rate : 4 732 Kbps
Width : 640 pixels
Height : 464 pixels
Display aspect ratio : 1.379
Frame rate : 23.976 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 0.665
Stream size : 121 MiB (97%)
Writing library : DivX 6.8.5
Encoding settings: -bv1q 2 -vbv 4854000,3145728,3145728 -dir "C:\Documents and Settings\DJAlik\Application Data\DivX\DivX Codec" -pq 8610 -b 1 -profile=3 -quantization=2

Output x264:

File size : 667 MiB
Duration : 3mn 34s
Overall bit rate : 26.1 Mbps
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 3 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 3mn 34s
Bit rate mode : Variable
Bit rate : 25.9 Mbps
Maximum bit rate : 36.5 Mbps
Width : 640 pixels
Height : 464 pixels
Display aspect ratio : 1.379
Frame rate mode : Constant
Frame rate : 23.976 fps
Resolution : 24 bits
Colorimetry : 4:2:0
Scan type : Progressive
Bits/(Pixel*Frame) : 3.639
Stream size : 663 MiB (99%)
Writing library : x264 core 67 r1145M d2e1e1c
Encoding settings : "C:\Program Files\megui\tools\x264\x264.exe" --qp 2 --level 4.1 --ref 3 --mixed-refs --bframes 3 --b-adapt 2 --b-pyramid --weightb --direct auto --subme 7 --trellis 2 --partitions p8x8,b8x8,i4x4,i8x8 --8x8dct --me umh --merange 12 --threads auto --thread-input --sar 1:1 --aud --progress --no-psnr --no-ssim --output "Lady GaGa - Poker Face.264" "Lady GaGa - Poker Face.avs"

Dark Shikari
7th May 2009, 16:56
H.264 quantizers are totally different from MPEG-4 ASP quantizers.

QP 2 in H.264 provides roughly 2^((18-2)/6) = 6.34x the coding precision of QP 2 in MPEG-4 ASP.

You can't compare "compressibility" between such different encoders and quantizer scales--and you should never use --qp mode in x264 either.

cogman
7th May 2009, 17:07
What he said.

Compressibility is hard to measure, especially since both formats are lossy. (How do you measure somethings compression ratio when that thing will inherently loose some data regardless?). What you can do is measure quality at a given bitrate (and indeed, this is commonly what is done).

Set both encoders at a 500 kbits/sec bitrate, and see which one produces the better quality video. That is where you'll see one of the biggest differences between x264 and divX.

Dark Eiri
7th May 2009, 17:10
I believe CRF 18 would give better visual results (or at the very least, the same) than QP2 in DivX. And smaller filesizes.
Oh, you can increase merange to 16 also, for a tiny bit extra quality.

DJ Alik
7th May 2009, 17:18
I remember back in the Gordian Knot days I used to use Compressibility to test to determine the right bitrate to use for my videos based on Doom9 guides. Is there anything available for x264 to guide what bitrate to use or is it a guessing game?

Dark Shikari
7th May 2009, 17:30
I remember back in the Gordian Knot days I used to use Compressibility to test to determine the right bitrate to use for my videos based on Doom9 guides. Is there anything available for x264 to guide what bitrate to use or is it a guessing game?If you don't know what bitrate you want, use CRF. Simple as that.

nm
7th May 2009, 17:37
I remember back in the Gordian Knot days I used to use Compressibility to test to determine the right bitrate to use for my videos based on Doom9 guides. Is there anything available for x264 to guide what bitrate to use or is it a guessing game?
If you don't have a specific size constraint, you can simply determine a CRF value that produces the quality you want and use that for most sources. For example, I'm satisfied with CRF 22 - 24 for DVB archival purposes and I generally encode everything with CRF 23. If I wanted near-transparent quality, I'd use CRF 20 or less.

DJ Alik
7th May 2009, 17:41
If you don't have a specific size constraint, you can simply determine a CRF value that produces the quality you want and use that for most sources. For example, I'm satisfied with CRF 22 - 24 for DVB archival purposes and I generally encode everything with CRF 23. If I wanted near-transparent quality, I'd use CRF 20 or less.

The only size constraint I have is I want my encode to be smaller than the source obviously. Otherwise what's the point of re-encoding :) . But I also want near the same quality as the source.

LoRd_MuldeR
7th May 2009, 19:30
The only size constraint I have is I want my encode to be smaller than the source obviously. Otherwise what's the point of re-encoding :) . But I also want near the same quality as the source.

Then find the highest possible CRF value that still gives satisfactory quality for you and then use that CRF value for your x264 encodes.

If your source is MPEG-2, then x264 will be able to re-encode that video to a MUCH smaller size while retaining a transparent or near-transparent quality.

You may want to start with CRF=18 and then raise the CRF value step by step...

multimediaman
7th May 2009, 19:43
According to my experience it is OK to use crf 20 or less. But for bitrate starved (2500 kbps mpeg-2) sources above 20 (like 22) is required in order to keep file sizes reasonable small.

Sagekilla
7th May 2009, 19:46
Also note, that DivX / XviD q2 is roughly equivalent to x264 crf 18. The reason why you got such an absurdly huge file size is because the quantizer scale in x264 is logarithmic, whereas XviD / DivX have a linear scale. The logarithmic scale is -much- better than the linear one though, as you get much finer grained control over quality.

One other thing, to add on what LoRd_MuldeR said, you'll probably want to stay below crf 25, since above that is pretty poor quality unless you're working with absurdly clean sources / anime.

benwaggoner
8th May 2009, 00:46
According to my experience it is OK to use crf 20 or less. But for bitrate starved (2500 kbps mpeg-2) sources above 20 (like 22) is required in order to keep file sizes reasonable small.
That's when to bring out the MPEG-2 decoder with deblocking/deringing. Trying to encode someone else's artifacts is good bits after bad.