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 6th January 2019, 06:50   #21  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
Thanks so much friends for reading, and putting out of your time to reply, truly I'm honored, and in other ways I help the world too

Loved these answers, will try with --vbv-maxrate 49000 so it will possibly avoid "clipping" in those instants; interestingly, it only happens on few sources, so far 2 out of 15 or so produced this warning/error.

I'll report back once it happens again and the outcome...
stormy1777 is offline   Reply With Quote
Old 7th January 2019, 20:32   #22  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by stormy1777 View Post
Thanks so much friends for reading, and putting out of your time to reply, truly I'm honored, and in other ways I help the world too

Loved these answers, will try with --vbv-maxrate 49000 so it will possibly avoid "clipping" in those instants; interestingly, it only happens on few sources, so far 2 out of 15 or so produced this warning/error.

I'll report back once it happens again and the outcome...
Specify --vbv-bufsize as well; just maxrate doesn't do anything about peak bitrate. 49000 is a good value there as well; in HEVC the maximum peak bitrate and VBV size is identical for Main Tier profile@level combinations.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 7th January 2019, 20:37   #23  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
Okay, so next time it fails like that run it with:

Code:
--vbv-maxrate 49000 --vbv-bufsize 49000
Ok, thanks, will report back when it reproduces again, it seems to be HIGHLY source-dependent....
stormy1777 is offline   Reply With Quote
Old 7th January 2019, 22:24   #24  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by stormy1777 View Post
Okay, so next time it fails like that run it with:

Code:
--vbv-maxrate 49000 --vbv-bufsize 49000
Ok, thanks, will report back when it reproduces again, it seems to be HIGHLY source-dependent....
If you care about HW decoder compatibility, you should ALWAYS set --profile, --level, --vbv-maxrate, --vbv-bufsize, and make sure --ref isn't above the max allowed.

I can't think of a good use case for not setting those for lossy encodes.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 23rd January 2019, 10:50   #25  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
Finally got a source that appear to produce, while still using Level 4.1 for all encodes:

Code:
[!] x264 [warning]: MB rate (448800) > level limit (245760)
so, added to VD2 x264 configuration panel:

Code:
--vbv-maxrate 49000 --vbv-bufsize 49000
kept everything the SAME, re-encode failed with identical warning and produced a slightly larger file.. 71.9MB vs. 74.3MB.

Confirmed with MediaInfo that the flags are honored (the video component):

Code:
Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 48 s
Bit rate                                 : 3 378 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 55.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.030
Stream size                              : 67.7 MiB (91%)
Writing library                          : x264 core 152 r2851M ba24899
Encoding settings                        : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=9 / 
psy=1 / psy_rd=1.00:0.15 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / 
deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=6 / lookahead_threads=1 / sliced_threads=0 /
 nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 /
 b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 /
 scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=16.0 / qcomp=0.60 / qpmin=0 /
 qpmax=69 / qpstep=4 / vbv_maxrate=49000 / vbv_bufsize=49000 / crf_max=0.0 / nal_hrd=none / filler=0 /
 ip_ratio=1.40 / aq=1:1.00
Color range                              : Limited
Matrix coefficients                      : BT.470 System B/G
Codec configuration box                  : avcC
Decided to re-encode with the VD2 option to 'convert to fps 25', the error went away!! total filesize grew to 82.6MB (the video portion of media info):

Code:
Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4.1
Format settings                          : CABAC / 4 Ref Frames
Format settings, CABAC                   : Yes
Format settings, RefFrames               : 4 frames
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 2 min 48 s
Bit rate                                 : 3 801 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.073
Stream size                              : 76.2 MiB (92%)
Writing library                          : x264 core 152 r2851M ba24899
Encoding settings                        : cabac=1 / ref=4 / deblock=1:-1:-1 / analyse=0x3:0x133 / me=umh / subme=9 / psy=1 / psy_rd=1.00:0.15 /
 mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=6 /
 lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 /
 b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 /
 rc_lookahead=60 / rc=crf / mbtree=1 / crf=16.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=49000 /
 vbv_bufsize=49000 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.40 / aq=1:1.00
Color range                              : Limited
Matrix coefficients                      : BT.470 System B/G
Codec configuration box                  : avcC
Then dropping the 'vbv*' flags and keeping the convert to 25fps, error did not reproduce, filesize grew a bit to 83MB.

So it seems the limit is not completely bounded by the vbv flags, but the FPS plays a key role too and being too high causes "too much" content for a given time-slice (with certain sources)..

I'm OK with this, the original source is 25 fps, which is run at 55fps to have a fast-motion-effect, and typically down-convert to 25fps, so this is fine!

In summary, for anyone curious, not that it makes a huge difference, these were the findings:

Code:
no-vbv   fps=55 SIZE: 71.9MB - Limit error
vbv=49K fps=55 SIZE: 74.3MB - Limit error
vbv=49K fps=25 SIZE: 82.6MB - NO limit error
no-vbv   fps=25 SIZE: 83.0MB - NO limit error
For time being I'm trying to avoid adding anything extra that is not absolutely required, or that I *fully* understand, so going with the last option, to just down convert fps to 25, lets see if any future source will show up that still breaks the limit bounds

Thanks,

Stormy.
stormy1777 is offline   Reply With Quote
Old 23rd January 2019, 20:55   #26  |  Link
Rocinante
Registered User
 
Join Date: Jul 2018
Posts: 9
Quick thought, I think why setting a vbvrate doesn't help in this case, it's because "MB error" is not a bitrate error or peak error, it's "Macroblock per second of decoding speed limit", as for Level 4.1 it is 245,760. Which I would say ignore the error prompt, as it shouldn't affect encoding quality, it's just telling you that x264 will limit the macroblock per second according to level profile limit in decoding speed.
Rocinante is offline   Reply With Quote
Old 23rd January 2019, 21:14   #27  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by stormy1777 View Post
So it seems the limit is not completely bounded by the vbv flags, but the FPS plays a key role too and being too high causes "too much" content for a given time-slice (with certain sources)..
The VBV restrictions are the maximum. Any given encode may not come close to that maximum. A --bitrate 1000 encode probably won't hit level 4.1 VBV limits! Increasing frame rate will increase the odds of hitting the VBV cap, since there is more stuff to encode.

I always set maxrate/bufsize for all encodes. It doesn't hurt ones that wouldn't hit the VBV cap, but it makes the ones that would hit the cap remain compliant to codec spec. A good feature of x265 is that it does this automatically whenever level is specified. There are some x264 builds that do this as well, and I strongly feel that should be the default behavior. Limiting ref frames to what's supported based on Profile, level, and frame size should also be automatic. Encoders just shouldn't produce streams that aren't spec compliant with what the bitstream is flagged as being constrained by.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 2nd February 2019, 07:38   #28  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
I should probably have started a new thread for this error:

Code:
[!] x264 [warning]: MB rate (408000) > level limit (245760)
now got it on a source that was originally taken at 50fps. Despite placing the buffer vbv variables the error still occurs, only way to avoid it is to downsample to 25fps.. is that expected? I don't mind placing vbv variables, however, they don't seem to prevent this pop up at the end of a 30min encode
stormy1777 is offline   Reply With Quote
Old 2nd February 2019, 08:15   #29  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
one sort of unexpected outcome of 'downsampling' the fps from 50 to 25, is filesize INCREASED?? the 50fps encoded to 317MB, whereas when encoded to 25fps came to 338MB, not a big delta, but still, not very clear why
stormy1777 is offline   Reply With Quote
Old 2nd February 2019, 12:09   #30  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
On the "flip side", a different 50fps original source encoded to size 243MB, whereas when downconverted to 25fps with rest of settings identical, size *reduced* to 238MB, so I guess this is some sort of unpredictable "noise" related to fps and the actual source material.. Since the only way to avoid the error at end of the encode is to downsample to 25fps, will keep doing that for now... The vbv parameters did not prevent the error.
stormy1777 is offline   Reply With Quote
Old 2nd February 2019, 13:09   #31  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
1. 1080p50 will NEVER fit into H.264 level 4.1. Choose level 4.2 if necessary. The H.264 levels define maximum resolutions/fps.
2. x264 CRF is framerate aware. So with lower framerate it will increase the per-frame bitrate. This can sometimes outweigh the effect of reducing the framerate when the inter-frame compression is high.
sneaker_ger is offline   Reply With Quote
Old 2nd February 2019, 18:30   #32  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
[QUOTE=sneaker_ger;1864527]1. 1080p50 will NEVER fit into H.264 level 4.1. Choose level 4.2 if necessary. The H.264 levels define maximum resolutions/fps.

Ah, ok, now i see:

http://blog.mediacoderhq.com/h264-profiles-and-levels/

I'll choose 4.2 going forward.. still, the vbv buffer settings did not make the error/warning/pop up go away, only reducing the fps during encoding did the trick... not that it's a big deal for ME, just saying
stormy1777 is offline   Reply With Quote
Old 2nd February 2019, 21:41   #33  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Vbv only affects bitrate/buffer so naturally it doesn't affect resolution/fps. No vbv setting will ever "fix" this. In the blog you linked there is a table. The first column is "Max macroblocks per second". With 1080p50 you exceed the 245760 allowed for level 4.1.
sneaker_ger is offline   Reply With Quote
Old 3rd February 2019, 10:49   #34  |  Link
stormy1777
Registered User
 
Join Date: Jul 2002
Posts: 241
OK, great news, switched to Level 4.2, all else remained same, and error about MB (macroblock) did not occur.. I still downsample in most cases to 25fps, since the high fps is not always needed.. (On very fast movement I'll keep it at 50fps..) Thanks all for the help and tolerance in allowing this thread to go a BIT off topic very helpful nonetheless
stormy1777 is offline   Reply With Quote
Old 8th February 2019, 21:31   #35  |  Link
hello_hello
Registered User
 
Join Date: Mar 2011
Posts: 4,823
The MB warning isn't an error, just a warning to let you know you've exceeded the specified level due to the resolution/frame rate. The alternative would be for x264 to refuse to encode until you specified a higher level, so it doesn't enforce a resolution/frame rate. I think I mentioned earlier that x264 doesn't enforce the VBV settings for the specified level either. Some decoders will cope with higher bitrates, while some don't cope with the official VBV rates for the level they support.

Bluray supports level 4.1, but with further restrictions such as --vbv-bufsize 30000 --vbv-maxrate 40000.

You can leave the level at 4.1 and your player will either play it or not, just as it will or won't if you specify level 4.2 instead
Level 4.2 seems to be level 4.1 with a higher decoding speed to support higher frame rates. The maximum bitrate is the same and I think the maximum number of reference frames is the same for both, so setting level 4.2 probably doesn't change the way the video is encoded (don't hold me to that) but it does prevent the warning message.

Quote:
Originally Posted by FranceBB View Post
Level 4.1 defines a maximum bitrate of 50Mbit/s, so if you wanna set them, you should set your vbv lower than 50000 kbit/s.
Actually, it's 50Mbps for the Baseline, Extended and Main profiles. For high profile it's 50Mbps x 1.25, for Hi10P it's x3 and for Hi422P/Hi444PP it's x4. So High Profile 4.1 has these limits.
--vbv-bufsize 78125 --vbv-maxrate 62500

It's mentioned below the table here. The table in the blog linked to earlier seems to be wrong in places.

Someone has removed the maximum reference frame values from the Wikipedia table. I wonder why.

It used to display like this:

1,280×720@60 (9)
2,048×1,024@30 (4)

but now looks like this:

1,280×720@60
2,048×1,024@30

Last edited by hello_hello; 8th February 2019 at 21:38.
hello_hello is offline   Reply With Quote
Old 11th February 2019, 18:39   #36  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by hello_hello View Post
Bluray supports level 4.1, but with further restrictions such as --vbv-bufsize 30000 --vbv-maxrate 40000.
Plus --slices, strictly hierarchical pyramid, and others. I strongly recommend using --bluray-compat if you want to work on that hardware. Alas, it turns off Open GOP which would be helpful with 25 frame GOPs. And don't use it if you aren't targeting Blu-ray
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 11th February 2019, 18:45   #37  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
x264 --bluray-compat does not turn off open GOP.
sneaker_ger is offline   Reply With Quote
Old 11th February 2019, 18:59   #38  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,752
Quote:
Originally Posted by sneaker_ger View Post
x264 --bluray-compat does not turn off open GOP.
Oh, they fixed it? Awesome.

I wish x264 had the same caliber of user-facing documentation as x265.readthedocs.io.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner 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 03:21.


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