Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 15th November 2013, 12:32   #1  |  Link
xkfz007
Registered User
 
Join Date: Sep 2013
Posts: 38
What is the exactly CBR in x264?

Today I read some material from Internet about rate control of x264 and I learned what is the ABR mode. When only the param --bitrate is set, ABR mode is used. But I am confused about the CBR mode.
At first I think when the params --vbv-maxrate and --vbv-bufsize are set together with --bitrate , the CBR mode is used. Then I see these codes from x264:
Code:
  s += sprintf( s, " rc=%s mbtree=%d", p->rc.i_rc_method == X264_RC_ABR ?
                               ( p->rc.b_stat_read ? "2pass" : p->rc.i_vbv_max_bitrate == p->rc.i_bitrate ? "cbr" : "abr" )
                               : p->rc.i_rc_method == X264_RC_CRF ? "crf" : "cqp", p->rc.b_mb_tree );
Apparently, only the situation that vbv-maxrate equals bitrate, it is CBR. When the vbv-maxrate is greater than bitrate, it is still ABR mode. I want to confirm if it is correct.
xkfz007 is offline   Reply With Quote
Old 16th November 2013, 23:04   #2  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,988
If you just set --bitrate then the encoder will operate in unconstrained VBR.

If you set --vbv-maxrate and --vbv-bufsize to something basic like the H.264 High Profile @ Level 4.1 limitations, the encoder will still operate in ABR mode, but will constrain itself to not go outside these specifications.

If you set --vbv-maxrate to the same value as --bitrate, then the encoder will operate in CBR mode. Note, this is not hard CBR where every picture is the same size. That's a terrible idea, and is basically never necessary. --vbv-bufsize controls the size of the buffer - which allows for bitrate variance while still staying inside the CBR limitations. Also note, this is how every other encoder does CBR, so don't be frightened
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 17th November 2013, 11:39   #3  |  Link
xkfz007
Registered User
 
Join Date: Sep 2013
Posts: 38
@Blue_MiSfit
In my experience, if --bitrate is set , the ABR mode is on. And the final real bitrate will be towards the target, which is the value set by --bitrate. However, when --vbv-maxrate and --vbv-bufsize are included, the value of --bitrate is no longer the target. The final real bitrate will exceeds the --bitrate a lot and will not greateer than --vbv-maxrate.
xkfz007 is offline   Reply With Quote
Old 17th November 2013, 11:52   #4  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by xkfz007 View Post
In my experience, if --bitrate is set , the ABR mode is on. And the final real bitrate will be towards the target, which is the value set by --bitrate. However, when --vbv-maxrate and --vbv-bufsize are included, the value of --bitrate is no longer the target. The final real bitrate will exceeds the --bitrate a lot and will not greateer than --vbv-maxrate.
--bitrate should be the approximate target even with VBV. How many frames did your test clips have?
nm is offline   Reply With Quote
Old 18th November 2013, 02:20   #5  |  Link
xkfz007
Registered User
 
Join Date: Sep 2013
Posts: 38
@nm
In my test, 300 frames are used. if only --bitrate is used, the real bitrate differs the target about 10%. However, when vbv-related params are set, it is far more than 10%.
xkfz007 is offline   Reply With Quote
Old 18th November 2013, 07:12   #6  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by xkfz007 View Post
@nm
In my test, 300 frames are used. if only --bitrate is used, the real bitrate differs the target about 10%. However, when vbv-related params are set, it is far more than 10%.
300 frames is too short for ABR to converge in a meaningful and repeatable way given different content or settings. Did you try different clips? How about 3000 or 30000 frames?

If you really need to get closer to the target with ABR, you could use a lower --ratetol, such as 0.1. This will reduce quality though.
nm is offline   Reply With Quote
Old 18th November 2013, 10:16   #7  |  Link
xkfz007
Registered User
 
Join Date: Sep 2013
Posts: 38
@nm
I have tried about 25 sequences. Also 300 frames are used. For some sequences, the difference is about 1~3%,but for several sequences it is about 10%, even 15%.
About --ratetol, I have tried too. Indeed, it will improve the accuracy, leading to bad quality. About the accuracy, owing to the low delay of my application, it is unacceptable to converge after about 3000 frames(60s @fps=50).
The current ABR in x264 only used on Frame level, and when MB level is considered, the vbv-related params should be set. So I want to adjust the QP of each MB based on the QP decided by ABR in Frame level. However I have not find some useful methods. So it is appreciated if you could give me some suggestions. Thanks in advance.
xkfz007 is offline   Reply With Quote
Old 18th November 2013, 13:21   #8  |  Link
nm
Registered User
 
Join Date: Mar 2005
Location: Finland
Posts: 2,641
Quote:
Originally Posted by xkfz007 View Post
@nm
I have tried about 25 sequences. Also 300 frames are used. For some sequences, the difference is about 1~3%,but for several sequences it is about 10%, even 15%.
About --ratetol, I have tried too. Indeed, it will improve the accuracy, leading to bad quality. About the accuracy, owing to the low delay of my application, it is unacceptable to converge after about 3000 frames(60s @fps=50).
If you can't lower the target bitrate by 10% or 15% to compensate, sounds like you want CBR.


Quote:
Originally Posted by xkfz007 View Post
The current ABR in x264 only used on Frame level, and when MB level is considered, the vbv-related params should be set. So I want to adjust the QP of each MB based on the QP decided by ABR in Frame level.
Sorry, I'm not quite following you here. How exactly do you want to change the way macroblock QPs are decided? Why wouldn't you use VBV parameters?

Last edited by nm; 18th November 2013 at 13:23.
nm is offline   Reply With Quote
Old 19th November 2013, 02:09   #9  |  Link
xkfz007
Registered User
 
Join Date: Sep 2013
Posts: 38
@nm
I have tried one method, in which the SAD of the macroblock is used as the complexity and if the SAD is greater than the average, I increase the QP, and vice versa. My idea is to adjust the QP of each MB according to its complexity. And the principle is to move bits of some MBs to others. I hope this can reduce the bitrate or improve the quality of the frame. I think it is an obvious method which is easy to think about. But the tests results are not too good.
As you have mentioned before, the VBV-compliant CBR will reduce the quality and I don't want too much input params.
xkfz007 is offline   Reply With Quote
Reply

Tags
rate control, x264

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 19:54.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.