Log in

View Full Version : Which rate control method does x264 use? Is it 2-pass?


rubypin
23rd May 2006, 14:58
2-pass is time-consuming, so can x264 acheive real-time?

or who can tell me what's the r-c steps used in x264?

bkman
23rd May 2006, 16:10
Afaik, x264 can do

1-Pass:
CBR (Constant Bitrate)
ABR (Average Bitrate)
CQ (Constant Quantiser)
CRF (Constant Quality)
2-Pass:
ABR
3-Pass:
ABR
n-Pass:
ABR

imcold
23rd May 2006, 17:13
encoding is time-consuming, if you select all the options that noticeably slow it down :D
I got about 3x-4x higher fps when turning off / lowering some options.

unmei
23rd May 2006, 17:44
there is not special CBR mode, but you can force the (average-) bitrate mode to behave as CBR by restricting its variability down to none

rubypin
24th May 2006, 03:28
so what's the difference between x264 and jm in r-c? I want to know more details in x264 r-c, thanks~~~

imcold
24th May 2006, 03:49
x264's ratecontrol description by Loren Merritt (http://trac.videolan.org/x264/browser/trunk/doc/ratecontrol.txt?format=txt)
(btw. Loren do you mind hotlinking or I should host the file elsewhere and give link to that place? )

akupenguin
24th May 2006, 05:05
Links are fine. Just because I don't bother with pretty cover pages doesn't make it not a website.
Note, however, that that particular document is also included in the x264 repository, so the videolan page (http://trac.videolan.org/x264/browser/trunk/doc/ratecontrol.txt?format=txt) might be a better url.

xyloy
25th May 2006, 16:55
H.264 allows each macroblock to have a different QP. x264 does not do so. Ratecontrol returns one QP which is used for the whole frame.
Is it still true ?

imcold
25th May 2006, 18:29
Yes. Only adaptive quantization patches assign different qp-s to macroblocks within one frame.

akupenguin
25th May 2006, 21:48
Macroblock-level ratecontrol is now done in CBR mode only. (ratecontrol.txt ignores psy adaptive quant, that's separate from ratecontrol.)

rubypin
22nd August 2006, 08:57
x264 can do
1 pass:
CBR ABR CQ CRF
2 pass:
ABR
n pass:
ABR

but how to set paraments to choose the mode?
rc.b_cbr,
rc.b_stat_write,
rc.b_stat_read,
rc.b_abr.
rc.b_2pass

is: rc.b_cbr = 0 ------ 1 pass CQ
rc.b_abr = 1 ------ 1 pass ABR
rc.b_2pass = 1 ------ 2 pass ABR ?

but how to set 1pass-CBR/CRF and n-pass ?
who can tell me the detail?

is 1pass in x264 samilar to JVT-G012, 2pass samilar to F086?

rubypin
22nd August 2006, 09:59
I use 2pass ,set i_bitrate=1000,encode 20 frames,the sequence is IPPPP... the result is:

x264 [info]: slice I:1 Avg QP:13.00 Avg size: 11528 PSNR Mean Y:48.67 U:49.35
V:50.12 Avg:48.99 Global:48.99
x264 [info]: slice P:19 Avg QP:14.00 Avg size: 4447 PSNR Mean Y:46.27 U:46.64
V:48.08 Avg:46.58 Global:46.58
x264 [info]: slice I Avg I4x4:98.0% I16x16:2.0%
x264 [info]: slice P Avg I4x4:0.2% I16x16:1.0% P:63.3% P8x8:35.5% PSKIP:0.
1%
x264 [info]: PSNR Mean Y:46.39 U:46.77 V:48.18 Avg:46.71 Global:46.68 kb/s:960.1

encoded 20 frames, 8.89 fps, 960.29 kb/s

size of each frame is:

11429 4070 4345 4487 4574 4542 4584 4551.....

my question is: what is the ralationship between i_bitrate=1000 and frame size about 4000?

unmei
22nd August 2006, 19:23
my question is: what is the ralationship between i_bitrate=1000 and frame size about 4000?

Just an observation:
if you assume 25 FPS,
bitrate 1000 = 1000000 bit/s -> /25 -> 40000 bit/frame -> 5000 byte/ frame.
In your small sequence, if you include the larger first frame, that about matches.

The second part of your question, i don't understand and suspect i couldn't answer even if i understood.

Mug Funky
23rd August 2006, 05:02
btw, i noticed that the V channel always (?) has a fair bt higher PSNR. would it be possible to hit it a little harder and save some bits? or is that outside the scope of x264's ratecontrol?

akupenguin
23rd August 2006, 06:20
--chroma-qp-offset
Note that chroma is normally 3-10% of the total bitrate (depending on content), so there isn't all that much to save.

rubypin
24th August 2006, 03:52
but how to set paraments to choose the rc mode?

rc.b_cbr,
rc.b_stat_write,
rc.b_stat_read,
rc.b_abr.
rc.b_2pass

is: rc.b_cbr = 0 ------ 1 pass CQ
rc.b_abr = 1 ------ 1 pass ABR
rc.b_2pass = 1 ------ 2 pass ABR ?

but how to set 1pass-CBR/CRF and n-pass ?
who can tell me the detail?

is 1pass in x264 samilar to JVT-G012, 2pass samilar to F086?[/QUOTE]

rubypin
8th September 2006, 09:52
there is not special CBR mode, but you can force the (average-) bitrate mode to behave as CBR by restricting its variability down to none

in the programe, i found four models, i consider it as:
if(i_force_qp) ......................all frames use the sanme QP
else if (rc->b_abr)......................1 pass abr
else if(rc->b_2pass)....................2 pass abr
else /*CQP*/ ...........................1 pass cqp

am i right?
the params i set is: (i dont know if they are correct)
CQP: --fps 25 --seek 0 --frames 20 --qcomp 0.6 --qp 26 -r 1

1pass abr: -B 1500 --vbv-maxrate 1500 --vbv-bufsize 1500 --pass 1 --stats "2pass.log" --fps 25 --seek 0 --frames 20 --qcomp 0.6 --qp 26 -r 1(when do not use vbv-maxrate and vbv-bufsize the result reduces a little, about 0.04db, is this also 1pass cbr?)

2pass abr: -B 1500 --vbv-maxrate 1500 --vbv-bufsize 1500 --pass 2 --stats "2pass.log" --fps 25 --seek 0 --frames 20 --qcomp 0.6 --qp 26 -r 1

result is:
CQP: PSNR Mean Y:37.36 U:40.28 V:41.99 Avg:38.28 Global:38.22 kb/s:167.3

1pass abr:PSNR Mean Y:47.27 U:47.89 V:48.69 Avg:47.54 Global:45.98 kb/s:1217.7

2pass abr:PSNR Mean Y:49.48 U:49.65 V:50.02 Avg:49.60 Global:49.57 kb/s:1494.0

question 1: is this your mean by "there is not special CBR mode"? i didn't find the 1pass cbr mode.

question 2: and i read x264 also can do "--crf constant ratefactor", i also didin't find how to set it, i use the 20050530 vesion, is it because my vesion is too low?

rbt01
9th October 2007, 10:02
what's the meaning of zone in x264 ratecontrol.c, such as parse_zones() function?
it's also an option of x264 CLI, --zones <zone0>/<zone1>/... Tweak the bitrate of some regions of the video

how to use it, anybody can explain it for me, thanks.

Gabriel_Bouvigne
9th October 2007, 13:49
Suggestion: try asking only 1 question each time, otherwise some people could have a hard time figuring out what you want.

If you want to know if x264 is able to use multi-pass rate control, the answer is yes.
If you want to know if it can encode in real time, the answer is likely yes, but of course you would have to reduce quality.

CBR mode: CBR means that you chosed a CPB value, and are using a max bitrate identical to the target bitrate.

Gabriel_Bouvigne
9th October 2007, 13:52
i use the 20050530 vesion, is it because my vesion is too low?
Are you serious there? A version more than 2 years old? You will likely have a hard time finding people explaining you how x264 was working 2 years ago.

nm
9th October 2007, 14:02
Note that rubypin's question was posted over a year ago.

Gabriel_Bouvigne
9th October 2007, 15:18
Note that rubypin's question was posted over a year ago.
I've been fooled by the thread bumping, and thought that it was a new thread...

foxyshadis
9th October 2007, 16:37
rbt, don't bump old threads to ask unrelated questions and don't crosspost your question. If you feel you made an error, delete your post or pm a moderator! (You can also use the report button to do this.)