H265 bitstream size is too large when using external rate control

Hi, I’m testing NVENC external rate control feature with H265.
I found encoded bits was too large when upper part of input frame has no movement.

This case happens following platforms.

  • Jetson Nano with JetPack 4.6.2
  • Jetson Xavier NX with JetPack 4.6.2
  • Jetson AGX Xavier with JetPack 5.1

Prepare for reprodoucing

I use this video for testing
(Creative Commons licenced video).

  1. Download video using youtube-dl
$ youtube-dl -f 137 1O4qUaij0h8 -o pan.mp4
  1. Create original input_src
$ ffmpeg - i pan.mp4 -pix_fmt yuv420p input_src.yuv
  1. Edit video using FFmpeg. (croping and padding)
$ BAR=128 # set bar height to 128px.
$ ffmpeg -i pan.mp4 -filter:v "crop=w=in_w:h=in_h-$BAR:x=0:y=0,pad=h=1080:y=$BAR" \
  -pix_fmt yuv420p input_src2.yuv

Reproducing problem

I executed video_encode example with following parameters.

Parameter Value Note
nTargetFrameBits 340000 10Mbps / fps
nFrameQP 25
nFrameMinQp 1
nFrameMaxQP 51
nMaxQPDeviation 0 No effect for HEVC
nSessionMaxQP 51
Hardware Preset fast
$ echo "166666 25 1 51 0" > hints.txt

$ video_encode input_src.yuv 1920 1080 H265 original.265 \
  --input_metadata --erh -hf hints.txt \
  -hpt 2 -fps 30 1

$ video_encode input_src2.yuv 1920 1080 H265 modified.265 \
  --input_metadata --erh -hf hints.txt \
  -hpt 2 -fps 30 1

Encoded result of modificed.265 is larger than original.265.
I checked output bitstream size with 3 kinds of bar height.

Bar height [px] File size [byte]
0 (original) 23986425
128 26644149
256 35592979
512 89602178

I think this is strange behavior.
If bar height is large, input frame has less complexity than without bar.
So, encoded bitstream size should be smaller.
Can I improve this behavior with some other encoder settings?
And, Jetson Orin platform behaves same?

Regards.

Hi,
Please try to set nFrameMinQp and nFrameMaxQP in a milted range and see if it helps. Also for balancing bitrate and video quality, you may try to configure CBR + virtual buffer size. Here is a topic for reference:
Random blockiness in the picture RTSP server-client -Jetson TX2 - #5 by DaneLLL

Hi, DaneLLL

Thank you for your information.
I’ll try to control QP range.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.