I need to the ability to encode and stream h.264 and h.265 at very controlled constant bitrates regardless of quality output. I understand encoding at a low bitrate can result in poor quality.
The main issue I am having though is I can’t get some of the video encodes (ones with high motion) to stay at a constant bitrate when set to a low bitrate.
I have tried many different gstreamer settings. I even compiled the newer omx source on my system to take advantage of EnableTwopassCBR which also didn’t seem to make a difference.
Running the following tests I have the following issues:
Test 1
gst-launch-1.0 v4l2src device=/dev/video0 do-timestamp=true io-mode=rw \
! "video/x-raw, width=1280, height=720, format=(string)UYVY, framerate=(fraction)60/1" \
! nvvidconv output-buffers=125 \
! 'video/x-raw(memory:NVMM), width=1280, height=720,format=I420, framerate=60/1' \
! omxh265enc bitrate=500000 control-rate=constant vbv-size=1 EnableTwopassCBR=true iframeinterval=60\
! 'video/x-h265, stream-format=(string)byte-stream' \
! h265parse \
! queue \
! mpegtsmux alignment=7 \
! filesink location=/opt/out.ts
Issue 1:
This is a 720p60 stream with HIGH motion video which obviously makes it difficult to encode. As you can see I am requesting an encode at a bitrate of 500kbps. The resulting video though is 1.8-1.9mbps. Is there anyway to force the feed to stay at 500kbps? Maybe with dynamic frame dropping?
I’ve tried this at multiple resolutions and all show the same symptom as long as the video feed is high motion.
Test 2
gst-launch-1.0 v4l2src device=/dev/video0 do-timestamp=true io-mode=rw \
! "video/x-raw, width=1920, height=1080, format=(string)UYVY, framerate=(fraction)30/1" \
! nvvidconv output-buffers=125 \
! 'video/x-raw(memory:NVMM), width=1920, height=1080,format=I420, framerate=30/1' \
! omxh264enc bitrate=500000 control-rate=constant vbv-size=1 EnableTwopassCBR=true iframeinterval=60\
! 'video/x-h264, stream-format=(string)byte-stream' \
! h264parse \
! queue \
! mpegtsmux alignment=7 \
! filesink location=/opt/out.ts
Issue 2:
This is a 1080p30 video with subtle motion. The encoder does stay at the requested 500kbps, but once every 2-3 seconds spikes up to 1.5 before going back down to 500kbps. Oddly H.265 does not exhibit this issue, only H.264.
Previously I asked for help with constant bitrate controls on this thread:
https://devtalk.nvidia.com/default/topic/948594/?comment=4928467
The answer was to set vbv-size to 1 which works for low motion video, but not for this high motion.
Would changing the quantization factor help? What is this temporal tradeoff and will that help?