PDA

View Full Version : x264, good compromise quality/size


msm_007
3rd June 2009, 10:54
hi all,
I work with x264 on HD YUV files,
I want to find the command line that give a good compromise between quality and size
time of coding is not important for my case

I use this cmd:
./x264 --qp 24 --8x8dct --subme 6 --trellis 2 --me umh --mixed-refs --direct spatial --no-b-adapt --keyint 999 --scenecut -1 -o SOCCER_1_80_704x576_1.264 SOCCER_1_80_704x576_1.yuv

LoRd_MuldeR
3rd June 2009, 11:05
There are no "best" settings per definition. However it is highly recommended to use CRF instead of CQ!

Also if quality is more important than speed, use "--subme 9", replace "--no-b-adapt" with "--b-adapt 2", replace "--direct spatial" with "--direct auto", add "--bframe 5" plus "--refs 5" ("--mixed-refs" is useless with one single ref!) and remove "--keyint 999 --scenecut -1". If you have a lot of time to waste, you can raise "--merange" and/or use "--me esa" (or even "--me tesa").

Last but not least find the highest possible CRF value that still gives satisfactory quality. That will probably be the best quality/size trade-off you can find...

Chengbin
3rd June 2009, 13:23
One way to increase quality is to use subme 9

roozhou
3rd June 2009, 13:43
The quality gain from m6 to m9 can hardly be noticed by human eyes.

Chengbin
3rd June 2009, 13:49
The quality gain from m6 to m9 can hardly be noticed by human eyes.

I beg to differ.

subme 6 to 9 is one of the worthwhile noticeable improvements.

buzzqw
3rd June 2009, 14:00
subme 6 to 9 is one of the worthwhile noticeable improvements.
i agree, at least in file size

BHH

roozhou
3rd June 2009, 14:18
i agree, at least in file size

BHH

File size is not determined by subme.
You should compare two videos with same file size.

nakTT
3rd June 2009, 15:18
One way to increase quality is to use subme 9
Sorry for my noob question. Is "subme" = "Subpixel Refinement" as in the GUI? Thank you in advance.

neuron2
3rd June 2009, 15:21
Sorry for my noob question. Is "subme" = "Subpixel Refinement" as in the GUI? Thank you in advance. What GUI? Have you read the approriate documents?

nakTT
3rd June 2009, 15:51
What GUI? Have you read the approriate documents?
Here is the GUI screenshot:

http://img10.imageshack.us/img10/654/001top.th.jpg (http://img10.imageshack.us/my.php?image=001top.jpg)

I have read some info at:
http://mewiki.project357.com/wiki/X264_Settings
And its look like that "subme" = "Subpixel Refinement". Anyway just to get a confirmation from the experts here. Thanks.

kemuri-_9
3rd June 2009, 16:38
And its look like that "subme" = "Subpixel Refinement". Anyway just to get a confirmation from the experts here. Thanks.

use x264 --help and --longhelp for clarification on what the parameters mean, not some random gui.


-m, --subme <integer> Subpixel motion estimation and mode decision [6]

Kurtnoise
3rd June 2009, 18:05
use x264 --help and --longhelp for clarification on what the parameters mean, not some random gui.

?????

Manao
3rd June 2009, 20:37
File size is not determined by subme.
You should compare two videos with same file size. No ! How many will it have to be repeated. The only way to judge the efficiency of a setting is to encode with and without the setting at the same visual quality, and to compare the resulting filesize.

Apart from that, Lord_Mulder's answer was perfect (and the thread should have ended there...)

LoRd_MuldeR
3rd June 2009, 20:45
But it's practically impossible to create two files of the same quality. How do you define same quality? Certainly not by a metric like PSNR or SSIM - that was discussed enough, I think. And using your eyes it's almost impossible to define "same quality" in a reliable way. But what your eyes actually can do is to decide whether A looks better than B or vice versa. So you can create two files of the identical size, one with the setting enabled and one without it. And then you can decide whether that settings improved or degraded the quality at same size/bitrate (or didn't have any significant impact). This should be a valid and fair comparison! Isn't it? Of course we must use a reasonable bitrate for the comparision. Not one where both encodes look transparent anyway and also not one where both encodes look like crap...

Manao
3rd June 2009, 22:14
But what your eyes actually can do is to decide whether A looks better than B or vice versaNot when A and B are close from one another, which happens with most switches from x264 (when considered alone). So most of the time, you end up concluding nothing. Attempting to match the visual quality can be a long process, but one with which you can conclude something.

A proper methodology to test the setting X would be :
- create an anchor encoding without X, at a defined crf (close to the one you'll use)
- create several encoding with X, at several crfs, so that you have at least one encoding with X that is visually worse, and one that is visually better than the anchor.
- reduce as much as possible the uncertainty interval by refining the crfs of the worse and better encoding with X until they become almost indistinguishable from the anchor.

Once that is done, you have a bitrate interval with setting X enclosing - quality wise, an encoding without X. you can draw your conclusions. If you really have a lot of time to spend, you can do the same without X and draw a second interval around the anchor.

And, in the end, you are even able to tell "using setting X is x% better than not using it", which allows to compare different settings together.

LoRd_MuldeR
3rd June 2009, 22:46
Think I got your point :thanks:

roozhou
4th June 2009, 05:42
Anyway, I prefer MuldeR's method.

Here is my test. The souce is ~60sec short clip from an anime DVD.
1) 1st pass w/ crf 26 r1 m1
2) 2nd pass under bitrate 450 w/ subme 6 and subme 9 from the same stats file

The difference of resulting filesizes are below 0.1%. But subme 6 gave me 35.23fps and subme 9 gave me 19.50 fps in 2nd pass (x264 r1163 on E8400).
I don't think 45% decrease in encoding speed gives any noticeable quality improvement.

Here are the two encoded clip:
http://files.filefront.com/m9+vs+m6zip/;13850279;/fileinfo.html

IgorC
4th June 2009, 07:08
Of cource you removed settings data from stream.
Well, I think
1.mkv is subme6
2.mkv is subme9

I might be wrong but I prefer 2.mkv

gizzin
4th June 2009, 07:12
is crf just is good as 2pass? not refering to filesize, we know who wins that one...

roozhou
4th June 2009, 08:23
Of cource you removed settings data from stream.
Well, I think
1.mkv is subme6
2.mkv is subme9

I might be wrong but I prefer 2.mkv

Mmm... I'd like to ask those who said "subme 6 to 9 is one of the worthwhile noticeable improvements" to give the right answer.

buzzqw
4th June 2009, 09:02
The difference of resulting filesizes are below 0.1%. But subme 6 gave me 35.23fps and subme 9 gave me 19.50 fps in 2nd pass (x264 r1163 on E8400).
I don't think 45% decrease in encoding speed gives any noticeable quality improvement.

on longer sample (2hour) the difference % is more significative, and on 2cd rip or 4gb rip the video file size mean something

BHH

roozhou
4th June 2009, 09:57
on longer sample (2hour) the difference % is more significative, and on 2cd rip or 4gb rip the video file size mean something

BHH

Please prove it. IIRC when you use higher bitrate, the difference will be less noticeable.

And again comparison between different file sizes are meaningless. I am measuring the quality improvement of slower settings. If even at such low bitrate (450kbps for 480P) people cannot distinguish subme 6 and subme 9, how can there be "more sigificative" difference when using higher bitrate?

10L23r
5th June 2009, 02:33
If even at such low bitrate (450kbps for 480P) people cannot distinguish subme 6 and subme 9

its easy to distinguish differences... its a different thing to tell you which is which. i think 1.mkv is subme6 and 2.mkv is subme9. 2.mkv has noticeably less noise/artifacts near areas of motion, at least in the one frame that i looked at. not surprising cus the setting applies to motion estimation, and because of this, you may want to redo the test with a source with more motion. or u can reduce the bitrate even further to make differences more obvious

roozhou
5th June 2009, 09:00
I know animes contains less motion than real actions, but 450kbps is quite low for 480P encode even for animes. Both encodes look bad for me and I cannot tell which is worse.

If lower bitrate is needed, we should first downscale to a lower resolution.