Nvv4l2h264enc vs omxh264enc - large variation in file size

Hello. As I understand, the omxh264enc is about to be deprecated and it is recommended to use nvv4l2h264enc instead. I also think we need to use the latter because we are using Docker.

I made the script below to record 20 seconds of video in 4K resolution and encode it with both nvv4l2h264enc and omxh264enc. In both cases, I use variable bitrate and I set the bitrate to 30000000 and the peak-bitrate to 52000000. The file compressed with nvv4l2h264enc ended up being 75MB while the one compressed with omxh264enc ended up being 40MB.

Can you explain to me what is the reason for this large difference in file size? When I visually inspect the videos, they look very similar in quality. How can I configure nvv4l2h264 to behave in the same way as omxh264enc?

I am also wondering about the qp-range parameter. It seems to have a large impact on file size and video quality for the nvv4lh264enc. How does this parameter relate to the bitrate and peak bitrate parameter? Can you suggest how to set this parameter for 4K video to produce videos of equal quality and compression rate as with the omxh264enc?

gst-launch-1.0 nvarguscamerasrc num-buffers=600 ! \
  'video/x-raw(memory:NVMM), width=(int)3840, height=(int)2160, format=(string)NV12, framerate=(fraction)30/1' ! \
  tee name=t t. ! queue ! nvv4l2h264enc control-rate=0 \
  bitrate=30000000 peak-bitrate=52000000 ! h264parse ! qtmux ! filesink location=test_nvv4l2.mp4 \
  t. ! queue ! omxh264enc control-rate=1 bitrate=30000000 peak-bitrate=52000000 ! qtmux ! filesink location=test_omx.mp4 -e


The deviation should be from qp-range. In VBR mode, the q value of each frame will be in the range. Please save the h264 stream and check the q values. Can check through JM decoder: