x264参数选择

x264参数选择…

samples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Wind River 2017 1080p BluRay DTS x264-DON

Technical Information:
RELEASE SiZE...: 12.3 GiB
RUNTiME........: 1h 46mn
ViDEO CODEC....: x264 High@L4.1
FRAMERATE......: 23.976 fps
BiTRATE........: Variable ~ 14.6 Mbps
ASPECT RATiO...: 2.40:1
RESOLUTiON.....: 1920x804
AUDiO..........: English DTS 6ch @ 1509 Kbps
CHAPTERS.......: Yes
SOURCE.........: 1080p Blu-ray AVC DTS-HD MA 5.1-MTeam ~ Thanks !
SUBTiTLES......: English,English-SDH,English-SDH-Colored,Spanish,Vietnamese-PDV.

ENCODER........: hungdaita @ DON
RELEASE.DATE...: 08/11/2017

.x264 iNFO:
--crf 17.4 --preset placebo --me umh --subme 11 --bframes 9 --deblock -3:-3 --ipratio 1.30 --pbratio 1.20
--psy-rd 1.0 --qcomp 0.65 --aq-strength 0.80 --merange 32 --no-fast-pskip --no-mbtree --no-dct-decimate

.x264 LOG:
x264 [info]: frame I:1022 Avg QP:14.83 size:183438
x264 [info]: frame P:29306 Avg QP:15.82 size:104870
x264 [info]: frame B:123289 Avg QP:17.13 size: 70814
x264 [info]: consecutive B-frames: 1.2% 1.6% 6.8% 9.1% 8.4% 59.4% 4.9% 1.3% 5.3% 2.1%

encoded 153617 frames, 5.368 fps, 14972.63 kb/s, 11436 MB ~ encoding duration 7:56:57

.NOTES:
* Special thanks to Elheym for the subs.
* Semi-dark, dark scenes background blocking, so they needed mild filter
* and the lower CRF to be kept looking good. Debanded, deblocked with 4 types of f3kdb.
* Greetings: TayTO, DON, Nick007, rose, v0danh, BodoiCuHo, riverstore, wolgone, superstar, AraGorN, NOiZE and my friends !
1
2
Writing library                          : x264 core 152 r2851+58 429492e t_mod_Custom [8-bit@all X86_64]
Encoding settings : cabac=1 / ref=5 / deblock=1:-3:-3 / analyse=0x3:0x133 / me=umh / subme=11 / psy=1 / fade_compensate=0.00 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=12 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=9 / 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=60 / rc=crf / mbtree=0 / crf=17.4000 / qcomp=0.65 / qpmin=0:0:0 / qpmax=69:69:69 / qpstep=4 / vbv_maxrate=62500 / vbv_bufsize=78125 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.30 / pb_ratio=1.20 / aq=3:0.80 / aq-sensitivity=10.00 / aq-factor=1.00:1.00:1.00 / aq2=0 / aq3=0 / zones=85,321,crf=14/900,2062,crf=16.4/2807,2856,crf=14.4/4500,4804,crf=15.4/6490,6510,crf=14.4/7414,7460,crf=15.4/12051,12120,crf=15.4/23430,23472,crf=16.4/23636,23667,crf=14.4/23706,23770,crf=14.4/23806,23875,crf=14.4/23936,23996,crf=15.4/24363,24482,crf=15.4/24524,24621,crf=15.4/24985,25177,crf=15.4/26912,26940,crf=14/27218,27515,crf=15.4/35041,35743,crf=16.4/43222,43313,crf=16.4/44949,45044,crf=14.4/55268,55311,crf=15.4/55504,55667,crf=15.4/57566,58213,crf=15.4/58269,58950,crf=14.4/59075,60253,crf=14.4/63825,63869,crf=14.4/67910,68401,crf=16.8/68782,75218,crf=16.4/83740,84064,crf=14.4/86448,86694,crf=15.4/103154,103582,crf=14.4/116029,116056,crf=14.4/121120,121205,crf=14.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Wind River 2017 1080p BluRay DTS x264-TayTO

CONTAINER FORMAT..: Matroska
SIZE..............: 15.1 GiB
RUNTIME...........: 1:50:27
FRAMERATE.........: 23.976 fps
RESOLUTION........: 1920x804
ASPECT RATIO......: 2.40:1
VIDEO CODEC.......: x264, High@L4.1, ref=5
VIDEO BITRATE.....: 18631 Kbps
AUDIO ............: English DTS 6ch @ 1509 Kbps
SUBTITLES.........: English (US + CAN), English SDH (US + CAN), English SDH Colored (US + CAN) (.srt)
SUBTITLES.........: Arabic, Chinese: Simplified x3 + Traditional x2, Czech, Czech SDH, Danish, Dutch, Finnish (.srt)
SUBTITLES.........: French (Canadian + Fansub), French SDH (Canadian), German, Greek, Hungarian (.srt)
SUBTITLES.........: Korean, Norwegian, Polish, Portuguese, Russian, Slovak, Spanish, Swedish, Ukrainian, Vietnamese (.srt)
CHAPTERS..........: Included
SOURCE............: Wind River 2017 1080p CZE Blu-ray AVC DTS-HD MA 5.1-HyperX (thx KHAN!)
ENCODER...........: Elheym @ TayTO
RELEASE DATE......: 27/07/2018

Notes:
* Encode from better source - more detailed PQ, not contained of any banding.
* Comparisons US vs HUN can be found here. Mirror.
* Some subs have it not perfect sync: some things I synchronized, some not. Chapters from US source, just synced.
* Greetings: to all TayTO members, Juvelir, Delia, hungdaita, leewee, Nick007, rose, wolgone, superstar, and my friends!

x264 [info]: frame I:996 Avg QP:15.00 size:205634
x264 [info]: frame P:28265 Avg QP:16.22 size:131133
x264 [info]: frame B:124763 Avg QP:17.38 size: 88566
x264 [info]: consecutive B-frames: 1.2% 0.9% 5.1% 10.1% 13.4% 45.6% 10.7% 1.9% 3.8% 3.8% 2.2% 1.3%
x264 [info]: kb/s:18631.12
1
2
Writing library                          : x264 core 155 r2867+82 a249126 t_mod_Custom_2 [8-bit@all X86_64]
Encoding settings : cabac=1 / ref=5 / deblock=1:-3:-3 / analyse=0x3:0x133 / me=umh / subme=11 / psy=1 / fade_compensate=0.00 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=32 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=11 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=240 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=0 / crf=17.2000 / qcomp=0.65 / qpmin=0:0:0 / qpmax=69:69:69 / qpstep=4 / vbv_maxrate=62500 / vbv_bufsize=78125 / crf_max=0.0 / nal_hrd=none / filler=0 / ip_ratio=1.30 / pb_ratio=1.20 / aq=3:0.80 / aq-sensitivity=10.00 / aq-factor=1.00:1.00:1.00 / aq2=0 / aq3=0 / zones=1290,2472,crf=15/3217,3266,crf=13/10448,10600,crf=13/26013,27426,crf=15/55914,56022,crf=16/58042,61110,crf=16/64172,64662,crf=13/68501,75628,crf=16/77329,78486,crf=15/136254,138083,crf=15/140176,143825,crf=16

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
release info

RELEASE NAME..: Gladiator.2000.2in1.1080p.BluRay.x264-EbP
RELEASE DATE..: 12/08/2010
RELEASE SIZE..: 16.9 GB
RUNTIME.......: 2:50:56(Extended), 2:34:58(Theatrical)
VIDEO CODEC...: x264, 2pass, L4.1
FRAMERATE.....: 23.976 fps
BITRATE.......: 12 Mbps
RESOLUTION....: 1920x816
AUDIO 1.......: Eng AC3 5.1 @ 640 Kbps
AUDIO 2.......: Commentary with Russell Crowe
AUDIO 3.......: Commentary with Ridley Scott
SUBTITLES.....: eng, dan, dut, fin, fre, ger, ita, nor,
por, spa, swe, commentary
CHAPTER.......: Included
SOURCE........: REMASTERED 1080p AVC Blu-ray DTS-HD MA 5.1
1
2
Writing library                          : x264 core 104 r1688 0b36c6d
Encoding settings : cabac=1 / ref=5 / deblock=1:-3:-3 / analyse=0x3:0x113 / me=tesa / subme=10 / psy=1 / psy_rd=1.10:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-2 / threads=12 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / constrained_intra=0 / bframes=7 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=1 / weightp=2 / keyint=250 / keyint_min=23 / scenecut=40 / intra_refresh=0 / rc=2pass / mbtree=0 / bitrate=12000 / ratetol=1.0 / qcomp=0.60 / qpmin=10 / qpmax=51 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1:0.70

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
.Release.Info
ENCODER...................: Jubowo @ WiKi
RELEASE DATE..............: 2018-07-27
RELEASE SIZE..............: 9.75 GiB
SOURCE....................: JPN 1080p Blu-ray AVC DTS-HD MA 5.1-TTG

.Media.Info
RUNTIME...................: 1h:58m:41s
VIDEO CODEC...............: x264 @ 10244 kbps
RESOLUTION................: 1920x804
DISPLAY ASPECT RATIO......: 2.39:1
FRAME RATE................: 23.976 fps
AUDiO CODEC...............: Japanese DTS 5.1 @ 1510 kbps
SUBTiTLES.................: CHT_SUBPiG

.x264.Info
x264 [info]: profile High, level 4.1 @ pass2
x264 [info]: frame I:1034 Avg QP:11.27 size:240725
x264 [info]: frame P:33307 Avg QP:13.65 size:103687
x264 [info]: frame B:136399 Avg QP:15.05 size: 39684
x264 [info]: consecutive B-frames: 2.1% 1.5% 6.3% 5.6% 9.3% 61.0% 7.6% 1.1% 2.5% 0.9% 2.2%
1
2
3
Writing library : x264 core 129 r2245+704+36 8e61944 tMod+MixAQ [8-
bit@4:2:0 X86_64]
Encoding settings : cabac=1 / ref=5 / deblock=1:-3:-3 / analyse=0x3:0x133 / me=umh / subme=11 / psy=1 / fade_compensate=0.00 / psy_rd=1.05:0.10 / mixed_ref=1 / me_range=64 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=0 / chroma_qp_offset=-3 / threads=18 / lookahead_threads=3 / sliced_threads=0 / nr=0 / decimate=0 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / fgo=0 / bframes=10 / 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=2pass / mbtree=0 / bitrate=10244 / ratetol=1.0 / qcomp=0.70 / qpmin=0 / qpmax=69 / qpstep=4 / cplxblur=20.0 / qblur=0.5 / ip_ratio=1.40 / pb_ratio=1.30 / aq=1 / aq-strength=0.90 / aq-sensitivity=10.00 / aq-ifactor=1.00 / aq-pfactor=1.00 / aq-bfactor=1.00 / aq2=0

参数选择

固定参数 Part 1

1
--level 4.1 --vbv-bufsize 78125 --vbv-maxrate 62500

考虑播放硬件兼容性设置,以上设置是大部分桌面播放设置支持的规格

固定参数 Part 2

1
--preset placebo --me umh  --merange 32 --subme 11 --ref 4? --bframes 16? --deblock -3:-3 --no-fast-pskip --no-mbtree --no-dct-decimate

preset

1
2
3
4
5
6
7
8
9
10
11
12
13
--preset <string>       Use a preset to select encoding settings [medium]
Overridden by user settings.
- veryslow:
--b-adapt 2 --bframes 8 --direct auto
--me umh --merange 24 --partitions all
--ref 16 --subme 10 --trellis 2
--rc-lookahead 60
- placebo:
--bframes 16 --b-adapt 2 --direct auto
--slow-firstpass --no-fast-pskip
--me tesa --merange 24 --partitions all
--rc-lookahead 60 --ref 16 --subme 11
--trellis 2

me方法是preset veryslow和placebo主要区别,实际上无论是在哪个preset基础上修改参数,最终我们还是用到一样的结果。注意preset选这两个档次隐性的包含了

1
--b-adapt 2 --direct auto --trellis 2

–me

Motion search method

umh|esa|tesa

一般用umh配合32-48的merange

–merange

Motion search range

32

x265的参数设置对于merange的为什么设置57这么一个值讲的比较清楚。
x264的宏块16x16,这里设置32是16*2的意思?
如果me选tesa一般可配合小一点的merange,例如16

–subme

Set the subpixel estimation complexity. RDO(Rate Distortion Optimization)

10|11

不怕慢的选11

–no-mbtree

https://forum.doom9.org/showthread.php?t=166356

蓝光电影压制的达成共识的选项,具体的讨论参考上贴内容

–no-fast-pskip

Disables early skip detection on P-frames. Very slightly increases quality at a large speed cost.

为了质量而关闭的选项

–no-dct-decimate

DCT Decimation will drop DCT blocks it deems “unnecessary”. This will improve coding efficiency, with a usually negligible loss in quality. Setting this option will disable it.

为了质量而关闭的选项

–deblock

https://forum.doom9.org/showthread.php?t=109747

-3:-3是真人电影的惯用设置,具体的讨论参考上贴内容

–ref

ref这个参数按照level 4.1是有最大限制的,如果是全屏的1080p应该是4,但是由于我们切过黑边,可能调整成5。具体的计算办法8388608 / (width * height)

–bframes

先用16测试,根据x264返回结果确定

可变参数

剩下的这些参数是控制码率的,针对具体电影具体调整

1
--crf ? --qcomp 0.60 --psy-rd 1.00:0.00 --aq-mode 1 --aq-strength 0.8 --ipratio 1.4 --pbratio 1.3

–crf

The final ratecontrol method: Constant Ratefactor

15-20

最主要的一个控制码率(质量)参数

–qcomp

Quantizer curve compression factor. 0.0 => Constant Bitrate, 1.0 => Constant Quantizer

0.6-0.8

控制时间轴上码率的分配,变化越快的画面倾向与分配跟多的码率,多多少就是有这个参数来控制。注意这个参数是在计算公式中是指数,不宜变化太大。一般用默认值0.6即可,遇到一些动作片,速度与激情,变形金刚这种可以稍微调高一点

–aq-mode –aq-strength

Adaptive Quantization Mode/Strength

–aq-mode 1 –aq-strength 0.8-0.6

官方中–aq-mode 1是标准方法,–aq-mode 2是实验方法。不少mod版本的x264都在这个上面做文章,具体情况参考具体mod版本的说明
aq-strength控制的是同一张画面中码率的分布,值越高越倾向于分配给细节更多码率。当一张画面颗粒感比较强应该用较低的值。0.8是建议值,可以尝试跟宽的取值范围

–ipratio –pbratio

Modifies the target average increase in quantizer for I-frames as compared to P-frames. Higher values increase the quality of I-frames generated

Modifies the target average decrease in quantizer for B-frames as compared to P-frames. Higher values decrease the quality of B-frames generated

–ipratio 1.4 –pbratio 1.3

这一对参数,一般同时变化。这两参数控制i帧与p帧,p帧与b帧的质量比。当你做测试的时候发先p帧,b帧质量比较差,而i帧都满意的时候就该把这个值调小一点了。会明显加大整体码率

–psy-rd

The first number is the strength of Psy-RDO to use (requires subme>=6 to activate). The second number is the strength of Psy-Trellis (requires trellis>=1 to activate). Note that Trellis is still considered ‘experimental’, and almost certainly is a Bad Thing for at least cartoons.

https://forum.doom9.org/showthread.php?t=138293

讨论参考上帖,建议默认,或小幅度调整

最终参数

1
--level 4.1 --vbv-bufsize 78125 --vbv-maxrate 62500 --preset placebo --me umh  --merange 32 --subme 11 --ref ? --bframes ? --deblock -3:-3 --no-fast-pskip --no-mbtree --no-dct-decimate --crf ? --qcomp 0.60? --psy-rd 1.00:0.00? --aq-mode 1 --aq-strength 0.8? --ipratio 1.4? --pbratio 1.3?