使用ffmpeg转码H.264视频:
参考帖子:
最终我得出的最精简配置是:
ffmpeg -i 我的视频.ogv -subq 9 -me_range 32 -g 250 -i_qfactor 1.3 -b_qfactor 1.4 test.m4v
(省略了-vcodec libx264,因为使用m4v自动就这样了,如果使用其他的扩展名,就要手动指定这个参数,如mkv扩展名)
ps我目前使用的最佳(清晰、高压缩、超级速度)转换命令:
- bufsize 影响速度
- cqp 影响质量 0-31,越小最终文件越小
- coder(0,1) 设置1启用cabac算法
- refs:参考帧,缺省6,越小文件越小
ffmpeg -i 我的视频.ogv -threads 2 -bufsize 700000k -vcodec libx264 -cqp 28 -coder 1 -refs 3 -me_method umh -subq 9 -me_range 32 -g 250 -i_qfactor 1.3 -b_qfactor 1.4 我的视频.mkv
我测试了,加上coder和refs后对压缩的共享还是比较少的。
各个参数含义:
- -subq 1-9 default 6
- -me_range 32
For HEX and DIA, this is clamped to between 4 and 16, with a default of 16.
For UMH and ESA, it can be increased beyond the default 16 to allow for a wider-range motion search, which is useful on HD footage and for high-motion footage. Note that for UMH and ESA, increasing MErange will significantly slow down encoding. - -g==>-keyint default 250 (1-250)
- -i_qfactor 1.3 Qscale difference between I-frames and P-frames.
- -b_qfactor 1.4 Qscale difference between P-frames and B-frames.