We found some TX2 encoding quality issues, the encoded video quality is much worse than X264, mainly as follows:
1: When the video picture is switched from static to dynamic, TX2 does not allocate enough bit rate to the motion, and the mosaic effect is very serious.
2: When the background of the video screen is rich in details, such as lawn, leaves, smoke, etc., the I frame bit allocation is insufficient (the qp value is not small enough).
The attachment contains the source files corresponding to the above two issues.
The encoding command for TX2 is as follows (using MMAPI):
./video_encode ../../dump_1080p_v300_10.264.yuv 1920 1080 H264 ../../dump_1080p_v300_10_tx2_1000_90.264 -br 1000000 -nrf 4 -nbf 2 -p high -rc vbr -fps 30 1 -ifi 90 -hpt 4
./video_encode ../../dump_1080p_v300_3.264.yuv 1920 1080 H264 ../../dump_1080p_v300_3_tx2_1000_90.264 -br 1000000 -nrf 4 -nbf 2 -p high -rc vbr -fps 30 1 -ifi 90 -hpt 4
The encoding command for X264 is as follows:
ffmpeg -r 30 -fflags +genpts -i dump_1080p_v300_10.264 -c:v libx264 -vb 1000k -preset medium -g 90 -x264-params min-keyint=90:rc-lookahead=20:bframes=2 dump_1080p_v300_10_x264_1000_90.264 -y
ffmpeg -r 30 -fflags +genpts -i dump_1080p_v300_3.264 -c:v libx264 -vb 1000k -preset medium -g 90 -x264-params min-keyint=90:rc-lookahead=20:bframes=2 dump_1080p_v300_3_x264_1000_90.264 -y
In addition, we have also tried to use the Two-Pass-Cbr mode, which has improved the continuous dynamic video picture, but the video quality of continuous static video pictures has dropped too much.
Is there any way to improve the video quality in the above two situations, such as two-pass-vbr?
video_src.zip (9.43 MB)
We have confirmed your result is correct. SW x264 encoder brings better video qualiy in offline encoding. One deviation is that x264 encoder has weighted prediction, which gives better video quality, but consumes more time. Real time performance and video quality are tradeoff.
If you don’t need real time performance, please use SW x264 encoder instead.
For using HW encoder, we have suggest you run CBR and tune vbv-size:
Thank you for your patience.
Our application requires real-time encoding, so we can’t use X264.
As I explained in the above post, we also use the TWO-PASS-CBR mode, and set a large vbv-size at the same time, there will be a better video quality in the continuous dynamic video picture, and the video bit rate will increase a lot. We have also tried to adjust the bit rate by externally calculating SATD, the continuous dynamic picture video quality can be improved, but due to the hysteresis, the video quality is not as good as TWO-PASS-CBR+vbv-size.
But use the same settings (TWO-PASS-CBR+vbv-size) to encode continuous static video (pictures with rich background details, such as lawn, leaves, smoke, etc.), bit allocation is too low (qp value is too large) leading to full screen mosaic, if we lower the initial I frame QP maximum, this is the ideal quality for video quality.
As the above analysis, I think that the motion estimation of TX2 is no problem, it may be the problem of quantization and bit allocation. Can optimize the quantization and bit allocation strategy, or can provide some dynamic interfaces in the encoding process, such as dynamic feedback quality, dynamic setting QP.
We have given suggestion and explained the deviation between HW and SW encoders. If you require further support, please contact your NVIDIA region salesperson. Let’s review your usecase and see if we can have further cooperaion. Thanks.