x264编码 1pass 与 2pass 性能质量对比

1 素材

链接:https://pan.baidu.com/s/1SyDyvuNwLxbmW6r1QGCbFQ 密码:hv7l

crowd_run_1080p50.y4m 帧率:50;分辨率1920x1080;

 

2 编码测试

time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 1 -o 1pass.h264 crowd_run_1080p50.y4m;

time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 2 -o 2pass.h264 crowd_run_1080p50.y4m;

time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 3 -o 3pass.h264 crowd_run_1080p50.y4m;

这里转码是用 high profile、 veryslow 、 vbr 模式转码,码率为10Mbps,其实同样也有测试低码率模式,除转码时间比较快,质量上结论和高码率差不多,而且片源画面偏复杂,码率过低画面实在太差了;

 

3 编码资源开销对比

模式     片源时长     转码时间     转码资源开销

1pass     10s       0m11.619s      116.19%

2pass     10s      1m15.736s       757.36%

3pass     10s      1m16.072s       760.72%

通过上面可以看出 2pass 转码开销确实会高很多,转码效率低很多,码率比较小的时候,这个值差别没有这么大;

 

4 转码质量对比

模式 1pass

x264 [info]: SSIM Mean Y:0.8185420 ( 7.412db)

x264 [info]: PSNR Mean Y:28.510 U:34.313 V:34.936 Avg:29.757 Global:29.554 kb/s:10045.72

模式 2pass

x264 [info]: SSIM Mean Y:0.8526914 ( 8.318db)

x264 [info]: PSNR Mean Y:29.407 U:35.088 V:35.787 Avg:30.655 Global:30.638 kb/s:9928.51

模式 3pass

x264 [info]: SSIM Mean Y:0.8527646 ( 8.320db)

x264 [info]: PSNR Mean Y:29.408 U:35.089 V:35.786 Avg:30.656 Global:30.639 kb/s:9928.22

 

5 总结

2pass 和 3pass 不管是转码效率和转码质量差别都是非常小;

2pass 与 1pass 质量提升不到1个db,约10%的码率;

如果是单个片源做点播转码,对质量要求较高,可以考虑2pass模式,如果是大批量或者是云服务器做转码,不建议做2pass转码;

 

6 附件:x264编码日志文件

time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 1 -o 1pass.h264 crowd_run_1080p50.y4m; 
;
y4m [info]: 1920x1080p 1:1 @ 50/1 fps (cfr)
x264 [warning]: --psnr used with psy on: results will be invalid!
x264 [warning]: --tune psnr should be used if attempting to benchmark psnr!
x264 [warning]: NAL HRD parameters require VBV parameters
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
x264 [info]: profile Main, level 4.2
[0.2%] 1/500 frames, 0.71 fps, 184057.20 kb/s, eta 0:11:47  
[2.4%] 12/500 frames, 7.01 fps, 53141.17 kb/s, eta 0:01:09  
[4.8%] 24/500 frames, 12.18 fps, 30832.03 kb/s, eta 0:00:39  
[7.2%] 36/500 frames, 16.16 fps, 21613.48 kb/s, eta 0:00:28   
...
...
... 
[84.2%] 421/500 frames, 37.65 fps, 10190.93 kb/s, eta 0:00:02  
[89.8%] 449/500 frames, 39.28 fps, 10136.17 kb/s, eta 0:00:01  
                                                                               
x264 [info]: frame I:2     Avg QP:27.96  size:325112  PSNR Mean Y:35.19 U:37.40 V:37.93 Avg:35.84 Global:35.09
x264 [info]: frame P:128   Avg QP:35.53  size: 58316  PSNR Mean Y:29.02 U:34.28 V:34.90 Avg:30.20 Global:30.05
x264 [info]: frame B:370   Avg QP:39.24  size: 12007  PSNR Mean Y:28.30 U:34.31 V:34.93 Avg:29.57 Global:29.38
x264 [info]: consecutive B-frames:  0.4%  0.4%  9.0% 87.2%  3.0%  0.0%  0.0%  0.0%  0.0%
x264 [info]: mb I  I16..4: 19.8%  0.0% 80.2%
x264 [info]: mb P  I16..4: 15.8%  0.0%  0.0%  P16..4: 59.4%  0.0%  0.0%  0.0%  0.0%    skip:24.8%
x264 [info]: mb B  I16..4:  0.9%  0.0%  0.0%  B16..8: 27.2%  0.0%  0.0%  direct: 6.2%  skip:65.8%  L0:28.9% L1:39.6% BI:31.4%
x264 [info]: final ratefactor: 28.59
x264 [info]: direct mvs  spatial:98.4% temporal:1.6%
x264 [info]: coded y,uvDC,uvAC intra: 71.5% 66.9% 38.8% inter: 12.5% 8.0% 0.8%
x264 [info]: i16 v,h,dc,p: 31% 19% 37% 13%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 17% 15% 14%  9%  9%  8%  9%  9% 11%
x264 [info]: i8c dc,h,v,p: 59% 13% 23%  5%
x264 [info]: Weighted P-Frames: Y:0.8% UV:0.0%
x264 [info]: SSIM Mean Y:0.8185420 ( 7.412db)
x264 [info]: PSNR Mean Y:28.510 U:34.313 V:34.936 Avg:29.757 Global:29.554 kb/s:10045.72

encoded 500 frames, 43.12 fps, 10045.72 kb/s

real	0m11.619s
user	0m59.255s
sys	0m1.105s


[root@bogon 16_x264_2pass]# time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 2 -o 2pass.h264 crowd_run_1080p50.y4m; 
;
y4m [info]: 1920x1080p 1:1 @ 50/1 fps (cfr)
x264 [warning]: --psnr used with psy on: results will be invalid!
x264 [warning]: --tune psnr should be used if attempting to benchmark psnr!
x264 [warning]: NAL HRD parameters require VBV parameters
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
x264 [info]: profile High, level 5.1
[0.2%] 1/500 frames, 1.52 fps, 83775.20 kb/s, eta 0:05:27  
[0.8%] 4/500 frames, 4.25 fps, 29829.00 kb/s, eta 0:01:56  
[2.0%] 10/500 frames, 7.36 fps, 19334.04 kb/s, eta 0:01:06  
[3.0%] 15/500 frames, 7.48 fps, 16222.99 kb/s, eta 0:01:04  
[3.8%] 19/500 frames, 7.83 fps, 15058.55 kb/s, eta 0:01:01  
[4.2%] 21/500 frames, 7.84 fps, 14272.25 kb/s, eta 0:01:01  
...
...
... 
[97.0%] 485/500 frames, 6.57 fps, 9983.77 kb/s, eta 0:00:02  
[97.8%] 489/500 frames, 6.51 fps, 9977.41 kb/s, eta 0:00:01  
[98.6%] 493/500 frames, 6.54 fps, 9969.75 kb/s, eta 0:00:01  
[99.8%] 499/500 frames, 6.59 fps, 9939.31 kb/s, eta 0:00:00  
                                                                               
x264 [info]: frame I:2     Avg QP:32.91  size:201405  PSNR Mean Y:32.46 U:36.50 V:37.15 Avg:33.49 Global:33.48
x264 [info]: frame P:128   Avg QP:36.99  size: 54916  PSNR Mean Y:29.72 U:35.10 V:35.80 Avg:30.93 Global:30.92
x264 [info]: frame B:370   Avg QP:40.46  size: 13456  PSNR Mean Y:29.28 U:35.07 V:35.77 Avg:30.54 Global:30.53
x264 [info]: consecutive B-frames:  0.4%  0.4%  9.0% 87.2%  3.0%  0.0%  0.0%  0.0%  0.0%
x264 [info]: mb I  I16..4: 11.9% 72.6% 15.5%
x264 [info]: mb P  I16..4:  0.2%  4.0%  0.4%  P16..4: 37.5% 20.0% 14.8%  0.5%  0.1%    skip:22.5%
x264 [info]: mb B  I16..4:  0.0%  0.1%  0.0%  B16..8: 45.8%  9.2%  2.4%  direct: 2.3%  skip:40.1%  L0:40.5% L1:51.5% BI: 8.1%
x264 [info]: 8x8 transform intra:84.2% inter:57.5%
x264 [info]: direct mvs  spatial:91.9% temporal:8.1%
x264 [info]: coded y,uvDC,uvAC intra: 76.3% 74.8% 43.8% inter: 12.4% 8.1% 1.1%
x264 [info]: i16 v,h,dc,p: 26% 25%  6% 43%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13%  4%  3% 11% 15% 15% 14% 13% 11%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9%  4%  2% 10% 14% 15% 15% 14% 16%
x264 [info]: i8c dc,h,v,p: 40% 19% 23% 18%
x264 [info]: Weighted P-Frames: Y:0.8% UV:0.0%
x264 [info]: ref P L0: 56.2% 11.1% 11.1%  3.0%  3.0%  2.3%  2.6%  1.5%  1.7%  1.2%  1.0%  0.8%  0.9%  0.9%  1.3%  1.4%
x264 [info]: ref B L0: 95.2%  2.6%  0.9%  0.3%  0.2%  0.2%  0.1%  0.1%  0.1%  0.1%  0.0%  0.1%  0.0%  0.0%  0.0%
x264 [info]: ref B L1: 99.1%  0.9%
x264 [info]: SSIM Mean Y:0.8526914 ( 8.318db)
x264 [info]: PSNR Mean Y:29.407 U:35.088 V:35.787 Avg:30.655 Global:30.638 kb/s:9928.51

encoded 500 frames, 6.60 fps, 9928.51 kb/s

real	1m15.736s
user	9m23.884s
sys	0m0.761s


[root@bogon 16_x264_2pass]# time x264 --profile high --preset veryslow --tune film --psnr --ssim --nal-hrd vbr --bitrate 10000 --pass 3 -o 3pass.h264 crowd_run_1080p50.y4m; 
;
y4m [info]: 1920x1080p 1:1 @ 50/1 fps (cfr)
x264 [warning]: --psnr used with psy on: results will be invalid!
x264 [warning]: --tune psnr should be used if attempting to benchmark psnr!
x264 [warning]: NAL HRD parameters require VBV parameters
x264 [info]: using SAR=1/1
x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
x264 [info]: profile High, level 5.1
[0.2%] 1/500 frames, 1.61 fps, 83775.20 kb/s, eta 0:05:10  
[0.8%] 4/500 frames, 4.58 fps, 29829.00 kb/s, eta 0:01:48  
[1.6%] 8/500 frames, 7.10 fps, 20233.15 kb/s, eta 0:01:09  
[2.0%] 10/500 frames, 7.11 fps, 19334.04 kb/s, eta 0:01:08  
[3.0%] 15/500 frames, 7.56 fps, 16222.99 kb/s, eta 0:01:04  
...
...
... 
[97.0%] 485/500 frames, 6.53 fps, 9983.04 kb/s, eta 0:00:02  
[97.8%] 489/500 frames, 6.49 fps, 9976.97 kb/s, eta 0:00:01  
[98.6%] 493/500 frames, 6.51 fps, 9969.47 kb/s, eta 0:00:01  
[99.6%] 498/500 frames, 6.55 fps, 9950.66 kb/s, eta 0:00:00  
                                                                               
x264 [info]: frame I:2     Avg QP:32.93  size:201201  PSNR Mean Y:32.46 U:36.49 V:37.15 Avg:33.48 Global:33.48
x264 [info]: frame P:128   Avg QP:36.99  size: 54919  PSNR Mean Y:29.72 U:35.10 V:35.80 Avg:30.93 Global:30.92
x264 [info]: frame B:370   Avg QP:40.43  size: 13455  PSNR Mean Y:29.28 U:35.08 V:35.77 Avg:30.55 Global:30.53
x264 [info]: consecutive B-frames:  0.4%  0.4%  9.0% 87.2%  3.0%  0.0%  0.0%  0.0%  0.0%
x264 [info]: mb I  I16..4: 11.9% 72.4% 15.7%
x264 [info]: mb P  I16..4:  0.2%  4.0%  0.4%  P16..4: 37.5% 20.0% 14.7%  0.5%  0.1%    skip:22.6%
x264 [info]: mb B  I16..4:  0.0%  0.1%  0.0%  B16..8: 45.8%  9.3%  2.4%  direct: 2.3%  skip:40.2%  L0:40.4% L1:51.5% BI: 8.1%
x264 [info]: 8x8 transform intra:83.9% inter:57.5%
x264 [info]: direct mvs  spatial:91.9% temporal:8.1%
x264 [info]: coded y,uvDC,uvAC intra: 76.4% 74.6% 43.6% inter: 12.4% 8.1% 1.1%
x264 [info]: i16 v,h,dc,p: 27% 24%  6% 43%
x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 13%  4%  3% 11% 15% 15% 14% 13% 11%
x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu:  9%  4%  2% 10% 14% 15% 15% 14% 16%
x264 [info]: i8c dc,h,v,p: 41% 18% 23% 17%
x264 [info]: Weighted P-Frames: Y:0.8% UV:0.0%
x264 [info]: ref P L0: 56.2% 11.2% 11.1%  3.0%  2.9%  2.3%  2.6%  1.5%  1.7%  1.2%  1.0%  0.8%  0.9%  0.9%  1.3%  1.4%
x264 [info]: ref B L0: 95.2%  2.5%  0.8%  0.3%  0.2%  0.2%  0.1%  0.1%  0.1%  0.1%  0.1%  0.1%  0.0%  0.0%  0.1%
x264 [info]: ref B L1: 99.0%  1.0%
x264 [info]: SSIM Mean Y:0.8527646 ( 8.320db)
x264 [info]: PSNR Mean Y:29.408 U:35.089 V:35.786 Avg:30.656 Global:30.639 kb/s:9928.22

encoded 500 frames, 6.58 fps, 9928.22 kb/s

real	1m16.072s
user	9m25.357s
sys	0m0.807s

你可能感兴趣的:(#,h264)