Log in

View Full Version : broken bitrate control in x264 rev736 (Megui update server version)?!


Wishbringer
19th February 2008, 17:03
I am trying to convert some hdtv broadcast streams to PS3 compatible mp4 files.
So resulting filesize has to be below 4GB.
I do no resize, only cropping for example from 1920x1088 to 1920x1040(816) - removing black borders.

Using MeGUI PS3 predefined profile.

Example (2pass):
While trying to archive a bitrate of 4510 kb/s, x264 produces a file with an bitrate of 5214 kb/s videostream.
Around 15% oversized!

Version of x264 on MeGUI update server is no plain svn build, it includes some patches: vbv, AQ, hrd etc.

talen9
19th February 2008, 17:11
You already answered yourself: the version you're using contains the AQ patch, which is not extremely bitrate-accurate.

If you want a more accurate rate control, pass the option "--aq-strength 0" in the "Custom commandline" in the "Zones" tab of x264 profile configuration, though this will disable the new AQ algorihtm ;)

Dark Shikari
19th February 2008, 17:15
You already answered yourself: the version you're using contains the AQ patch, which is not extremely bitrate-accurate.In twopass mode it should be no more or less bitrate-accurate than without AQ.

Sharktooth
19th February 2008, 17:32
I am trying to convert some hdtv broadcast streams to PS3 compatible mp4 files.
So resulting filesize has to be below 4GB.
I do no resize, only cropping for example from 1920x1088 to 1920x1040(816) - removing black borders.

Using MeGUI PS3 predefined profile.

Example (2pass):
While trying to archive a bitrate of 4510 kb/s, x264 produces a file with an bitrate of 5214 kb/s videostream.
Around 15% oversized!

Version of x264 on MeGUI update server is no plain svn build, it includes some patches: vbv, AQ, hrd etc.
did you aim for a specfic bitrate or filesize?
also :logfile:

Wishbringer
19th February 2008, 18:02
did you aim for a specfic bitrate or filesize?
also :logfile:

After recode AC3 to AAC-LC I used MeGUI Bitrate calculator to get bitrate for 4GB filesize: Calculator gave me 4510 kb/s what I inserted into 2-pass mode in profile.

1st pass:

--[NoImage] Job commandline: "C:\Program Files (x86)\megui\tools\x264\x264.exe" --pass 1 --bitrate 4510 --stats "D:\Filme\City.stats" --level 4.1 --bframes 3 --direct auto --subme 1 --analyse none --vbv-bufsize 9000 --vbv-maxrate 24000 --me dia --threads auto --thread-input --sar 1:1 --progress --output NUL "D:\Filme\City.avs"
--[Information] [19.02.2008 07:52:49] Encoding started
--[NoImage] Standard output stream
--[NoImage] Standard error stream
---[NoImage] avis [info]: 1920x1040 @ 25.00 fps (178428 frames)
---[NoImage] x264 [info]: using SAR=1/1
---[NoImage] x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 Cache64
---[NoImage] x264 [info]: slice I:1390 Avg QP:20.22 size: 64362 PSNR Mean Y:48.74 U:55.61 V:57.37 Avg:49.85 Global:44.93
---[NoImage] x264 [info]: slice P:66641 Avg QP:20.68 size: 28158 PSNR Mean Y:48.22 U:54.87 V:55.66 Avg:49.22 Global:43.33
---[NoImage] x264 [info]: slice B:110397 Avg QP:20.39 size: 5469 PSNR Mean Y:53.01 U:57.99 V:58.45 Avg:53.64 Global:43.96
---[NoImage] x264 [info]: mb I I16..4: 59.2% 0.0% 40.8%
---[NoImage] x264 [info]: mb P I16..4: 20.3% 0.0% 0.0% P16..4: 29.1% 0.0% 0.0% 0.0% 0.0% skip:50.6%
---[NoImage] x264 [info]: mb B I16..4: 1.6% 0.0% 0.0% B16..8: 9.7% 0.0% 0.0% direct: 4.0% skip:84.7%
---[NoImage] x264 [info]: final ratefactor: 22.16
---[NoImage] x264 [info]: direct mvs spatial:51.6% temporal:48.4%
---[NoImage] x264 [info]: SSIM Mean Y:0.9814132
---[NoImage] x264 [info]: PSNR Mean Y:51.191 U:56.808 V:57.400 Avg:51.963 Global:43.723 kb/s:2880.39
---[NoImage] encoded 178428 frames, 24.97 fps, 2884.73 kb/s


2nd pass:

--[NoImage] Job commandline: "C:\Program Files (x86)\megui\tools\x264\x264.exe" --pass 2 --bitrate 4510 --stats "D:\Filme\City.stats" --level 4.1 --ref 3 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --ipratio 1.1 --pbratio 1.1 --vbv-bufsize 9000 --vbv-maxrate 24000 --qcomp 0.5 --me umh --merange 12 --threads auto --thread-input --sar 1:1 --progress --output "D:\Filme\City_video.mp4" "D:\Filme\City.avs"
--[Information] [19.02.2008 09:51:57] Encoding started
--[NoImage] Standard output stream:
--[NoImage] Standard error stream
---[NoImage] avis [info]: 1920x1040 @ 25.00 fps (178428 frames)
---[NoImage] x264 [info]: using SAR=1/1
---[NoImage] x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 SSE3 SSSE3 Cache64
---[NoImage] mp4 [info]: initial delay 1 (scale 25)
---[NoImage] x264 [warning]: VBV underflow (-106768 bits)
---[NoImage] x264 [warning]: VBV underflow (-168952 bits)
---[NoImage] x264 [warning]: VBV underflow (-109776 bits)
---[NoImage] x264 [info]: slice I:1390 Avg QP:18.85 size: 91753 PSNR Mean Y:46.56 U:54.05 V:56.02 Avg:47.96 Global:46.50
---[NoImage] x264 [info]: slice P:66641 Avg QP:22.23 size: 46879 PSNR Mean Y:43.59 U:51.60 V:52.88 Avg:45.00 Global:44.02
---[NoImage] x264 [info]: slice B:110397 Avg QP:27.25 size: 12663 PSNR Mean Y:41.97 U:50.93 V:52.43 Avg:43.44 Global:42.40
---[NoImage] x264 [info]: mb I I16..4: 29.7% 56.1% 14.3%
---[NoImage] x264 [info]: mb P I16..4: 9.4% 17.7% 3.0% P16..4: 37.2% 7.4% 2.5% 0.0% 0.0% skip:22.7%
---[NoImage] x264 [info]: mb B I16..4: 1.9% 2.9% 0.3% B16..8: 32.4% 0.9% 1.3% direct: 1.4% skip:58.8%
---[NoImage] x264 [info]: 8x8 transform intra:58.1% inter:60.5%
---[NoImage] x264 [info]: direct mvs spatial:48.5% temporal:51.5%
---[NoImage] x264 [info]: ref P 73.8% 16.2% 10.1%
---[NoImage] x264 [info]: ref B 86.2% 13.8%
---[NoImage] x264 [info]: SSIM Mean Y:0.9769413
---[NoImage] x264 [info]: PSNR Mean Y:42.608 U:51.207 V:52.626 Avg:44.060 Global:42.959 kb/s:5211.62
---[NoImage] encoded 178428 frames, 7.31 fps, 5214.64 kb/s
--[Information] Final statistics
---[NoImage] Desired video bitrate: 4510 kbit/s
---[NoImage] Obtained video bitrate (approximate: 5216 kbit/s

Atak_Snajpera
19th February 2008, 18:24
Why do you encode to mp4 instead of m2ts (no 4gb limit + AC3) ????

Wishbringer
19th February 2008, 18:44
I did some trials with m2ts files (fitting on DVD-SL) and blu-ray structurs.
But I would have there too same problems archieving desired bitrate.
And atm all blu-ray muxing tools are still in alpha or beta phase... (ff and rev for example)

Atak_Snajpera
19th February 2008, 19:22
And atm all blu-ray muxing tools are still in alpha or beta phase... (ff and rev for example)

You need to add --aud switch in your command line !!! It solves problem with ff and rev.

But I would have there too same problems archieving desired bitrate.

use these settings

--pass 1 --bitrate xxxx --stats ".stats" --level 4.1 --sar 1:1 --aud --nal-hrd --vbv-bufsize 14000 --vbv-maxrate 25000 --filter 0,0 --bframes 3 --direct auto --subme 2 --analyse none --me dia --threads auto --thread-input --progress --no-psnr --no-ssim --output "video.264"

--pass 2 --bitrate xxxx --stats ".stats" --level 4.1 --sar 1:1 --aud --nal-hrd --vbv-bufsize 14000 --vbv-maxrate 25000 --filter 0,0 --ref 3 --mixed-refs --bframes 3 --b-rdo --bime --weightb --direct auto --subme 6 --trellis 1 --analyse p8x8,b8x8,i4x4,i8x8 --8x8dct --me umh --threads auto --thread-input --progress --no-psnr --no-ssim --output "video.264"

Wishbringer
19th February 2008, 21:18
Will try "--aud" tomorrow.
Is "--subme 2" better than "--subme 1" for first pass? Because "--subme 1" is default setting in MeGUI when "turbo" is enabled.

Atak_Snajpera
19th February 2008, 23:25
Is "--subme 2" better than "--subme 1" for first pass?

subme 2 gives better quality. subme 3 should be max.

talen9
19th February 2008, 23:39
In twopass mode it should be no more or less bitrate-accurate than without AQ.

Whoops! :o

I definitely missed something in the loooong VAQ thread, sorry DS :p

Gabriel_Bouvigne
20th February 2008, 09:45
That's not exactly a stock version of x264 that you are using, aren't you?
Can you tell more about it? (version, patches)

Wishbringer
20th February 2008, 09:55
It's the version from megui patch server (experimental).
Seems be equal to:
http://files.x264.nl/force.php?file=./x264.736.modified.02.exe

General thread:
http://forum.doom9.org/showthread.php?t=130364

x264_aq_var.48.diff
http://forum.doom9.org/showthread.php?t=132760
x264.gaussian.cplxblur.01.diff
Dark Shikari: - gaussian cplxblur: gives a tiny improvement in 2pass ratecontrol
x264_me-prepass_DeathTheSheep.01.diff
http://forum.doom9.org/showthread.php?p=1093523
x264_2pass_vbv.4.MatMaul.diff
http://mailman.videolan.org/pipermail/x264-devel/2008-January/004015.html
x264_hrd_pulldown.04_interlace.diff
- HRD and pulldown for HD compatibility, updated patch for interlacing
http://forum.doom9.org/showthread.php?p=1047919#post1047919

After that all, maybe I should have posted it in den MeGUI thread... because it's not a plain svn-build.
Maybe one of the following causes the oversize:
x264_aq_var.48.diff
http://forum.doom9.org/showthread.php?t=132760
-> shouldn't!

x264.gaussian.cplxblur.01.diff
Dark Shikari: - gaussian cplxblur: gives a tiny improvement in 2pass ratecontrol
-> could be

x264_hrd_pulldown.04_interlace.diff
- HRD and pulldown for HD compatibility, updated patch for interlacing
http://forum.doom9.org/showthread.php?p=1047919#post1047919
-> shouldn't, because i didn't use "--nal-hrd"

Snowknight26
21st February 2008, 01:33
subme 2 gives better quality. subme 3 should be max.

From what I've tested, subme 4 works best with grain.

Dark Shikari
21st February 2008, 02:26
From what I've tested, subme 4 works best with grain.It really shouldn't make much of a difference tbh...