omxh264enc & omxh265enc - Unable to limit bitrate

I am using omxh264enc to encode h.264 video. I specify the bitrate and this seems to be respected… Most of the time. However, under certain circumstances (ex when videoing at night when there is not much data, which I guess trips up the compression algorithm), the encoded video ends up ballooning to 10x (or more!) than the bitrate I specified.

How can I overcome this?

I notice that there is a omxh264enc argument called EnableStringentBitrate. What does this do? Is that what I need? If you try a google search you will notice that nobody documents it. :)

Thank you!

Please refer to https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-28-2-ga

Thanks for that. I have read through that guide already. It’s true that it does mention the Stringent bitrate option, but it neglects to mention what it does. :)

Hi,
It is an option in two pass CBR mode. By default we give IDR frames more bit budget than P frames to have better video quality, but if you require limited and equivalent bit budget for every frame, you can enable it.

Thank you for that, but even with CBR I experience the same issue. Some more details:

  • I also experimented with omxh265enc and have the same problem - bitrate balloons (to ~10x what is set) in high-noise situations.
  • The problem can be reproduced by trying to encode the full-res stream of the camera built into the TX2 devkit, in low-light situations (or with any other camera that exhibits a lot of noise in low light). An easy repro is just to put the devkit in a (mostly) closed box so that little light gets to the camera.
  • One thing I don't understand is that the encoder has a 'peak-bitrate' option which apparently has a default value of "1.2*bitrate". Doesn't this mean that this should never happen? I.e. bitrate should not go above 1.2 of set bitrate?
  • In any case I tried setting control-rate to 2 (CBR), EnableStringentBitrate to TRUE, and EnableTwopassCBR to TRUE... I still experience the same issue.

Any help would be much appreciated.

Thanks much.

Hi,
Please try to tune qp-range. You can try qp-range=35,51:35,51:-1,-1.

But if your target bitrate is too low, it may not be achieved. We have seen a usecase targeting 500kbps for 1080p30:
https://devtalk.nvidia.com/default/topic/973295/jetson-tx1/constant-bitrate-help/post/5011599/#5011599
It can not be achieved because all frames are quantized at 50 which is the lowest bitrate encoder can give.

Thanks again for the response. Unfortunately I get the same results, probably due to the quantization limit as you suggest.

I think I will have to take similar path as described in the thread you link to and control things at a lower level. I.e. inspect the actual bitrate dynamically and drop frames if and when it gets too high…