zyl910

优化技巧、硬件体系、图像处理、图形学、游戏编程、国际化与文本信息处理。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

  x264是一款优秀的H.264编码器,能够压制出低码率高画质的视频。但它的编码参数很多,很多时候不知道怎么挑选。于是我决定做横向测试,彻底搞清楚各种参数的影响。

 

一、测试结果索引

 

  为了便于查看,将测试结果放在最前面。

 

01 subme与crf(a):http://www.cnblogs.com/zyl910/archive/2011/12/14/x264_encode_param_01_subme_crf_a.html

02 subme与crf(b):http://www.cnblogs.com/zyl910/archive/2011/12/15/x264_encode_param_02_subme_crf_b.html

03 subme与crf(c):http://www.cnblogs.com/zyl910/archive/2011/12/15/x264_encode_param_03_subme_crf_c.html

04 subme与crf(f):http://www.cnblogs.com/zyl910/archive/2011/12/16/x264_encode_param_04_subme_crf_f.html

05 subme与crf(g):http://www.cnblogs.com/zyl910/archive/2011/12/17/x264_encode_param_05_subme_crf_g.html

06 subme与crf(h):http://www.cnblogs.com/zyl910/archive/2012/01/05/x264_encode_param_06_subme_crf_h.html

07 subme与crf(小结):http://www.cnblogs.com/zyl910/archive/2012/01/08/x264_encode_param_07_subme_crf_all.html

08 subme与指定码率(1000Kbps):http://www.cnblogs.com/zyl910/archive/2012/01/16/x264_encode_param_08_subme_abr_all.html

09 trellis(crf26):http://www.cnblogs.com/zyl910/archive/2012/01/29/x264_encode_param_09_trellis_crf.html

10 trellis(1000Kbps):http://www.cnblogs.com/zyl910/archive/2012/02/01/x264_encode_param_10_trellis_abr.html

11 me与merange(crf26.a):

12 me与merange(crf26.b):

13 me与merange(crf26.c):

14 me与merange(crf26.f):

15 me与merange(crf26.g):

16 me与merange(crf26.h):

17 me与merange(crf26.小结):

18 me与merange(1000Kbps.a):

19 me与merange(1000Kbps.b):

20 me与merange(1000Kbps.c):

21 me与merange(1000Kbps.f):

22 me与merange(1000Kbps.g):

23 me与merange(1000Kbps.h):

24 me与merange(1000Kbps.小结):

25 direct(crf26):

26 direct(1000Kbps):

27 ref(crf26):

28 ref(1000Kbps):

29 bframes(crf26):

30 bframes(1000Kbps):

31 b-adapt(crf26):

32 b-adapt(1000Kbps):

33 threads(crf26):

34 threads(1000Kbps):

35 rc-lookahead(crf26):

36 rc-lookahead(1000Kbps):

37 open-gop(crf26):

38 open-gop(1000Kbps):

 

 

二、测试方法

 

  测试环境——

i3-2310M, DDR3 1333 4GB, winXP sp3

 

  软件版本——

x264 core:116 r2074 2641b9e

 

  参与测试的视频——

a(红):720P动画 Fate/Zero 07。简称“Fate”。

b(黄):720P动画 Hunter x Hunter 07。简称“HxH”。

c(绿):1080P动画 我的妹妹不可能那么可爱 11。简称“Oreimo”。

f(青):720P电影 《极品飞车12:无间风云》预告片。简称“nfs”。

g(蓝):720P电影 《变形金刚3》预告片。简称“tran3”。

h(紫):1080P电影 CoralReef.1080p(珊瑚礁)。简称“Coral”。

 

  指标说明——

FPS:压制时的帧率。用于比较压制速度,越高越好。

Kbps:码率。单位为Kbps。越低越好(压缩率高)。

SSIM:结构相似性(Structural similarity)指标。用于比较画质,越高越好,上限为1.0。

SSIM_db:以分贝方式表示的SSIM。越高越好。

DSSIM:Structural dissimilarity。DSSIM = 1/(1-SSIM)。用于比较画质,越高越好。

压缩率:压缩率 = 压制后的码率 / 原视频码率。是一个百分比,越低越好。

参考测试:从众多测试结果中选择一个作为参考,用于比较测试结果。

pFPS:相对FPS。pFPS = 当前测试的FPS / 参考测试的FPS。是一个百分比,越高越好。

pSSIM:相对SSIM。pSSIM = 当前测试的SSIM / 参考测试的SSIM。是一个百分比,越高越好。

 

  测试方法——

1.--ssim。输出SSIM信息,用于比较画质。

2.--tune ssim。为了保证SSIM测试结果的稳定性。

 

  测试类型大致可分为两类——

1.crf方式(默认crf26)。用于测试非严格限定码率的场合。

2.指定码率方式(默认1000Kbps)。用于测试严格限定码率的场合。

 

 

2.1 crf方式

 

  默认参数——

--profile main --preset medium --tune ssim --crf 26.0 --threads 2 --bframes 3 --ref 3 --merange 16 --me umh --subme 9 --trellis 2 --ssim

 

  实际的全部参数为——

cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=umh / subme=9 / psy=0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=26.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=2:1.00

 

 

2.2 指定码率方式

 

  默认采用1000Kbps。为了避免其他干扰,采用一次编码模式(abr)。

 

  默认参数——

--profile main --preset medium --tune ssim --bitrate 1000 --threads 2 --bframes 3 --ref 3 --merange 16 --me umh --subme 9 --trellis 2 --ssim

 

  实际的全部参数为——

cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x1:0x111 / me=umh / subme=9 / psy=0 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=1000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=2:1.00

 

 

三、参与测试的视频

 

3.1 a(红):720P动画 Fate/Zero 07

 

  下载地址——

http://bt.ktxp.com/html/2011/1116/225409.html

 

  视频信息——

General
Unique ID : 236703501303336169099493620968487153479 (0xB2136FA4EA03FF38959E0F60ABA86F47)
Complete name : F:\Temp\3\a720 Fate\Fate_Zero07.mkv
Format : Matroska
Format version : Version 2
File size : 361 MiB
Duration : 23mn 59s
Overall bit rate : 2 103 Kbps
Encoded date : UTC 2011-11-13 07:14:03
Writing application : mkvmerge v4.0.0 ('The Stars were mine') built on Jun 6 2010 16:18:42
Writing library : libebml v1.0.0 + libmatroska v1.0.0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Codec ID : V_MPEG4/ISO/AVC
Duration : 23mn 59s
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Writing library : x264 core 116 r2037+592M_L-SMASH/MixAQ bf4a774 [Built by X5-452]
Encoding settings : cabac=1 / ref=4 / deblock=1:1:0 / analyse=0x3:0x133 / me=umh / subme=8 / psy=1 / fade_compensate=0.00 / psy_rd=0.30:0.10 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-3 / threads=8 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=5 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=50 / rc=crf / mbtree=1 / crf=21.0000 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1 / aq-strength=1.00 / aq-sensitivity=10.00 / aq-ifactor=1.00 / aq-pfactor=1.00 / aq-bfactor=1.00 / aq2=1 / aq2-strength=0.80 / aq2-sensitivity=15.00
Language : Japanese
Default : Yes
Forced : No

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : A_AAC
Duration : 23mn 59s
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Language : Japanese
Default : Yes
Forced : No

 

 

  因只测试该视频的OP,avs为——

DirectShowSource("F:\Temp\3\a720 Fate\Fate_Zero07.mkv", fps=23.976, audio=false).trim(840,3240)
#deinterlace
#crop
#resize
#denoise


 

 

3.2 b(黄):720P动画 Hunter x Hunter 07

 

  下载地址——

http://115.com/folder/f281736a1b1

 

  视频信息——

General
Complete name : F:\Temp\3\a720\[FLsnow][HUNTER×HUNTER][07][720p][AVC_AAC].mp4
Format : MPEG-4
Format profile : Base Media
Codec ID : isom
File size : 327 MiB
Duration : 23mn 44s
Overall bit rate mode : Variable
Overall bit rate : 1 922 Kbps
Encoded date : UTC 2011-11-13 09:51:03
Tagged date : UTC 2011-11-13 09:51:03

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L3.1
Format settings, CABAC : Yes
Format settings, ReFrames : 5 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 23mn 44s
Bit rate : 1 726 Kbps
Maximum bit rate : 13.8 Mbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.078
Stream size : 293 MiB (90%)
Writing library : x264 core 119 r2106+624_tMod+MixAQ-8bit 1c8a33e
Encoding settings : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x1:0x131 / me=tesa / subme=10 / psy=1 / fade_compensate=0.60 / psy_rd=0.40:0.10 / mixed_ref=1 / me_range=64 / chroma_me=1 / trellis=2 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=12 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=2 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=infinite / keyint_min=2 / scenecut=40 / intra_refresh=0 / rc_lookahead=160 / rc=crf / mbtree=1 / crf=18.5000 / qcomp=0.80 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1 / aq-strength=0.85 / aq-sensitivity=10.00 / aq-ifactor=1.00 / aq-pfactor=1.00 / aq-bfactor=1.00 / aq2=0 / zones=950,1060,b=1.4,aq-strength=1.2
Encoded date : UTC 2011-11-13 09:51:03
Tagged date : UTC 2011-11-13 09:51:05

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 23mn 44s
Bit rate mode : Variable
Bit rate : 192 Kbps
Maximum bit rate : 230 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 32.6 MiB (10%)
Encoded date : UTC 2011-11-13 09:51:05
Tagged date : UTC 2011-11-13 09:51:05

Menu
00:00:00.000 : intro
00:00:34.034 : op
00:01:58.952 : main-part-1
00:12:00.970 : main-part-2
00:22:04.907 : ed

 

 

  因只测试该视频的OP,avs为——

DirectShowSource("F:\Temp\3\a720 HxH\[FLsnow][HUNTER×HUNTER][07][720p][AVC_AAC].mp4", fps=23.976, audio=false).trim(0,3000)
#deinterlace
#crop
#resize
#denoise


 

 

3.3 c(绿):1080P动画 我的妹妹不可能那么可爱 11

 

  下载地址——

http://bt.ktxp.com/html/2011/1105/223507.html

 

  视频信息——

General
Unique ID : 232115446900662820973631284257627830918 (0xAE9FCF18ECE60A968EBD1B07CDC7FA86)
Complete name : F:\Temp\3\a1080 Oreimo\Oreimo11.mkv
Format : Matroska
Format version : Version 2
File size : 643 MiB
Duration : 24mn 13s
Overall bit rate mode : Variable
Overall bit rate : 3 713 Kbps
Encoded date : UTC 2011-11-04 16:55:08
Writing application : mkvmerge v5.0.1 ('Es ist Sommer') built on Oct 9 2011 11:55:43
Writing library : libebml v1.2.2 + libmatroska v1.3.0

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : High@L4.1
Format settings, CABAC : Yes
Format settings, ReFrames : 4 frames
Muxing mode : Header stripping
Codec ID : V_MPEG4/ISO/AVC
Duration : 24mn 13s
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Title : Video
Writing library : x264 core 112 r1867 22bfd31
Encoding settings : cabac=1 / ref=4 / deblock=1:1:1 / analyse=0x3:0x133 / me=umh / subme=7 / psy=1 / psy_rd=0.40:0.00 / mixed_ref=1 / me_range=16 / chroma_me=0 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / constrained_intra=0 / bframes=5 / b_pyramid=0 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=300 / keyint_min=20 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / vbv_maxrate=38000 / vbv_bufsize=30000 / crf_max=0.0 / nal_hrd=none / ip_ratio=1.40 / aq=1:1.00
Language : Japanese
Default : Yes
Forced : No

Audio
ID : 2
Format : FLAC
Format/Info : Free Lossless Audio Codec
Codec ID : A_FLAC
Duration : 24mn 13s
Bit rate mode : Variable
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Title : Audio
Writing library : libFLAC 1.2.0 (UTC 2007-07-15)
Language : Japanese
Default : Yes
Forced : No


 

  因只测试该视频的OP,avs为——

DirectShowSource("F:\Temp\3\a1080 Oreimo\Oreimo11.mkv", fps=23.976, audio=false).trim(1100,3400)
#blank deinterlace line
#crop
#resize
#denoise


 

 

3.4 f(青):720P电影 《极品飞车12:无间风云》预告片

 

  下载地址——

http://www.gaoqing.tv//movie720/movie720_1153.html

 

  视频信息——

General
Complete name : F:\Temp\3\f720 nfs\nfsundercover.wmv
Format : Windows Media
File size : 131 MiB
Duration : 5mn 33s
Overall bit rate mode : Variable
Overall bit rate : 3 289 Kbps
Maximum Overall bit rate : 5 181 Kbps
Encoded date : UTC 2001-03-10 11:12:33.218

Video
ID : 31
Format : VC-1
Format profile : MP@HL
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Description of the codec : Windows Media Video 9 - Professional
Duration : 5mn 33s
Bit rate mode : Variable
Bit rate : 3 072 Kbps
Width : 1 280 pixels
Height : 720 pixels
Display aspect ratio : 16:9
Frame rate : 29.970 fps
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.111
Stream size : 122 MiB (93%)
Language : English (US)

Audio
ID : 1
Format : WMA
Format version : Version 2
Codec ID : 161
Codec ID/Info : Windows Media Audio
Description of the codec : Windows Media Audio 9.2 - 192 kbps, 48 kHz, stereo (A/V) 1-pass CBR
Duration : 5mn 33s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Stream size : 7.64 MiB (6%)
Language : English (US)

 

 

  因只测试该视频的前100秒,avs为——

DirectShowSource("F:\Temp\3\f720 nfs\nfsundercover.wmv", fps=29.970, audio=false).trim(0,3000)
#deinterlace
#crop
#resize
#denoise


 

 

3.5 g(蓝):720P电影 《变形金刚3》预告片

 

  下载地址——

http://www.dyxiazai.com/yugaopian/transformers3-480p-720p-1080p-trailer.html

 

  视频信息——

General
Complete name : F:\Temp\3\f720 tran3\tran3.mov
Format : MPEG-4
Format profile : QuickTime
Codec ID : qt
File size : 94.4 MiB
Duration : 2mn 27s
Overall bit rate : 5 353 Kbps
Movie name : Transformers: Dark of the Moon
Movie name/More : In theaters 2011
Encoded date : UTC 2011-04-25 22:07:51
Tagged date : UTC 2011-04-25 22:07:53
Writing library : Apple QuickTime 7.6.0
Copyright : ?2011 Paramount Pictures. All Rights Reserved
Comment : Encoded and delivered by apple.com/trailers/
com.apple.quicktime.player.movie : (Binary)

Video
ID : 1
Format : AVC
Format/Info : Advanced Video Codec
Format profile : Main@L3.1
Format settings, CABAC : No
Format settings, ReFrames : 2 frames
Codec ID : avc1
Codec ID/Info : Advanced Video Coding
Duration : 2mn 27s
Bit rate : 5 216 Kbps
Width : 1 280 pixels
Height : 532 pixels
Display aspect ratio : 2.40:1
Frame rate mode : Constant
Frame rate : 23.976 fps
Color space : YUV
Chroma subsampling : 4:2:0
Bit depth : 8 bits
Scan type : Progressive
Bits/(Pixel*Frame) : 0.319
Stream size : 91.9 MiB (97%)
Language : English
Encoded date : UTC 2011-04-25 19:41:01
Tagged date : UTC 2011-04-25 22:07:53
Color primaries : BT.709-5, BT.1361, IEC 61966-2-4, SMPTE RP177
Transfer characteristics : BT.709-5, BT.1361
Matrix coefficients : BT.709-5, BT.1361, IEC 61966-2-4 709, SMPTE RP177

Audio
ID : 2
Format : AAC
Format/Info : Advanced Audio Codec
Format profile : LC
Codec ID : 40
Duration : 2mn 27s
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Channel positions : Front: L R
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 2.33 MiB (2%)
Language : English
Encoded date : UTC 2011-04-25 19:41:02
Tagged date : UTC 2011-04-25 22:07:53
Material_Duration : 147861
Material_StreamSize : 2446946

Menu
ID : 3
Language : English
Encoded date : UTC 2011-04-25 19:41:14
Tagged date : UTC 2011-04-25 22:07:53

 

 

  avs为——

DirectShowSource("F:\Temp\3\f720 tran3\tran3.mov", fps=23.976, audio=false)
LoadPlugin("F:\MeGUI\MeGUI_2050_x86\tools\avisynth_plugin\TIVTC.dll")
TDecimate(cycleR=1)
#crop
#resize
#denoise


 

 

3.6 h(紫):1080P电影 CoralReef.1080p(珊瑚礁)

 

  下载地址——

(忘了当初在哪下载的了。现在网上有很多)

 

  视频信息——

General
Complete name : F:\Temp\3\f1080 CoralReef\CoralReef.1080p.wmv
Format : Windows Media
File size : 103 MiB
Duration : 1mn 43s
Overall bit rate mode : Constant
Overall bit rate : 8 372 Kbps
Maximum Overall bit rate : 8 255 Kbps
Encoded date : UTC 2003-05-16 20:40:55.483

Video
ID : 2
Format : VC-1
Format profile : SP
Codec ID : WMV3
Codec ID/Info : Windows Media Video 9
Codec ID/Hint : WMV3
Description of the codec : Windows Media Video 9 - Professional
Duration : 1mn 43s
Bit rate mode : Constant
Bit rate : 8 000 Kbps
Width : 1 920 pixels
Height : 1 080 pixels
Display aspect ratio : 16:9
Frame rate : 23.976 fps
Bit depth : 8 bits
Scan type : Progressive
Compression mode : Lossy
Bits/(Pixel*Frame) : 0.161
Stream size : 98.3 MiB (96%)
Language : English (US)

Audio
ID : 1
Format : WMA
Format version : Version 2
Codec ID : 161
Codec ID/Info : Windows Media Audio
Description of the codec : Windows Media Audio 9 - 192 kbps, 48 kHz, stereo (A/V) 1-pass CBR
Duration : 1mn 43s
Bit rate mode : Constant
Bit rate : 192 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Bit depth : 16 bits
Stream size : 2.36 MiB (2%)
Language : English (US)


 

  avs为——

DirectShowSource("F:\Temp\3\f1080 CoralReef\CoralReef.1080p.wmv", fps=23.976, audio=false)
LoadPlugin("F:\MeGUI\MeGUI_2050_x86\tools\avisynth_plugin\TIVTC.dll")
TDecimate(cycleR=1)
#crop
#resize
#denoise


 

 

 

posted on 2011-12-14 21:27  zyl910  阅读(7337)  评论(2编辑  收藏  举报