Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > High Efficiency Video Coding (HEVC)

Reply
 
Thread Tools Search this Thread Display Modes
Old 17th January 2018, 16:07   #1  |  Link
fadedmaple
Registered User
 
fadedmaple's Avatar
 
Join Date: Dec 2017
Posts: 8
Will the quality change when add --pass 1 in CRF mode ?

We all know that x265 encoding is very time-consuming.
I usually use CRF mode to control quality,in a range (18-21).
Quote:
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.
Quote:
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...

Last edited by fadedmaple; 17th January 2018 at 16:13.
fadedmaple is offline   Reply With Quote
Old 17th January 2018, 23:34   #2  |  Link
Ma
Registered User
 
Join Date: Feb 2015
Posts: 326
--preset slower --crf 19 gives exactly the same quality as --preset slower --crf 19 --pass 1.
Ma is offline   Reply With Quote
Old 18th January 2018, 13:32   #3  |  Link
Motenai Yoda
Registered User
 
Motenai Yoda's Avatar
 
Join Date: Jan 2010
Posts: 709
@Ma there will be differences between 2 pass encode using crf based first pass and abr based one?
__________________
powered by Google Translator
Motenai Yoda is offline   Reply With Quote
Old 18th January 2018, 13:39   #4  |  Link
sneaker_ger
Registered User
 
Join Date: Dec 2002
Posts: 5,565
Yes, but probably not too big.
sneaker_ger is offline   Reply With Quote
Old 18th January 2018, 19:29   #5  |  Link
Ma
Registered User
 
Join Date: Feb 2015
Posts: 326
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
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
Code:
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):
Code:
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
--bitrate 470 --pass 1 / --bitrate 470 --pass 2: bitrate.mkv
2pass at bitrate 470 and true placebo options: 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.
Attached Files
File Type: txt scr.txt (35.3 KB, 44 views)
Ma is offline   Reply With Quote
Old 18th January 2018, 20:22   #6  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,406
I was curious about exactly this point myself. Thanks a lot for actually doing the test.

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.
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:25.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.