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

Closed Thread
 
Thread Tools Search this Thread Display Modes
Old 19th June 2010, 00:48   #1  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
[2-pass] Inaccurate average bitrate

x264 r1649 (64bit) from x264.nl

Avatar BD
Code:
C:\>"C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\avs2yuv\pipebuf.exe" "C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\avs2yuv\avs2yuv.exe" "C:\temp\RipBot264temp\job1\job1.avs" - : "C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\x264\x264_x64.exe" --pass 1 --bitrate 2966 --stats "C:\temp\RipBot264temp\job1\job1.stats" --fps 24000/1001 --force-cfr  --min-keyint 24 --keyint 240 --frames 232606 --sar 1:1 --level 4.0 --aud --nal-hrd vbr --vbv-bufsize 25000 --vbv-maxrate 25000 --filter 0,0 --ref 3  --bframes 3 --b-adapt 1   --b-pyramid none --subme 7 --aq-mode 1 --trellis 1 --partitions all --me umh --stdin y4m --output "C:\temp\RipBot264temp\video.264" - : 2 
y4m [info]: 1280x720p 1:1 @ 10000000/417083 fps (cfr)
x264 [info]: using SAR=1/1
x264 [warning]: VBV bitrate (25000) > level limit (20000)
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile Main, level 4.0
C:\temp\RipBot264temp\job1\job1.avs: 1280x720, 10000000/417083 fps, 232606 frames                                                                          
x264 [info]: frame I:2585  Avg QP:21.94  size: 77743
x264 [info]: frame P:127011 Avg QP:25.21  size: 22405
x264 [info]: frame B:103010 Avg QP:27.13  size:  5309
x264 [info]: consecutive B-frames: 23.2% 46.3% 14.5% 15.9%
x264 [info]: mb I  I16..4: 33.5%  0.0% 66.5%
x264 [info]: mb P  I16..4: 21.5%  0.0%  0.0%  P16..4: 57.7%  0.0%  0.0%  0.0%  0.0%    skip:20.8%
x264 [info]: mb B  I16..4:  1.8%  0.0%  0.0%  B16..8: 24.4%  0.0%  0.0%  direct: 6.7%  skip:67.1%  L0:28.1% L1:49.6% BI:22.4%
x264 [info]: final ratefactor: 22.92
x264 [info]: coded y,uvDC,uvAC intra: 41.4% 46.3% 15.8% inter: 19.1% 13.6% 1.6%
x264 [info]: i16 v,h,dc,p: 31% 22% 24% 23%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 20% 20% 18%  4% 10%  6%  7%  6%  8%
x264 [info]: i8c dc,h,v,p: 57% 18% 19%  6%
x264 [info]: Weighted P-Frames: Y:3.2%
x264 [info]: kb/s:2963.25

encoded 232606 frames, 15.37 fps, 2963.25 kb/s

C:\>"C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\avs2yuv\pipebuf.exe" "C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\avs2yuv\avs2yuv.exe" "C:\temp\RipBot264temp\job1\job1.avs" - : "C:\Users\Dawid\Documents\Delphi_Projects\RipBot264\tools\x264\x264_x64.exe" --pass 2 --bitrate 2966 --stats "C:\temp\RipBot264temp\job1\job1.stats" --fps 24000/1001 --force-cfr  --min-keyint 24 --keyint 240 --frames 232606 --sar 1:1 --level 4.0 --aud --nal-hrd vbr --vbv-bufsize 25000 --vbv-maxrate 25000 --filter 0,0 --ref 3  --bframes 3 --b-adapt 1   --b-pyramid none --subme 7 --aq-mode 1 --trellis 1 --partitions all --me umh --stdin y4m --output "C:\temp\RipBot264temp\video.264" - : 2 
y4m [info]: 1280x720p 1:1 @ 10000000/417083 fps (cfr)
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 Cache64
x264 [info]: profile High, level 4.0
C:\temp\RipBot264temp\job1\job1.avs: 1280x720, 10000000/417083 fps, 232606 frames                                                                            
x264 [info]: frame I:2585  Avg QP:24.86  size: 58349
x264 [info]: frame P:127011 Avg QP:26.49  size: 22757
x264 [info]: frame B:103010 Avg QP:28.91  size:  5485
x264 [info]: consecutive B-frames: 23.2% 46.3% 14.5% 15.9%
x264 [info]: mb I  I16..4: 14.4% 68.0% 17.6%
x264 [info]: mb P  I16..4:  2.4%  9.5%  2.0%  P16..4: 42.2% 11.8%  2.7%  0.4%  0.3%    skip:28.7%
x264 [info]: mb B  I16..4:  0.3%  1.0%  0.1%  B16..8: 40.3%  5.0%  1.0%  direct: 1.6%  skip:50.6%  L0:37.2% L1:57.8% BI: 5.1%
x264 [info]: 8x8 transform intra:68.5% inter:74.9%
x264 [info]: coded y,uvDC,uvAC intra: 62.4% 65.1% 32.2% inter: 18.3% 15.8% 2.3%
x264 [info]: i16 v,h,dc,p: 32% 19%  8% 41%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 15% 14% 15%  7% 10% 10% 10%  9%  9%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 16% 13%  7% 12% 10% 11%  7%  7%
x264 [info]: i8c dc,h,v,p: 57% 17% 18%  8%
x264 [info]: Weighted P-Frames: Y:3.7%
x264 [info]: ref P L0: 62.4% 22.4% 10.5%  4.4%  0.3%
x264 [info]: ref B L0: 93.1%  6.9%
x264 [info]: kb/s:2973.73

encoded 232606 frames, 11.83 fps, 2973.73 kb/s
Atak_Snajpera is offline  
Old 19th June 2010, 00:54   #2  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
You're complaining about an inaccuracy of 0.26%? Seriously? Is this some kind of practical joke?

Last edited by Dark Shikari; 19th June 2010 at 09:03.
Dark Shikari is offline  
Old 19th June 2010, 07:09   #3  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
This is not a one case http://forum.doom9.org/showthread.ph...19#post1409119
Accuracy is crucial for AVCHD. BTW. Shouldn't be more accurate with longer footage?

Last edited by Atak_Snajpera; 19th June 2010 at 07:15.
Atak_Snajpera is offline  
Old 19th June 2010, 07:11   #4  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Atak_Snajpera View Post
Of course it's not. x264 is not designed to get 99.99999999999% accuracy on bitrate.
Quote:
Originally Posted by Atak_Snajpera View Post
Accuracy is crucial for AVCHD.
Then I suggest you stop using x264 and instead use your magical psychic encoder from space.

Last edited by Dark Shikari; 19th June 2010 at 09:06.
Dark Shikari is offline  
Old 19th June 2010, 08:26   #5  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
@Atak_Snajpera: try to lower qcomp to 0.5 (helped me)
__________________
Hybrid here in the forum, homepage
Selur is offline  
Old 19th June 2010, 08:31   #6  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Selur View Post
@Atak_Snajpera: try to lower qcomp to 0.5 (helped me)
Lowering qcomp should not affect this at all. If it does, it's sheer dumb luck. It's no different from any other trivial modification to settings -- it's rerolling the dice on something that is 100% random.

Last edited by Dark Shikari; 19th June 2010 at 09:02.
Dark Shikari is offline  
Old 19th June 2010, 08:46   #7  |  Link
Selur
Registered User
 
Selur's Avatar
 
Join Date: Oct 2001
Location: Germany
Posts: 7,259
than I just had 'sheer dumb luck'
__________________
Hybrid here in the forum, homepage
Selur is offline  
Old 19th June 2010, 08:51   #8  |  Link
AnonCrow
Registered User
 
Join Date: Aug 2009
Location: 61.45° , 23.86°
Posts: 120
Might also consider a slower preset , 3/n-pass encoding or even slow-firstpass.
AnonCrow is offline  
Old 19th June 2010, 11:58   #9  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by AnonCrow View Post
Might also consider a slower preset , 3/n-pass encoding or even slow-firstpass.
I don't think using three passes helps here.

It probably would help, if x264 didn't hit the desired target bitrate by accident, i.e. x264 is off by more than what is to be expected. But in this case the deviation from the target bitrate is within the expected range. x264 intentionally doesn't hit the target bitrate 100% exact, because (as far as I know) enforcing the bitrate too strictly would hurt quality. So if you do a third (or even forth pass), x264 still won't hit the bitrate 100% accurate, as it still doesn't try to. I assume using "--slow-firstpass" won't help either, for the very same reason. I wonder if "--ratetol" has an effect on 2-Pass...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 19th June 2010 at 12:03.
LoRd_MuldeR is offline  
Old 19th June 2010, 12:14   #10  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Yes, --ratetol has an effect on 2-pass and does exactly what you think it does: affect how aggressively x264 tries to hit the target
Dark Shikari is offline  
Old 19th June 2010, 12:16   #11  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Quote:
Originally Posted by Dark Shikari View Post
Yes, --ratetol has an effect on 2-pass and does exactly what you think it does: affect how aggressively x264 tries to hit the target
Then this should be solution here, right ???
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊
LoRd_MuldeR is offline  
Old 19th June 2010, 12:23   #12  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by LoRd_MuldeR View Post
Then this should be solution here, right ???
Of course.

There is a way that x264 can be improved here slightly though. Currently the rate tolerance converges to zero towards the end of the video. But this isn't useful if the end of the video has no bits to adjust anyways (e.g. all black, like the end of the credits). So I've made a commit locally to do the adjustment based on the position in the video bit-wise instead of frame-wise. This reduced misprediction by 50% on a quick contrived test case.
Dark Shikari is offline  
Old 19th June 2010, 21:28   #13  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
Quote:
You're complaining about an inaccuracy of 0.26%? Seriously? Is this some kind of practical joke?
I wouldn't complain if bitrate was 8kbps below. The real joke is that average Joe instead of ~4473MB gets 4483MB. Now try to put this on DVD+R without cutting.
Atak_Snajpera is offline  
Old 19th June 2010, 21:35   #14  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Atak_Snajpera View Post
I wouldn't complain if bitrate was 8kbps below. The real joke is that average Joe instead of ~4473MB gets 4483MB. Now try to put this on DVD+R without cutting.
Then stop trying to cut it so close. If your software can't author a DVD because it chose too high a bitrate, it isn't x264's fault.
Dark Shikari is offline  
Old 19th June 2010, 22:24   #15  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
Quote:
If your software can't author a DVD because it chose too high a bitrate, it isn't x264's fault.
DVD-SL is treated as 4480 MB instead of 4482.62 MB. When encoder is able to not go above calculated bitrate then final size is ALWAYS below 4480MB. Look at my example.
2966 kbps / 2974 kbps = 0.9973100201748487 * 4483 MB (<- size with 2974kbps) = 4471 MB
Atak_Snajpera is offline  
Old 19th June 2010, 22:47   #16  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by Atak_Snajpera View Post
DVD-SL is treated as 4480 MB instead of 4482.62 MB. When encoder is able to not go above calculated bitrate then final size is ALWAYS below 4480MB. Look at my example.
2966 kbps / 2974 kbps = 0.9973100201748487 * 4483 MB (<- size with 2974kbps) = 4471 MB
Sorry, I give up. You refuse to read a single post that I write, so I'm not going to bother writing them for you.
Dark Shikari is offline  
Old 19th June 2010, 22:57   #17  |  Link
Atak_Snajpera
RipBot264 author
 
Atak_Snajpera's Avatar
 
Join Date: May 2006
Location: Poland
Posts: 7,806
I give up as well Your Highness. Obviously We are not on the same page.

Last edited by Atak_Snajpera; 19th June 2010 at 23:01.
Atak_Snajpera is offline  
Old 19th June 2010, 23:10   #18  |  Link
Audionut
Registered User
 
Join Date: Nov 2003
Posts: 1,281
Yeah, If I'm encoding for media I always leave enough room.

So If the bitrate calc says encode at 3460, I'll encode it at 3400.
Honestly, 60kb/s is neither here nor there when aiming for size.
And I know I won't have to re-encode because the encoder overshoot the bitrate.

Quote:
Originally Posted by LoRd_MuldeR View Post
x264 intentionally doesn't hit the target bitrate 100% exact, because (as far as I know) enforcing the bitrate too strictly would hurt quality.
Having the encoder hit the exact bitrate would hurt the quality as LM stated.
So, the way x264 works, shaving a few kb/s off the encode and having that encode hit 2950, is better than an encoder made to hit 2966 exactly.
It just means that the end user has to apply a little common sense.

Besides, I challenge you 2 find the difference in quality between 2966 and 29??
__________________
http://www.7-zip.org/

Last edited by Audionut; 19th June 2010 at 23:24.
Audionut is offline  
Old 19th June 2010, 23:47   #19  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,988
LOL why don't you just undershoot the bitrate by like 1%??? I always do at least this much when I'm preparing stuff for optical media.

Derek
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline  
Old 20th June 2010, 00:43   #20  |  Link
Groucho2004
 
Join Date: Mar 2006
Location: Barcelona
Posts: 5,034
Quote:
Originally Posted by Atak_Snajpera View Post
Obviously We are not on the same page.
Clearly.

If you don't like the fact that x264 doesn't hit the target bitrate exactly, why don't you use ratetol as suggested? If this doesn't satisfy you - like you're getting 4789.01 Kbps instead of 4789.0 Kbps - how about looking for a different encoder that can do it better?
Groucho2004 is offline  
Closed Thread

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 01:07.


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