Log in

View Full Version : CRF vs. AQ-Strength


Stingrey
27th November 2007, 08:44
Hi guys,
i have some new stuff to encode so I got curious what is more important, the crf or the aq-strength setting.
so I made some testencodes with this setting:
--crf XX.X --keyint 100 --min-keyint 1 --ref 3 --mixed-refs --no-fast-pskip --bframes 2 --b-pyramid --bime --weightb --direct temporal --analyse p8x8,b8x8,i4x4,p4x4 --8x8dct --vbv-maxrate 25000 --merange 12 --threads auto --thread-input --progress --no-psnr --no-ssim --output "output" "input" --aq-strength 0.X --aq-sensitivity 10
I always just changed the crf and the aq-strength to get almost the same bitrate.
This came up:
E0=orig
E1=CRF 20.6, AQ 0.3, Bitrate 769.44
E2=CRF 21.1, AQ 0.4, Bitrate 773.92
E3=CRF 21.8, AQ 0.5, Bitrate 775.21
E4=CRF 22.8, AQ 0.6, Bitrate 771.15
E5=CRF 24.1, AQ 0.7, Bitrate 765.25
E6=CRF 25.4, AQ 0.8, Bitrate 768.24
E7=CRF 26.4, AQ 0.9, Bitrate 767.41
Targetbitrate: 770

Here are two pics of every encode that are showing the difference.
Pic 1 Helmet (losing Details with to low crf)
E0
http://img521.imageshack.us/img521/5844/e0188xm9.png
E1
http://img505.imageshack.us/img505/2264/e1188pc7.png
E2
http://img501.imageshack.us/img501/3325/e2188jf4.png
E3
http://img156.imageshack.us/img156/8521/e3188oq9.png
E4
http://img524.imageshack.us/img524/1336/e4188ff5.png
E5
http://img520.imageshack.us/img520/128/e5188gr6.png
E6
http://img504.imageshack.us/img504/5015/e6188pn4.png
E7
http://img521.imageshack.us/img521/728/e7188td4.png

Pic 2 Screen (Blockiness around the screen with too low AQ)
E0
http://img254.imageshack.us/img254/3842/e0410yo9.png
E1
http://img528.imageshack.us/img528/4804/e1410ru8.png
E2
http://img520.imageshack.us/img520/2311/e2410tk5.png
E3
http://img504.imageshack.us/img504/5192/e3410su1.png
E4
http://img254.imageshack.us/img254/7894/e4410ig5.png
E5
http://img101.imageshack.us/img101/8163/e5410od4.png
E6
http://img519.imageshack.us/img519/9485/e6410hk9.png
E7
http://img503.imageshack.us/img503/9764/e7410yn3.png

So witch setting would be the best choice?

Here you can get the sample pics plus videos:
http://rapidshare.com/files/72580819/Samples.rar.html

Dark Shikari
27th November 2007, 08:53
They're totally different things... CRF affects the overall quantizer, while AQ lowers the quantizer in specific (flat) parts of the frame.

Past a certain point, this will probably give the flat parts too much quality gain, at the cost of the quality of the rest of the frame.

Stingrey
27th November 2007, 09:11
I know that they are totally different things.
I'm just trying to find a good mix between them.
To high the one, to low the other and it looks like crap.

Added rapidshare link.

onesloth
28th November 2007, 19:41
You just need to decide what crf you need to get the complex detail you want and then increase your AQ until the blocking in flat areas is gone.

I've found that --aq-strength 0.5 --aq-sensitivity 5 works best when you have a bad blocking problem. 0.5 & 10 works well for some stuff but the bitrate cost of going from 10 to 5 isn't usually that high. crf 22 and AQ 0.5-10 is what I like for stuff that only needs an sensitivity of 10.

I don't see any blocking in the helmet pics but the screen pic looks like it still has blocking even in pic 7. It looks it might not be that noticeable in pic 5 when playing. But if you use a crf of 26 you'll notice a loss of detail. You should try these again at a sensitivity of 5. If you're limited to these settings and a bitrate of 770 it looks like you just have to decide what bothers you more: lower detail or blocking.

ditche
28th November 2007, 20:52
Hello,
I don't find the option called "AQ" in meGUI... Can you help me ?

http://users.skynet.be/bk314761/smileys/008.gif

LoRd_MuldeR
28th November 2007, 20:58
Hello,
I don't find the option called "AQ" in meGUI... Can you help me ?

http://users.skynet.be/bk314761/smileys/008.gif
AQ is not an official x264 feature yet, it's only available via patch!
If you don't build x264 yourself, you'll need to find a pre-compiled x264.exe that was built with the AQ patch included.
I guess MeGUI doesn't have an AQ option, because it would be useless with all "official" x264 builds...

ditche
28th November 2007, 21:18
Arf, OK, thanks LoRd_MuldeR. ;)
I find I've too much blocking in my videos. :mad:

Atak_Snajpera
28th November 2007, 22:16
If you don't build x264 yourself, you'll need to find a pre-compiled x264.exe that was built with the AQ patch included.
I guess MeGUI doesn't have an AQ option, because it would be useless with all "official" x264 builds...

Megui uses Cef's bulid with AQ path. However You will have to manually add following line in zones?!
--aq-strength 0.5 --aq-sensitivity 5

Dark Shikari
28th November 2007, 22:24
Megui uses Cef's bulid with AQ path. However You will have to manually add following line in zones?!
--aq-strength 0.5 --aq-sensitivity 5

--aq-sensitivity 5 seems silly IMO, that would apply the AQ to far too many blocks.

Atak_Snajpera
28th November 2007, 23:32
--aq-sensitivity 5 seems silly IMO, that would apply the AQ to far too many blocks.

At least it works (blue and dark areas only)

desta
29th November 2007, 01:25
I very rarely go below 10 for sensitivity. 12-13 is a nice halfway point, and then you can just raise the strength if needs be.

skontel
29th November 2007, 03:08
Hmmm... This reminds of something I've always wanted to ask, but never found the appropriate forum to do so... :)

Is there a post that gives a rule-of-thumb advice on how to use the --aq-strength and --aq-sensitivity with the AQ patch for x264? I realize that the actual values will vary depending on content, as do many other arguments to x264. What I'm primarily interested in, is getting a better understanding of how these two options interact with each other, and how they interact with other x264 options.

I realize I could just study the code. Unfortunately, I barely have the time to compile all the tools and encode things.

Any and all help/information would be very much appreciated.

Haali
30th November 2007, 22:55
The general idea that my AQ patch uses is that we adjust the QP by the amount of flatness of the block.

The flatness factor that I used is:
fc = e ^ (-k * sum(AC dct coeffs) ^ 2)

Then the qp adjustment is:
QP_adj = QP * strength * (2 - fc) ^ -sensitivity

Sensitivity controls the steepness of the curve and strength controls the amount of adjustment.

onesloth
2nd December 2007, 04:23
--aq-sensitivity 5 seems silly IMO, that would apply the AQ to far too many blocks.

A sensitivity of 10 works for most stuff but I was recommending 5 for *bad* blocking.

I spent a lot of time trying to encode a popular film, by a recent Nobel Peace Prize winner, that had severe blocking with x264 at crf22. The source had a lot of footage of the speaker in front of a large projected display with large areas of flat greens and dark grays. Without AQ I had to increase the crf to 14-15 to get rid of the blocking. At crf22, an aq-str 0.5 and an aq-sen 10 had a significant effect but in some scenes -- particularly where almost the entire screen was a flat gradient of green -- a sensitivity of 10 made the blocking into more of a slight banding but there just wasn't transparency. Using a sensitivity of 5 made the encode almost indistinguishable from the original.