kenjysn
帖子: 5
注册时间: 2012-12-20 1:44

求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定?

我采用最新的megui配合X264压缩一些视频,片源分辨率是1280×720,为了节省空间打算用megui X264重新编码成960×544分辨率。一直采用的CRF19编码,编码出来QP(I:17.65 P:19.82 B:20.82)码率大约为2900~3100之间
觉得码率有点高了,我就指定码率2500kbps进行重新压缩(采用的二次编码方式),才发现最终码率范围大幅缩小到2300~2450,QP(I:17.65 P:18.50 B:19.30),发现二次编码后的QP均小于CRF19的QP,这是不是说明二次编码的品质要高于CRF呢?CRF19和2500kbps二次编码的,参数均相同。

program --preset slower --crf 19.0 --bframes 4 --ref 5 --qpmin 15 --qpmax 50 --ratetol 50 --qcomp 0.7 --no-mbtree --merange 24 --direct spatial --partitions p8x8,b8x8,i4x4,i8x8 --trellis 1 --no-fast-pskip --range pc --output "output" "input"

program --preset slower --pass 2 --bitrate 2500 --stats ".stats" --bframes 4 --ref 5 --qpmin 16 --qpmax 50 --ratetol 50 --qcomp 0.7 --no-mbtree --merange 20 --direct spatial --partitions p8x8,b8x8,i4x4,i8x8 --trellis 1 --no-fast-pskip --output "output" "input"
上次由 kenjysn 在 2012-12-20 13:19,总共编辑 1 次。
kenjysn
帖子: 5
注册时间: 2012-12-20 1:44

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终码率要高30%呢

我可能犯了个错误,之前码率过高的CRF--bframes为3,二次压缩改成4了,我没注意到这个变化,后来我采用4的--bframes进行CRF19压缩,发现码率竟然比二次压缩更低而且QP也要更好,不过也发现一个问题,同一个片源二次压缩的最终处理帧数为49570 frames,CRF为43030 frames,其中RF少了6000帧,不知道是不是出了什么问题,望解答

附上,CRF19和2500kbps二次压缩的日志
2500k

[Information] [2012/12/20 10:33:10] Standard error stream
-[NoImage] [mov,mp4,m4a,3gp,3g2,mj2 @ 018f99a0] max_analyze_duration 25000000 reached at 25002667
-[NoImage] avs [info]: 960x544p 136:135 @ 30000/1001 fps (cfr)
-[NoImage] x264 [info]: using SAR=136/135
-[NoImage] x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
-[NoImage] x264 [info]: profile High, level 3.1
-[NoImage]
-[NoImage] x264 [info]: frame I:203 Avg QP:19.21 size: 44403
-[NoImage] x264 [info]: frame P:12689 Avg QP:20.64 size: 18790
-[NoImage] x264 [info]: frame B:36678 Avg QP:22.36 size: 7043
-[NoImage] x264 [info]: consecutive B-frames: 0.8% 3.4% 8.3% 64.6% 22.8%
-[NoImage] x264 [info]: mb I I16..4: 11.3% 66.3% 22.5%
-[NoImage] x264 [info]: mb P I16..4: 1.5% 13.6% 2.0% P16..4: 43.4% 23.7% 11.5% 0.0% 0.0% skip: 4.3%
-[NoImage] x264 [info]: mb B I16..4: 0.3% 2.0% 0.2% B16..8: 45.3% 11.4% 2.6% direct: 5.9% skip:32.4% L0:41.5% L1:50.3% BI: 8.1%
-[NoImage] x264 [info]: 8x8 transform intra:79.1% inter:73.6%
-[NoImage] x264 [info]: coded y,uvDC,uvAC intra: 84.0% 85.3% 34.9% inter: 29.3% 36.0% 1.0%
-[NoImage] x264 [info]: i16 v,h,dc,p: 25% 7% 5% 63%
-[NoImage] x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 7% 4% 2% 11% 18% 18% 14% 14% 11%
-[NoImage] x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 4% 2% 9% 17% 18% 14% 12% 11%
-[NoImage] x264 [info]: i8c dc,h,v,p: 39% 20% 20% 21%
-[NoImage] x264 [info]: Weighted P-Frames: Y:3.4% UV:1.4%
-[NoImage] x264 [info]: ref P L0: 46.6% 13.6% 18.7% 9.0% 10.4% 1.7% 0.1%
-[NoImage] x264 [info]: ref B L0: 80.5% 12.0% 4.8% 2.8%
-[NoImage] x264 [info]: ref B L1: 94.3% 5.7%
-[NoImage] x264 [info]: kb/s:2446.30
-[NoImage] encoded 49570 frames, 24.64 fps, 2446.30 kb/s


CFR19
[Information] [2012/12/20 12:57:24] Standard error stream
-[NoImage] [mov,mp4,m4a,3gp,3g2,mj2 @ 02cd2940] max_analyze_duration 25000000 reached at 25002667
-[NoImage] avs [info]: 960x544p 136:135 @ 30000/1001 fps (cfr)
-[NoImage] resize [warning]: converting range from TV to PC
-[NoImage] x264 [info]: using SAR=136/135
-[NoImage] x264 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2 AVX
-[NoImage] x264 [info]: profile High, level 3.1
-[NoImage]
-[NoImage] x264 [info]: frame I:147 Avg QP:18.21 size: 53554
-[NoImage] x264 [info]: frame P:10753 Avg QP:19.40 size: 20226
-[NoImage] x264 [info]: frame B:32130 Avg QP:21.15 size: 6458
-[NoImage] x264 [info]: consecutive B-frames: 0.5% 2.0% 6.4% 68.5% 22.5%
-[NoImage] x264 [info]: mb I I16..4: 10.1% 61.2% 28.6%
-[NoImage] x264 [info]: mb P I16..4: 1.8% 9.8% 2.6% P16..4: 41.7% 28.5% 13.1% 0.0% 0.0% skip: 2.5%
-[NoImage] x264 [info]: mb B I16..4: 0.2% 0.8% 0.2% B16..8: 45.4% 11.7% 2.8% direct: 5.6% skip:33.3% L0:37.5% L1:50.8% BI:11.7%
-[NoImage] x264 [info]: 8x8 transform intra:68.5% inter:70.1%
-[NoImage] x264 [info]: coded y,uvDC,uvAC intra: 79.4% 80.3% 43.9% inter: 26.1% 28.5% 1.1%
-[NoImage] x264 [info]: i16 v,h,dc,p: 18% 12% 10% 59%
-[NoImage] x264 [info]: i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 7% 6% 9% 15% 15% 14% 12% 13%
-[NoImage] x264 [info]: i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 7% 4% 8% 16% 16% 15% 11% 13%
-[NoImage] x264 [info]: i8c dc,h,v,p: 40% 22% 20% 17%
-[NoImage] x264 [info]: Weighted P-Frames: Y:1.9% UV:0.8%
-[NoImage] x264 [info]: ref P L0: 53.0% 15.1% 16.4% 7.6% 7.3% 0.5% 0.0%
-[NoImage] x264 [info]: ref B L0: 85.4% 9.8% 2.9% 1.9%
-[NoImage] x264 [info]: ref B L1: 94.4% 5.6%
-[NoImage] x264 [info]: kb/s:2411.87
-[NoImage] encoded 43030 frames, 21.67 fps, 2411.87 kb/s
头像
-o-o-304-o-o-
超级版主
帖子: 640
注册时间: 2010-10-10 20:00
来自: US
联系: 网站

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

为啥比QP?QP不是“质量”衡量用的标准,想看成品质量对比请参考PSNR/SSIM
---编辑更新部分---
用DSS出现任何RP问题请勿惊讶……
► 显示剧情透露 En Taro 06!Taro Pie NC Fanclub project始动!聊天用Q群开放中
► 显示剧情透露 胸中有万言,退敌无一策,是谓书生误国"
► 显示剧情透露 前辈们的信念
► 显示剧情透露 妇联招新广告,走过路过可以看看撒
► 显示剧情透露 香芋派,后期菊苣们的一致选择
► 显示剧情透露 众菊苣喜评香芋派
► 显示剧情透露 聊天用工具
cunhan
核心会员
核心会员
帖子: 214
注册时间: 2010-09-20 22:09

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

请详述您如何“二次压缩”,否则没人能解答你的问题
fansge
帖子: 36
注册时间: 2010-09-23 21:48

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

max analyze duration 25000000 reached at 25002667
请贴出AVS,源滤镜是什么?参数哪里是一样的,用avs,x264不会强制SAR来保持比例,显然贴出的参数也没写出来。
kenjysn
帖子: 5
注册时间: 2012-12-20 1:44

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

AVS
# Set DAR in encoder to 16 : 9. The following line is for automatic signalling
global MeGUI_darx = 16
global MeGUI_dary = 9
LoadPlugin("C:\Program Files (x86)\WMZHE\Pure Codec\Codecs\avss.dll")
dss2("F:\Download\megui\NoBlit.mp4", fps=29.970).AssumeFPS(30000,1001)
#deinterlace
#crop
LanczosResize(960,544) # Lanczos (Sharp)
#denoise
ConvertToYV12()

注:ConvertToYV12()为使用megui添加时自动增加的项,我采用Megui的AVS创建功能生成的avs脚本,AVS预览时颜色已经和kmplayer中稍有差异,颜色整体偏红(目前还没找到原因),二次压缩直接采用的megui auto二次压缩功能

片源属性如下
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Format settings, GOP : M=1, N=60
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 19mn 55s
Bit rate mode : Variable
Bit rate : 3 800 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 29.970 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.138
Stream size : 540 MiB (93%)
Writing library : x264 core 114 r1913 5fd3dce
fansge
帖子: 36
注册时间: 2010-09-23 21:48

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

avs上我没看出来什么异常,待其他高人来看吧。DSS2好像也要借助dshow的,顺便问下默认的H.264解码器是什么?
kenjysn
帖子: 5
注册时间: 2012-12-20 1:44

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

默认解码器是FFDShow(参数我都没有调节过,用的默认配置),我也试过将解码器改成CoreAVC,用AVS预览的时候效果也是一样的,颜色都偏红。不过用播放器看的时候颜色就是正常的。
头像
mawen1250
核心会员
核心会员
帖子: 670
注册时间: 2011-07-24 20:33

Re: 求助,采用x264 二次编码和CRF达到相同的QP,为啥CRF最终处理帧数不一致呢,难道CRF有丢弃重复帧的判定

--range pc
LZ在这里就有这个问题,把TV Range的源标上PC Range是想干啥:http://bbs.popgo.org/bbs/read.php?tid=553189

AVS里的ConvertTo系列滤镜默认用的都是Rec601的matrix,所以对于通常matrix为Rec709的HD视频直接进行YUV<-->RGB转换后的颜色自然是错误的,而现在的AvsPmod预览时会自动根据源分辨率选择matrix。

至于平均QP值这个东西,只能作为参考不能作为质量衡量的标准,相同的平均QP,而QP的时间空间分布不同,出来的码率和画面质量都会大大不同。crf也一样,相同crf下,aq、mbtree/qcomp、psy-rd、fgo等参数不同,出来的质量可以天上地下。

回到 “视频编码器 / Video encoder discussion”