fadedmaple
17th January 2018, 16:07
We all know that x265 encoding is very time-consuming.
I usually use CRF mode to control quality,in a range (18-21).
vspipe --y4m 1080p.vpy - | x265 --y4m --preset slower --crf 19 --qcomp 0.70 --aq-mode 2 --aq-strength 0.8 --cbqpoffs -2 --crqpoffs -2 --subme 5 --merange 25 --ref 5 --rc-lookahead 60 --rd 4 --rdoq-level 1 --psy-rdoq 1.50 --ssim-rd --no-sao --no-amp --no-rect --no-open-gop --no-strong-intra-smoothing --rdpenalty 1 --ctu 32 --max-tu-size 16 --qg-size 16 --keyint 360 --min-keyint 1 --colorprim bt709 --deblock -1 --frames 14400 --output "265.hevc" -
I always use the sampling method to control the bit rate.(4-6Mb/s ,1080P)
If the bit rate is too low,I will use the 18,Otherwise use 21.
This method looks good, but it also takes a long time.
src = core.std.SelectEvery(src, cycle = 8000, offsets = range(480))
src = core.std.AssumeFPS(src,fpsnum=24000, fpsden=1001)
2pass is a good quality and bit rate control method,but it consumes more time.
So i want to add --pass 1 and --stats xx.log parameter in crf encode setting and only use crf 18.
When the bit rate is not in my satisfactory range,Then the pass 2 encoding.
The most important question is : Will there be quality differences?
--cfr 18 ................
--crf 18 ................ --pass 1 --stats xx.log
Because I saw this sentence in the document,So I think there should be no difference.
--slow-firstpass, --no-slow-firstpass
Enable first pass encode with the exact settings specified.Default enabled.
But my friend did not recommend me to do that, he thinks it will reduce the quality...
Ma
17th January 2018, 23:34
--preset slower --crf 19 gives exactly the same quality as --preset slower --crf 19 --pass 1.
Motenai Yoda
18th January 2018, 13:32
@Ma there will be differences between 2 pass encode using crf based first pass and abr based one?
sneaker_ger
18th January 2018, 13:39
Yes, but probably not too big.
Ma
18th January 2018, 19:29
I've made some tests -- encoding lighthouse_lossless.mp4 with option from first post + --pass 1, it gives bitrate 4729.80 kb/s and stat file.
Then I've made --pass 2 with bitrates: 6000, 47000, 470.
Next I've made normal 2pass encoding with bitrates: 6000, 47000, 470.
Encoder output for bitrate 6000:
--crf 19 --pass 1 / --bitrate 6000 --pass 2
x265 [info]: frame I: 10, Avg QP:15.76 kb/s: 32764.07 PSNR Mean: Y:50.487 U:52.686 V:52.955 SSIM Mean: 0.992639 (21.331dB)
x265 [info]: frame P: 451, Avg QP:17.93 kb/s: 19709.38 PSNR Mean: Y:48.223 U:50.469 V:51.202 SSIM Mean: 0.989792 (19.911dB)
x265 [info]: frame B: 2391, Avg QP:23.04 kb/s: 3304.15 PSNR Mean: Y:47.097 U:49.813 V:50.826 SSIM Mean: 0.988271 (19.307dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 212.82s (13.40 fps), 6001.68 kb/s, Avg QP:22.21, Global PSNR: 48.068, SSIM Mean Y: 0.9885269 (19.403 dB)
--bitrate 6000 --pass 1 / --bitrate 6000 --pass 2
x265 [info]: frame I: 10, Avg QP:15.21 kb/s: 32928.63 PSNR Mean: Y:50.534 U:52.709 V:52.955 SSIM Mean: 0.992642 (21.332dB)
x265 [info]: frame P: 451, Avg QP:17.84 kb/s: 19714.45 PSNR Mean: Y:48.220 U:50.468 V:51.191 SSIM Mean: 0.989778 (19.905dB)
x265 [info]: frame B: 2391, Avg QP:23.10 kb/s: 3263.86 PSNR Mean: Y:47.073 U:49.785 V:50.799 SSIM Mean: 0.988256 (19.302dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 216.01s (13.20 fps), 5969.28 kb/s, Avg QP:22.24, Global PSNR: 48.046, SSIM Mean Y: 0.9885122 (19.398 dB)
It's not the same but very close.
Encoder output for bitrate 47000 (10 x initial bitrate):
--crf 19 --pass 1 / --bitrate 47000 --pass 2
x265 [info]: frame I: 10, Avg QP:6.40 kb/s: 110071.93 PSNR Mean: Y:56.851 U:58.880 V:59.144 SSIM Mean: 0.997462 (25.955dB)
x265 [info]: frame P: 451, Avg QP:7.59 kb/s: 97851.53 PSNR Mean: Y:54.125 U:56.525 V:56.540 SSIM Mean: 0.995821 (23.789dB)
x265 [info]: frame B: 2391, Avg QP:11.45 kb/s: 37646.98 PSNR Mean: Y:50.590 U:52.694 V:53.076 SSIM Mean: 0.992554 (21.281dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 651.60s (4.38 fps), 47421.35 kb/s, Avg QP:10.82, Global PSNR: 51.749, SSIM Mean Y: 0.9930877 (21.604 dB)
--bitrate 47000 --pass 1 / --bitrate 47000 --pass 2
x265 [info]: frame I: 10, Avg QP:6.31 kb/s: 107304.13 PSNR Mean: Y:55.865 U:57.660 V:57.614 SSIM Mean: 0.997423 (25.889dB)
x265 [info]: frame P: 451, Avg QP:7.09 kb/s: 102963.77 PSNR Mean: Y:54.081 U:56.158 V:56.220 SSIM Mean: 0.996354 (24.382dB)
x265 [info]: frame B: 2391, Avg QP:10.96 kb/s: 36069.54 PSNR Mean: Y:50.467 U:52.249 V:52.592 SSIM Mean: 0.992833 (21.447dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 734.99s (3.88 fps), 46897.61 kb/s, Avg QP:10.33, Global PSNR: 51.552, SSIM Mean Y: 0.9934062 (21.809 dB)
A little bigger difference but also close.
Encoder output for bitrate 470 (1/10 x initial bitrate):
--crf 19 --pass 1 / --bitrate 470 --pass 2
x265 [info]: frame I: 10, Avg QP:34.14 kb/s: 5107.12 PSNR Mean: Y:43.364 U:45.721 V:47.801 SSIM Mean: 0.975181 (16.052dB)
x265 [info]: frame P: 451, Avg QP:36.58 kb/s: 1698.13 PSNR Mean: Y:39.685 U:42.999 V:44.569 SSIM Mean: 0.955541 (13.520dB)
x265 [info]: frame B: 2391, Avg QP:40.47 kb/s: 206.85 PSNR Mean: Y:39.626 U:43.039 V:44.625 SSIM Mean: 0.956620 (13.627dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 137.60s (20.73 fps), 459.85 kb/s, Avg QP:39.83, Global PSNR: 40.695, SSIM Mean Y: 0.9565141 (13.617 dB)
--bitrate 470 --pass 1 / --bitrate 470 --pass 2
x265 [info]: frame I: 10, Avg QP:33.09 kb/s: 5165.24 PSNR Mean: Y:43.567 U:45.821 V:47.647 SSIM Mean: 0.975448 (16.099dB)
x265 [info]: frame P: 451, Avg QP:36.95 kb/s: 1724.23 PSNR Mean: Y:39.553 U:42.890 V:44.438 SSIM Mean: 0.955861 (13.552dB)
x265 [info]: frame B: 2391, Avg QP:40.82 kb/s: 213.57 PSNR Mean: Y:39.496 U:42.985 V:44.462 SSIM Mean: 0.956724 (13.638dB)
x265 [info]: Weighted P-Frames: Y:4.9% UV:2.0%
x265 [info]: Weighted B-Frames: Y:2.8% UV:1.3%
x265 [info]: consecutive B-frames: 3.5% 2.0% 1.5% 26.9% 5.4% 13.9% 9.3% 14.3% 23.2%
encoded 2852 frames in 130.75s (21.81 fps), 469.82 kb/s, Avg QP:40.18, Global PSNR: 40.570, SSIM Mean Y: 0.9566535 (13.630 dB)
It's like in 47000 case -- close but not so close as at 6000.
Finally I've made 2pass encoding with bitrate 470 and true placebo options (-p placebo --multi-pass-opt-distortion --rc-lookahead 120 --bframes 12 --ref 6 --subme 7 -F1 --keyint 480):
x265 [info]: frame I: 8, Avg QP:29.44 kb/s: 7590.07 PSNR Mean: Y:44.546 U:47.358 V:48.733 SSIM Mean: 0.973047 (15.694dB)
x265 [info]: frame P: 386, Avg QP:34.36 kb/s: 1994.17 PSNR Mean: Y:40.655 U:44.214 V:45.990 SSIM Mean: 0.961267 (14.119dB)
x265 [info]: frame B: 2458, Avg QP:39.67 kb/s: 205.17 PSNR Mean: Y:40.518 U:44.226 V:46.059 SSIM Mean: 0.962178 (14.223dB)
x265 [info]: Weighted P-Frames: Y:6.2% UV:4.1%
x265 [info]: Weighted B-Frames: Y:1.8% UV:0.8%
x265 [info]: consecutive B-frames: 2.3% 1.5% 2.0% 29.2% 4.3% 14.0% 4.8% 7.1% 5.6% 5.1% 3.8% 7.1% 13.2%
encoded 2852 frames in 3378.23s (0.84 fps), 468.01 kb/s, Avg QP:38.92, Global PSNR: 41.697, SSIM Mean Y: 0.9620852 (14.212 dB)
Samples to watch at bitrate 470 (it is very low bitare):
--crf 19 --pass 1 / --bitrate 470 --pass 2: crf.mkv (http://msystem.waw.pl/x265/crf.mkv)
--bitrate 470 --pass 1 / --bitrate 470 --pass 2: bitrate.mkv (http://msystem.waw.pl/x265/bitrate.mkv)
2pass at bitrate 470 and true placebo options: placebo.mkv (http://msystem.waw.pl/x265/placebo.mkv)
Full command lines and encoder outputs in attachment.
For me it is OK to make second pass with stat file from crf encoding -- if the bitrate is close, it is very close to normal 2pass encoding.
Asmodian
18th January 2018, 20:22
I was curious about exactly this point myself. Thanks a lot for actually doing the test. :thanks:
Comforting to know, I suppose even changing the bit rate by 2x would be very close. Your changes were more on the order of 10x (7.8x and 0.078x) with little impact.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.