15.01.2022, 15:29
To provide an example of difference between CQP and CRF, I encoded to 1080p the movie "Big Buck Bunny" using the x265 encoder with CRF=22 which is the suggested setting for HD movies. In the table below you can find the output quality parameters calculated by x265.
As you can see even if I set CRF=22 the Avg QP of the movie is 27.06 with an average BitRate of 2642.73 kb/s. So the average quantizer of the movie is well above the quality of 22 defined for the encoding. For comparison I encoded the same movie with NVenc using the "constant quality" of 27 (near the avg CQP). I put the log in the table below
The average BitRate in this case is 2,788.63 kb/s. Unfortunately it is not available the Avg QP, but are available the SSIM and PSNR.
Just to check if I can match the Avg QP of x265, I encoded again the movie using the "constant quantizer" with CQP: 20-22-28, which are near to the Avg QP calculated by x265, the encoding output is the following.
Now the average BitRate is 2600.68 kb/s which is near to 2642.73 kb/s obtained with x265 and CRF=22. The problem is that is not possible to know in advance the optimal values for CQP, so using the "constant quality" (aka CRF) with NVenc is probably the best option.
[13:53:05] work: average encoding speed for job is 58.058235 fps
[13:53:05] comb detect: heavy 4 | light 561 | uncombed 13750 | total 14315
[13:53:05] decomb: deinterlaced 4 | blended 561 | unfiltered 13750 | total 14315
[13:53:05] vfr: 14315 frames output, 0 dropped and 0 duped for CFR/PFR
[13:53:05] vfr: lost time: 0 (0 frames)
[13:53:05] vfr: gained time: 0 (0 frames) (0 not accounted for)
[13:53:05] hevc-decoder done: 14315 frames, 0 decoder errors
[13:53:05] sync: got 14315 frames, 14315 expected
[13:53:05] sync: framerate min 24.000 fps, max 24.000 fps, avg 24.000 fps
x265 [info]: frame I: 152, Avg QP:19.95 kb/s: 30377.15
x265 [info]: frame P: 2865, Avg QP:22.34 kb/s: 7530.22
x265 [info]: frame B: 11298, Avg QP:28.35 kb/s: 1030.20
x265 [info]: Weighted P-Frames: Y:4.7% UV:3.4%
x265 [info]: consecutive B-frames: 5.1% 0.6% 0.8% 1.7% 91.8%
encoded 14315 frames in 247.50s (57.84 fps), 2642.73 kb/s, Avg QP:27.06
As you can see even if I set CRF=22 the Avg QP of the movie is 27.06 with an average BitRate of 2642.73 kb/s. So the average quantizer of the movie is well above the quality of 22 defined for the encoding. For comparison I encoded the same movie with NVenc using the "constant quality" of 27 (near the avg CQP). I put the log in the table below
Output Info H.265/HEVC main10 @ Level auto
1920x1080p 1:1 24.000fps (24/1fps)
Encoder Preset default
Rate Control VBR
Multipass 2pass-full
Bitrate 0 kbps (Max: 240000 kbps)
Target Quality 27.00
Initial QP I:20 P:23 B:25
QP Offset cb:0 cr:0
VBV buf size auto
Lookahead on, 16 frames, Adaptive I, B Insert
GOP length 240 frames
B frames 4 frames [ref mode: each]
Ref frames 4 frames, MultiRef L0:auto L1:auto
AQ on
CU max / min auto / auto
VUI matrix:bt709
Others mv:Q-pel nonrefp
encoded 14315 frames, 300.17 fps, 2788.63 kbps, 198.28 MB
encode time 0:00:47, CPU: 3.7, GPU: 42.4, VE: 95.1, VD: 85.9, GPUClock: 1878MHz, VEClock: 1657MHz
frame type IDR 137
frame type I 137, total size 16.71 MB
frame type P 3322, total size 104.46 MB
frame type B 10856, total size 77.11 MB
ssim/psnr/vmaf: SSIM YUV: 0.993079 (21.598220), 0.992116 (21.032410), 0.993133 (21.632587), All: 0.992927 (21.504229), (Frames: 14315)
ssim/psnr/vmaf: PSNR YUV: 45.265175, 48.234129, 49.389327, Avg: 46.152116, (Frames: 14315)
The average BitRate in this case is 2,788.63 kb/s. Unfortunately it is not available the Avg QP, but are available the SSIM and PSNR.
Just to check if I can match the Avg QP of x265, I encoded again the movie using the "constant quantizer" with CQP: 20-22-28, which are near to the Avg QP calculated by x265, the encoding output is the following.
Output Info H.265/HEVC main10 @ Level auto
1920x1080p 1:1 24.000fps (24/1fps)
Encoder Preset default
Rate Control CQP I:20 P:22 B:28
ChromaQPOffset cb:0 cr:0
Lookahead on, 16 frames, Adaptive I, B Insert
GOP length 240 frames
B frames 4 frames [ref mode: each]
Ref frames 4 frames, MultiRef L0:auto L1:auto
AQ off
CU max / min auto / auto
VUI matrix:bt709
Others mv:Q-pel nonrefp
encoded 14315 frames, 321.76 fps, 2600.68 kbps, 184.92 MB
encode time 0:00:44, CPU: 3.4, GPU: 42.6, VE: 90.6, VD: 93.5, GPUClock: 1860MHz, VEClock: 1645MHz
frame type IDR 137
frame type I 137, total size 19.77 MB
frame type P 3322, total size 112.50 MB
frame type B 10856, total size 52.65 MB
ssim/psnr/vmaf: SSIM YUV: 0.992313 (21.142605), 0.992405 (21.194449), 0.993497 (21.869194), All: 0.992526 (21.264396), (Frames: 14315)
ssim/psnr/vmaf: PSNR YUV: 45.414124, 48.511711, 49.641120, Avg: 46.322234, (Frames: 14315)
Now the average BitRate is 2600.68 kb/s which is near to 2642.73 kb/s obtained with x265 and CRF=22. The problem is that is not possible to know in advance the optimal values for CQP, so using the "constant quality" (aka CRF) with NVenc is probably the best option.