I want to encode Blu-ray M2TS files with x264, my code is like this:
enc_ctx = avcodec_alloc_context3(codec);
enc_ctx->codec_id = AV_CODEC_ID_H264;
enc_ctx->bit_rate = 20000000;
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 20M/s, the subsequent bitrate will be very large, sometimes reaching 150M/s. , at this time Blu-ray Player will freeze due to high bitrate.
I set enc_ctx->rc_max_rate = 50000000;
but it seems to have no effect. How can I limit the maximum bitrate? Thanks
+ Reply to Thread
Results 1 to 10 of 10
-
-
Seet this:
https://www.videohelp.com/hd#tech
and this:
https://web.archive.org/web/20180227201628/http://www.x264bluray.com/ (There are links to subpages at the bottom with specific examples). -
Your expectations are bit contradictory - seem your goal is more like Constant BitRate. Maximum bitrate is described by your decoder capabilities - mostly by level supported by decoder. Definitely you should not go beyond this limitation. As you not providing any details about your decoder then i strongly recommends https://en.wikipedia.org/wiki/Advanced_Video_Coding?useskin=vector#Levels so you can set encoder to particular level supported by your decoder. By telling to encoder what is your goal i.e. level then it should automatically limit itself to not go beyond level.
-
Use CRF instead of bitrate with x264.
Start with CRF 18 (visually lossless).
Smaller values increase the quality, but also the bit rate and file size. -
I don't know about the front end you are using but the x264 command line options are --vbv-bufsize 30000 --vbv-maxrate 30000. You will also need to limit other settings like reference frames, max consecutive b-frames Profile and Level, etc. There's also a blu-ray compatibility option --bluray-compat. I don't know if it automatically sets all those options for you.
https://forum.videohelp.com/threads/377772-x264-compatible-settings#post2439267 -
-
Bitrate peaks can be reduced by denoising the video. However, as has been pointed out, the way to go is via the VBV settings.
-
Using the aforementioned --bluray-compat argument will a.o. set a max bitrate and VBV params within blu-ray specs. Where you still can encode in variable bitrate.
In my experience, with --bluray-compat set, there's still more than enough headroom for high-quality encodes.
[EDIT]
I overlooked, sorry. To control filesize, you can use 2-pass encoding (setting average bitrate). In some frontends the filesize can be set.
For quality, enter --preset <value>. This value has to be set to one of the following phrases, from lowest to highest quality:
ultrafast - superfast - veryfast - faster - fast - slow - slower - veryslow - placebo (forget this last, encoding time would take forever).
When the --preset argument is not used, x264 defaults to "medium", which merits lie between fast and slow.
I hardly use 2-pass anymore. Encoding with crf has my preference eventhough exact size in outcome isn't guaranteed.
My preferred --preset values are slower and veryslow, but try & find out for yourself.Last edited by Ennio; 24th Jan 2024 at 11:01.
-
You need as it was already pointed multiple times guide encoder about your requirements - for example excerpt from one of my ffmpeg scripts:
Code:@SET x264opts="crf=16:vbv_maxrate=19999:vbv_bufsize=9999:level=4.0:qpmin=4:ref=3:cabac=1:tff=1:interlaced=0:fake-interlaced=0:no_psnr=1:no_ssim=1:bluray_compat=1:open-gop=0:pic_struct=1:aud=1:nal_hrd=vbr:force_cfr=1:fullrange=off:overscan=show:colorprim=bt709:transfer=bt709:colormatrix=bt709:stitchable=1"
Similar Threads
-
Maximum Bitrate for Images
By Jay123210599 in forum Newbie / General discussionsReplies: 11Last Post: 21st Jan 2024, 16:31 -
Constraining x264's max bitrate to optimize (remote) streaming
By sebastiaaan in forum Newbie / General discussionsReplies: 0Last Post: 15th Nov 2023, 04:14 -
Cannot mux a H264 with AAC on .TS with Maximum overall bitrate of 8,000
By dogmydog in forum Video ConversionReplies: 36Last Post: 16th Mar 2022, 13:24 -
Maximum Video bitrate possible (best settings)
By VideoLover in forum Newbie / General discussionsReplies: 8Last Post: 28th Mar 2020, 01:10 -
x264 - bitrate always spikes high during beginning of video
By palaceplace in forum Video ConversionReplies: 9Last Post: 30th Sep 2019, 16:36