2010年7月19日
x264的码率控制是基于lib 几点理论:1、固定质量并不等价于PSNR 几种码率控制模式:2pass:指定目标码率,2趟 ABR:1趟编码,平均码率 CBR:1趟编码,恒定码率(用VBV限制) CRF:1趟编码,恒定码率因子 CQP:恒定量化参数 以上所有类型: 翻译自:http://git. FLV及各profile的x2
|
01 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -o 2.avi -of lavf -nosound -ovc lavc -lavcopts
vcodec=flv:vbit<wbr>rate=400:mbd=2:<wbr>mv0:trell:v4mv:<wbr>cbp:last_pred=3<wbr> |
02 |
real 1m52.594s |
03 |
user 1m52.272s |
04 |
sys 0m0.314s |
05 |
06 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:noc<wbr>abac:weightp=0:<wbr>no8x8dct:bframe<wbr>s=0:weight_b:mi<wbr>xed-refs:trelli<wbr>s=2:partitions=<wbr>all:me=umh:subq<wbr>=7:threads=1 |
07 |
real 3m57.288s |
08 |
user 3m56.771s |
09 |
sys 0m0.456s |
10 |
11 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:cab<wbr>ac:weightp=2:no<wbr>8x8dct:bframes=<wbr>3:weight_b:mixe<wbr>d-refs:trellis=<wbr>2:partitions=al<wbr>l:me=umh:subq=7<wbr>:threads=1 |
12 |
real 5m41.048s |
13 |
user 5m40.507s |
14 |
sys 0m0.470s |
15 |
16 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:cab<wbr>ac:weightp=2:8x<wbr>8dct:bframes=3:<wbr>weight_b:mixed-<wbr>refs:trellis=2:<wbr>partitions=all:<wbr>me=umh:subq=7:t<wbr>hreads=1 |
17 |
real 6m1.585s |
18 |
user 6m1.050s |
19 |
sys 0m0.479s |
20 |
21 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:cab<wbr>ac:weightp=2:8x<wbr>8dct:bframes=3:<wbr>weight_b:mixed-<wbr>refs:trellis=2:<wbr>partitions=all:<wbr>me=dia:subq=6:t<wbr>hreads=1 |
22 |
real 4m17.232s |
23 |
user 4m16.680s |
24 |
sys 0m0.518s |
25 |
26 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:cab<wbr>ac:weightp=2:8x<wbr>8dct:bframes=3:<wbr>weight_b:mixed-<wbr>refs:trellis=2:<wbr>partitions=all:<wbr>me=dia:subq=5:t<wbr>hreads=1 |
27 |
real 3m27.635s |
28 |
user 3m27.140s |
29 |
sys 0m0.485s |
30 |
31 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:noc<wbr>abac:weightp=0:<wbr>no8x8dct:bframe<wbr>s=0:weight_b:mi<wbr>xed-refs:trelli<wbr>s=2:partitions=<wbr>all:me=dia:subq<wbr>=6:threads=1 |
32 |
real 2m57.230s |
33 |
user 2m56.772s |
34 |
sys 0m0.447s |
35 |
36 |
[root@localhost<wbr> bvideo] #
time mencoder 1.mpg -nosound -o 2.avi -ovc x264 -x264encopts
bitrate=400:noc<wbr>abac:weightp=0:<wbr>no8x8dct:bframe<wbr>s=0:weight_b:mi<wbr>xed-refs:trelli<wbr>s=2:partitions=<wbr>all:me=dia:subq<wbr>=5:threads=1 |
37 |
real 2m39.449s |
38 |
user 2m38.969s |
39 |
sys 0m0.468s |
用MP4Box抽出纯h264的
01 |
#! /usr/bin/env perl |
02 |
03 |
my $h264file = shift ; |
04 |
local $/; |
05 |
open my $fh , "<" , $h264fi <wbr>le; |
06 |
my $bin = < $fh >; |
07 |
08 |
my $reg = qr(x264[\w\d\s\<wbr>=\:\_\-\,\.\/\\<wbr>]*); |
09 |
my ( $str ) = $bin =~ /( $reg )/; |
10 |
11 |
$str =~ s/./ /g; |
12 |
$bin =~ s/ $reg / $str /; |
13 |
14 |
close $fh ; |
15 |
16 |
open $fh , ">" , $h264fi <wbr>le; |
17 |
print $fh $bin ; |
18 |
close $fh ; |
MP4Box和mp4tags都
H264视频解码的速度是编码速
如果有硬解码设备参与,这速度比
在没有显卡的Server上:
1 |
time mencoder 1.mpg -ovc raw -of rawvideo -nosound -o 1.raw |
2 |
user 0m3.706s |
3 |
sys 0m1.704s |
4 |
5 |
time x264 -o 1.h264 --fps 25 --bitrate 500 1.raw 600x450 |
6 |
user 1m6.952s |
7 |
sys 0m0.641s |
以上的实验中编码速度为解码速度
考虑到我们编码的一大堆参数,而
H264 Main 释放出来的raw文件是原来的5
MPEG 释放出来的raw文件是原来的1
avis [info]: 1280×544 @ 23.98 fps (239470 frames)
输入文件的分辨率、帧率、总帧数
x264 [info]: using cpu capabilities: MMX MMXEXT SSE SSE2 3DNow!
CPU中可被x264使用的指令
x264 [warning]: VBV maxrate specified, but no bufsize.
定义了码率,没定义缓冲区的警报
mp4 [info]: initial delay 834166 (scale 10000000)
x264 [info]: slice I:2323 Avg QP:19.01 size: 78885a 0:00:00
x264 [info]: slice P:101512 Avg QP:21.38 size: 28261
x264 [info]: slice B:135635 Avg QP:22.36 size: 9179
每种帧使用的数量,平均量化参数
x264 [info]: mb I I16..4: 19.1% 75.0% 5.9%
x264 [info]: mb P I16..4: 6.8% 17.0% 1.1% P16..4: 36.9% 6.0% 7.8% 0.0% 0.0% skip:14.4%
x264 [info]: mb B I16..4: 0.3% 1.0% 0.2% B16..8: 26.6% 2.0% 4.4% direct: 4.5% skip:61.0%
各种块类型的使用。这里显示了5
x264 [info]: 8×8 transform intra:68.8% inter:73.5%
转换中开启了-8x8dct参数
x264 [info]: coded y,uvDC,uvAC intra: 32.1% 39.2% 15.9% inter: 17.9% 13.6% 1.5%
至少含有一个DCT系数的8x8
x264 [info]: direct mvs spatial:96.3% temporal:3.7%
如果使用了默认的–direct
x264 [info]: ref P 68.0% 17.8% 6.6% 4.6% 2.9%
x264 [info]: ref B 83.3% 10.7% 2.9% 1.9% 1.2%
5个百分数说明编码时设置了fr
x264 [info]: kb/s:3441.8
编码出的H264的最终码率。
encoded 239470 frames, 3.55 fps, 3441.84 kb/s
总帧数,编码速度(每秒 编了多少帧),总帧率
翻译自:http://foru
1、2、4、8
1、更多的线程会消耗更多总CP
2、获得的时间收益随线程增多呈
3、PNSR下降随线程数增加呈
4、设置threads=aut
如果启用了turbo特性,那么
测试机器配置为:Xeon E5520(8核+超线程),内
threads = 1:
x264 [info]: SSIM Mean Y:0.9719788
x264 [info]: PSNR Mean Y:38.438 U:43.524 V:41.191 Avg:39.352 Global:38.796 kb/s:401.41
real 0m45.528s
user 0m45.486s
sys 0m0.047s
threads = 2:
x264 [info]: SSIM Mean Y:0.9719308
x264 [info]: PSNR Mean Y:38.434 U:43.525 V:41.228 Avg:39.353 Global:38.806 kb/s:401.40
real 0m26.281s
user 0m46.744s
sys 0m0.086s
threads = 4:
x264 [info]: SSIM Mean Y:0.9718774
x264 [info]: PSNR Mean Y:38.429 U:43.508 V:41.222 Avg:39.348 Global:38.817 kb/s:401.11
real 0m14.951s
user 0m47.585s
sys 0m0.117s
threads = 8:
x264 [info]: SSIM Mean Y:0.9716865
x264 [info]: PSNR Mean Y:38.397 U:43.480 V:41.171 Avg:39.313 Global:38.802 kb/s:400.77
real 0m8.368s
user 0m48.637s
sys 0m0.093s
threads = 12:
x264 [info]: SSIM Mean Y:0.9713859
x264 [info]: PSNR Mean Y:38.311 U:43.417 V:41.130 Avg:39.235 Global:38.734 kb/s:400.34
real 0m7.209s
user 0m51.494s
sys 0m0.110s
threads = 16:
x264 [info]: SSIM Mean Y:0.9706691
x264 [info]: PSNR Mean Y:38.198 U:43.415 V:41.077 Avg:39.136 Global:38.607 kb/s:399.22
real 0m6.962s
user 0m52.314s
sys 0m0.121s
threads = 24:
x264 [info]: SSIM Mean Y:0.9686221
x264 [info]: PSNR Mean Y:37.972 U:43.254 V:40.949 Avg:38.914 Global:38.071 kb/s:400.82
real 0m6.927s
user 0m53.975s
sys 0m0.116s
threads = auto:
x264 [info]: SSIM Mean Y:0.9686221
x264 [info]: PSNR Mean Y:37.972 U:43.254 V:40.949 Avg:38.914 Global:38.071 kb/s:400.82
real 0m6.941s
user 0m53.422s
sys 0m0.144s
这份指南主要介绍两类编码选项:
第一类,主要对速度质量平衡造成
第二类,可以满足个性化需求的选
要注意的是,虽然不是主要目的,
继续之前还有两点要说明:
1、这份指南只以一个指标作为视
2、所有的选项介绍以使用2次编
1、subq。它和下面的frameref是
如果是要在速度和质量牺牲一者换
不管frameref怎样设置,
subq=6更慢一些,但会换来
subq=7是最慢质量最好的选
2、frameref。它的默认值是1,但不意味着1
把frameref调整到2就可
不幸的是,从3开始,收益开始迅
但无论frameref调得再高
目前,如果把frameref调
如果十分在意编码速度,可以在第
frameref可能偶尔会影响
3、me。这个选项用于选择运动估计搜索
me=dia比默认选项(me=
4、partition=all。这个选项会在默认值的
5、bframes。如果用其它编码器编码,会发现
B帧对提高PSNR有重大作用,
6、b_adapt。默认开启,此时编码器将用一个
可以使用b_bias选项调节排
7、b_pyramid。如果bframes选项大于等
8、weight_b。这个选项通常不会带来什么好处
在MPEG-4 ASP中,类似的场景会用一连串
9、threads。此选项可以在多核CPU的机器
1、2次编码。
本文一开始建议始终开启2次编码
再反过来继续说说2次编码的好处
多次编码能对码率分配产生非常大
另外,2次编码并不真的要花费2
2、3次编码。
x264可以进行任意次数的连续
但在实际应用中,这样做所带来的
对于高级用户而言,3次以上的编
3、qcomp。用于调节在视频片段间转移码率
一个极端就是设置qcomp=0
qcomp=0.6是默认值,大
4、keyint。这是唯一平衡编码效率和视频可
默认值是250,这意味着在1个
5、deblock。该参数调整的是H.264内循
这是这篇指南中唯一一个稍微有些
此滤镜默认的行为是大力过滤QP
一些人认为应该大幅度调低过滤强
首先且必须知道的是,这个内循环
正值会导致滤镜干掉更多视频细节
如果视频源不是空间复杂度很高(
以上并非说明调低反块效应滤镜的
我们还能在后续处理中进一步处理
以下参数演示了在目标码率相同时
测试环境:
视频源:720×448@29.
注意1:表格第三列的PSNR数
注意2:不同视频源、转码机器和
类型 | 参数选择 | 每秒编码帧数 | 相对 PSNR 损失 |
---|---|---|---|
超高质量 | subq=6:partitio :me=umh:framere b_pyramid:weigh |
6fps | 0dB |
高质量 | subq=5:8x8dct:f bframes=3:b_pyr |
13fps | -0.89dB |
快速 | subq=4:bframes= |
17fps | -1.48dB |
本文翻译自:http://ww
|