Log in

View Full Version : X264 and filesize


weaver4
8th October 2008, 20:01
I do all my X264 encoding with crf. In the past I have used -crf=22 with good results. The picture quality was slightly better than DivX with a CQ=4 and the filesizes were about 20% smaller.

Recently now I have found that X264 encodes are running much larger with -crf=22 than builds that were done a few months ago. I think it has to do with this (found in change log):

commit 173b40c276ee187de31ef630fd207a62de1b2cc7 r968
Author: Jason Garrett-Glaser <darkshikari@gmail.com>
Date: Sat Sep 13 14:03:12 2008 -0700

Move adaptive quantization to before ratecontrol, eliminate qcomp bias
This change improves VBV accuracy and improves bit distribution in CRF and 2pass.
Instead of being applied after ratecontrol, AQ becomes part of the complexity measure that ratecontrol uses.
This allows for modularity for changes to AQ; a new AQ algorithm can be introduced simply by introducing a new aq_mode and a corresponding if in adaptive_quant_frame.
This also allows quantizer field smoothing, since quantizers are calculated beofrehand rather during encoding.
Since there is no more reason for it, aq_mode 1 is removed. The new mode 1 is in a sense a merger of the old modes 1 and 2.
WARNING: This change redefines CRF when using AQ, so output bitrate for a given CRF may be significantly different from before this change!


Can someone give me a hand on what I should be using as a crf value to get similar results to what I had a few months ago with a -crf=22? I am using -level=4.1 if that makes any differance.

Sharktooth
8th October 2008, 20:04
rise the crf value until you get your desired size

LoRd_MuldeR
8th October 2008, 20:10
Make sure you use "--b-adapt 2" with recent builds. It makes the file considerably smaller in CRF mode, in my experience...

(but don't raise "--bframes" to far if you do that, ~5 should be fine)

weaver4
8th October 2008, 21:04
rise the crf value until you get your desired size

Actually I am more interested in quality than filesize. But quality is so hard to judge unless you are a real expert; or you spend a great deal of time evaluating it. So, I thought someone (an expert) could just tell me.

Sagekilla
8th October 2008, 21:29
I'm sorry but that statement is, pardon my language, complete bullshit. You don't need to be an "expert" to tell what you think looks good to your eyes ;) IMO, if you're an "expert" and spend a lot of time looking at video for artifacts, you're going to miss the whole experience of watching the video in the first place because you're too busy criticizing the flaws of the video.

Shinigami-Sama
8th October 2008, 23:31
Actually I am more interested in quality than filesize. But quality is so hard to judge unless you are a real expert; or you spend a great deal of time evaluating it. So, I thought someone (an expert) could just tell me.

if it looks good whats the problem
if its to big just raise crf a little, or up your settings
and if its only 20% smaller than a divx at the same quality I think you're doing something wrong...

LoRd_MuldeR
8th October 2008, 23:34
Actually I am more interested in quality than filesize.

Then find the CRF value that makes you happy and accept whatever filesize comes out. It's that easy, really ;)

Most people seem to be happy in the range between 18 and 24 -- there's not more we can tell you. Go and find out yourself...

Avenger007
8th October 2008, 23:39
It's probably more like "find <= CRF_value that makes you happy", which means you'll have to find that threshold CRF_value that makes you unhappy.

Sagekilla
8th October 2008, 23:48
As a general guideline, the lower your CRF value the "sharper" the image will look because there will be more fine detail. From 18 - 24, there is a very subtle gradation in fine detail present. 18 is generally transparent, if that helps any. My personal preference is crf 18 - 20 for transparency, depending on how good the source was. As others said, try it yourself and see what you like :)


Also, if you post your settings we can help you tweak them.

chainring
9th October 2008, 04:20
Something else that I don't see mentioned when it's said to "judge with your own eyes" is, judge with your own eyes on the display device you're utimately targeting. Meaning, you may do the encoding on your computer, but will do the actual watching on a much larger display. Do some periodic visual samples to make sure it'll be good all the way through.

Tarutaru
9th October 2008, 05:05
add '--psy-rd 0:0' to command line.
PSY RD makes output larger.

foxyshadis
9th October 2008, 05:12
if it looks good whats the problem
if its to big just raise crf a little, or up your settings
and if its only 20% smaller than a divx at the same quality I think you're doing something wrong...

The actual problem here is that it's no longer a question of just 'upping' settings: AQ and PsyRDO have completely changed the way x264 keeps details. In fact, tesa is sometimes worse than umh with them. It's not even a question of finding the crf value that looks 'good enough' anymore. You have to play with all three settings until you find your favorite tradeoff, which is much harder and takes much longer.

If you want the old behavior, with the old filesizes and old quality, you can just use --aq-mode 0 --psyrd 0:0 on your command line. If you just want to brute force a new size through it, you can play with just the crf, though that will trade off new artifacts in place of the old so it won't look the same. But you're passing up a golden opportunity to really get the most out of the current x264 by adjusting to your visual preferences. (eg, I lower aq and rd to reduce their size impact, I like it smaller. It took a few moviesg to find my preferred combo: crf22/aq0.7/psyrd 0.8:0.8, still larger than my old crf 20.5 encodes.)

Snowknight26
9th October 2008, 06:55
add '--psy-rd 0:0' to command line.
PSY RD makes output larger.

That's not always the case, you silly taru-waru. :p

audyovydeo
9th October 2008, 07:52
I'm sorry but that statement is, pardon my language, complete bullshit. You don't need to be an "expert" to tell what you think looks good to your eyes ;) IMO, if you're an "expert" and spend a lot of time looking at video for artifacts, you're going to miss the whole experience of watching the video in the first place because you're too busy criticizing the flaws of the video.

One may pardon your language, but not your point, which is only true if one encodes uniquely for oneself.
Anyone -and it's not just experts - encoding any video (and videos != DVDs) for an audience would rather have a quality metric to go by, rather that one's own eyes.

I don't wear glasses, but I can't tell the difference between a video encoded with a CRF 20 and 23. But I don't assume that's the case for my target audience.

cheers
audyovydeo

Ranguvar
9th October 2008, 12:07
add '--psy-rd 0:0' to command line.
PSY RD makes output larger.

By itself, yes, but adding Psy RDO and then slightly lowering CRF to get the same size output usually increases quality.

Sagekilla
9th October 2008, 17:26
@audyovydeo: Very true, but it is reasonable to assume when you're transcoding content for your own personal usage you can use your own eyes to determine what's best. But, I think it's safe to say your average consumer wouldn't notice some of the artifacts in x264, considering how horribly mangled some sources (the DVD version of 300, many digital streams on TV) are.

weaver4
9th October 2008, 20:58
I'm sorry but that statement is, pardon my language, complete bullshit. You don't need to be an "expert" to tell what you think looks good to your eyes ;) IMO, if you're an "expert" and spend a lot of time looking at video for artifacts, you're going to miss the whole experience of watching the video in the first place because you're too busy criticizing the flaws of the video.

Look; I don't have the best equipment now but, I want to make sure that videos I encode now will look good in a few years. I was just seeking a opinion like "The new x264 encoder will look as good now as it use to with the same filesizes." or "crf=24 looks as good as crf=22 use to". Something like that. Besides that I am over 50 and "my eyes" are not the only ones that I am concerned with.

Do the developers do MOS (mean opinion scores)?

weaver4
9th October 2008, 21:16
and if its only 20% smaller than a divx at the same quality I think you're doing something wrong...

This is an old MOS study but it implies that DivX at at 20%-25% higher bitrate has a equivalent MOS score to X264. Now of course this only applies in the middle of the spectrum because at some point no DivX bitrate can approach the quality of the best X264. So these tested bitrates were in the 700kbps to 1000kbps.

http://compression.ru/video/codec_comparison/subjective_codecs_comparison_en.html

Dark Shikari
9th October 2008, 21:22
This is an old MOS study but it implies that DivX at at 20%-25% higher bitrate has a equivalent MOS score to X264. Now of course this only applies in the middle of the spectrum because at some point no DivX bitrate can approach the quality of the best X264. So these tested bitrates were in the 700kbps to 1000kbps.

http://compression.ru/video/codec_comparison/subjective_codecs_comparison_en.htmlThat's an extremely old comparison, pre-AQ and pre-psy-RD, so I wouldn't put much stock in it.

Also, of course DivX can approach x264 quality at any bitrate; even DivX is visually lossless if you throw enough bitrate at it.

weaver4
9th October 2008, 21:38
DivX has also made encoding improvements. But, you are right...it is old.

Shinigami-Sama
9th October 2008, 21:42
DivX has also made encoding improvements. But, you are right...it is old.

compared to x264 all they got was a coat of paint

weaver4
10th October 2008, 14:13
The actual problem here is that it's no longer a question of just 'upping' settings: AQ and PsyRDO have completely changed the way x264 keeps details. In fact, tesa is sometimes worse than umh with them. It's not even a question of finding the crf value that looks 'good enough' anymore. You have to play with all three settings until you find your favorite tradeoff, which is much harder and takes much longer.

I could be cursed at again, but this statement makes me feel that using x264 is just to much effort. Bee-Jeezze; how much do I need to know to encode good quality movies. I know I am simple minded but how about something like:
x264 --level 4.1 --pass 1 --quality good.

Even the tool people are having problems; I encode the same movie on four x264 GUI encoding tools all with resolutions of 640x272 with a -crf of 22 and the filesizes vary 40%! Yep, 40%.

That aside; with so many parameters how can I be sure that a movie that I encode now will play on future SAPs?

OK, Everyone curse at me....

Dark Shikari
10th October 2008, 14:26
I could be cursed at again, but this statement makes me feel that using x264 is just to much effort. Bee-Jeezze; how much do I need to know to encode good quality movies. I know I am simple minded but how about something like:
x264 --level 4.1 --pass 1 --quality good. That's what the GUIs are for. x264 is designed to be versatile; its the job of a good GUI to make it simple.

Avenger007
10th October 2008, 14:27
Try MeGUI's 1-pass (CRF) HQ or Extra Q profiles. Those settings should give good quality together with your appropriate CRF value.
If you don't yet know how to use AQ and Psy-rd then leave them at their default.

weaver4
10th October 2008, 14:41
Try MeGUI's 1-pass (CRF) HQ or Extra Q profiles. Those settings should give good quality together with your appropriate CRF value.
If you don't yet know how to use AQ and Psy-rd then leave them at their default.

What level are those profiles? Will they work with my PopCornHour (level 4.1 max) and my iPod (level 3.0)?

I will give it a try.

Rumbah
10th October 2008, 14:52
The thing I did to get "my" new CRF value is to take some old encoding I did ,reencode it with the new x264 and turn all the new things on. Then I adjusted the CRF to get nearly the same file size and compared the quality.

If you do not see the difference you have found your new value, try to reencode some older encodings with the new CRF value and compare the filesizes. If they stay close together use the new CRF value.

Of course you could then adjust the CRF a little to get your sweet spot but of course you can only do that if you are the only audience or the one that sees the most artefacts.

check
11th October 2008, 03:13
What level are those profiles? Will they work with my PopCornHour (level 4.1 max) and my iPod (level 3.0)?If you pick the DXVA compliant variants, then they will be DXVA compliant, which should be L4.1.

foxyshadis
11th October 2008, 09:38
I could be cursed at again, but this statement makes me feel that using x264 is just to much effort. Bee-Jeezze; how much do I need to know to encode good quality movies.
I simply said the opportunity is there, whether you want to take advantage of it is your choice. Same with CQMs, deadzones, deblocking, and other tweaks. If you want to press a button, then do so. I posted just because no one else mentioned it.

Even the tool people are having problems; I encode the same movie on four x264 GUI encoding tools all with resolutions of 640x272 with a -crf of 22 and the filesizes vary 40%! Yep, 40%.

This might be a surprise, but the majority of windows GUIs use MeGUI's x264 profiles by default. Handbrake is the major exception. You don't even say whether you choose the same/similar profile in the GUI, they all have different ideas of a good default, after all. Even then, they all use different kinds of filtering, which hugely changes the quality and compressibility of a movie, so size alone is a bad way to compare GUIs.

LoRd_MuldeR
11th October 2008, 11:55
Also even at a given CRF value there still is a "Speed vs. Quality/Compression" trade-off, which the GUI cannot decide for you.
With "Faster" settings you get worse quality and bigger file, with "Slower" settings you get better quality and smaller file.
Also there are various "Psy" settings now, that are not that easy to tune, because there is no "better" or "worse" for all sources/people...