PDA

View Full Version : My x264 Options


MMoudry
18th October 2007, 09:32
Hi,
I am encoding video at home on a linux server and I would like to check with you guys here my options. I don't care about speed at all, the goal is maximum quality and minumum size. Can you please provide feedback on the options listed below? I would like to know if I should add some option or have it configured differentely (I am using x264 version Ubuntu Feisty) :

pass=1
bitrate=2035
subq=7
frameref=16
mixed-refs
direct=auto
b-rdo
weightb=1
bime=1
me=umh
trellis=1
partitions=all
8x8dct=1
bframes=4
b_adapt
b_pyramid
weight_b
qcomp=0.8
threads=auto

Thanks,

MMourdy

J_Darnley
18th October 2007, 10:49
Are you really only doind one pass? Target bitrate will give much better quality with two passes. If you really want to do one pass use cq or crf as the rate control method. Is there a reason you aren't using 16 b-frames? More b-frames don't increase the encoding or decoding time much. I switched from 3 to 16 (max) when I learned and did a quick test of this.

salehin
18th October 2007, 11:30
Your goal to achieve 'maximum quality and minumum size' don't go together. You have to find a middle ground based on your preference of quality or size. I don't have linux, so what follows are based around windows xp sp2. Start off with selecting HQ Slower profile. Now try the following customisation on HQ-Slower profile:

o ColorCorrection(ColorMatrix):
Simple: If it's anything but 601 for SD or 709 for HD you should use it, make sure you always use it with source->dest arguments. The readme mentions BT.470 and 170M are the same as 601, so just refer back to it if you ever forget.
To make sure use AvsP (http://avisynth.org/qwerpoi/Overview.html)

o Resolution: Always use mod16 resolution for your output

o Deblocking: The best way to judge it is drag the file back and forth under AvsP with and without deblocking. Then seeing the preview you can easily decide what is best. Of course this applies only to those sources where it's not easy to determine what to choose. Always, look into fast, flashy and the most grainy sequences for macroblocks. And If so, you choose deblockings. See Small FAQ on Mpeg4 AVC deblocking (http://forum.doom9.org/showthread.php?p=810932) for more info
oo Deblock_QED (http://avisynth.org/mediawiki/Deblock_QED#Examples) A better deblocker than 'cpu = 4' for source with small amount of blockings.

Some Notes on Deblock_QED:

ooo Other required tools: Masktools2 (you should already have if you're using seesaw, lsf, soothe, etc.) and DCTFilter of Tom Barry
ooo If you intend to use Deblock_qed with HiDef contents then it requires an edit (hack), an extra stacking (http://forum.doom9.org/showthread.php?p=769131#post769131)
ooo Notes 1 (http://forum.doom9.org/showthread.php?p=799158#post799158)
ooo For extremely blocky stuff use this (http://forum.doom9.org/showthread.php?p=798026#post798026)


o If you intend to reach a top notch quality without thinking about file size, then try using crf 17-19 (http://forum.doom9.org/showthread.php?t=128695). But do note that sometimes, the outcome sizes can be very close the source file size, or sometimes even larger than the source. If that happens and you're not happy then either try using higher crf or do 2 pass encode. Consequently, this will result in higher *quants - less transparent (* = see below)

o Use custom matrix (aka, CQM) with weak adaptive quantization (aq). See corresponding CQM notes for some recommended aq values.
oo Sharktooth's (http://forum.doom9.org/showthread.php?t=96298)
oo *.mp4 guy (http://forum.doom9.org/showthread.php?p=887125#post887125)
oo Prestige CQM by *.mp4 guy (http://forum.doom9.org/showpost.php?p=989214&postcount=2)

o Always start off with using the least powerful sharpening filters. The idea is bring out background details slightly clear without introducing artificial sharpening. LSF (the customised one), Soothe comes my mind - see intro (http://hdbits.org/redir.php?url=http://forum.doom9.org/showthread.php?t=84196) and an example of settings (http://hdbits.org/redir.php?url=http://forum.doom9.org/showthread.php?p=1032304#post1032304)

o If you're denoising, make sure you're not softening the picture quality (PQ)- otherwise this will result in less transparent output

o Last but not the least always keep an eye on quants (aka, Avg QP) (http://forum.doom9.org/showthread.php?t=130531). This gives an overall idea of how transparent your encode is in relation to the source. Try to reach an avg quants of 17, especially in P frames. Going too below of 17 (i.e., dedicating more bitrate) is just a waste of encode time, space and bandwidth.

MMoudry
18th October 2007, 11:50
Thanks for your replies, actually I copy pasted the command from the first pass. Normally I always do two passes. Also the maximum quality / minimum size, I mean to say that I would like to get maximum quality for the specified bitrate (have the best optimization turned up to their higherst setting.).

I am reassured that you guys didn't find anything crazy in my options.

I thought the b-frames were specified by the frameref option, hmmm I'll look into it....

The ColorCorrection and deblocking are useful tips :)

Thanks for your feedback,

MMoudry

Atak_Snajpera
18th October 2007, 13:20
I am reassured that you guys didn't find anything crazy in my options.

frameref=16 ?!?!!? If you will see difference between 5 an 16 you must be a cyborg :) and also
subq=6 will be enough

bond
18th October 2007, 22:44
moved

Dark Shikari
18th October 2007, 23:42
frameref=16 ?!?!!? If you will see difference between 5 an 16 you must be a cyborg :) and also
subq=6 will be enough16 is very useful with anime sources (SSIM goes up by 1% per ref above 5-6). Otherwise though its useless.

Ranguvar
18th October 2007, 23:57
16 is very useful with anime sources (SSIM goes up by 1% per ref above 5-6). Otherwise though its useless.Beat me to it :p

neuron2
19th October 2007, 00:27
@Ranguvar

That is a "useless post" and you can be struck for it (rule 11). Don't do it again, please.

Adub
19th October 2007, 00:27
@salehin
Very nice post. Well organized, informative. Top notch. I even learned a few things, thanks.

Atak_Snajpera
19th October 2007, 01:14
16 is very useful with anime sources (SSIM goes up by 1% per ref above 5-6). Otherwise though its useless.

1% it's still too small to see it. But if you like waste time/energy go ahead.

akupenguin
19th October 2007, 01:26
The only thing that matters is compression gains per CPU time. If you discard a possible 1% improvement just because 1% isn't visible, then you might as well take a 1% quality reduction to save 1% bitrate for free. Because 1% isn't visible, right? So do it again...

Dark Shikari
19th October 2007, 03:34
1% it's still too small to see it. But if you like waste time/energy go ahead.1% is per ref. Therefore, 10 more refs = roughly 10% higher quality.

Sergey A. Sablin
19th October 2007, 08:30
1% is per ref. Therefore, 10 more refs = roughly 10% higher quality.

why the heck they limit maximum to 16 refs :rolleyes:

Dark Shikari
19th October 2007, 08:31
why the heck they limit maximum to 16 refs :rolleyes:Because the H.264 standard says so?

Also, even in anime, more than 16 refs would probably start to give less and less of an advantage :p

shirohamada
20th October 2007, 20:08
anything would help if you're encoding at 456kbps like me >_<

RaynQuist
21st October 2007, 02:18
16 is very useful with anime sources (SSIM goes up by 1% per ref above 5-6). Otherwise though its useless.

Do you still have your test results? The one test I did showed about 0.2% SSIM improvement per ref after 3.


?? ref, me range 16, subme 6, umh, trellis 1, b-rdo

time bitate SSIM avgPSNR glbPSNR I P B
1 ref 784 4024.66 0.9867304 47.000 45.583 22.23 24.37 23.96
2 ref 953 4025.05 0.9868495 47.049 45.628 22.11 24.34 23.95
3 ref 1091 4025.23 0.9869425 47.087 45.666 22.09 24.27 23.90
4 ref 1237 4025.27 0.9869638 47.097 45.678 22.02 24.24 23.88
5 ref 1421 4025.34 0.9869897 47.109 45.691 22.00 24.23 23.86
6 ref 1561 4025.32 0.9870155 47.120 45.701 22.02 24.21 23.83
7 ref 1708 4025.37 0.9870319 47.128 45.709 22.02 24.20 23.82
8 ref 1870 4025.28 0.9870465 47.132 45.720 22.02 24.18 23.79
12 ref 2555 4025.98 0.9871230 47.179 45.760 21.89 24.09 23.69
16 ref 3154 4026.08 0.9871446 47.199 45.771 21.86 24.07 23.66


Improvement

Time SSIM avgPSNR glbPSNR
1 ref 784 0.9867304 47.000 45.583
------------------------------------------------
2 ref 169 0.0001191 0.049 0.045
3 ref 138 0.0000930 0.038 0.038
4 ref 146 0.0000213 0.010 0.012
5 ref 184 0.0000259 0.012 0.013
6 ref 140 0.0000258 0.011 0.010
7 ref 147 0.0000164 0.008 0.008
8 ref 162 0.0000146 0.004 0.011


This is a 1080p anime op though; maybe 4Mbps is overkill.

Dark Shikari
21st October 2007, 05:39
Do you still have your test results? The one test I did showed about 0.2% SSIM improvement per ref after 3.


?? ref, me range 16, subme 6, umh, trellis 1, b-rdo

time bitate SSIM avgPSNR glbPSNR I P B
1 ref 784 4024.66 0.9867304 47.000 45.583 22.23 24.37 23.96
2 ref 953 4025.05 0.9868495 47.049 45.628 22.11 24.34 23.95
3 ref 1091 4025.23 0.9869425 47.087 45.666 22.09 24.27 23.90
4 ref 1237 4025.27 0.9869638 47.097 45.678 22.02 24.24 23.88
5 ref 1421 4025.34 0.9869897 47.109 45.691 22.00 24.23 23.86
6 ref 1561 4025.32 0.9870155 47.120 45.701 22.02 24.21 23.83
7 ref 1708 4025.37 0.9870319 47.128 45.709 22.02 24.20 23.82
8 ref 1870 4025.28 0.9870465 47.132 45.720 22.02 24.18 23.79
12 ref 2555 4025.98 0.9871230 47.179 45.760 21.89 24.09 23.69
16 ref 3154 4026.08 0.9871446 47.199 45.771 21.86 24.07 23.66


Improvement

Time SSIM avgPSNR glbPSNR
1 ref 784 0.9867304 47.000 45.583
------------------------------------------------
2 ref 169 0.0001191 0.049 0.045
3 ref 138 0.0000930 0.038 0.038
4 ref 146 0.0000213 0.010 0.012
5 ref 184 0.0000259 0.012 0.013
6 ref 140 0.0000258 0.011 0.010
7 ref 147 0.0000164 0.008 0.008
8 ref 162 0.0000146 0.004 0.011


This is a 1080p anime op though; maybe 4Mbps is overkill.That's an OP; usually they contain drastically more detail and motion, making more refs far less useful. Not all anime is the same anyways, so what I stated was a generalization to begin with.

Terranigma
21st October 2007, 17:30
b-frames are more beneficial than reference frames. Try getting x264 to use more (http://forum.doom9.org/showthread.php?p=1029256#post1029256) of them. :p