x264 01 命令行用法

x264的二进制文件

x264的官网x264, the best H.264/AVC encoder - VideoLAN上有编译好的Windows、Linux、Mac平台对应的二进制文件,比如Windows下是exe文件,可以直接用该文件来进行编码的操作。

x264 Binaries

列表

Windows下的exe列表

x264 --help

C:\Users\ZL Guo\Desktop\x264>x264-r2901-7d0ff22.exe --help
x264 core:155 r2901 7d0ff22
Syntax: x264 [options] -o outfile infile

Infile can be raw (in which case resolution is required),
  or YUV4MPEG (*.y4m),
  or Avisynth if compiled with support (yes).
  or libav* formats if compiled with lavf support (yes) or ffms support (no).
Outfile type is selected by filename:
 .264 -> Raw bytestream
 .mkv -> Matroska
 .flv -> Flash Video
 .mp4 -> MP4 if compiled with GPAC or L-SMASH support (no)
Output bit depth: 8/10
.
Options:

  -h, --help                  List basic options
      --longhelp              List more options
      --fullhelp              List all options

Example usage:

      Constant quality mode:
            x264 --crf 24 -o <output> <input>

      Two-pass with a bitrate of 1000kbps:
            x264 --pass 1 --bitrate 1000 -o <output> <input>
            x264 --pass 2 --bitrate 1000 -o <output> <input>

      Lossless:
            x264 --qp 0 -o <output> <input>

      Maximum PSNR at the cost of speed and visual quality:
            x264 --preset placebo --tune psnr -o <output> <input>

      Constant bitrate at 1000kbps with a 2 second-buffer:
            x264 --vbv-bufsize 2000 --bitrate 1000 -o <output> <input>

Presets:

      --profile <string>      Force the limits of an H.264 profile
                                  Overrides all settings.
                                  - baseline,main,high,high10,high422,high444
      --preset <string>       Use a preset to select encoding settings [medium]
                                  Overridden by user settings.
                                  - ultrafast,superfast,veryfast,faster,fast
                                  - medium,slow,slower,veryslow,placebo
      --tune <string>         Tune the settings for a particular type of source
                              or situation
                                  Overridden by user settings.
                                  Multiple tunings are separated by commas.
                                  Only one psy tuning can be used at a time.
                                  - psy tunings: film,animation,grain,
                                                 stillimage,psnr,ssim
                                  - other tunings: fastdecode,zerolatency

Frame-type options:

  -I, --keyint <integer or "infinite"> Maximum GOP size [250]
      --tff                   Enable interlaced mode (top field first)
      --bff                   Enable interlaced mode (bottom field first)
      --pulldown <string>     Use soft pulldown to change frame rate
                                  - none, 22, 32, 64, double, triple, euro (requ
ires cfr input)

Ratecontrol:

  -B, --bitrate <integer>     Set bitrate (kbit/s)
      --crf <float>           Quality-based VBR (-12-51) [23.0]
      --vbv-maxrate <integer> Max local bitrate (kbit/s) [0]
      --vbv-bufsize <integer> Set size of the VBV buffer (kbit) [0]
  -p, --pass <integer>        Enable multipass ratecontrol
                                  - 1: First pass, creates stats file
                                  - 2: Last pass, does not overwrite stats file

Input/Output:

  -o, --output <string>       Specify output file
      --sar width:height      Specify Sample Aspect Ratio
      --fps <float|rational>  Specify framerate
      --seek <integer>        First frame to encode
      --frames <integer>      Maximum number of frames to encode
      --level <string>        Specify level (as defined by Annex A)
      --quiet                 Quiet Mode

Filtering:

      --vf, --video-filter <filter0>/<filter1>/... Apply video filtering to the
input file

      Filter options may be specified in <filter>:<option>=<value> format.

      Available filters:
      crop:left,top,right,bottom
      resize:[width,height][,sar][,fittobox][,csp][,method]
      select_every:step,offset1[,...]

可以看出命令行的基本用法如下:

Syntax: x264 [options] -o outfile infile

可以输出为以下四种格式:

Outfile type is selected by filename:
 .264 -> Raw bytestream
 .mkv -> Matroska
 .flv -> Flash Video
 .mp4 -> MP4 if compiled with GPAC or L-SMASH support (no)

用法举例

基本用法
x264命令行基本用法

用MediaInfo可查看生成的264文件的信息。


查看编码信息

可以看出默认编码的帧率为25帧/秒,启用了8*8dct变换,qp的最小值为0,qp的最大值为69,qp的步长为4等信息。

指定码率 --bitrate
x264 --bitrate 1000 -o output.264 input_640x360_yuv420p.yuv
编码信息
指定帧率 --fps
x264 --fps 10 -o output.264 input_640x360_yuv420p.yuv
编码信息
指定编码速度 --preset

--preset的参数主要调节编码速度和质量的平衡

--preset <string>       Use a preset to select encoding settings [medium] 
                        Overridden by user settings.
                        - ultrafast,superfast,veryfast,faster,fast
                        - medium,slow,slower,veryslow,placebo
x264 --preset ultrafast -o output.264 input_640x360_yuv420p.yuv

运行过程

可以看出,使用ultrafast参数时,速度非常快,只有I帧和P帧,没有B帧,而且码率也比较大。个人理解是以空间换时间

x264 --preset placebo -o output.264 input_640x360_yuv420p.yuv

运行过程

可以看到使用了更多的编码参数,速度也非常慢,但码率得到了有效控制。个人理解是提高算法复杂度,以时间换空间

配合视觉优化 --tune
 --tune <string>    Tune the settings for a particular type of source 
                    or situation 
                    Overridden by user settings.
                    Multiple tunings are separated by commas.
                    Only one psy tuning can be used at a time.

                    - psy tunings: 
                                   film,
                                   animation,
                                   grain,
                                   stillimage,
                                   psnr,
                                   ssim

                    - other tunings: 
                                    fastdecode,
                                    zerolatency
tune说明

References:

http://blog.csdn.net/daixinmei/article/details/51886850

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • FFmpeg X264编码参数 目录 码率控制 1 X264的preset和tune 2 编码延时建议...
    古则阅读 30,581评论 1 15
  • 相关 x264编码示例 源码分析 h264编码原理复杂,参数众多。为了方便使用无论x264还是其他编码的实现框架,...
    Don_阅读 2,270评论 0 1
  • [TOC] 音视频&流媒体 是什么促使我要写这一篇音视频入门文章?那是因为和一妹子打赌码率的概念,结果输了;对一个...
    AllenWu阅读 4,992评论 1 24
  • 精致的女人, 是一种对生活认真负责, 热爱且珍惜的态度。 扮靓是女人一生的战略目标;是自我价值的提升;容貌+服饰+...
    予美形象管理阅读 802评论 0 3
  • “你害怕死亡吗。她看着我。小时候,家里死人,我站在棺材旁边看,不明白一切为什么可以这样完美地停顿。”(安妮宝贝) ...
    三木科阅读 386评论 2 0