记录FFmpeg的help文档中命令行参数。

来源:互联网 发布:请叫我威廉三世知轩 编辑:程序博客网 时间:2024/06/04 08:47

 

 

Synopsis:

ffmpeg [global_options] {[input_file_options] -i input_file}... {[output_file_options]output_file}...

Description

ffmpegis a very fast video and audio converter that can also grab from a liveaudio/video source. It can also convert between arbitrary sample rates andresize video on the fly with a high quality polyphase filter.

Ffmpeg是一种快速的转换和截取视频和音频的工具。

ffmpegreads from an arbitrary number of input "files" (which can be regularfiles, pipes, network streams, grabbing devices, etc.), specified by the -i option, and writes to an arbitrary number of output"files", which are specified by a plain output filename. Anythingfound on the command line which cannot be interpreted as an option isconsidered to be an output filename.

Ffmpeg通过-i 选项 指明输入文件名,通过-o选项指明输出文件,且输入和输出文件可以为多个文件。

Each input or output file can, inprinciple, contain any number of streams of different types (video/audio/subtitle/attachment/data).The allowed number and/or types of streams may be limited by the containerformat. Selecting which streams from which inputs will go into which output iseither done automatically or with the -map option (see the Stream selection chapter).

输入和输出文件的数量和类型可以不同,并由容器的格式决定。输入和输出的映射关系可以通过-map参数来进行设置。

To refer to input files in options,you must use their indices (0-based). E.g. the first input file is 0, the second is 1, etc. Similarly, streams within a file are referred to bytheir indices. E.g. 2:3refers to the fourth stream in the third input file. Also see the Streamspecifiers chapter.

命令中文件的索引参数,可以是从0开始的数字。一个文件中的流也可以通过索引来指明。

As a general rule, options areapplied to the next specified file. Therefore, order is important, and you canhave the same option on the command line multiple times. Each occurrence isthen applied to the next input or output file. Exceptions from this rule arethe global options (e.g. verbosity level), which should be specified first.

命令中的参数,顺序很重要,如果用在后面是针对某个文件的,如果放在最前面则是全局命令参数。

Do not mix input and output files –first specify all input files, then all output files. Also do not mix optionswhich belong to different files. All options apply ONLY to the next input oroutput file and are reset between files.

  • To set the video bitrate of the output file to 64 kbit/s:

·       ffmpeg -i input.avi -b:v 64k-bufsize 64k output.avi

  • To force the frame rate of the output file to 24 fps:

·       ffmpeg -i input.avi -r 24 output.avi

  • To force the frame rate of the input file (valid for raw formats only) to 1 fps and the frame rate of the output file to 24 fps:

·       ffmpeg -r 1 -i input.m2v -r 24output.avi

The format option may be needed forraw input files.

输入文件在命令前边,输出文件在后面。命令参数只要用在其后的文件中。

Detaileddescription

The transcodingprocess

in ffmpeg for each output can be described by the following diagram:

 _______              ______________

|       |            |              |

|input |  demuxer   | encoded data |   decoder

|file  | ---------> | packets      | -----+

|_______|            |______________|      |

                                           v

                                      _________

                                      |         |

                                      | decoded|

                                      | frames  |

                                     |_________|

 ________             ______________       |

|        |           |              |      |

|output | <-------- | encoded data | <----+

|file   |  muxer   | packets      |  encoder

|________|           |______________|

 

 

ffmpegcalls the libavformat library (containing demuxers) to read input files and getpackets containing encoded data from them. When there are multiple input files,ffmpeg tries to keep them synchronized bytracking lowest timestamp on any active input stream.

Ffmpeg调用libavformat库,包含去多路器来 读取输入文件。当有多个输入文件,ffmpeg来跟踪输入流的时间戳。

Encoded packets are then passed tothe decoder (unless streamcopy is selected for the stream, see further for adescription). The decoder produces uncompressed frames (raw video/PCMaudio/...) which can be processed further by filtering (see next section).After filtering, the frames are passed to the encoder, which encodes them andoutputs encoded packets. Finally those are passed to the muxer, which writesthe encoded packets to the output file.

编码的包传给解码器,产生无压缩的原始编码,通过滤波器之后,传给编码器重新编码,并输出编码的包,最后传给混合器,并输出到输出文件。

Filtering

Before encoding, ffmpeg can process rawaudio and video frames using filters from the libavfilter library. Severalchained filters form a filter graph.ffmpegdistinguishes between two types of filtergraphs: simple and complex.

Ffmpeg支持对原始帧数据进行滤波,主要通过libavfilter库来实现。不同的filtergraphs类型,简单和复杂的。

Simplefiltergraphs

Simple filtergraphs are those that have exactly one input and output, bothof the same type. In the above diagram they can be represented by simplyinserting an additional step between decoding and encoding:

 _________                        ______________
|         |                      |              |
| decoded |                      | encoded data |
| frames  |\                   _ | packets      |
|_________| \                  /||______________|
             \   __________   /
  simple     _\||          | /  encoder
  filtergraph   | filtered |/
                | frames   |
                |__________|
 
简单模式的filtergraphs。

Simple filtergraphs are configured with the per-stream -filteroption (with-vf and-af aliases for video and audiorespectively). A simple filtergraph for video can look for example like this:

 _______        _____________        _______        ________
|       |      |             |      |       |      |        |
| input | ---> | deinterlace | ---> | scale | ---> | output |
|_______|      |_____________|      |_______|      |________|
 

Note that some filters change frame properties but not frame contents. E.g.thefps filter in theexample above changes number of frames, but does not touch the frame contents.Another example is thesetptsfilter, which only sets timestamps and otherwise passes the frames unchanged.

Complexfiltergraphs

Complex filtergraphs are those which cannot be described as simply a linearprocessing chain applied to one stream. This is the case, for example, when thegraph has more than one input and/or output, or when output stream type isdifferent from input. They can be represented with the following diagram:

 _________
|         |
| input 0 |\                    __________
|_________| \                  |          |
             \   _________    /| output 0 |
              \ |         |  / |__________|
 _________     \| complex | /
|         |     |         |/
| input 1 |---->| filter  |\
|_________|     |         | \   __________
               /| graph   |  \ |          |
              / |         |   \| output 1 |
 _________   /  |_________|    |__________|
|         | /
| input 2 |/
|_________|
 

Complex filtergraphs are configured with the -filter_complexoption. Note that this option is global, since a complex filtergraph, by itsnature, cannot be unambiguously associated with a single stream or file.

The -lavfi option is equivalent to -filter_complex.

A trivial example of a complex filtergraph is the overlay filter, which has two videoinputs and one video output, containing one video overlaid on top of the other.Its audio counterpart is theamixfilter.

Stream copy

Stream copy is a mode selected by supplying the copyparameter to the-codec option. It makesffmpegomit the decoding and encoding step for the specified stream, so it does onlydemuxing and muxing. It is useful for changing the container format ormodifying container-level metadata. The diagram above will, in this case,simplify to this:

 _______              ______________            ________
|       |            |              |          |        |
| input |  demuxer   | encoded data |  muxer   | output |
| file  | ---------> | packets      | -------> | file   |
|_______|            |______________|          |________|
 

Since there is no decoding or encoding, it is very fast and there is noquality loss. However, it might not work in some cases because of many factors.Applying filters is obviously also impossible。

流复制,对于不需要进行编解码的应用,在-codec的选项后面添加copy参数。可以忽略掉ffmpeg的编解码步骤,只是改变了视频流的封装格式。一般这种变换是质量无损的变换,没有必要使用滤波器。

Stream selection

By default, ffmpeg includes only onestream of each type (video, audio, subtitle) present in the input files andadds them to each output file. It picks the "best" of each based uponthe following criteria: for video, it is the stream with the highestresolution, for audio, it is the stream with the most channels, for subtitles,it is the first subtitle stream. In the case where several streams of the sametype rate equally, the stream with the lowest index is chosen.

You can disable some of those defaults by using the -vn/-an/-snoptions. For full manual control, use the-mapoption, which disables the defaults just described.

Options

All the numerical options, if not specified otherwise, accept a stringrepresenting a number as input, which may be followed by one of the SI unit prefixes,for example: ’K’, ’M’, or ’G’.

If ’i’ is appended to the SI unit prefix, the complete prefix will beinterpreted as a unit prefix for binary multiples, which are based on powers of1024 instead of powers of 1000. Appending ’B’ to the SI unit prefix multipliesthe value by 8. This allows using, for example: ’KB’, ’MiB’, ’G’ and ’B’ asnumber suffixes.

Options which do not take arguments are boolean options, and set thecorresponding value to true. They can be set to false by prefixing the option namewith "no". For example using "-nofoo" will set the booleanoption with name "foo" to false.

单位 K,M,G。B->byte。-noXXX,表示不设置此选项。

Stream specifiers

码流说明符

Some options are applied per-stream,e.g. bitrate or codec. Stream specifiers are used to precisely specify whichstream(s) a given option belongs to.

主要针对码流的配置选项,用于精准的控制哪个码流的特性。

A stream specifier is a stringgenerally appended to the option name and separated from it by a colon. E.g. -codec:a:1ac3 contains the a:1 stream specifier, which matches the second audio stream.Therefore, it would select the ac3 codec for the second audio stream.

A stream specifier can match severalstreams, so that the option is applied to all of them. E.g. the streamspecifier in -b:a 128k matches all audio streams.

码流说明符由冒号分割,如-codec:a:1  ac3,指示,是音频码流,是第二个码流,使用ac3音频编码格式。如果没有a后面的1,指的是对所有的码流有效,如 –b:a 128k,设置的是所有的码流。

An empty stream specifier matchesall streams. For example, -codec copy or -codec: copy would copy all the streams without reencoding.

如果码流说明符,有copy,则是不需要进行编解码的。

Possible forms of stream specifiersare:

所有的码流说明符。

stream_index

Matchesthe stream with this index. E.g. -threads:14 would set the thread count for thesecond stream to 4.

码流索引号。

stream_type[:stream_index]

stream_type is one of following: ’v’ or ’V’ for video, ’a’ for audio,’s’ for subtitle, ’d’ for data, and ’t’ for attachments. ’v’ matches all videostreams, ’V’ only matches video streams which are not attached pictures, videothumbnails or cover arts. If stream_index is given, then it matchesstream number stream_index of this type. Otherwise, it matches allstreams of this type.

码流类型。

v

视频

a

音频

s

字母

d

数据

t

附加

 

p:program_id[:stream_index]

If stream_indexis given, then it matches the stream with number stream_index in theprogram with the idprogram_id. Otherwise, it matches all streams in theprogram.

#stream_id or i:stream_id

Match thestream by stream id (e.g. PID in MPEG-TS container).

通过stream_id来选择码流。

m:key[:value]

Matchesstreams with the metadata tag key having the specified value. Ifvalueis not given, matches streams that contain the given tag with any value.

通过元数据tag的key值,来选择码流。

u

Matchesstreams with usable configuration, the codec must be defined and the essentialinformation such as video dimension or audio sample rate must be present.

Note thatin ffmpeg, matching by metadata will onlywork properly for input files.

Generic options

These options are shared amongst theff* tools.

-L

Showlicense.

-h, -?, -help, --help [arg]

Show help.An optional parameter may be specified to print help about a specific item. Ifno argument is specified, only basic (non advanced) tool options are shown.

Possiblevalues of arg are:

long

Printadvanced tool options in addition to the basic tool options.

full

Printcomplete list of options, including shared and private options for encoders,decoders, demuxers, muxers, filters, etc.

decoder=decoder_name

Printdetailed information about the decoder named decoder_name. Use the -decoders option to get a list of all decoders.

encoder=encoder_name

Printdetailed information about the encoder named encoder_name. Use the -encoders option to get a list of all encoders.

demuxer=demuxer_name

Printdetailed information about the demuxer named demuxer_name. Use the -formats option to get a list of all demuxers and muxers.

muxer=muxer_name

Printdetailed information about the muxer named muxer_name. Use the -formats option to get a list of all muxers and demuxers.

filter=filter_name

Printdetailed information about the filter name filter_name. Use the -filters option to get a list of all filters.

-version

Showversion.

-formats

Show availableformats (including devices).

-devices

Showavailable devices.

-codecs

Show allcodecs known to libavcodec.

Note thatthe term ’codec’ is used throughout this documentation as a shortcut for whatis more correctly called a media bitstream format.

-decoders

Showavailable decoders.

-encoders

Show allavailable encoders.

-bsfs

Showavailable bitstream filters.

-protocols

Showavailable protocols.

-filters

Showavailable libavfilter filters.

-pix_fmts

Showavailable pixel formats.

-sample_fmts

Showavailable sample formats.

-layouts

Showchannel names and standard channel layouts.

-colors

Showrecognized color names.

-sources device[,opt1=val1[,opt2=val2]...]

Showautodetected sources of the intput device. Some devices may providesystem-dependent source names that cannot be autodetected. The returned listcannot be assumed to be always complete.

ffmpeg-sources pulse,server=192.168.0.4

-sinks device[,opt1=val1[,opt2=val2]...]

Showautodetected sinks of the output device. Some devices may providesystem-dependent sink names that cannot be autodetected. The returned listcannot be assumed to be always complete.

ffmpeg-sinks pulse,server=192.168.0.4

-loglevel [repeat+]loglevel | -v [repeat+]loglevel

Set thelogging level used by the library. Adding "repeat+" indicates thatrepeated log output should not be compressed to the first line and the"Last message repeated n times" line will be omitted."repeat" can also be used alone. If "repeat" is used alone,and with no prior loglevel set, the default loglevel will be used. If multipleloglevel parameters are given, using ’repeat’ will not change the loglevel.loglevelis a string or a number containing one of the following values:

‘quiet, -8’

Shownothing at all; be silent.

‘panic, 0’

Only showfatal errors which could lead the process to crash, such as and assert failure.This is not currently used for anything.

‘fatal, 8’

Only showfatal errors. These are errors after which the process absolutely cannotcontinue after.

‘error, 16’

Show allerrors, including ones which can be recovered from.

‘warning, 24’

Show allwarnings and errors. Any message related to possibly incorrect or unexpectedevents will be shown.

‘info, 32’

Showinformative messages during processing. This is in addition to warnings anderrors. This is the default value.

‘verbose, 40’

Same as info, except more verbose.

‘debug, 48’

Showeverything, including debugging information.

‘trace, 56’

By defaultthe program logs to stderr, if coloring is supported by the terminal, colorsare used to mark errors and warnings. Log coloring can be disabled setting theenvironment variable AV_LOG_FORCE_NOCOLOR or NO_COLOR, or can be forced setting the environment variable AV_LOG_FORCE_COLOR. The use of the environment variable NO_COLOR is deprecated and will be dropped in a following FFmpegversion.

-report

Dump fullcommand line and console output to a file named program-YYYYMMDD-HHMMSS.log in the current directory. This file can be useful for bugreports. It also implies -loglevel verbose.

Settingthe environment variable FFREPORT to any value has the same effect. If the value is a’:’-separated key=value sequence, these options will affect the report; optionvalues must be escaped if they contain special characters or the optionsdelimiter ’:’ (see the “Quoting and escaping” section in the ffmpeg-utilsmanual).

Thefollowing options are recognized:

file

set thefile name to use for the report; %p is expanded to the name of the program, %t is expanded to a timestamp, %% is expanded to a plain %

level

set thelog verbosity level using a numerical value (see -loglevel).

Forexample, to output a report to a file named ffreport.log using a log level of 32 (alias for log level info):

FFREPORT=file=ffreport.log:level=32ffmpeg -i input output

Errors inparsing the environment variable are not fatal, and will not appear in thereport.

-hide_banner

Suppressprinting banner.

All FFmpegtools will normally show a copyright notice, build options and libraryversions. This option can be used to suppress printing this information.

-cpuflags flags (global)

Allowssetting and clearing cpu flags. This option is intended for testing. Do not useit unless you know what you’re doing.

ffmpeg-cpuflags -sse+mmx ...

ffmpeg-cpuflags mmx ...

ffmpeg-cpuflags 0 ...

Possibleflags for this option are:

‘x86’

‘mmx’

‘mmxext’

‘sse’

‘sse2’

‘sse2slow’

‘sse3’

‘sse3slow’

‘ssse3’

‘atom’

‘sse4.1’

‘sse4.2’

‘avx’

‘avx2’

‘xop’

‘fma3’

‘fma4’

‘3dnow’

‘3dnowext’

‘bmi1’

‘bmi2’

‘cmov’

‘ARM’

‘armv5te’

‘armv6’

‘armv6t2’

‘vfp’

‘vfpv3’

‘neon’

‘setend’

‘AArch64’

‘armv8’

‘vfp’

‘neon’

‘PowerPC’

‘altivec’

‘Specific Processors’

‘pentium2’

‘pentium3’

‘pentium4’

‘k6’

‘k62’

‘athlon’

‘athlonxp’

‘k8’

-opencl_bench

Thisoption is used to benchmark all available OpenCL devices and print the results.This option is only available when FFmpeg has been compiled with --enable-opencl.

WhenFFmpeg is configured with --enable-opencl, the options for the global OpenCL context are set via -opencl_options. See the "OpenCL Options" section in theffmpeg-utils manual for the complete list of supported options. Amongst others,these options include the ability to select a specific platform and device torun the OpenCL code on. By default, FFmpeg will run on the first device of thefirst platform. While the options for the global OpenCL context provideflexibility to the user in selecting the OpenCL device of their choice, mostusers would probably want to select the fastest OpenCL device for their system.

Thisoption assists the selection of the most efficient configuration by identifyingthe appropriate device for the user’s system. The built-in benchmark is run onall the OpenCL devices and the performance is measured for each device. Thedevices in the results list are sorted based on their performance with thefastest device listed first. The user can subsequently invoke ffmpeg using the device deemed most appropriate via -opencl_options to obtain the best performance for the OpenCL acceleratedcode.

Typicalusage to use the fastest OpenCL device involve the following steps.

Run thecommand:

ffmpeg-opencl_bench

Note downthe platform ID (pidx) and device ID (didx) of the first i.e.fastest device in the list. Select the platform and device using the command:

ffmpeg-opencl_options platform_idx=pidx:device_idx=didx ...

-opencl_options options (global)

Set OpenCLenvironment options. This option is only available when FFmpeg has beencompiled with --enable-opencl.

options must be a list of key=value option pairsseparated by ’:’. See the “OpenCL Options” section in the ffmpeg-utils manualfor the list of supported options.

 

AVOptions

These options are provided directlyby the libavformat, libavdevice and libavcodec libraries. To see the list ofavailable AVOptions, use the -help option. They are separated into two categories:

这些参数选项都是从libavformat,libavdevice,liavcodec库从直接继承过来的。

generic

Theseoptions can be set for any container, codec or device. Generic options arelisted under AVFormatContext options for containers/devices and underAVCodecContext options for codecs.

private

Theseoptions are specific to the given container, device or codec. Private optionsare listed under their corresponding containers/devices/codecs.

For example to write an ID3v2.3header instead of a default ID3v2.4 to an MP3 file, use the id3v2_version private option of the MP3 muxer:

ffmpeg-i input.flac -id3v2_version 3 out.mp3

All codec AVOptions are per-stream,and thus a stream specifier should be attached to them.

所有的AVOptions参数都是针对码流的,所以码流说明符需要添加。

Note: the -nooption syntax cannot be used for boolean AVOptions, use -option0/-option 1.

对于boolean的AVOptions参数,不设置需要用0/1来开关。

Note: the old undocumented way ofspecifying per-stream AVOptions by prepending v/a/s to the options name is nowobsolete and will be removed soon.

v/a/s的参数设置方法已经淘汰了。

Main option

-f fmt (input/output)

Forceinput or output file format. The format is normally auto detected for inputfiles and guessed from the file extension for output files, so this option isnot needed in most cases.

强制输入输出文件格式。

-i filename (input)

input filename

输入文件名。

-y (global)

Overwriteoutput files without asking.

覆盖已有输出文件。

-n (global)

Do notoverwrite output files, and exit immediately if a specified output file alreadyexists.

不覆盖已有输出文件。

-stream_loop number (input)

Set numberof times input stream shall be looped. Loop 0 means no loop, loop -1 meansinfinite loop.

设置码流循环次数。

-c[:stream_specifier] codec (input/output,per-stream)

-codec[:stream_specifier] codec (input/output,per-stream)

Select anencoder (when used before an output file) or a decoder (when used before aninput file) for one or more streams.codec is the name of adecoder/encoder or a special value copy (output only) to indicate that the stream is not to bere-encoded.

Forexample

ffmpeg-i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT

encodesall video streams with libx264 and copies all audio streams.

For eachstream, the last matching c option is applied, so

ffmpeg-i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT

will copyall the streams except the second video, which will be encoded with libx264,and the 138th audio, which will be encoded with libvorbis.

该参数设置码流的编解码器的编码类型。

-t duration (input/output)

When usedas an input option (before -i), limit the duration of data read from the inputfile.

When usedas an output option (before an output filename), stop writing the output afterits duration reachesduration.

duration must be a time duration specification, see (ffmpeg-utils)theTime duration section in the ffmpeg-utils(1) manual.

-to and -tare mutually exclusive and -t has priority.

设置输入和输出文件的时间长度。

-to position (output)

Stopwriting the output at position. position must be a time durationspecification, see(ffmpeg-utils)theTime duration section in the ffmpeg-utils(1) manual.

-to and -tare mutually exclusive and -t has priority.

设置输出文件停止写入的位置。

-fs limit_size (output)

Set the filesize limit, expressed in bytes. No further chunk of bytes is written after thelimit is exceeded. The size of the output file is slightly more than therequested file size.

设置文件停止写入的大小。

-ss position (input/output)

When usedas an input option (before -i), seeks in this input file to position. Note that inmost formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point beforeposition.When transcoding and -accurate_seek is enabled (the default), this extra segment between theseek point andposition will be decoded and discarded. When doing streamcopy or when -noaccurate_seek is used, it will be preserved.

When usedas an output option (before an output filename), decodes but discards inputuntil the timestamps reachposition.

position must be a time duration specification, see (ffmpeg-utils)theTime duration section in the ffmpeg-utils(1) manual.

-sseof position (input/output)

Like the -ss option but relative to the "end of file". That isnegative values are earlier in the file, 0 is at EOF.

-itsoffset offset (input)

Set theinput time offset.

offset must be a time duration specification, see (ffmpeg-utils)theTime duration section in the ffmpeg-utils(1) manual.

The offsetis added to the timestamps of the input files. Specifying a positive offsetmeans that the corresponding streams are delayed by the time duration specifiedinoffset.

以上3个命令都是设置文件的offset。

-timestamp date (output)

Set therecording timestamp in the container.

设置容器的时间戳。

date must be a date specification, see (ffmpeg-utils)theDate section in the ffmpeg-utils(1) manual.

-metadata[:metadata_specifier] key=value (output,per-metadata)

Set ametadata key/value pair.

Anoptional metadata_specifier may be given to set metadata on streams,chapters or programs. See -map_metadata documentation for details.

Thisoption overrides metadata set with -map_metadata. It is also possible to delete metadata by using an emptyvalue.

Forexample, for setting the title in the output file:

ffmpeg-i in.avi -metadata title="my title" out.flv

To set thelanguage of the first audio stream:

ffmpeg-i INPUT -metadata:s:a:0 language=eng OUTPUT

-program [title=title:][program_num=program_num:]st=stream[:st=stream...](output)

Creates aprogram with the specified title, program_num and adds thespecifiedstream(s) to it.

设置元数据当中的内容为指定值。

-target type (output)

Specifytarget file type (vcd,svcd, dvd, dv,dv50). type may be prefixed with pal-, ntsc-or film- to use the corresponding standard.All the format options (bitrate, codecs, buffer sizes) are then setautomatically. You can just type:

ffmpeg-i myfile.avi -target vcd /tmp/vcd.mpg

Neverthelessyou can specify additional options as long as you know they do not conflictwith the standard, as in:

ffmpeg-i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg

制定输出文件的目标类型。

-dframes number (output)

Set thenumber of data frames to output. This is an alias for -frames:d.

设置输出文件的帧数。

-frames[:stream_specifier] framecount (output,per-stream)

Stopwriting to the stream after framecount frames.

满足帧数要求后,停止写入输出文件。

-q[:stream_specifier] q (output,per-stream)

-qscale[:stream_specifier] q (output,per-stream)

Use fixedquality scale (VBR). The meaning of q/qscale is codec-dependent.Ifqscale is used without astream_specifier then it applies onlyto the video stream, this is to maintain compatibility with previous behaviorand as specifying the same codec specific value to 2 different codecs that isaudio and video generally is not what is intended when no stream_specifier isused.

-filter[:stream_specifier]filtergraph (output,per-stream)

Create thefiltergraph specified by filtergraph and use it to filter the stream.

filtergraph is a description of the filtergraph to apply to the stream,and must have a single input and a single output of the same type of the stream.In the filtergraph, the input is associated to the label in, and the output to the label out. See the ffmpeg-filters manual for more information aboutthe filtergraph syntax.

See the -filter_complexoption if you want to create filtergraphs with multiple inputs and/oroutputs.

创建滤波器图;

-filter_script[:stream_specifier] filename (output,per-stream)

Thisoption is similar to -filter, the only difference is that its argument is the name ofthe file from which a filtergraph description is to be read.

类似于上面的命令,不过滤波器图在文件中实现。

-pre[:stream_specifier] preset_name (output,per-stream)

Specifythe preset for matching stream(s).

指定预置值。

-stats (global)

Printencoding progress/statistics. It is on by default, to explicitly disable it youneed to specify -nostats.

编码过程的统计信息打印。

-progress url (global)

Sendprogram-friendly progress information to url.

Progressinformation is written approximately every second and at the end of theencoding process. It is made of "key=value" lines.keyconsists of only alphanumeric characters. The last key of a sequence ofprogress information is always "progress".

把进度信息发到某个URL处。

-stdin

Enableinteraction on standard input. On by default unless standard input is used asan input. To explicitly disable interaction you need to specify -nostdin.

Disablinginteraction on standard input is useful, for example, if ffmpeg is in thebackground process group. Roughly the same result can be achieved with ffmpeg... < /dev/null but it requires a shell.

与stdin的交互开关。

-debug_ts (global)

Printtimestamp information. It is off by default. This option is mostly useful fortesting and debugging purposes, and the output format may change from oneversion to another, so it should not be employed by portable scripts.

See alsothe option -fdebug ts.

打印时间戳信息,默认是关掉的。

-attach filename (output)

Add anattachment to the output file. This is supported by a few formats like Matroskafor e.g. fonts used in rendering subtitles. Attachments are implemented as aspecific type of stream, so this option will add a new stream to the file. Itis then possible to use per-stream options on this stream in the usual way.Attachment streams created with this option will be created after all the otherstreams (i.e. those created with -map or automatic mappings).

Note thatfor Matroska you also have to set the mimetype metadata tag:

ffmpeg-i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-fontout.mkv

(assumingthat the attachment stream will be third in the output file).

对输出文件增加额外的码流通道。

-dump_attachment[:stream_specifier] filename (input,per-stream)

Extractthe matching attachment stream into a file named filename. If filenameis empty, then the value of the filename metadata tag will be used.

E.g. toextract the first attachment to a file named ’out.ttf’:

ffmpeg-dump_attachment:t:0 out.ttf -i INPUT

To extractall attachments to files determined by the filename tag:

ffmpeg-dump_attachment:t "" -i INPUT

Technicalnote – attachments are implemented as codec extradata, so this option canactually be used to extract extradata from any stream, not just attachments.

从输出文件中提取额外的码流通道数据到指定文件。

-noautorotate

Disableautomatically rotating video based on file metadata.

 

Video Options

-vframes number (output)

Set thenumber of video frames to output. This is an alias for -frames:v.

设置输出文件的video帧数。

-r[:stream_specifier] fps (input/output,per-stream)

Set framerate (Hz value, fraction or abbreviation).

As aninput option, ignore any timestamps stored in the file and instead generatetimestamps assuming constant frame ratefps. This is not the same as the-framerate optionused for some input formats like image2 or v4l2 (it used to be the same inolder versions of FFmpeg). If in doubt use -framerate instead of the input option -r.

As anoutput option, duplicate or drop input frames to achieve constant output frameratefps.

-s[:stream_specifier] size (input/output,per-stream)

Set framesize.

As aninput option, this is a shortcut for the video_size private option, recognized by some demuxers for which theframe size is either not stored in the file or is configurable – e.g. raw videoor video grabbers.

As anoutput option, this inserts the scale video filter to the end of the correspondingfiltergraph. Please use the scale filter directly to insert it at the beginning or some otherplace.

The formatis ‘wxh’ (default - same as source).

-aspect[:stream_specifier] aspect (output,per-stream)

Set thevideo display aspect ratio specified by aspect.

aspect can be a floating point number string, or a string of theform num:den, where num and den are the numeratorand denominator of the aspect ratio. For example "4:3","16:9", "1.3333", and "1.7777" are valid argumentvalues.

If usedtogether with -vcodec copy, it will affect the aspect ratio stored at container level,but not the aspect ratio stored in encoded frames, if it exists.

-vn (output)

Disablevideo recording.

-vcodec codec (output)

Set thevideo codec. This is an alias for -codec:v.

-pass[:stream_specifier] n (output,per-stream)

Select thepass number (1 or 2). It is used to do two-pass video encoding. The statisticsof the video are recorded in the first pass into a log file (see also theoption -passlogfile), and in the second pass that log file is used to generatethe video at the exact requested bitrate. On pass 1, you may just deactivateaudio and set output to null, examples for Windows and Unix:

ffmpeg-i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL

ffmpeg-i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null

-passlogfile[:stream_specifier] prefix (output,per-stream)

Settwo-pass log file name prefix to prefix, the default file name prefix is“ffmpeg2pass”. The complete file name will be PREFIX-N.log, where N is a number specific to the output stream

-vf filtergraph (output)

Create thefiltergraph specified by filtergraph and use it to filter the stream.

This is analias for -filter:v, see the -filteroption.

Advanced Video options

-pix_fmt[:stream_specifier] format (input/output,per-stream)

Set pixelformat. Use -pix_fmts to show all the supported pixel formats. If the selectedpixel format can not be selected, ffmpeg will print a warning and select thebest pixel format supported by the encoder. Ifpix_fmt is prefixed by a +, ffmpeg will exit with an error if the requested pixelformat can not be selected, and automatic conversions inside filtergraphs aredisabled. Ifpix_fmt is a single +, ffmpeg selects the same pixel format as the input (orgraph output) and automatic conversions are disabled.

-sws_flags flags (input/output)

SetSwScaler flags.

-vdt n

Discardthreshold.

-rc_override[:stream_specifier] override (output,per-stream)

Ratecontrol override for specific intervals, formatted as "int,int,int"list separated with slashes. Two first values are the beginning and end framenumbers, last one is quantizer to use if positive, or quality factor ifnegative.

-ilme

Forceinterlacing support in encoder (MPEG-2 and MPEG-4 only). Use this option ifyour input file is interlaced and you want to keep the interlaced format forminimum losses. The alternative is to deinterlace the input stream with -deinterlace, but deinterlacing introduces losses.

-psnr

CalculatePSNR of compressed frames.

-vstats

Dump videocoding statistics to vstats_HHMMSS.log.

-vstats_file file

Dump videocoding statistics to file.

-top[:stream_specifier] n (output,per-stream)

top=1/bottom=0/auto=-1field first

-dc precision

Intra_dc_precision.

-vtag fourcc/tag (output)

Forcevideo tag/fourcc. This is an alias for -tag:v.

-qphist (global)

Show QPhistogram

-vbsf bitstream_filter

Deprecatedsee -bsf

-force_key_frames[:stream_specifier] time[,time...](output,per-stream)

-force_key_frames[:stream_specifier] expr:expr(output,per-stream)

Force keyframes at the specified timestamps, more precisely at the first frames aftereach specified time.

If theargument is prefixed with expr:, the string expr is interpreted like an expressionand is evaluated for each frame. A key frame is forced in case the evaluationis non-zero.

If one ofthe times is "chapters[delta]", it is expanded into the time of thebeginning of all chapters in the file, shifted bydelta, expressed as atime in seconds. This option can be useful to ensure that a seek point ispresent at a chapter mark or any other designated place in the output file.

Forexample, to insert a key frame at 5 minutes, plus key frames 0.1 second beforethe beginning of every chapter:

-force_key_frames0:05:00,chapters-0.1

Theexpression in expr can contain the following constants:

n

the numberof current processed frame, starting from 0

n_forced

the numberof forced frames

prev_forced_n

the numberof the previous forced frame, it is NAN when no keyframe was forced yet

prev_forced_t

the timeof the previous forced frame, it is NAN when no keyframe was forced yet

t

the timeof the current processed frame

Forexample to force a key frame every 5 seconds, you can specify:

-force_key_framesexpr:gte(t,n_forced*5)

To force akey frame 5 seconds after the time of the last forced one, starting from second13:

-force_key_framesexpr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))

Note thatforcing too many keyframes is very harmful for the lookahead algorithms ofcertain encoders: using fixed-GOP options or similar would be more efficient.

-copyinkf[:stream_specifier] (output,per-stream)

When doingstream copy, copy also non-key frames found at the beginning.

-hwaccel[:stream_specifier] hwaccel (input,per-stream)

Usehardware acceleration to decode the matching stream(s). The allowed values ofhwaccelare:

none

Do not useany hardware acceleration (the default).

auto

Automaticallyselect the hardware acceleration method.

vda

Use AppleVDA hardware acceleration.

vdpau

Use VDPAU(Video Decode and Presentation API for Unix) hardware acceleration.

dxva2

Use DXVA2(DirectX Video Acceleration) hardware acceleration.

qsv

Use theIntel QuickSync Video acceleration for video transcoding.

Unlikemost other values, this option does not enable accelerated decoding (that isused automatically whenever a qsv decoder is selected), but acceleratedtranscoding, without copying the frames into the system memory.

For it towork, both the decoder and the encoder must support QSV acceleration and nofilters must be used.

Thisoption has no effect if the selected hwaccel is not available or not supportedby the chosen decoder.

Note thatmost acceleration methods are intended for playback and will not be faster thansoftware decoding on modern CPUs. Additionally, ffmpeg will usually need to copy the decoded frames from the GPUmemory into the system memory, resulting in further performance loss. Thisoption is thus mainly useful for testing.

-hwaccel_device[:stream_specifier] hwaccel_device(input,per-stream)

Select adevice to use for hardware acceleration.

This optiononly makes sense when the -hwaccel option is also specified. Its exact meaning depends on thespecific hardware acceleration method chosen.

vdpau

For VDPAU,this option specifies the X11 display/screen to use. If this option is notspecified, the value of theDISPLAY environment variable is used

dxva2

For DXVA2,this option should contain the number of the display adapter to use. If thisoption is not specified, the default adapter is used.

qsv

For QSV,this option corresponds to the valus of MFX_IMPL_* . Allowed values are:

auto

sw

hw

auto_any

hw_any

hw2

hw3

hw4

-hwaccels

List allhardware acceleration methods supported in this build of ffmpeg.

Audio Options

-aframes number (output)

Set thenumber of audio frames to output. This is an alias for -frames:a.

-ar[:stream_specifier] freq (input/output,per-stream)

Set theaudio sampling frequency. For output streams it is set by default to thefrequency of the corresponding input stream. For input streams this option onlymakes sense for audio grabbing devices and raw demuxers and is mapped to thecorresponding demuxer options.

-aq q (output)

Set theaudio quality (codec-specific, VBR). This is an alias for -q:a.

-ac[:stream_specifier] channels (input/output,per-stream)

Set thenumber of audio channels. For output streams it is set by default to the numberof input audio channels. For input streams this option only makes sense foraudio grabbing devices and raw demuxers and is mapped to the correspondingdemuxer options.

-an (output)

Disableaudio recording.

-acodec codec (input/output)

Set theaudio codec. This is an alias for -codec:a.

-sample_fmt[:stream_specifier] sample_fmt (output,per-stream)

Set theaudio sample format. Use -sample_fmts to get a list of supported sample formats.

-af filtergraph (output)

Create thefiltergraph specified by filtergraph and use it to filter the stream.

This is analias for -filter:a, see the -filteroption.

Advanced Audio options

-atag fourcc/tag (output)

Forceaudio tag/fourcc. This is an alias for -tag:a.

-absf bitstream_filter

Deprecated,see -bsf

-guess_layout_max channels (input,per-stream)

If someinput channel layout is not known, try to guess only if it corresponds to atmost the specified number of channels. For example, 2 tells to ffmpeg to recognize 1 channel as mono and 2 channels as stereo butnot 6 channels as 5.1. The default is to always try to guess. Use 0 to disableall guessing.

Subtitle options

-scodec codec (input/output)

Set thesubtitle codec. This is an alias for -codec:s.

-sn (output)

Disablesubtitle recording.

-sbsf bitstream_filter

Deprecated,see -bsf

Advanced Subtitleoptions

-fix_sub_duration

Fixsubtitles durations. For each subtitle, wait for the next packet in the samestream and adjust the duration of the first to avoid overlap. This is necessarywith some subtitles codecs, especially DVB subtitles, because the duration inthe original packet is only a rough estimate and the end is actually marked byan empty subtitle frame. Failing to use this option when necessary can resultin exaggerated durations or muxing failures due to non-monotonic timestamps.

Note thatthis option will delay the output of all data until the next subtitle packet isdecoded: it may increase memory consumption and latency a lot.

-canvas_size size

Set thesize of the canvas used to render subtitles.

Advanced options

-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]|[linklabel] (output)

Designateone or more input streams as a source for the output file. Each input stream isidentified by the input file indexinput_file_id and the input streamindexinput_stream_id within the input file. Both indices start at 0. Ifspecified,sync_file_id:stream_specifier sets which input streamis used as a presentation sync reference.

The first -map option on the command line specifies the source for outputstream 0, the second -mapoption specifies the source for output stream 1, etc.

A - character before the stream identifier creates a"negative" mapping. It disables matching streams from already createdmappings.

Analternative [linklabel] form will map outputs from complex filter graphs(see the -filter_complex option) to the output file.linklabel mustcorrespond to a defined output link label in the graph.

Forexample, to map ALL streams from the first input file to output

ffmpeg-i INPUT -map 0 output

Forexample, if you have two audio streams in the first input file, these streamsare identified by "0:0" and "0:1". You can use -map to select which streams to place in an output file. Forexample:

ffmpeg-i INPUT -map 0:1 out.wav

will mapthe input stream in INPUTidentified by "0:1" to the (single) output stream in out.wav.

Forexample, to select the stream with index 2 from input file a.mov (specified by the identifier "0:2"), and streamwith index 6 from input b.mov(specified by the identifier "1:6"), and copy them to the output fileout.mov:

ffmpeg-i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov

To selectall video and the third audio stream from an input file:

ffmpeg-i INPUT -map 0:v -map 0:a:2 OUTPUT

To map allthe streams except the second audio, use negative mappings

ffmpeg-i INPUT -map 0 -map -0:a:1 OUTPUT

To pickthe English audio stream:

ffmpeg-i INPUT -map 0:m:language:eng OUTPUT

Note thatusing this option disables the default mappings for this output file.

设置输入流和输出流之间的映射关系。

-ignore_unknown

Ignoreinput streams with unknown type instead of failing if copying such streams isattempted.

忽略不知道的码流,处理时并不报错。

-copy_unknown

Allowinput streams with unknown type to be copied instead of failing if copying suchstreams is attempted.

复制不知道类型的码流,处理时并不报错。

-map_channel [input_file_id.stream_specifier.channel_id|-1][:output_file_id.stream_specifier]

Map anaudio channel from a given input to an output. If output_file_id.stream_specifieris not set, the audio channel will be mapped on all the audio streams.

Using"-1" instead of input_file_id.stream_specifier.channel_idwill map a muted channel.

Forexample, assuming INPUT is a stereo audio file, you can switch the twoaudio channels with the following command:

ffmpeg-i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT

If youwant to mute the first channel and keep the second:

ffmpeg-i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT

The orderof the "-map_channel" option specifies the order of the channels inthe output stream. The output channel layout is guessed from the number ofchannels mapped (mono if one "-map_channel", stereo if two, etc.).Using "-ac" in combination of "-map_channel" makes thechannel gain levels to be updated if input and output channel layouts don’tmatch (for instance two "-map_channel" options and "-ac6").

You canalso extract each channel of an input to specific outputs; the followingcommand extracts two channels of theINPUT audio stream (file 0, stream0) to the respectiveOUTPUT_CH0 andOUTPUT_CH1 outputs:

ffmpeg-i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1

Thefollowing example splits the channels of a stereo input into two separatestreams, which are put into the same output file:

ffmpeg-i stereo.wav -map 0:0 -map 0:0 -map_channel 0.0.0:0.0 -map_channel 0.0.1:0.1-y out.ogg

Note thatcurrently each output stream can only contain channels from a single inputstream; you can’t for example use "-map_channel" to pick multipleinput audio channels contained in different streams (from the same or differentfiles) and merge them into a single output stream. It is therefore notcurrently possible, for example, to turn two separate mono streams into asingle stereo stream. However splitting a stereo stream into two single channelmono streams is possible.

If youneed this feature, a possible workaround is to use the amerge filter.For example, if you need to merge a media (here input.mkv) with 2 mono audio streams into one single stereo channelaudio stream (and keep the video stream), you can use the following command:

ffmpeg-i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:vcopy output.mkv

音频通道的输入文件与输出文件的映射。

-map_metadata[:metadata_spec_out] infile[:metadata_spec_in](output,per-metadata)

Setmetadata information of the next output file from infile. Note thatthose are file indices (zero-based), not filenames. Optionalmetadata_spec_in/outparameters specify, which metadata to copy. A metadata specifier can have thefollowing forms:

g

globalmetadata, i.e. metadata that applies to the whole file

s[:stream_spec]

per-streammetadata. stream_spec is a stream specifier as described in theStreamspecifiers chapter. In an input metadata specifier, the first matchingstream is copied from. In an output metadata specifier, all matching streamsare copied to.

c:chapter_index

per-chaptermetadata. chapter_index is the zero-based chapter index.

p:program_index

per-programmetadata. program_index is the zero-based program index.

Ifmetadata specifier is omitted, it defaults to global.

Bydefault, global metadata is copied from the first input file, per-stream andper-chapter metadata is copied along with streams/chapters. These defaultmappings are disabled by creating any mapping of the relevant type. A negativefile index can be used to create a dummy mapping that just disables automaticcopying.

Forexample to copy metadata from the first stream of the input file to globalmetadata of the output file:

ffmpeg-i in.ogg -map_metadata 0:s:0 out.mp3

To do thereverse, i.e. copy global metadata to all audio streams:

ffmpeg-i in.mkv -map_metadata:s:a 0:g out.mkv

Note thatsimple 0would work as well in this example, since global metadata is assumed by default.

输入文件与输出文件的元设局的映射与复制。

-map_chapters input_file_index (output)

Copychapters from input file with index input_file_index to the next outputfile. If no chapter mapping is specified, then chapters are copied from thefirst input file with at least one chapter. Use a negative file index todisable any chapter copying.

输入文件的章节复制。

-benchmark (global)

Showbenchmarking information at the end of an encode. Shows CPU time used andmaximum memory consumption. Maximum memory consumption is not supported on allsystems, it will usually display as 0 if not supported.

显示系统的资源消耗。

-benchmark_all (global)

Showbenchmarking information during the encode. Shows CPU time used in varioussteps (audio/video encode/decode).

转码过程中的系统资源使用情况。

-timelimit duration (global)

Exit afterffmpeg has been running for duration seconds.

软件定时周期的退出。

-dump (global)

Dump eachinput packet to stderr.

输入包的显示。

-hex (global)

Whendumping packets, also dump the payload.

显示包和载荷。

-re (input)

Read inputat native frame rate. Mainly used to simulate a grab device. or live inputstream (e.g. when reading from a file). Should not be used with actual grabdevices or live input streams (where it can cause packet loss). By default ffmpeg attempts to read the input(s) as fast as possible. Thisoption will slow down the reading of the input(s) to the native frame rate ofthe input(s). It is useful for real-time output (e.g. live streaming).

-loop_input

Loop overthe input stream. Currently it works only for image streams. This option isused for automatic FFserver testing. This option is deprecated, use -loop 1.

-loop_output number_of_times

Repeatedlyloop output for formats that support looping such as animated GIF (0 will loopthe output infinitely). This option is deprecated, use -loop.

-vsync parameter

Video syncmethod. For compatibility reasons old values can be specified as numbers. Newlyadded values will have to be specified as strings always.

0,passthrough

Each frameis passed with its timestamp from the demuxer to the muxer.

1,cfr

Frameswill be duplicated and dropped to achieve exactly the requested constant framerate.

2,vfr

Frames arepassed through with their timestamp or dropped so as to prevent 2 frames fromhaving the same timestamp.

drop

Aspassthrough but destroys all timestamps, making the muxer generate freshtimestamps based on frame-rate.

-1,auto

Choosesbetween 1 and 2 depending on muxer capabilities. This is the default method.

Note thatthe timestamps may be further modified by the muxer, after this. For example,in the case that the format option avoid_negative_ts is enabled.

With -mapyou can select from which stream the timestamps should be taken. You can leaveeither video or audio unchanged and sync the remaining stream(s) to theunchanged one.

视频流的同步设置。

-frame_drop_threshold parameter

Frame dropthreshold, which specifies how much behind video frames can be before they aredropped. In frame rate units, so 1.0 is one frame. The default is -1.1. Onepossible usecase is to avoid framedrops in case of noisy timestamps or toincrease frame drop precision in case of exact timestamps.

帧丢弃的阈值。

-async samples_per_second

Audio syncmethod. "Stretches/squeezes" the audio stream to match thetimestamps, the parameter is the maximum samples per second by which the audiois changed. -async 1 is a special case where only the start of the audio streamis corrected without any later correction.

Note thatthe timestamps may be further modified by the muxer, after this. For example,in the case that the format option avoid_negative_ts is enabled.

Thisoption has been deprecated. Use the aresample audio filter instead.

-copyts

Do notprocess input timestamps, but keep their values without trying to sanitizethem. In particular, do not remove the initial start time offset value.

Note that,depending on the vsyncoption or on specific muxer processing (e.g. in case the format option avoid_negative_ts is enabled) the output timestamps may mismatch with theinput timestamps even when this option is selected.

-start_at_zero

When usedwith copyts, shift input timestamps so theystart at zero.

This meansthat using e.g. -ss 50will make output timestamps start at 50 seconds, regardless of what timestampthe input file started at.

-copytb mode

Specifyhow to set the encoder timebase when stream copying. mode is an integernumeric value, and can assume one of the following values:

1

Use thedemuxer timebase.

The timebase is copied to the output encoder from the corresponding input demuxer. Thisis sometimes required to avoid non monotonically increasing timestamps whencopying video streams with variable frame rate.

0

Use thedecoder timebase.

The timebase is copied to the output encoder from the corresponding input decoder.

-1

Try tomake the choice automatically, in order to generate a sane output.

Defaultvalue is -1.

设置编码器的时间基准。。。。。。。。。。。。。。。

-shortest (output)

Finishencoding when the shortest input stream ends.

-dts_delta_threshold

Timestampdiscontinuity delta threshold.

-muxdelay seconds (input)

Set themaximum demux-decode delay.

-muxpreload seconds (input)

Set theinitial demux-decode delay.

-streamid output-stream-index:new-value (output)

Assign anew stream-id value to an output stream. This option should be specified priorto the output filename to which it applies. For the situation where multipleoutput files exist, a streamid may be reassigned to a different value.

Forexample, to set the stream 0 PID to 33 and the stream 1 PID to 36 for an outputmpegts file:

ffmpeg-i infile -streamid 0:33 -streamid 1:36 out.ts

-bsf[:stream_specifier] bitstream_filters (output,per-stream)

Setbitstream filters for matching streams. bitstream_filters is acomma-separated list of bitstream filters. Use the -bsfs option to get the list of bitstream filters.

ffmpeg-i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264

ffmpeg-i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt

-tag[:stream_specifier] codec_tag (input/output,per-stream)

Force atag/fourcc for matching streams.

-timecode hh:mm:ssSEPff

SpecifyTimecode for writing. SEP is ’:’ for non drop timecode and ’;’ (or ’.’)for drop.

ffmpeg-i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg

-filter_complexfiltergraph (global)

Define acomplex filtergraph, i.e. one with arbitrary number of inputs and/or outputs.For simple graphs – those with one input and one output of the same type – seethe -filter options.filtergraphis a description of the filtergraph, as described in the “Filtergraph syntax”section of the ffmpeg-filters manual.

Input linklabels must refer to input streams using the [file_index:stream_specifier] syntax (i.e. the same as -map uses). Ifstream_specifier matches multiple streams,the first one will be used. An unlabeled input will be connected to the firstunused input stream of the matching type.

Outputlink labels are referred to with -map. Unlabeled outputs are added to the first output file.

Note thatwith this option it is possible to use only lavfi sources without normal inputfiles.

Forexample, to overlay an image over video

ffmpeg-i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map

'[out]'out.mkv

Here [0:v] refers to the first video stream in the first input file,which is linked to the first (main) input of the overlay filter. Similarly thefirst video stream in the second input is linked to the second (overlay) inputof overlay.

Assumingthere is only one video stream in each input file, we can omit input labels, sothe above is equivalent to

ffmpeg-i video.mkv -i image.png -filter_complex 'overlay[out]' -map

'[out]'out.mkv

Furthermorewe can omit the output label and the single output from the filter graph willbe added to the output file automatically, so we can simply write

ffmpeg-i video.mkv -i image.png -filter_complex 'overlay' out.mkv

Togenerate 5 seconds of pure red video using lavfi color source:

ffmpeg-filter_complex 'color=c=red' -t 5 out.mkv

-lavfi filtergraph (global)

Define acomplex filtergraph, i.e. one with arbitrary number of inputs and/or outputs.Equivalent to -filter_complex.

-filter_complex_script filename (global)

Thisoption is similar to -filter_complex, the only difference is that its argument is the name ofthe file from which a complex filtergraph description is to be read.

-accurate_seek (input)

Thisoption enables or disables accurate seeking in input files with the -ss option. It is enabled by default, so seeking is accuratewhen transcoding. Use -noaccurate_seek to disable it, which may be useful e.g. when copying somestreams and transcoding the others.

-seek_timestamp (input)

Thisoption enables or disables seeking by timestamp in input files with the -ss option. It is disabled by default. If enabled, the argumentto the -ssoption is considered an actual timestamp, and is not offset by the start timeof the file. This matters only for files which do not start from timestamp 0,such as transport streams.

-thread_queue_size size (input)

Thisoption sets the maximum number of queued packets when reading from the file ordevice. With low latency / high rate live streams, packets may be discarded ifthey are not read in a timely manner; raising this value can avoid it.

-override_ffserver (global)

Overridesthe input specifications from ffserver. Using this option you can map any input stream to ffserver and control many aspects of the encoding from ffmpeg. Without this option ffmpeg will transmit to ffserver what is requested by ffserver.

The optionis intended for cases where features are needed that cannot be specified to ffserver but can be to ffmpeg.

-sdp_file file (global)

Print sdpinformation for an output stream to file. This allows dumping sdpinformation when at least one output isn’t an rtp stream. (Requires at leastone of the output formats to be rtp).

-discard (input)

Allowsdiscarding specific streams or frames of streams at the demuxer. Not alldemuxers support this.

none

Discard noframe.

default

Default,which discards no frames.

noref

Discardall non-reference frames.

bidir

Discardall bidirectional frames.

nokey

Discardall frames excepts keyframes.

all

Discardall frames.

-abort_on flags (global)

Stop andabort on various conditions. The following flags are available:

empty_output

No packetswere passed to the muxer, the output is empty.

-xerror (global)

Stop andexit on error

As a special exception, you can usea bitmap subtitle stream as input: it will be converted into a video with thesame size as the largest video in the file, or 720x576 if no video is present.Note that this is an experimental and temporary solution. It will be removedonce libavfilter has proper support for subtitles.

For example, to hardcode subtitleson top of a DVB-T recording stored in MPEG-TS format, delaying the subtitles by1 second:

ffmpeg-i input.ts -filter_complex \

  '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0][sub] overlay' \

  -sn -map '#0x2dc' output.mkv

(0x2d0, 0x2dc and 0x2ef are theMPEG-TS PIDs of respectively the video, audio and subtitles streams; 0:0, 0:3and 0:7 would have worked too)

Preset files

A preset file contains a sequence of option=valuepairs, one for each line, specifying a sequence of options which would be awkwardto specify on the command line. Lines starting with the hash (’#’) characterare ignored and are used to provide comments. Check the presetsdirectory in the FFmpeg source tree for examples.

There are two types of preset files: ffpreset and avpreset files.

命令行方式的FFmpeg可以通过preset文件的方式运行其命令。有两种类型的文件ffpreset和 avpreset。

ffpreset files are specified with the vpre,apre, spre,and fpre options. The fpreoption takes the filename of the preset instead of a preset name as input andcan be used for any kind of codec. For thevpre,apre, andspreoptions, the options specified in a preset file are applied to the currentlyselected codec of the same type as the preset option.

The argument passed to the vpre, apre,and spre preset options identifies the preset file touse according to the following rules:

First ffmpeg searches for a file named arg.ffpreset in thedirectories$FFMPEG_DATADIR (if set), and$HOME/.ffmpeg,and in the datadir defined at configuration time (usuallyPREFIX/share/ffmpeg)or in affpresets folder along the executable on win32, in thatorder. For example, if the argument islibvpx-1080p,it will search for the filelibvpx-1080p.ffpreset.

If no such file is found, then ffmpeg will search for a file named codec_name-arg.ffpresetin the above-mentioned directories, wherecodec_name is the name ofthe codec to which the preset file options will be applied. For example, if youselect the video codec with-vcodec libvpx and use -vpre1080p, then it will search for the filelibvpx-1080p.ffpreset.

avpreset files are specified with the preoption. They work similar to ffpreset files, but they only allow encoder-specific options. Therefore, anoption=valuepair specifying an encoder cannot be used.

When the pre option is specified,ffmpeg will look for files with the suffix .avpreset in the directories$AVCONV_DATADIR(if set), and$HOME/.avconv, and in the datadir defined atconfiguration time (usuallyPREFIX/share/ffmpeg), in that order.

First ffmpeg searches for a file named codec_name-arg.avpresetin the above-mentioned directories, wherecodec_name is the name ofthe codec to which the preset file options will be applied. For example, if youselect the video codec with-vcodec libvpx and use -pre1080p, then it will search for the filelibvpx-1080p.avpreset.

If no such file is found, then ffmpeg will search for a file named arg.avpresetin the same directories.

0 0
原创粉丝点击