Log in

View Full Version : Help Me To Find My "Dream" Quantizer


DoomNoob
6th June 2006, 08:22
Hi All,
I recently switched to X264, so I am trying to find what quantizer provides the best Quality/Size ratio according to my own needs, but my CPU/GPU is rather low for heavy X264 testing (Athlon XP2600+GForce2GTS), as I use the Quantizer Mode I get pure VBR so I need to test a signifiant amount of video in order to get an rought idea of the average bitrate each quantizer will outputs for each input resolution.
Happily I know exactly what average bitrate I want to get for each resolution, & I want:
Minimum Bitrate: (Input Resolution Total number Pixels/1000) X2.0
Maximum Bitrate: (Input Resolution Total number Pixels/1000) X2.543

so for 1280x720 input I want
Minimal (921.6X2.000)=1844Kbps
Maximum (921.6X2.543)=2344Kbps

according to my test with some Apple trailers I actually fall somewhere near Quant24

1280x720-Q24-X264-Rev531
---------------------------
Lady In The Water 1649Kbps
La Mujer De Mi Hermano 1794Kbps
Alexander 1936Kbps
One Last Thing 2042Kbps
Sketches Of Frank Gehry 2400Kbps
World Trade Center 2904Kbps
Lost City 3474Kbps
---------------------------
===>Average 2315Kbps

so on a quick test Q24 average bitrate for 1280x720 seems to work but my test is rather poor, I fear it could be slightly more or slightly less if I would encode a more signifiant amount of video ... but with my low CPU I don't want to do the job twice ;(

so I need advices from more experienced X264 users,
which Quantizer (between Q22max & Q27min) do you think will output a bitrate between 1844Kbps & 2344Kbps on average for 1280x720 input ? do you think I am too low or too high with Q24 ?

Thks for any Help ;)

foxyshadis
6th June 2006, 08:50
I can't fathom why minimum bitrate matters; if something gets the same quality at 1Mbps as something else at 2Mbps because it's so compressible, why force it higher? Maximum bitrate is also odd; if you have size restrictions you should use 2pass or just raise the crf of a source you find badly compressible. If it's because you're trying to limit how high it goes to keep it playable, that won't work anyway, you need to set a max vbv size.

Basically, if you want to combine crf with bitrate restrictions, you'll end up frustrated and re-encoding much more often than you would if you stick to two-pass, your own test results bear out that crf can vary widely in bitrate, so any "average" is useless. (Although early visual inspection may help you know when to raise or lower the crf, it's hardly a guaranteed process.)

DoomNoob
6th June 2006, 09:20
well I use nero digital in quantizer mode for audio that's why I don't want to use 2pass with video ... I disagree with using VBR/Quant for Audio & ABR/2Pass for Video ... for me it's either you use 2pass for both or pure VBR for both ... as I will not switch to 2 pass AAC & get variable quality, the only option is to use X264 in pure VBR.

I know its frustrating if you target a specific size, but it's seems I didn't explain myself well enough sorry ;( I don't target a real-life specific bitrate/size ... I target an ideal average bitrate in order to still have a limit but not a strict limit ...

I target the quantizer that will give me the maximum quality while still having an average bitrate under 2344Kbps for 1280x720 (you're right the minimal bitrate doesn't matter at all) doing so I know I will always optimize my Quality/Size on my HD & if a movie gets above 2344Kbps for 1280x720 because it doesn't compress easyly then I will split it when I will burn it ... so filesize doesn't matter ... I target an ideal average & if it doesn't fit I split ... no problem ;)

sorry if I wasn't clear ...

for example Garf said nero AAC Q0.55 will outputs 197Kbps on average with CD input, I try to do the same with X264 targetting 2344Kbps output with 720p input ;)

using quantizers is frustrating in the beginning because they seems random at first sight but when you found the quantizer that best fits your needs on average, there is no way you would switch back to CBR/ABR ...

anyway thks for trying to make things clearer

foxyshadis
6th June 2006, 09:58
No, you explained yourself well enough, but thinking about quality in terms of some kind of average bitrate across a vast array of sources is kind of silly, if you have no size restrictions. With neroaac, you encode to a quality. With x264, you encode to a quality. Bitrate is entirely unimportant for both, if you have no size restrictions whatsoever. If it satisfies your curiosity you can keep track, and find out what the average for your cd collection or your movies turns out to be, but the only thing that makes sense is what you did - encode a few things at a few quants (well, crfs) and see what quality looks or sounds good enough to you, then set everything to it.

Rough average bitrates only exist to give you guidelines for when you want to keep it below a certain size.

I still have no idea how you arrived at 2344 kbps as some measure of quality.

DoomNoob
6th June 2006, 10:12
If you wonder why 2344Kbps, hang on ;), here is the explanation:
-Even if I am on NTFS, my personnal maximum filesize for a video is 4095mega because it's fat32 max filesize, so I consider it's the max filesize for a release.
-4095mo rougthly give 1H30 at 6200Kbps (6000Kbps for Video + 200Kbps for Audio)
-I consider 16/9 HD resolutions are
648p-720p-792p-864p/936p-1008p-1080p-1152p which are each a multiple of 09-10-11-12/13-14-15-16
, with 720p & 1080p being the official ones but not specially the best quality/size HD resolution (it's 864p & 1152p)
-so 1152p, 2048x1152 is the max 16/9 HD resolution. (You can always go higher but it's not classic HD anymore ... it's ultra HD)
- so 2048x1152 at ~6000Kbps is the absolute maximum compromise between high bitrate & high resolution while still having a movie that is transferable & playable (with rather high bandwith & high CPU indeed)
-so 2048x1152=2.359.296pixel, 2.359.296px/1000=2.359, 6000Kbps/2359=2.543
-1280x0720=921.600, 921.600px/1000=921.6, 921.6x2.543=2344Kbps

... this is a rather complex calculation but using a quantizer that outputs 2344Kbps max on average with 720p contents I know that I will not go "on average" higher than 4095mega with a 1152p 1H30 input using the same quantizer.

I agree it's a very personnal weird setting ;) but in the end all i wanna know is if there is a consensus on which quantizer give you which bitrate on average with a representative amount of inputed data ... like there is with nero AAC

I know rough bitrates are guidelines for pure VBR ... but the more you encodes the more this bitrate becomes valid ... it's the same as playing dice, the more you roll a D6 the more you fall on 3.5 on average ...

Sagittaire
6th June 2006, 10:27
for example Garf said nero AAC Q0.55 will outputs 197Kbps on average with CD input, I try to do the same with X264 targetting 2344Kbps output with 720p input

Well Garf make simply false observation : bitrate prediction is simply impossible in pure quality mode for audio/video. Encoder can't predict and will never predict next complexity frame without analyse (and multipass). With source like movie audio track (generaly low average complexity) bitrate will never at 197 Kbps for q 0.55 and will never the same ...

If you want know real average bitrate for video you must make real statistic poll:
- 1000 movies (it's minimum value for good poll, 10 000 is really better)
- movie must be representative panel

With that you have a good statistic poll but nobody make that for audio and even less for video.

Conclusion : There are no direct relation between quality and bitrate, just statistic relation with very high value panel ...

foxyshadis
6th June 2006, 11:56
I know rough bitrates are guidelines for pure VBR ... but the more you encodes the more this bitrate becomes valid ... it's the same as playing dice, the more you roll a D6 the more you fall on 3.5 on average ...
I think that pretty much sums up why asking for this is useless. You're still as likely to hit a 1 or 6 as a 3 or 4, no matter what the average is. And while video quality isn't quite as random, the same holds true.

And basically, no one's ever done the kind of tests on movies you'd need to get this (besides, filtering can wildly change compressibility), like sagittaire says.

On the other hand, nero actually has sampled thousands of songs at different quality levels and probably has a spreadsheet that breaks down average bitrate and acoustics of different musical genres somewhere. :p So for that situation it is somewhat applicable (within a genre; a lump of everything is useless).

Sagittaire
6th June 2006, 18:39
If you wonder why 2344Kbps, hang on , here is the explanation:
-Even if I am on NTFS, my personnal maximum filesize for a video is 4095mega because it's fat32 max filesize, so I consider it's the max filesize for a release.
-4095mo rougthly give 1H30 at 6200Kbps (6000Kbps for Video + 200Kbps for Audio)
-I consider 16/9 HD resolutions are
648p-720p-792p-864p/936p-1008p-1080p-1152p which are each a multiple of 09-10-11-12/13-14-15-16
, with 720p & 1080p being the official ones but not specially the best quality/size HD resolution (it's 864p & 1152p)
-so 1152p, 2048x1152 is the max 16/9 HD resolution. (You can always go higher but it's not classic HD anymore ... it's ultra HD)
- so 2048x1152 at ~6000Kbps is the absolute maximum compromise between high bitrate & high resolution while still having a movie that is transferable & playable (with rather high bandwith & high CPU indeed)
-so 2048x1152=2.359.296pixel, 2.359.296px/1000=2.359, 6000Kbps/2359=2.543
-1280x0720=921.600, 921.600px/1000=921.6, 921.6x2.543=2344Kbps

bpf doesn't work ... read that:

Many coders use the bits/pixel (like GK use bpf for example) to make their encodings. But this method has two problems:
- the source compressibility is not predictible
- bpf = f (resolution) with same source



|---------------|--------------------|--------------------|--------------------|
| | files sizes | bit/(pel*fps) | bit/(pel^0.75*fps) |
|---------------|--------------------|--------------------|--------------------|
| q2 1024*576 | 3389 Kbps | 0.239 bpf | 6.63 sci |
| q2 720*400 | 1890 Kbps | 0.273 bpf | 6.33 sci |
| q2 512*288 | 1143 Kbps | 0.323 bpf | 6.32 sci |
| q2 384*208 | 714 Kbps | 0.372 bpf | 6.26 sci |
|---------------|--------------------|--------------------|--------------------|
| q3 1024*576 | 2067 Kbps | 0.146 bpf | 4.04 sci |
| q3 720*400 | 1188 Kbps | 0.172 bpf | 3.98 sci |
| q3 512*288 | 735 Kbps | 0.207 bpf | 4.07 sci |
| q3 384*208 | 462 Kbps | 0.241 bpf | 4.05 sci |
|---------------|--------------------|--------------------|--------------------|
| q4 1024*576 | 1492 Kbps | 0.105 bpf | 2.92 sci |
| q4 720*400 | 875 Kbps | 0.127 bpf | 2.93 sci |
| q4 512*288 | 548 Kbps | 0.155 bpf | 3.03 sci |
| q4 384*208 | 344 Kbps | 0.179 bpf | 3.02 sci |
|---------------|--------------------|--------------------|--------------------|
source 1280*720
resize with lanczos
encoding with XviD



|----------------|--------------------|--------------------|--------------------|
| | files sizes | bit/(pel*fps) | bit/(pel^0.75*fps) |
|----------------|--------------------|--------------------|--------------------|
| q20 1280*720 | 4026 Kbps | 0.182 bpf | 5.63 sci |
| q20 720*400 | 1728 Kbps | 0.250 bpf | 5.79 sci |
| q20 512*288 | 1057 Kbps | 0.299 bpf | 5.85 sci |
| q20 384*208 | 661 Kbps | 0.345 bpf | 5.80 sci |
|----------------|--------------------|--------------------|--------------------|
| q25 1280*720 | 2074 Kbps | 0.094 bpf | 2.90 sci |
| q25 720*400 | 924 Kbps | 0.134 bpf | 3.09 sci |
| q25 512*288 | 573 Kbps | 0.162 bpf | 3.17 sci |
| q25 384*208 | 363 Kbps | 0.189 bpf | 3.18 sci |
|----------------|--------------------|--------------------|--------------------|
| q30 1280*720 | 1023 Kbps | 0.046 bpf | 1.43 sci |
| q30 720*400 | 460 Kbps | 0.067 bpf | 1.54 sci |
| q30 512*288 | 286 Kbps | 0.081 bpf | 1.58 sci |
| q30 384*208 | 181 Kbps | 0.094 bpf | 1.59 sci |
|----------------|--------------------|--------------------|--------------------|
source 1920*1088
resize with lanczos
encoding with x264


If you use bit/(pel^0.75*fps) to make your encoding then you don't have the second problem: with same source bit/(pel^0.75*fps) is constant whatever the resolution.

DoomNoob
9th June 2006, 08:53
Thks for your help & advices,

I finally decided to forget about targetting a filesize ... even a statistical average one, because my strategy didn't worked if the framerate jumps from 24-25 to 30 or if the movie length is 2H00 instead of 1H30 ...

I think I finally found what I was looking for by splitting the quantizer scale following some basic logic in order to find 3 optimized settings for High, Medium & Low Quality

I decided to use
Q24 Low Quality (~1800-2000Kbps)
Q20 Medium Quality (~3600-4000Kbps)
Q16 High Quality (~7200-8000Kbps) Near Transparency

I sorted Quantizer like this:

Quant 01 to 10 + Quant 00 Useless: Too Big Size
Quant 40 to 50 + Quant 51 Useless: Too Low Quality

Quant 11
Quant 12
Quant 13
Quant 14
Quant 15 ~Max
Quant 16 ~Max
Quant 17
Quant 18
Quant 19
Quant 20

Quant 21
Quant 22
Quant 23
Quant 24
Quant 25 ~Default
Quant 26 ~Default
Quant 27
Quant 28
Quant 29
Quant 30

Quant 31
Quant 32
Quant 33
Quant 34
Quant 35 ~Min
Quant 36 ~Min
Quant 37
Quant 38
Quant 39
Quant 40

Then I started testing Q25-LQ Q20-MQ Q15-HQ,
but I quickly realized Q25-LQ was slightly too low & Q15-HQ slightly too high, so I switched to Q24-LQ Q20-MQ Q16-HQ, & now I am happy with the quality-size ratio these quantizer output ;)

Again thks for tips

Sagittaire
9th June 2006, 10:24
be carefull: constant quant mode is not not real "constant HVS" mode for x264. Use crf mode for that ...