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 29th August 2009, 17:56   #1  |  Link
jdobbs
Moderator
 
Join Date: Oct 2001
Posts: 20,973
X264 Pass Differences

I've been doing a lot of testing of Blu-ray reencodes using the X264 "--preset veryfast" setting and I noticed that in all my encodes the second pass is considerably faster than the first pass (~25fps compared to ~15fps). That seems to be the opposite of what I see in other presets. I'm sure there is a good reason, but I'm just not seeing it and its driving me nuts... I was just wondering if someone could explain it?

Here are my command lines -- almost identical except the first pass outputs to NUL.

Code:
"E:\BD_Rebuilder\tools\x264.exe" "E:\WORKING4\WORKFILES\VID_00102.AVS" --preset veryfast --bitrate 7114 
  --level 4.1 --sar 1:1 --fps 24000/1001 --aud --vbv-bufsize 25000 --keyint 24 --min-keyint 1 
  --ipratio 1.1 --pbratio 1.1 --vbv-maxrate 35000 --threads auto --thread-input 
  --stats "E:\WORKING4\WORKFILES\VID_00102.AVS.MKV.stats" --pass 1 
  --output NUL
"E:\BD_Rebuilder\tools\x264.exe" "E:\WORKING4\WORKFILES\VID_00102.AVS" --preset veryfast --bitrate 7114 
  --level 4.1 --sar 1:1 --fps 24000/1001 --aud --vbv-bufsize 25000 --keyint 24 --min-keyint 1 
  --ipratio 1.1 --pbratio 1.1 --vbv-maxrate 35000 --threads auto --thread-input 
  --stats "E:\WORKING4\WORKFILES\VID_00102.AVS.MKV.stats" --pass 2 
  --output "E:\WORKING4\WORKFILES\VID_00102.AVS.MKV"
I thought about the fact that fast first pass doesn't really have any effect with that preset, and that might contribute to the difference in behaviour with other higher quality presets -- but is seems like 10fps (60% speed difference) is a lot of delta between passes.
__________________
Help with development of new apps: Donations.
Website: www.jdobbs.net

Last edited by jdobbs; 29th August 2009 at 18:14.
jdobbs is offline   Reply With Quote
Old 29th August 2009, 18:14   #2  |  Link
shon3i
BluRay Maniac
 
shon3i's Avatar
 
Join Date: Dec 2005
Posts: 2,419
@jdobbs, sorry for ot but why use settings that are incompatible with Blu-ray standard like Level 4.1 require 4 or more slices. I know that maybe no one has ever had a problem with SAP, but why not follow the standard, btw you use vbv buffer 25000 which limits peak bitrate over 25mbps so vbv maxrate of Level 4.0 will not limit the quality anyway.

shon3i is offline   Reply With Quote
Old 29th August 2009, 18:19   #3  |  Link
jdobbs
Moderator
 
Join Date: Oct 2001
Posts: 20,973
Quote:
Originally Posted by shon3i View Post
@jdobbs, sorry for ot but why use settings that are incompatible with Blu-ray standard like Level 4.1 require 4 or more slices. I know that maybe no one has ever had a problem with SAP, but why not follow the standard, btw you use vbv buffer 25000 which limits peak bitrate over 25mbps so vbv maxrate of Level 4.0 will not limit the quality anyway.

No reason really, the slice requirement is something that I've never seen enforced anywhere -- so I ignore it. I guess it might come back to bite me at some point, like when they start putting more powerful processors on SAPs... if I remember correctly the vbv buffer size can change depending upon what I set for destination size, it just happened to be 25000 here.
__________________
Help with development of new apps: Donations.
Website: www.jdobbs.net

Last edited by jdobbs; 29th August 2009 at 18:26.
jdobbs is offline   Reply With Quote
Old 29th August 2009, 18:25   #4  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,248
Well, the frame-type decision is made in the first pass and as far as I know the "lookahead" part is still not multi-threaded. So it may be that serial part that makes your first pass slow.

So with "slower" presets this just doesn't show up, simply because all the rest is much slower. But when everything is speeded-up (as with "veryfast" preset), the lookahead can become the bottleneck easily...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 29th August 2009 at 18:29.
LoRd_MuldeR is offline   Reply With Quote
Old 29th August 2009, 18:29   #5  |  Link
jdobbs
Moderator
 
Join Date: Oct 2001
Posts: 20,973
Makes sense. Thanks.
__________________
Help with development of new apps: Donations.
Website: www.jdobbs.net
jdobbs is offline   Reply With Quote
Old 29th August 2009, 18:30   #6  |  Link
Snowknight26
Registered User
 
Join Date: Aug 2007
Posts: 1,430
The default is --b-adapt 1 still so I don't think that's the issue.
Snowknight26 is offline   Reply With Quote
Old 29th August 2009, 18:55   #7  |  Link
kemuri-_9
Compiling Encoder
 
kemuri-_9's Avatar
 
Join Date: Jan 2007
Posts: 1,348
the speed cost seen there is likely vbv-lookahead in combination with b-adapt 1.

according to
Code:
    h->param.rc.i_lookahead = x264_clip3( h->param.rc.i_lookahead, 0, X264_LOOKAHEAD_MAX );
    {
        int maxrate = X264_MAX( h->param.rc.i_vbv_max_bitrate, h->param.rc.i_bitrate );
        float bufsize = maxrate ? (float)h->param.rc.i_vbv_buffer_size / maxrate : 0;
        float fps = h->param.i_fps_num > 0 && h->param.i_fps_den > 0 ? (float) h->param.i_fps_num / h->param.i_fps_den : 25.0;
        h->param.rc.i_lookahead = X264_MIN( h->param.rc.i_lookahead, X264_MAX( h->param.i_keyint_max, bufsize*fps ) );
    }
the lookahead size in the above case would be set to
MIN( 40, MAX( 24, 35000/25000 * ~24 ) ) , so 33.

b-adapt 1 takes some time to perform and this should be noticeable compared to the rest of veryfast's settings when compounded with vbv-lookahead on a multicore processor.
__________________
custom x264 builds & patches | F@H | My Specs
kemuri-_9 is offline   Reply With Quote
Old 29th August 2009, 19:21   #8  |  Link
ajp_anton
Registered User
 
ajp_anton's Avatar
 
Join Date: Aug 2006
Location: Stockholm/Helsinki
Posts: 805
--preset veryfast includes --b-adapt 1 and --no-mbtree.
ajp_anton is offline   Reply With Quote
Old 29th August 2009, 19:23   #9  |  Link
Dark Shikari
x264 developer
 
Dark Shikari's Avatar
 
Join Date: Sep 2005
Posts: 8,666
Quote:
Originally Posted by ajp_anton View Post
--preset veryfast includes --b-adapt 1 and --no-mbtree.
But it still does VBV lookahead.

Remember, presets like "veryfast" are so fast that they're about the same speed as x264's "fast first pass" system, so the first pass will surely be slower--it simply does more work! (since the first pass does frametype does frametype decision)

At this point, it would be better to use ABR mode if trying to maximize performance.
Dark Shikari is offline   Reply With Quote
Old 29th August 2009, 20:04   #10  |  Link
jdobbs
Moderator
 
Join Date: Oct 2001
Posts: 20,973
Thanks to all. The explanation is appreciated.
__________________
Help with development of new apps: Donations.
Website: www.jdobbs.net

Last edited by jdobbs; 29th August 2009 at 20:07.
jdobbs is offline   Reply With Quote
Reply

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 05:50.


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