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 > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 23rd January 2024, 04:06   #1  |  Link
zhouting
Registered User
 
Join Date: Jun 2022
Posts: 9
How to limit the maximum bitrate of x265?

I want to encode UHD Blu-ray M2TS files with x265, my code is like this: enc_ctx = avcodec_alloc_context3(codec);
enc_ctx->codec_id = AV_CODEC_ID_H265;
enc_ctx->bit_rate = 40000000;

When a video has a simple scene, such as 10 seconds, its encoding bitrate will be very small, only 1M or 2M bitrate. In order to achieve an average bitrate of 40M/s, the subsequent bitrate will be very large, sometimes reaching 200M/s, at this time UHD Blu-ray Player will freeze due to high bitrate.
I set
enc_ctx->rc_max_rate = 80000000;
but it seems to have no effect. How can I limit the maximum bitrate? Thanks
zhouting is offline   Reply With Quote
Old 23rd January 2024, 06:01   #2  |  Link
RanmaCanada
Registered User
 
Join Date: May 2009
Posts: 333
would it not be --vbv-maxrate <integer> So something like --input 1080pSource.y4m --ctu 32 --bitrate 5800 --vbv-maxrate 8700

--vbv-maxrate <integer>
Maximum local bitrate (kbits/sec). Will be used only if vbv-bufsize is also non-zero. Both vbv-bufsize and vbv-maxrate are required to enable VBV in CRF mode. Default 0 (disabled)

Note that when VBV is enabled (with a valid --vbv-bufsize), VBV emergency denoising is turned on. This will turn on aggressive denoising at the frame level when frame QP > QP_MAX_SPEC (51), drastically reducing bitrate and allowing ratecontrol to assign lower QPs for the following frames. The visual effect is blurring, but removes significant blocking/displacement artifacts.

https://x265.readthedocs.io/en/master/cli.html

Sorry just took it straight from the docs. I hope this is correct.
RanmaCanada is offline   Reply With Quote
Old 23rd January 2024, 23:11   #3  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,827
You're correct. With really complex content x265 can overshoot the VBV by a trivial amount sometimes, so lowering it 5% is a good idea if you REALLY need it to be spot on. Almost no uses cases actually do.
__________________
Ben Waggoner
Principal Video Specialist, Amazon Prime Video

My Compression Book
benwaggoner is offline   Reply With Quote
Old 24th January 2024, 07:56   #4  |  Link
zhouting
Registered User
 
Join Date: Jun 2022
Posts: 9
How should vbv-bufsize be set?
zhouting is offline   Reply With Quote
Old 24th January 2024, 17:54   #5  |  Link
benwaggoner
Moderator
 
Join Date: Jan 2006
Location: Portland, OR
Posts: 4,827
Quote:
Originally Posted by zhouting View Post
How should vbv-bufsize be set?
set --vbv-bufsize and --vbv-maxrate to the desired values. You need to set both for either to do anything.

Setting --level-idc will also default to the Profile @ Level @ Tier maximums. And x265 will default to picking the lowest level that can handle your frame size and fps, so generally sane values will be applied. But if you want something different, as in your case, seeing them manually does the trick nicely.
__________________
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 20:43.


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