Quality of encoded video is primarily a function of target-bit rate and the type of the video content. There few encoder parameters which can be used to adjust the encoder quality. Perform the following steps to debug HEVC/AVC encoder quality issues.
- Adjust the number of B-frames (Gop.NumB) according to the amount of motion, e.g. increased to 2 for static scenes or video conference-like of content, or reduced to 0 for sequences with a lot of motion and/or high frame rates
- The VBR rate control mode can improve the average quality when some parts of the sequence have lower complexity and/or motion
- For video conference or when random access is not needed, replace the IPP... GOP by the LOW_DELAY_P GOP and optionally enable the GDR intra refresh
- If there are many scene changes, enable the ScnChgResilience setting to reduce artifacts following scene change transitions
- If scene changes can be detected by the system, the encoder's scene change signaling API should be called instead (i.e. with ScnChgResilience disabled) for the encoder to dynamically adapt the encoding parameters and GOP pattern. The scene change information can be provided in a separate input file (CmdFile) when using the control software test application.
Tip: To improve the video quality, consider using Scene Change Detect hardware.
- If the highest PSNR figures are targeted instead of subjective quality, it is recommended to set QPCtrlMode = UNIFORM_QP and ScalingList = FLAT.
- Evaluate the valid bit rate range for the given video stream by using CONST_QP rate control algorithm.
- Use a QP value of 22, 27, 32, 37 with the CONST_QP rate control algorithm
- Using the bit rate range from step 2, evaluate PSNR for CBR/VBR/Low latency rate control algorithms
- Run similar experiments for libx264 or libx265 encoders.
Here is an example pipeline for CBR:
ffmpeg -s 1280x720 -pix_fmt yuv420p -framerate 50 -I /srv/data1/kvikrama/vcu_video_quality_runs/source/old_town_cross_420_720p50.yuv -c:v libx265 -preset medium -x265-params bframes=0:ref=1:keyint=30:rc lookahead=0:ipratio=1:pbratio=1:trellis=0 -b:v 1M -minrate 1M -maxrate 1M -bufsize 2M -frames 500 old_town_cross_420_720p50_x265.mp4
- Calculate the BD-rate using JCT-VC common test conditions evaluation metric.
- If there is difference in PSNR between VCU and libx264/libx265, tune the following parameters to see impact:
MinQP, MaxQP, ScnChgResilience (should be Enabled), NumSlices (set to 1).