这是用户在 2024-8-27 10:52 为 https://www.ffmpeg.org/ffmpeg.html 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?

ffmpeg Documentation

Table of Contents 目录

1 Synopsis 1 概要

ffmpeg [global_options] {[input_file_options] -i input_url} ... {[output_file_options] output_url} ...
ffmpeg [全局选项] {[输入文件选项] -i input_url } ... {[输出文件选项] output_url } ...

2 Description 2 描述

ffmpeg is a universal media converter. It can read a wide variety of inputs - including live grabbing/recording devices - filter, and transcode them into a plethora of output formats.
ffmpeg 是一款通用媒体转换器。它能读取多种输入源——包括实时抓取/录制设备——进行过滤,并将其转码为多种输出格式。

ffmpeg reads from an arbitrary number of input "files" (which can be regular files, 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 url. Anything found on the command line which cannot be interpreted as an option is considered to be an output url.
ffmpeg 从任意数量的输入“文件”(可以是常规文件、管道、网络流、抓取设备等)读取数据,这些输入文件由 -i 选项指定,并写入任意数量的输出“文件”,这些输出文件由普通的输出 URL 指定。命令行上无法解释为选项的任何内容都被视为输出 URL。

Each input or output url can, in principle, 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 container format. Selecting which streams from which inputs will go into which output is either done automatically or with the -map option (see the Stream selection chapter).
每个输入或输出 URL 原则上可以包含任意数量的不同类型流(视频/音频/字幕/附件/数据)。允许的流数量和/或类型可能受容器格式限制。选择哪些输入流进入哪些输出,既可以自动完成,也可以通过 -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 by their indices. E.g. 2:3 refers to the fourth stream in the third input file. Also see the Stream specifiers chapter.
要在选项中引用输入文件,必须使用它们的索引(从 0 开始)。例如,第一个输入文件是 0 ,第二个是 1 ,依此类推。类似地,文件中的流通过其索引来引用。例如, 2:3 指的是第三个输入文件中的第四个流。另请参阅“流指定符”章节。

As a general rule, options are applied to the next specified file. Therefore, order is important, and you can have the same option on the command line multiple times. Each occurrence is then applied to the next input or output file. Exceptions from this rule are the 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 options which belong to different files. All options apply ONLY to the next input or output file and are reset between files.
不要混合输入和输出文件——首先指定所有输入文件,然后指定所有输出文件。也不要混合属于不同文件的选项。所有选项仅适用于下一个输入或输出文件,并在文件之间重置。

Some simple examples follow.
以下是一些简单的例子。

  • Convert an input media file to a different format, by re-encoding media streams:
    将输入的媒体文件转换为不同格式,通过重新编码媒体流:
    ffmpeg -i input.avi output.mp4
    
  • Set the video bitrate of the output file to 64 kbit/s:
    将输出文件的视频比特率设置为 64 kbit/s:
    ffmpeg -i input.avi -b:v 64k -bufsize 64k output.mp4
    
  • Force the frame rate of the output file to 24 fps:
    强制输出文件的帧率为 24 帧每秒:
    ffmpeg -i input.avi -r 24 output.mp4
    
  • 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:
    将输入文件的帧率强制设为 1 帧每秒(仅适用于原始格式),并将输出文件的帧率设为 24 帧每秒:
    ffmpeg -r 1 -i input.m2v -r 24 output.mp4
    

The format option may be needed for raw input files.
原始输入文件可能需要格式选项。

3 Detailed description 3 详细描述

The transcoding process in ffmpeg for each output can be described by the following diagram:
ffmpeg 中,每个输出的转码过程可以通过以下图示来描述:

 _______              ______________
|       |            |              |
| input |  demuxer   | encoded data |   decoder
| file  | ---------> | packets      | -----+
|_______|            |______________|      |
                                           v
                                       _________
                                      |         |
                                      | decoded |
                                      | frames  |
                                      |_________|
 ________             ______________       |
|        |           |              |      |
| output | <-------- | encoded data | <----+
| file   |   muxer   | packets      |   encoder
|________|           |______________|


ffmpeg calls the libavformat library (containing demuxers) to read input files and get packets containing encoded data from them. When there are multiple input files, ffmpeg tries to keep them synchronized by tracking lowest timestamp on any active input stream.
ffmpeg 调用 libavformat 库(包含解复用器)来读取输入文件并从中获取包含编码数据的包。当存在多个输入文件时, ffmpeg 通过跟踪任意活跃输入流上的最低时间戳来尝试保持它们的同步。

Encoded packets are then passed to the decoder (unless streamcopy is selected for the stream, see further for a description). The decoder produces uncompressed frames (raw video/PCM audio/...) which can be processed further by filtering (see next section). After filtering, the frames are passed to the encoder, which encodes them and outputs encoded packets. Finally, those are passed to the muxer, which writes the encoded packets to the output file.
编码后的数据包随后被传递给解码器(除非为该流选择了流复制,详情见下文描述)。解码器生成未压缩的帧(原始视频/PCM 音频/...),这些帧可以进一步通过滤波处理(见下一节)。经过滤波后,帧被传递给编码器,编码器对其进行编码并输出编码后的数据包。最终,这些数据包被传递给复用器,复用器将编码后的数据包写入输出文件。

3.1 Filtering 3.1 过滤

Before encoding, ffmpeg can process raw audio and video frames using filters from the libavfilter library. Several chained filters form a filter graph. ffmpeg distinguishes between two types of filtergraphs: simple and complex.
编码前, ffmpeg 可利用 libavfilter 库中的滤镜处理原始音视频帧。多个串联的滤镜构成一个滤镜图。 ffmpeg 将滤镜图区分为两种类型:简单型与复杂型。

3.1.1 Simple filtergraphs
3.1.1 简单滤镜图

Simple filtergraphs are those that have exactly one input and output, both of the same type. In the above diagram they can be represented by simply inserting an additional step between decoding and encoding:
简单滤镜图是指那些具有完全相同类型的一个输入和一个输出的情况。在上图中,它们可以通过在解码和编码之间插入一个额外的步骤来简单表示:

 _________                        ______________
|         |                      |              |
| decoded |                      | encoded data |
| frames  |\                   _ | packets      |
|_________| \                  /||______________|
             \   __________   /
  simple     _\||          | /  encoder
  filtergraph   | filtered |/
                | frames   |
                |__________|

Simple filtergraphs are configured with the per-stream -filter option (with -vf and -af aliases for video and audio respectively). A simple filtergraph for video can look for example like this:
简单滤镜图可以通过每个流的 -filter 选项进行配置(视频和音频分别有 -vf-af 的别名)。例如,一个用于视频的简单滤镜图可能看起来像这样:

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

Note that some filters change frame properties but not frame contents. E.g. the fps filter in the example above changes number of frames, but does not touch the frame contents. Another example is the setpts filter, which only sets timestamps and otherwise passes the frames unchanged.
请注意,某些滤镜会改变帧属性而非帧内容。例如,上述示例中的 fps 滤镜会改变帧数,但不会触及帧内容。另一个例子是 setpts 滤镜,它仅设置时间戳,其他情况下帧内容保持不变。

3.1.2 Complex filtergraphs
3.1.2 复杂滤镜图

Complex filtergraphs are those which cannot be described as simply a linear processing chain applied to one stream. This is the case, for example, when the graph has more than one input and/or output, or when output stream type is different 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_complex option. Note that this option is global, since a complex filtergraph, by its nature, cannot be unambiguously associated with a single stream or file.
复杂滤镜图通过 -filter_complex 选项进行配置。请注意,此选项是全局的,因为复杂滤镜图的本质决定了它无法明确关联到单一的流或文件。

The -lavfi option is equivalent to -filter_complex.
-lavfi 选项等同于 -filter_complex

A trivial example of a complex filtergraph is the overlay filter, which has two video inputs and one video output, containing one video overlaid on top of the other. Its audio counterpart is the amix filter.
复杂滤镜图的一个简单示例是 overlay 滤镜,它具有两个视频输入和一个视频输出,包含一个视频叠加在另一个视频之上。其音频对应的是 amix 滤镜。

3.2 Stream copy 3.2 流复制

Stream copy is a mode selected by supplying the copy parameter to the -codec option. It makes ffmpeg omit the decoding and encoding step for the specified stream, so it does only demuxing and muxing. It is useful for changing the container format or modifying container-level metadata. The diagram above will, in this case, simplify to this:
流复制是通过向 -codec 选项提供 copy 参数来选择的一种模式。它使 ffmpeg 跳过指定流的解码和编码步骤,仅进行解复用和复用。这对于更改容器格式或修改容器级元数据非常有用。在这种情况下,上述图表将简化为:

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

Since there is no decoding or encoding, it is very fast and there is no quality loss. However, it might not work in some cases because of many factors. Applying filters is obviously also impossible, since filters work on uncompressed data.
由于无需解码或编码,其速度极快且无质量损失。然而,由于多种因素,它在某些情况下可能无法工作。显然,应用滤镜也是不可能的,因为滤镜作用于未压缩的数据。

3.3 Loopback decoders 3.3 回环解码器

While decoders are normally associated with demuxer streams, it is also possible to create "loopback" decoders that decode the output from some encoder and allow it to be fed back to complex filtergraphs. This is done with the -dec directive, which takes as a parameter the index of the output stream that should be decoded. Every such directive creates a new loopback decoder, indexed with successive integers starting at zero. These indices should then be used to refer to loopback decoders in complex filtergraph link labels, as described in the documentation for -filter_complex.
虽然解码器通常与多路分离器流相关联,但也可以创建“回环”解码器,它们解码某些编码器的输出,并允许将其反馈到复杂的滤镜图中。这是通过 -dec 指令实现的,该指令以应解码的输出流索引作为参数。每条此类指令都会创建一个新的回环解码器,从零开始按顺序编号。这些索引随后应在复杂滤镜图链接标签中用于引用回环解码器,具体描述见 -filter_complex 的文档。

Decoding AVOptions can be passed to loopback decoders by placing them before -dec, analogously to input/output options.
解码 AVOptions 可以通过将其置于 -dec 之前传递给环回解码器,类似于输入/输出选项的处理方式。

E.g. the following example:
例如,以下示例:

ffmpeg -i INPUT                                        \
  -map 0:v:0 -c:v libx264 -crf 45 -f null -            \
  -threads 3 -dec 0:0                                  \
  -filter_complex '[0:v][dec:0]hstack[stack]'          \
  -map '[stack]' -c:v ffv1 OUTPUT

reads an input video and
读取一个输入视频并

  • (line 2) encodes it with libx264 at low quality;
    (第 2 行)以低质量用 libx264 编码;
  • (line 3) decodes this encoded stream using 3 threads;
    (第 3 行)使用 3 个线程解码这个编码流;
  • (line 4) places decoded video side by side with the original input video;
    (第 4 行)将解码后的视频与原始输入视频并排显示;
  • (line 5) combined video is then losslessly encoded and written into OUTPUT.
    (第 5 行)合并后的视频随后被无损编码并写入 OUTPUT

4 Stream selection 4 流选择

ffmpeg provides the -map option for manual control of stream selection in each output file. Users can skip -map and let ffmpeg perform automatic stream selection as described below. The -vn / -an / -sn / -dn options can be used to skip inclusion of video, audio, subtitle and data streams respectively, whether manually mapped or automatically selected, except for those streams which are outputs of complex filtergraphs.
ffmpeg 为每个输出文件提供了 -map 选项,用于手动控制流选择。用户可以跳过 -map ,让 ffmpeg 按照以下描述自动执行流选择。 -vn / -an / -sn / -dn 选项可用于分别跳过视频、音频、字幕和数据流的包含,无论是手动映射还是自动选择,除了那些作为复杂滤镜图输出的流。

4.1 Description 4.1 描述

The sub-sections that follow describe the various rules that are involved in stream selection. The examples that follow next show how these rules are applied in practice.
以下小节将介绍涉及流选择的各项规则。接下来的示例展示了这些规则在实际中的应用方式。

While every effort is made to accurately reflect the behavior of the program, FFmpeg is under continuous development and the code may have changed since the time of this writing.
虽然我们尽最大努力准确反映程序的行为,但 FFmpeg 正处于持续开发中,自撰写本文以来代码可能已经发生了变化。

4.1.1 Automatic stream selection
4.1.1 自动流选择

In the absence of any map options for a particular output file, ffmpeg inspects the output format to check which type of streams can be included in it, viz. video, audio and/or subtitles. For each acceptable stream type, ffmpeg will pick one stream, when available, from among all the inputs.
在特定输出文件缺少任何映射选项的情况下,ffmpeg 会检查输出格式,以确定可以包含哪种类型的流,即视频、音频和/或字幕。对于每种可接受的流类型,ffmpeg 会在所有输入中选择一个可用流。

It will select that stream based upon the following criteria:
它将根据以下标准选择该流:

  • for video, it is the stream with the highest resolution,
    对于视频,它是分辨率最高的流
  • for audio, it is the stream with the most channels,
    对于音频,它是拥有最多声道的流
  • for subtitles, it is the first subtitle stream found but there’s a caveat. The output format’s default subtitle encoder can be either text-based or image-based, and only a subtitle stream of the same type will be chosen.
    对于字幕,选择的是找到的首个字幕流,但有一个注意事项。输出格式的默认字幕编码器可能是基于文本的或基于图像的,只有同类型的字幕流才会被选中。

In the case where several streams of the same type rate equally, the stream with the lowest index is chosen.
在多个同类型流评分相等的情况下,选择索引值最低的流。

Data or attachment streams are not automatically selected and can only be included using -map.
数据或附件流不会自动选择,只能通过 -map 包含。

4.1.2 Manual stream selection
4.1.2 手动流选择

When -map is used, only user-mapped streams are included in that output file, with one possible exception for filtergraph outputs described below.
当使用 -map 时,仅包含用户映射的流在该输出文件中,以下描述的滤镜图输出可能是一个例外。

4.1.3 Complex filtergraphs
4.1.3 复杂滤镜图

If there are any complex filtergraph output streams with unlabeled pads, they will be added to the first output file. This will lead to a fatal error if the stream type is not supported by the output format. In the absence of the map option, the inclusion of these streams leads to the automatic stream selection of their types being skipped. If map options are present, these filtergraph streams are included in addition to the mapped streams.
如果存在带有未标记垫片的复杂滤镜图输出流,它们将被添加到第一个输出文件中。如果该流类型不受输出格式支持,这将导致致命错误。在没有 map 选项的情况下,这些流的包含会导致其类型的自动选择被跳过。如果存在 map 选项,这些滤镜图流除了映射的流之外还会被包含。

Complex filtergraph output streams with labeled pads must be mapped once and exactly once.
带有标签垫片的复杂滤镜图输出流必须且仅能映射一次。

4.1.4 Stream handling 4.1.4 流处理

Stream handling is independent of stream selection, with an exception for subtitles described below. Stream handling is set via the -codec option addressed to streams within a specific output file. In particular, codec options are applied by ffmpeg after the stream selection process and thus do not influence the latter. If no -codec option is specified for a stream type, ffmpeg will select the default encoder registered by the output file muxer.
流处理与流选择相互独立,但以下描述的字幕除外。流处理通过针对特定输出文件中的流的 -codec 选项进行设置。特别是,编解码器选项在流选择过程之后由 ffmpeg 应用,因此不会影响后者。如果未为某种流类型指定 -codec 选项,ffmpeg 将选择输出文件复用器注册的默认编码器。

An exception exists for subtitles. If a subtitle encoder is specified for an output file, the first subtitle stream found of any type, text or image, will be included. ffmpeg does not validate if the specified encoder can convert the selected stream or if the converted stream is acceptable within the output format. This applies generally as well: when the user sets an encoder manually, the stream selection process cannot check if the encoded stream can be muxed into the output file. If it cannot, ffmpeg will abort and all output files will fail to be processed.
对于字幕存在例外情况。如果为输出文件指定了字幕编码器,那么找到的第一个字幕流(无论是文本类型还是图像类型)都将被包含。ffmpeg 不会验证指定的编码器是否能转换所选流,或者转换后的流是否能在输出格式中被接受。这一原则普遍适用:当用户手动设置编码器时,流选择过程无法检查编码后的流是否能被混入输出文件。如果不能,ffmpeg 将中止,所有输出文件的处理都将失败。

4.2 Examples 4.2 示例

The following examples illustrate the behavior, quirks and limitations of ffmpeg’s stream selection methods.
以下示例展示了 ffmpeg 流选择方法的行为、特性和限制。

They assume the following three input files.
他们假设以下三个输入文件。

input file 'A.avi'
      stream 0: video 640x360
      stream 1: audio 2 channels

input file 'B.mp4'
      stream 0: video 1920x1080
      stream 1: audio 2 channels
      stream 2: subtitles (text)
      stream 3: audio 5.1 channels
      stream 4: subtitles (text)

input file 'C.mkv'
      stream 0: video 1280x720
      stream 1: audio 2 channels
      stream 2: subtitles (image)

Example: automatic stream selection
示例:自动流选择

ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov

There are three output files specified, and for the first two, no -map options are set, so ffmpeg will select streams for these two files automatically.
指定了三个输出文件,前两个文件未设置 -map 选项,因此 ffmpeg 将自动为这两个文件选择流。

out1.mkv is a Matroska container file and accepts video, audio and subtitle streams, so ffmpeg will try to select one of each type.
out1.mkv 是一个 Matroska 容器文件,接受视频、音频和字幕流,因此 ffmpeg 会尝试选择每种类型中的一个。

For video, it will select stream 0 from B.mp4, which has the highest resolution among all the input video streams.
对于视频,它将从所有输入视频流中选择分辨率最高的 B.mp4 ,即 stream 0

For audio, it will select stream 3 from B.mp4, since it has the greatest number of channels.
对于音频,它将选择 B.mp4 中的 stream 3 ,因为它具有最多的声道数。

For subtitles, it will select stream 2 from B.mp4, which is the first subtitle stream from among A.avi and B.mp4.
对于字幕,它将选择 stream 2 ,这是从 B.mp4 中选取的,即在 A.aviB.mp4 中的第一个字幕流。

out2.wav accepts only audio streams, so only stream 3 from B.mp4 is selected.
out2.wav 仅接受音频流,因此仅选择 B.mp4 中的 stream 3

For out3.mov, since a -map option is set, no automatic stream selection will occur. The -map 1:a option will select all audio streams from the second input B.mp4. No other streams will be included in this output file.
对于 out3.mov ,由于设置了 -map 选项,不会发生自动流选择。 -map 1:a 选项将从第二个输入 B.mp4 中选择所有音频流。此输出文件中不会包含其他流。

For the first two outputs, all included streams will be transcoded. The encoders chosen will be the default ones registered by each output format, which may not match the codec of the selected input streams.
对于前两个输出,所有包含的流都将被转码。所选编码器将是每个输出格式注册的默认编码器,这可能与所选输入流的编解码器不匹配。

For the third output, codec option for audio streams has been set to copy, so no decoding-filtering-encoding operations will occur, or can occur. Packets of selected streams shall be conveyed from the input file and muxed within the output file.
对于第三个输出,音频流的编解码器选项已设置为 copy ,因此不会发生也不可能发生解码-过滤-编码操作。所选流的包将从输入文件传递,并在输出文件中进行复用。

Example: automatic subtitles selection
示例:自动字幕选择

ffmpeg -i C.mkv out1.mkv -c:s dvdsub -an out2.mkv

Although out1.mkv is a Matroska container file which accepts subtitle streams, only a video and audio stream shall be selected. The subtitle stream of C.mkv is image-based and the default subtitle encoder of the Matroska muxer is text-based, so a transcode operation for the subtitles is expected to fail and hence the stream isn’t selected. However, in out2.mkv, a subtitle encoder is specified in the command and so, the subtitle stream is selected, in addition to the video stream. The presence of -an disables audio stream selection for out2.mkv.
尽管 out1.mkv 是一个接受字幕流的 Matroska 容器文件,但仅应选择视频和音频流。 C.mkv 的字幕流基于图像,而 Matroska 混流器的默认字幕编码器基于文本,因此预期字幕的转码操作会失败,故未选择该字幕流。然而,在 out2.mkv 中,命令中指定了字幕编码器,因此除了视频流外,字幕流也被选中。 -an 的存在使得 out2.mkv 无法选择音频流。

Example: unlabeled filtergraph outputs
示例:未标记的滤镜图输出

ffmpeg -i A.avi -i C.mkv -i B.mp4 -filter_complex "overlay" out1.mp4 out2.srt

A filtergraph is setup here using the -filter_complex option and consists of a single video filter. The overlay filter requires exactly two video inputs, but none are specified, so the first two available video streams are used, those of A.avi and C.mkv. The output pad of the filter has no label and so is sent to the first output file out1.mp4. Due to this, automatic selection of the video stream is skipped, which would have selected the stream in B.mp4. The audio stream with most channels viz. stream 3 in B.mp4, is chosen automatically. No subtitle stream is chosen however, since the MP4 format has no default subtitle encoder registered, and the user hasn’t specified a subtitle encoder.
此处使用 -filter_complex 选项设置了一个过滤器图形,并由单个视频过滤器组成。 overlay 过滤器需要确切的两路视频输入,但未指定,因此使用了前两路可用的视频流,即 A.aviC.mkv 的视频流。过滤器的输出端口未标记,因此被发送到第一个输出文件 out1.mp4 。由于这一原因,自动选择视频流的过程被跳过,否则会选择 B.mp4 中的视频流。音频流中通道数最多的,即 B.mp4 中的 stream 3 ,被自动选中。然而,没有选择字幕流,因为 MP4 格式未注册默认的字幕编码器,且用户未指定字幕编码器。

The 2nd output file, out2.srt, only accepts text-based subtitle streams. So, even though the first subtitle stream available belongs to C.mkv, it is image-based and hence skipped. The selected stream, stream 2 in B.mp4, is the first text-based subtitle stream.
第二个输出文件, out2.srt ,仅接受基于文本的字幕流。因此,尽管第一个可用的字幕流属于 C.mkv ,但由于它是基于图像的,所以被跳过了。选定的流, B.mp4 中的 stream 2 ,是第一个基于文本的字幕流。

Example: labeled filtergraph outputs
示例:标记的过滤器图形输出

ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
       -map '[outv]' -an        out1.mp4 \
                                out2.mkv \
       -map '[outv]' -map 1:a:0 out3.mkv

The above command will fail, as the output pad labelled [outv] has been mapped twice. None of the output files shall be processed.
上述命令将失败,因为标记为 [outv] 的输出端已被映射两次。所有输出文件均不会被处理。

ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
       -an        out1.mp4 \
                  out2.mkv \
       -map 1:a:0 out3.mkv

This command above will also fail as the hue filter output has a label, [outv], and hasn’t been mapped anywhere.
上述命令同样会失败,因为色调滤镜输出带有标签 [outv] ,但尚未映射到任何地方。

The command should be modified as follows,
命令应修改如下:

ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0,split=2[outv1][outv2];overlay;aresample" \
        -map '[outv1]' -an        out1.mp4 \
                                  out2.mkv \
        -map '[outv2]' -map 1:a:0 out3.mkv

The video stream from B.mp4 is sent to the hue filter, whose output is cloned once using the split filter, and both outputs labelled. Then a copy each is mapped to the first and third output files.
来自 B.mp4 的视频流被发送到色调滤镜,其输出通过分割滤镜克隆一次,并对两个输出进行标记。随后,每个副本分别映射到第一个和第三个输出文件。

The overlay filter, requiring two video inputs, uses the first two unused video streams. Those are the streams from A.avi and C.mkv. The overlay output isn’t labelled, so it is sent to the first output file out1.mp4, regardless of the presence of the -map option.
叠加滤镜需要两个视频输入,使用前两个未使用的视频流,即来自 A.aviC.mkv 的流。由于叠加输出未标记,因此无论是否存在 -map 选项,它都会被发送到第一个输出文件 out1.mp4

The aresample filter is sent the first unused audio stream, that of A.avi. Since this filter output is also unlabelled, it too is mapped to the first output file. The presence of -an only suppresses automatic or manual stream selection of audio streams, not outputs sent from filtergraphs. Both these mapped streams shall be ordered before the mapped stream in out1.mp4.
aresample 滤镜被发送第一个未使用的音频流,即来自 A.avi 的音频流。由于此滤镜输出同样未标记,它也被映射到第一个输出文件。 -an 的存在仅抑制音频流的自动或手动选择,而非来自滤镜图的输出。这两个映射流将在 out1.mp4 中的映射流之前排序。

The video, audio and subtitle streams mapped to out2.mkv are entirely determined by automatic stream selection.
视频、音频和字幕流映射到 out2.mkv 完全由自动流选择决定。

out3.mkv consists of the cloned video output from the hue filter and the first audio stream from B.mp4.
out3.mkv 由色调滤镜的克隆视频输出和 B.mp4 的第一个音频流组成。

5 Options 5 个选项

All the numerical options, if not specified otherwise, accept a string representing a number as input, which may be followed by one of the SI unit prefixes, for example: ’K’, ’M’, or ’G’.
所有数值选项,除非另有说明,均接受一个表示数字的字符串作为输入,该字符串后可跟一个国际单位制前缀,例如:'K'、'M' 或 'G'。

If ’i’ is appended to the SI unit prefix, the complete prefix will be interpreted as a unit prefix for binary multiples, which are based on powers of 1024 instead of powers of 1000. Appending ’B’ to the SI unit prefix multiplies the value by 8. This allows using, for example: ’KB’, ’MiB’, ’G’ and ’B’ as number suffixes.
如果在 SI 单位前缀后附加“i”,则完整前缀将被解释为用于二进制倍数的单位前缀,这些倍数基于 1024 的幂而不是 1000 的幂。在 SI 单位前缀后附加“B”会将数值乘以 8。这使得可以使用例如“KB”、“MiB”、“G”和“B”作为数字后缀。

Options which do not take arguments are boolean options, and set the corresponding value to true. They can be set to false by prefixing the option name with "no". For example using "-nofoo" will set the boolean option with name "foo" to false.
不带参数的选项是布尔选项,会将相应值设为真。通过在选项名称前加上"no",可以将它们设为假。例如,使用"-nofoo"会将名为"foo"的布尔选项设为假。

Options that take arguments support a special syntax where the argument given on the command line is interpreted as a path to the file from which the actual argument value is loaded. To use this feature, add a forward slash ’/’ immediately before the option name (after the leading dash). E.g.
支持参数的选项具有一种特殊语法,其中命令行上给出的参数被解释为从文件加载实际参数值的路径。要使用此功能,请在选项名称前(紧跟在引导破折号之后)立即添加一个正斜杠“/”。例如:

ffmpeg -i INPUT -/filter:v filter.script OUTPUT

will load a filtergraph description from the file named filter.script.
将从名为 filter.script 的文件加载滤镜图描述。

5.1 Stream specifiers 5.1 流标识符

Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers are used to precisely specify which stream(s) a given option belongs to.
某些选项是按流应用的,例如比特率或编解码器。流标识符用于精确指定给定选项属于哪个(些)流。

A stream specifier is a string generally appended to the option name and separated from it by a colon. E.g. -codec:a:1 ac3 contains the a:1 stream specifier, which matches the second audio stream. Therefore, it would select the ac3 codec for the second audio stream.
流标识符是一个字符串,通常附加在选项名称之后,并用冒号与选项名称分隔开。例如, -codec:a:1 ac3 包含 a:1 流标识符,它匹配第二个音频流。因此,它会选择 ac3 编解码器用于第二个音频流。

A stream specifier can match several streams, so that the option is applied to all of them. E.g. the stream specifier in -b:a 128k matches all audio streams.
流标识符可以匹配多个流,从而使选项应用于所有这些流。例如, -b:a 128k 中的流标识符匹配所有音频流。

An empty stream specifier matches all streams. For example, -codec copy or -codec: copy would copy all the streams without reencoding.
空的流标识符匹配所有流。例如, -codec copy-codec: copy 将复制所有流而不进行重新编码。

Possible forms of stream specifiers are:
可能的流选择器形式包括:

stream_index

Matches the stream with this index. E.g. -threads:1 4 would set the thread count for the second stream to 4. If stream_index is used as an additional stream specifier (see below), then it selects stream number stream_index from the matching streams. Stream numbering is based on the order of the streams as detected by libavformat except when a stream group specifier or program ID is also specified. In this case it is based on the ordering of the streams in the group or program.
匹配具有此索引的流。例如, -threads:1 4 会将第二个流的线程数设置为 4。如果 stream_index 用作附加流标识符(见下文),则它从匹配的流中选择编号为 stream_index 的流。流编号基于 libavformat 检测到的流顺序,除非还指定了流组标识符或程序 ID。在这种情况下,它基于组或程序中流的顺序。

stream_type[:additional_stream_specifier]

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 video streams, ’V’ only matches video streams which are not attached pictures, video thumbnails or cover arts. If additional_stream_specifier is used, then it matches streams which both have this type and match the additional_stream_specifier. Otherwise, it matches all streams of the specified type.
stream_type 可以是以下之一:'v' 或 'V' 表示视频,'a' 表示音频,'s' 表示字幕,'d' 表示数据,'t' 表示附件。'v' 匹配所有视频流,'V' 仅匹配非附加图片、视频缩略图或封面艺术的视频流。如果使用 additional_stream_specifier,则匹配同时具有此类型并符合 additional_stream_specifier 的流。否则,它匹配指定类型的所有流。

g:group_specifier[:additional_stream_specifier]

Matches streams which are in the group with the specifier group_specifier. if additional_stream_specifier is used, then it matches streams which both are part of the group and match the additional_stream_specifier. group_specifier may be one of the following:
匹配属于指定组标识符(group_specifier)的流。若使用额外的流标识符(additional_stream_specifier),则匹配同时属于该组且符合额外流标识符的流。组标识符可以是以下之一:

group_index

Match the stream with this group index.
将流与该组索引匹配。

#group_id or i:group_id

Match the stream with this group id.
将流与该组 ID 匹配。

p:program_id[:additional_stream_specifier]

Matches streams which are in the program with the id program_id. If additional_stream_specifier is used, then it matches streams which both are part of the program and match the additional_stream_specifier.
匹配程序中具有指定 program_id 的流。若使用 additional_stream_specifier,则匹配同时属于该程序且符合 additional_stream_specifier 的流。

#stream_id or i:stream_id

Match the stream by stream id (e.g. PID in MPEG-TS container).
按流 ID 匹配流(例如,MPEG-TS 容器中的 PID)。

m:key[:value]

Matches streams with the metadata tag key having the specified value. If value is not given, matches streams that contain the given tag with any value.
将流与具有指定值的元数据标签键匹配。如果未提供值,则匹配包含给定标签键且具有任意值的流。

u

Matches streams with usable configuration, the codec must be defined and the essential information such as video dimension or audio sample rate must be present.
匹配具有可用配置的流,必须定义编解码器,并且诸如视频尺寸或音频采样率等关键信息必须存在。

Note that in ffmpeg, matching by metadata will only work properly for input files.
请注意,在 ffmpeg 中,通过元数据匹配仅能正确处理输入文件。

5.2 Generic options 5.2 通用选项

These options are shared amongst the ff* tools.
这些选项在以下工具中共享。

-L

Show license.  显示许可证。

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

Show help. An optional parameter may be specified to print help about a specific item. If no argument is specified, only basic (non advanced) tool options are shown.
显示帮助。可以指定一个可选参数来打印关于特定项目的帮助。如果未指定任何参数,则仅显示基本(非高级)工具选项。

Possible values of arg are:
arg 的可能取值包括:

long

Print advanced tool options in addition to the basic tool options.
除了基本工具选项外,打印高级工具选项。

full

Print complete list of options, including shared and private options for encoders, decoders, demuxers, muxers, filters, etc.
打印完整选项列表,包括编码器、解码器、解复用器、复用器、过滤器等的共享和私有选项。

decoder=decoder_name

Print detailed information about the decoder named decoder_name. Use the -decoders option to get a list of all decoders.
打印名为 decoder_name 的解码器的详细信息。使用 -decoders 选项获取所有解码器的列表。

encoder=encoder_name

Print detailed information about the encoder named encoder_name. Use the -encoders option to get a list of all encoders.
打印名为 encoder_name 的编码器的详细信息。使用 -encoders 选项获取所有编码器的列表。

demuxer=demuxer_name

Print detailed information about the demuxer named demuxer_name. Use the -formats option to get a list of all demuxers and muxers.
打印名为 demuxer_name 的解复用器的详细信息。使用 -formats 选项获取所有解复用器和复用器的列表。

muxer=muxer_name

Print detailed information about the muxer named muxer_name. Use the -formats option to get a list of all muxers and demuxers.
打印名为 muxer_name 的复用器的详细信息。使用 -formats 选项获取所有复用器和解复用器的列表。

filter=filter_name

Print detailed information about the filter named filter_name. Use the -filters option to get a list of all filters.
打印名为 filter_name 的过滤器的详细信息。使用 -filters 选项获取所有过滤器的列表。

bsf=bitstream_filter_name

Print detailed information about the bitstream filter named bitstream_filter_name. Use the -bsfs option to get a list of all bitstream filters.
打印名为 bitstream_filter_name 的比特流过滤器的详细信息。使用 -bsfs 选项可获取所有比特流过滤器的列表。

protocol=protocol_name

Print detailed information about the protocol named protocol_name. Use the -protocols option to get a list of all protocols.
打印名为 protocol_name 的协议的详细信息。使用 -protocols 选项获取所有协议的列表。

-version

Show version.  显示版本。

-buildconf

Show the build configuration, one option per line.
显示构建配置,每行一个选项。

-formats

Show available formats (including devices).
显示可用格式(包括设备)。

-demuxers

Show available demuxers.
显示可用的解复用器。

-muxers

Show available muxers.  显示可用的复用器。

-devices

Show available devices.  显示可用设备。

-codecs

Show all codecs known to libavcodec.
显示 libavcodec 已知的所有编解码器。

Note that the term ’codec’ is used throughout this documentation as a shortcut for what is more correctly called a media bitstream format.
请注意,本文件中使用的术语“编解码器”作为更准确称为媒体比特流格式的简写。

-decoders

Show available decoders.
显示可用解码器。

-encoders

Show all available encoders.
显示所有可用编码器。

-bsfs

Show available bitstream filters.
显示可用的比特流滤镜。

-protocols

Show available protocols.
显示可用协议。

-filters

Show available libavfilter filters.
显示可用的 libavfilter 滤镜。

-pix_fmts

Show available pixel formats.
显示可用的像素格式。

-sample_fmts

Show available sample formats.
显示可用的样本格式。

-layouts

Show channel names and standard channel layouts.
显示频道名称和标准频道布局。

-dispositions

Show stream dispositions.
显示流处理方式。

-colors

Show recognized color names.
显示已识别的颜色名称。

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

Show autodetected sources of the input device. Some devices may provide system-dependent source names that cannot be autodetected. The returned list cannot be assumed to be always complete.
显示输入设备自动检测到的源。某些设备可能提供依赖于系统的源名称,这些名称无法自动检测。返回的列表不能假定为始终完整。

ffmpeg -sources pulse,server=192.168.0.4
-sinks device[,opt1=val1[,opt2=val2]...]

Show autodetected sinks of the output device. Some devices may provide system-dependent sink names that cannot be autodetected. The returned list cannot be assumed to be always complete.
显示输出设备的自动检测接收器。某些设备可能提供无法自动检测的与系统相关的接收器名称。返回的列表不能假定为始终完整。

ffmpeg -sinks pulse,server=192.168.0.4
-loglevel [flags+]loglevel | -v [flags+]loglevel

Set logging level and flags used by the library.
设置库使用的日志级别和标志。

The optional flags prefix can consist of the following values:
可选标志前缀可以包含以下值:

repeat

Indicates that repeated log output should not be compressed to the first line and the "Last message repeated n times" line will be omitted.
指示重复的日志输出不应压缩到第一行,并且将省略“上次消息重复 n 次”这一行。

level

Indicates that log output should add a [level] prefix to each message line. This can be used as an alternative to log coloring, e.g. when dumping the log to file.
指示日志输出应在每条消息行前添加 [level] 前缀。这可作为日志着色的替代方案,例如在将日志转储到文件时使用。

Flags can also be used alone by adding a ’+’/’-’ prefix to set/reset a single flag without affecting other flags or changing loglevel. When setting both flags and loglevel, a ’+’ separator is expected between the last flags value and before loglevel.
旗帜也可以单独使用,通过添加“+”/“-”前缀来设置/重置单个旗帜,而不影响其他旗帜或改变日志级别。当同时设置旗帜和日志级别时,期望在最后一个旗帜值和日志级别之前使用“+”分隔符。

loglevel is a string or a number containing one of the following values:
loglevel 是一个字符串或数字,包含以下值之一:

quiet, -8

Show nothing at all; be silent.
什么都不展示;保持沉默。

panic, 0

Only show fatal errors which could lead the process to crash, such as an assertion failure. This is not currently used for anything.
仅显示可能导致进程崩溃的致命错误,例如断言失败。目前并未将其用于任何用途。

fatal, 8

Only show fatal errors. These are errors after which the process absolutely cannot continue.
仅显示致命错误。这些错误发生后,进程绝对无法继续进行。

error, 16

Show all errors, including ones which can be recovered from.
显示所有错误,包括可恢复的错误。

warning, 24

Show all warnings and errors. Any message related to possibly incorrect or unexpected events will be shown.
显示所有警告和错误。任何与可能不正确或意外事件相关的消息都将被显示。

info, 32

Show informative messages during processing. This is in addition to warnings and errors. This is the default value.
在处理过程中显示信息性消息。这包括警告和错误。这是默认设置。

verbose, 40

Same as info, except more verbose.
info 相同,但更加详细。

debug, 48

Show everything, including debugging information.
显示所有内容,包括调试信息。

trace, 56

For example to enable repeated log output, add the level prefix, and set loglevel to verbose:
例如,要启用重复的日志输出,请添加 level 前缀,并将日志级别设置为 verbose

ffmpeg -loglevel repeat+level+verbose -i input output

Another example that enables repeated log output without affecting current state of level prefix flag or loglevel:
另一个示例,允许重复输出日志而不影响 level 前缀标志或日志级别的当前状态:

ffmpeg [...] -loglevel +repeat

By default the program logs to stderr. If coloring is supported by the terminal, colors are used to mark errors and warnings. Log coloring can be disabled setting the environment variable AV_LOG_FORCE_NOCOLOR, or can be forced setting the environment variable AV_LOG_FORCE_COLOR.
默认情况下,程序将日志记录到 stderr。如果终端支持着色,将使用颜色标记错误和警告。可以通过设置环境变量 AV_LOG_FORCE_NOCOLOR 来禁用日志着色,或者通过设置环境变量 AV_LOG_FORCE_COLOR 来强制启用日志着色。

-report

Dump full command line and log output to a file named program-YYYYMMDD-HHMMSS.log in the current directory. This file can be useful for bug reports. It also implies -loglevel debug.
将完整的命令行和日志输出保存到当前目录下的文件“ program-YYYYMMDD-HHMMSS.log ”中。此文件对于提交错误报告非常有用。同时,这也意味着“ -loglevel debug ”。

Setting the 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; option values must be escaped if they contain special characters or the options delimiter ’:’ (see the “Quoting and escaping” section in the ffmpeg-utils manual).
将环境变量 FFREPORT 设置为任意值具有相同的效果。如果该值是以冒号分隔的键=值序列,这些选项将影响报告;若选项值包含特殊字符或选项分隔符冒号(':'),则必须进行转义(详见 ffmpeg-utils 手册中的“引用与转义”部分)。

The following options are recognized:
以下选项被识别:

file

set the file 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 %
设置用于报告的文件名; %p 会被展开为程序名称, %t 会被展开为时间戳, %% 会被展开为纯文本 %

level

set the log verbosity level using a numerical value (see -loglevel).
使用数值设置日志详细程度级别(参见 -loglevel )。

For example, to output a report to a file named ffreport.log using a log level of 32 (alias for log level info):
例如,将报告输出到名为 ffreport.log 的文件,使用日志级别 32 (日志级别 info 的别名):

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

Errors in parsing the environment variable are not fatal, and will not appear in the report.
解析环境变量时出现的错误并非致命,且不会出现在报告中。

-hide_banner

Suppress printing banner.
禁止打印横幅。

All FFmpeg tools will normally show a copyright notice, build options and library versions. This option can be used to suppress printing this information.
所有 FFmpeg 工具通常会显示版权声明、构建选项和库版本信息。此选项可用于抑制打印这些信息。

-cpuflags flags (global)

Allows setting and clearing cpu flags. This option is intended for testing. Do not use it unless you know what you’re doing.
允许设置和清除 CPU 标志。此选项旨在用于测试。除非您知道自己在做什么,否则请勿使用它。

ffmpeg -cpuflags -sse+mmx ...
ffmpeg -cpuflags mmx ...
ffmpeg -cpuflags 0 ...

Possible flags 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
-cpucount count (global)

Override detection of CPU count. This option is intended for testing. Do not use it unless you know what you’re doing.
覆盖 CPU 数量检测。此选项专为测试设计,除非您清楚自己在做什么,否则请勿使用。

ffmpeg -cpucount 2
-max_alloc bytes

Set the maximum size limit for allocating a block on the heap by ffmpeg’s family of malloc functions. Exercise extreme caution when using this option. Don’t use if you do not understand the full consequence of doing so. Default is INT_MAX.
通过 ffmpeg 的 malloc 函数系列设置堆上分配块的最大大小限制。使用此选项时请格外小心。如果您不完全理解这样做的全部后果,请不要使用。默认值为 INT_MAX。

5.3 AVOptions 5.3 AVOptions 翻译文本: 5.3 AV 选项

These options are provided directly by the libavformat, libavdevice and libavcodec libraries. To see the list of available AVOptions, use the -help option. They are separated into two categories:
这些选项由 libavformat、libavdevice 和 libavcodec 库直接提供。要查看可用的 AVOptions 列表,请使用 -help 选项。它们分为两大类:

generic

These options can be set for any container, codec or device. Generic options are listed under AVFormatContext options for containers/devices and under AVCodecContext options for codecs.
这些选项可以为任何容器、编解码器或设备设置。通用选项在容器/设备的 AVFormatContext 选项下列出,而在编解码器的 AVCodecContext 选项下列出。

private

These options are specific to the given container, device or codec. Private options are listed under their corresponding containers/devices/codecs.
这些选项特定于给定的容器、设备或编解码器。私有选项列在其相应的容器/设备/编解码器下。

For example to write an ID3v2.3 header instead of a default ID3v2.4 to an MP3 file, use the id3v2_version private option of the MP3 muxer:
例如,要将 ID3v2.3 头信息而非默认的 ID3v2.4 写入 MP3 文件,请使用 MP3 复用器的 id3v2_version 私有选项:

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 都是针对每个流的,因此应将流指定符附加到它们上:

ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4

In the above example, a multichannel audio stream is mapped twice for output. The first instance is encoded with codec ac3 and bitrate 640k. The second instance is downmixed to 2 channels and encoded with codec aac. A bitrate of 128k is specified for it using absolute index of the output stream.
在上面的示例中,一个多声道音频流被映射了两次以进行输出。第一次实例采用 ac3 编码,比特率为 640k。第二次实例被混音为 2 声道,并采用 aac 编码。通过输出流的绝对索引,为其指定了 128k 的比特率。

Note: the -nooption syntax cannot be used for boolean AVOptions, use -option 0/-option 1.
注意: -nooption 语法不能用于布尔类型的 AVOptions,请使用 -option 0 / -option 1

Note: the old undocumented way of specifying per-stream AVOptions by prepending v/a/s to the options name is now obsolete and will be removed soon.
注意:通过在选项名称前添加 v/a/s 来指定每个流的 AVOptions 的旧未记录方法现已过时,并将在不久后移除。

5.4 Main options 5.4 主要选项

-f fmt (input/output)

Force input or output file format. The format is normally auto detected for input files and guessed from the file extension for output files, so this option is not needed in most cases.
强制输入或输出文件格式。通常情况下,输入文件的格式会自动检测,而输出文件的格式则根据文件扩展名猜测,因此大多数情况下不需要此选项。

-i url (input)

input file url  输入文件 URL

-y (global)

Overwrite output files without asking.
无需询问直接覆盖输出文件。

-n (global)

Do not overwrite output files, and exit immediately if a specified output file already exists.
不要覆盖输出文件,如果指定的输出文件已存在,请立即退出。

-stream_loop number (input)

Set number of times input stream shall be looped. Loop 0 means no loop, loop -1 means infinite loop.
设置输入流应循环的次数。循环次数为 0 表示不循环,循环次数为-1 表示无限循环。

-recast_media (global)

Allow forcing a decoder of a different media type than the one detected or designated by the demuxer. Useful for decoding media data muxed as data streams.
允许强制使用与解复用器检测或指定的不同媒体类型的解码器。这对于解码作为数据流复用的媒体数据非常有用。

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

Select an encoder (when used before an output file) or a decoder (when used before an input file) for one or more streams. codec is the name of a decoder/encoder or a special value copy (output only) to indicate that the stream is not to be re-encoded.
选择一个编码器(用于输出文件前)或解码器(用于输入文件前)以处理一个或多个流。codec 可以是解码器/编码器的名称,或特殊值 copy (仅限输出),表示该流无需重新编码。

For example  例如

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

encodes all video streams with libx264 and copies all audio streams.
使用 libx264 编码所有视频流并复制所有音频流。

For each stream, the last matching c option is applied, so
对于每个流,将应用最后匹配的 c 选项,因此

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

will copy all the streams except the second video, which will be encoded with libx264, and the 138th audio, which will be encoded with libvorbis.
将复制所有流,除了第二路视频,它将使用 libx264 编码,以及第 138 路音频,它将使用 libvorbis 编码。

-t duration (input/output)

When used as an input option (before -i), limit the duration of data read from the input file.
当用作输入选项时(在 -i 之前),限制从输入文件读取数据的持续时间。

When used as an output option (before an output url), stop writing the output after its duration reaches duration.
当用作输出选项(在输出网址之前)时,在输出持续时间达到指定时长后停止写入输出。

duration must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
持续时间必须是一个时间长度规范,请参阅 ffmpeg-utils(1) 手册中的时间长度部分。

-to and -t are mutually exclusive and -t has priority.
-to 和 -t 是互斥的,且 -t 具有优先级。

-to position (input/output)

Stop writing the output or reading the input at position. position must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
停止在指定位置写入输出或读取输入。位置必须是一个时间持续时间规范,请参阅 ffmpeg-utils(1) 手册中的“时间持续时间”部分。

-to and -t are mutually exclusive and -t has priority.
-to 和 -t 是互斥的,且 -t 具有优先级。

-fs limit_size (output)

Set the file size limit, expressed in bytes. No further chunk of bytes is written after the limit is exceeded. The size of the output file is slightly more than the requested file size.
设置文件大小限制,以字节为单位表示。一旦超出限制,不再写入任何字节块。输出文件的大小略大于所请求的文件大小。

-ss position (input/output)

When used as an input option (before -i), seeks in this input file to position. Note that in most formats it is not possible to seek exactly, so ffmpeg will seek to the closest seek point before position. When transcoding and -accurate_seek is enabled (the default), this extra segment between the seek point and position will be decoded and discarded. When doing stream copy or when -noaccurate_seek is used, it will be preserved.
当用作输入选项(在 -i 之前)时,会在此输入文件中定位。请注意,在大多数格式中无法精确查找,因此 ffmpeg 将查找位置之前的最近查找点。在转码且启用 -accurate_seek (默认设置)时,查找点与位置之间的额外片段将被解码并丢弃。在进行流复制或使用 -noaccurate_seek 时,该片段将被保留。

When used as an output option (before an output url), decodes but discards input until the timestamps reach position.
当用作输出选项(在输出网址之前)时,解码但丢弃输入,直到时间戳达到指定位置。

position must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
位置必须是一个时间持续规范,请参阅 ffmpeg-utils(1) 手册中的时间持续部分。

-sseof position (input)

Like the -ss option but relative to the "end of file". That is negative values are earlier in the file, 0 is at EOF.
类似于 -ss 选项,但相对于“文件末尾”。即负值表示文件中较早的位置,0 位于 EOF 处。

-isync input_index (input)

Assign an input as a sync source.
指定一个输入作为同步源。

This will take the difference between the start times of the target and reference inputs and offset the timestamps of the target file by that difference. The source timestamps of the two inputs should derive from the same clock source for expected results. If copyts is set then start_at_zero must also be set. If either of the inputs has no starting timestamp then no sync adjustment is made.
这将计算目标输入与参考输入起始时间之间的差异,并根据该差异调整目标文件的时间戳。为获得预期结果,两个输入的源时间戳应源自同一时钟源。如果设置了 copyts ,则 start_at_zero 也必须设置。如果任一输入没有起始时间戳,则不进行同步调整。

Acceptable values are those that refer to a valid ffmpeg input index. If the sync reference is the target index itself or -1, then no adjustment is made to target timestamps. A sync reference may not itself be synced to any other input.
可接受的值是指引用有效 ffmpeg 输入索引的值。如果同步参考是目标索引本身或 -1,则不会对目标时间戳进行调整。同步参考本身可能不会与其他任何输入同步。

Default value is -1.
默认值为 -1。

-itsoffset offset (input)

Set the input time offset.
设置输入时间偏移。

offset must be a time duration specification, see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.
偏移量必须是一个时间持续时间规范,请参阅 ffmpeg-utils(1) 手册中的“时间持续时间”部分。

The offset is added to the timestamps of the input files. Specifying a positive offset means that the corresponding streams are delayed by the time duration specified in offset.
偏移量被添加到输入文件的时间戳中。指定一个正偏移意味着相应的流将被延迟,延迟的时间长度由偏移量指定。

-itsscale scale (input,per-stream)

Rescale input timestamps. scale should be a floating point number.
重新调整输入时间戳。比例应为浮点数。

-timestamp date (output)

Set the recording timestamp in the container.
在容器中设置录制时间戳。

date must be a date specification, see (ffmpeg-utils)the Date section in the ffmpeg-utils(1) manual.
日期必须是一个日期规范,请参阅 ffmpeg-utils(1) 手册中的日期部分。

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

Set a metadata key/value pair.
设置一个元数据键/值对。

An optional metadata_specifier may be given to set metadata on streams, chapters or programs. See -map_metadata documentation for details.
可选的 metadata_specifier 可用于设置流、章节或节目的元数据。详情请参阅 -map_metadata 文档。

This option overrides metadata set with -map_metadata. It is also possible to delete metadata by using an empty value.
此选项会覆盖通过 -map_metadata 设置的元数据。还可以通过使用空值来删除元数据。

For example, for setting the title in the output file:
例如,设置输出文件的标题:

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

To set the language of the first audio stream:
设置第一个音频流的语言:

ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
-disposition[:stream_specifier] value (output,per-stream)

Sets the disposition for a stream.
设置流的处置方式。

By default, the disposition is copied from the input stream, unless the output stream this option applies to is fed by a complex filtergraph - in that case the disposition is unset by default.
默认情况下,处置方式会从输入流复制,除非该选项适用的输出流由一个复杂的滤镜图提供 - 在这种情况下,处置方式默认未设置。

value is a sequence of items separated by ’+’ or ’-’. The first item may also be prefixed with ’+’ or ’-’, in which case this option modifies the default value. Otherwise (the first item is not prefixed) this options overrides the default value. A ’+’ prefix adds the given disposition, ’-’ removes it. It is also possible to clear the disposition by setting it to 0.
值是由一系列项组成,项与项之间以“+”或“-”分隔。首项前也可以带有“+”或“-”,此时该选项会修改默认值。若首项未带前缀,则该选项将覆盖默认值。前缀“+”表示添加指定处理方式,“-”表示移除该处理方式。此外,通过将其设置为 0,还可以清除处理方式。

If no -disposition options were specified for an output file, ffmpeg will automatically set the ’default’ disposition on the first stream of each type, when there are multiple streams of this type in the output file and no stream of that type is already marked as default.
如果未为输出文件指定任何 -disposition 选项,当输出文件中存在多种类型的多个流且尚未有该类型的流被标记为默认时,ffmpeg 会自动为每种类型的第一个流设置“默认”处置。

The -dispositions option lists the known dispositions.
-dispositions 选项列出了已知的处理方式。

For example, to make the second audio stream the default stream:
例如,要将第二个音频流设为默认流:

ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv

To make the second subtitle stream the default stream and remove the default disposition from the first subtitle stream:
将第二条字幕流设为默认流,并从第一条字幕流中移除默认设置:

ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv

To add an embedded cover/thumbnail:
添加嵌入式封面/缩略图:

ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4

Not all muxers support embedded thumbnails, and those who do, only support a few formats, like JPEG or PNG.
并非所有多路复用器都支持嵌入式缩略图,而那些支持的,也仅限于少数格式,如 JPEG 或 PNG。

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

Creates a program with the specified title, program_num and adds the specified stream(s) to it.
创建一个具有指定标题和程序号的程序,并为其添加指定的流。

-stream_group [map=input_file_id=stream_group][type=type:]st=stream[:st=stream][:stg=stream_group][:id=stream_group_id...] (output)

Creates a stream group of the specified type and stream_group_id, or by mapping an input group, adding the specified stream(s) and/or previously defined stream_group(s) to it.
创建指定类型和 stream_group_id 的流组,或通过映射输入组,向其中添加指定的流和/或先前定义的流组。

type can be one of the following:
类型可以是以下之一:

iamf_audio_element

Groups streams that belong to the same IAMF Audio Element
将属于同一 IAMF 音频元素的流分组

For this group type, the following options are available
对于此类群组,以下选项可供选择

audio_element_type

The Audio Element type. The following values are supported:
音频元素类型。支持以下值:

channel

Scalable channel audio representation
可伸缩通道音频表示

scene

Ambisonics representation
全向声表示法

demixing

Demixing information used to reconstruct a scalable channel audio representation. This option must be separated from the rest with a ’,’, and takes the following key=value options
用于重建可伸缩通道音频表示的解混信息。此选项必须与其他选项用逗号“,”分隔,并采用以下键=值选项

parameter_id

An identifier parameters blocks in frames may refer to
帧中的标识符参数块可能指向

dmixp_mode

A pre-defined combination of demixing parameters
预定义的分离参数组合

recon_gain

Recon gain information used to reconstruct a scalable channel audio representation. This option must be separated from the rest with a ’,’, and takes the following key=value options
用于重建可伸缩通道音频表示的侦测增益信息。此选项必须与其他选项用逗号分隔,并采用以下键=值选项形式。

parameter_id

An identifier parameters blocks in frames may refer to
帧中的标识符参数块可能指向

layer

A layer defining a Channel Layout in the Audio Element. This option must be separated from the rest with a ’,’. Several ’,’ separated entries can be defined, and at least one must be set.
音频元素中定义声道布局的一层。此选项必须与其他选项用逗号分隔。可以定义多个用逗号分隔的条目,且至少需设置一个。

It takes the following ":"-separated key=value options
它采用以下冒号分隔的键=值选项

ch_layout

The layer’s channel layout
图层的通道布局

flags

The following flags are available:
以下旗帜可供选择:

recon_gain

Wether to signal if recon_gain is present as metadata in parameter blocks within frames
是否在帧内的参数块中将 recon_gain 作为元数据进行标记

output_gain
output_gain_flags

Which channels output_gain applies to. The following flags are available:
输出增益适用的通道。以下标志可供选择:

FL
FR
BL
BR
TFL
TFR
ambisonics_mode

The ambisonics mode. This has no effect if audio_element_type is set to channel.
全景声模式。如果 audio_element_type 设置为 channel,则此模式无效。

The following values are supported:
支持以下值:

mono

Each ambisonics channel is coded as an individual mono stream in the group
每个全景声通道在组合中被编码为单独的单声道流

default_w

Default weight value  默认权重值

iamf_mix_presentation

Groups streams that belong to all IAMF Audio Element the same IAMF Mix Presentation references
将属于同一 IAMF 混音演示的所有 IAMF 音频元素的参考流进行分组

For this group type, the following options are available
对于此类群组类型,以下选项可供选择

submix

A sub-mix within the Mix Presentation. This option must be separated from the rest with a ’,’. Several ’,’ separated entries can be defined, and at least one must be set.
混音演示中的一个子混音。此选项必须与其他选项用“,”分隔。可以定义多个用“,”分隔的条目,且至少需设置一个。

It takes the following ":"-separated key=value options
它采用以下冒号分隔的键=值选项

parameter_id

An identifier parameters blocks in frames may refer to, for post-processing the mixed audio signal to generate the audio signal for playback
帧中的标识符参数块可能用于后期处理混合音频信号,以生成用于播放的音频信号

parameter_rate

The sample rate duration fields in parameters blocks in frames that refer to this parameter_id are expressed as
引用此参数 ID 的帧中参数块内的采样率持续时间字段表示为

default_mix_gain

Default mix gain value to apply when there are no parameter blocks sharing the same parameter_id for a given frame
当某帧中没有参数块共享相同 parameter_id 时,应用的默认混合增益值

element

References an Audio Element used in this Mix Presentation to generate the final output audio signal for playback. This option must be separated from the rest with a ’|’. Several ’|’ separated entries can be defined, and at least one must be set.
引用此混音演示中使用的音频元素,以生成最终的播放输出音频信号。此选项必须与其他选项用“|”分隔开。可以定义多个由“|”分隔的条目,且至少需设置一个。

It takes the following ":"-separated key=value options:
它接受以下以冒号分隔的键=值选项:

stg

The stream_group_id for an Audio Element which this sub-mix refers to
该子混音所引用的音频元素的流组 ID

parameter_id

An identifier parameters blocks in frames may refer to, for applying any processing to the referenced and rendered Audio Element before being summed with other processed Audio Elements
帧中的标识符参数块可能引用并渲染音频元素,以便在与其他已处理音频元素相加之前对其应用任何处理

parameter_rate

The sample rate duration fields in parameters blocks in frames that refer to this parameter_id are expressed as
在引用此参数 ID 的帧中,参数块内的采样率持续时间字段表示为

default_mix_gain

Default mix gain value to apply when there are no parameter blocks sharing the same parameter_id for a given frame
在给定帧中没有参数块共享相同 parameter_id 时应用的默认混合增益值

annotations

A key=value string describing the sub-mix element where "key" is a string conforming to BCP-47 that specifies the language for the "value" string. "key" must be the same as the one in the mix’s annotations
描述子混音元素的键值字符串,其中“键”是一个符合 BCP-47 标准的字符串,指定了“值”字符串的语言。“键”必须与混音注释中的键相同。

headphones_rendering_mode

Indicates whether the input channel-based Audio Element is rendered to stereo loudspeakers or spatialized with a binaural renderer when played back on headphones. This has no effect if the referenced Audio Element’s audio_element_type is set to channel.
指示在耳机播放时,基于输入通道的音频元素是渲染为立体声扬声器还是通过双耳渲染器进行空间化处理。如果引用的音频元素的 audio_element_type 设置为 channel,则此设置无效。

The following values are supported:
支持以下值:

stereo
binaural
layout

Specifies the layouts for this sub-mix on which the loudness information was measured. This option must be separated from the rest with a ’|’. Several ’|’ separated entries can be defined, and at least one must be set.
指定在此子混音上测量响度信息的布局。此选项必须与其他选项用“|”分隔。可以定义多个用“|”分隔的条目,且至少需设置一个。

It takes the following ":"-separated key=value options:
它接受以下以冒号分隔的键=值选项:

layout_type
loudspeakers

The layout follows the loudspeaker sound system convention of ITU-2051-3.
布局遵循 ITU-2051-3 规定的扬声器音响系统惯例。

binaural

The layout is binaural.  布局为双耳式。

sound_system

Channel layout matching one of Sound Systems A to J of ITU-2051-3, plus 7.1.2 and 3.1.2 This has no effect if layout_type is set to binaural.
通道布局匹配 ITU-2051-3 中的声音系统 A 至 J 之一,加上 7.1.2 和 3.1.2。如果 layout_type 设置为双耳,则此设置无效。

integrated_loudness

The program integrated loudness information, as defined in ITU-1770-4.
该程序集成了 ITU-R BS.1770-4 标准中定义的响度信息。

digital_peak

The digital (sampled) peak value of the audio signal, as defined in ITU-1770-4.
音频信号的数字(采样)峰值,如 ITU-1770-4 标准所定义。

true_peak

The true peak of the audio signal, as defined in ITU-1770-4.
ITU-1770-4 标准定义的音频信号的真实峰值。

dialog_anchored_loudness

The Dialogue loudness information, as defined in ITU-1770-4.
根据 ITU-R BS.1770-4 标准定义的对话响度信息。

album_anchored_loudness

The Album loudness information, as defined in ITU-1770-4.
根据 ITU-1770-4 标准定义的专辑响度信息。

annotations

A key=value string string describing the mix where "key" is a string conforming to BCP-47 that specifies the language for the "value" string. "key" must be the same as the ones in all sub-mix element’s annotationss
描述混合的关键值字符串,其中“key”是一个符合 BCP-47 标准的字符串,指定了“value”字符串的语言。“key”必须与所有子混合元素注释中的“key”保持一致。

E.g. to create an scalable 5.1 IAMF file from several WAV input files
例如,从多个 WAV 输入文件创建一个可扩展的 5.1 声道 IAMF 文件

ffmpeg -i front.wav -i back.wav -i center.wav -i lfe.wav
-map 0:0 -map 1:0 -map 2:0 -map 3:0 -c:a opus
-stream_group type=iamf_audio_element:id=1:st=0:st=1:st=2:st=3,
demixing=parameter_id=998,
recon_gain=parameter_id=101,
layer=ch_layout=stereo,
layer=ch_layout=5.1,
-stream_group type=iamf_mix_presentation:id=2:stg=0:annotations=en-us=Mix_Presentation,
submix=parameter_id=100:parameter_rate=48000|element=stg=0:parameter_id=100:annotations=en-us=Scalable_Submix|layout=sound_system=stereo|layout=sound_system=5.1
-streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 output.iamf

To copy the two stream groups (Audio Element and Mix Presentation) from an input IAMF file with four streams into an mp4 output
将输入 IAMF 文件中的两个流组(音频元素和混音演示)从包含四个流的输入 IAMF 文件复制到 mp4 输出文件中

ffmpeg -i input.iamf -c:a copy -stream_group map=0=0:st=0:st=1:st=2:st=3 -stream_group map=0=1:stg=0
-streamid 0:0 -streamid 1:1 -streamid 2:2 -streamid 3:3 output.mp4
-target type (output)

Specify target 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 set automatically. You can just type:
指定目标文件类型( vcdsvcddvddvdv50 )。类型前可加上 pal-ntsc-film- 以采用相应标准。所有格式选项(比特率、编解码器、缓冲区大小)将自动设置。您只需输入:

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

Nevertheless you can specify additional options as long as you know they do not conflict with the standard, as in:
尽管如此,只要您知道这些选项不会与标准冲突,您可以指定额外的选项,例如:

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

The parameters set for each target are as follows.
为每个目标设定的参数如下。

VCD 视频压缩光盘

pal:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x288 -r 25
-codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k

ntsc:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x240 -r 30000/1001
-codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k

film:
-f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
-s 352x240 -r 24000/1001
-codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
-ar 44100 -ac 2
-codec:a mp2 -b:a 224k

SVCD 超级 VCD

pal:
-f svcd -packetsize 2324
-s 480x576 -pix_fmt yuv420p -r 25
-codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k

ntsc:
-f svcd -packetsize 2324
-s 480x480 -pix_fmt yuv420p -r 30000/1001
-codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k

film:
-f svcd -packetsize 2324
-s 480x480 -pix_fmt yuv420p -r 24000/1001
-codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
-ar 44100
-codec:a mp2 -b:a 224k

DVD

pal:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x576 -pix_fmt yuv420p -r 25
-codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k

ntsc:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x480 -pix_fmt yuv420p -r 30000/1001
-codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k

film:
-f dvd -muxrate 10080k -packetsize 2048
-s 720x480 -pix_fmt yuv420p -r 24000/1001
-codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
-ar 48000
-codec:a ac3 -b:a 448k

DV 数字视频

pal:
-f dv
-s 720x576 -pix_fmt yuv420p -r 25
-ar 48000 -ac 2

ntsc:
-f dv
-s 720x480 -pix_fmt yuv411p -r 30000/1001
-ar 48000 -ac 2

film:
-f dv
-s 720x480 -pix_fmt yuv411p -r 24000/1001
-ar 48000 -ac 2

The dv50 target is identical to the dv target except that the pixel format set is yuv422p for all three standards.
dv50 目标与 dv 目标相同,只是所有三种标准均采用 yuv422p 像素格式设置。

Any user-set value for a parameter above will override the target preset value. In that case, the output may not comply with the target standard.
任何用户为上述参数设定的值都将覆盖目标预设值。在这种情况下,输出可能不符合目标标准。

-dn (input/output)

As an input option, blocks all data streams of a file from being filtered or being automatically selected or mapped for any output. See -discard option to disable streams individually.
作为输入选项,阻止文件的所有数据流被过滤、自动选择或映射用于任何输出。请参阅 -discard 选项以单独禁用流。

As an output option, disables data recording i.e. automatic selection or mapping of any data stream. For full manual control see the -map option.
作为输出选项,禁用数据记录,即自动选择或映射任何数据流。如需完全手动控制,请参阅 -map 选项。

-dframes number (output)

Set the number of data frames to output. This is an obsolete alias for -frames:d, which you should use instead.
设置要输出的数据帧数量。这是 -frames:d 的过时别名,请改用 -frames:d

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

Stop writing to the stream after framecount frames.
在达到 framecount 帧后停止向流写入数据。

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

Use fixed quality scale (VBR). The meaning of q/qscale is codec-dependent. If qscale is used without a stream_specifier then it applies only to the video stream, this is to maintain compatibility with previous behavior and as specifying the same codec specific value to 2 different codecs that is audio and video generally is not what is intended when no stream_specifier is used.
使用固定质量比例(VBR)。q/qscale 的含义取决于编解码器。如果未使用 stream_specifier 而直接使用 qscale,则仅适用于视频流,这是为了保持与先前行为的兼容性,因为在未使用 stream_specifier 的情况下,通常不意味着要将相同的编解码器特定值同时应用于音频和视频两种不同的编解码器。

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

Create the filtergraph specified by filtergraph and use it to filter the stream.
创建由 filtergraph 指定的过滤器图,并使用它来过滤流。

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 about the filtergraph syntax.
filtergraph 是对应用于流的过滤器图的描述,必须具有与流类型相同的单一输入和单一输出。在过滤器图中,输入与标签 in 关联,输出与标签 out 关联。有关过滤器图语法的更多信息,请参阅 ffmpeg-filters 手册。

See the -filter_complex option if you want to create filtergraphs with multiple inputs and/or outputs.
如需创建包含多个输入和/或输出的滤镜图,请参阅 -filter_complex 选项。

-reinit_filter[:stream_specifier] integer (input,per-stream)

This boolean option determines if the filtergraph(s) to which this stream is fed gets reinitialized when input frame parameters change mid-stream. This option is enabled by default as most video and all audio filters cannot handle deviation in input frame properties. Upon reinitialization, existing filter state is lost, like e.g. the frame count n reference available in some filters. Any frames buffered at time of reinitialization are lost. The properties where a change triggers reinitialization are, for video, frame resolution or pixel format; for audio, sample format, sample rate, channel count or channel layout.
此布尔选项决定当输入帧参数在中途发生变化时,是否重新初始化该流所输入的过滤器图。默认情况下,此选项处于启用状态,因为大多数视频和所有音频过滤器无法处理输入帧属性的偏差。重新初始化时,现有过滤器状态会丢失,例如某些过滤器中可用的帧计数 n 引用。在重新初始化时缓冲的任何帧也会丢失。触发重新初始化的属性包括:对于视频,帧分辨率或像素格式;对于音频,采样格式、采样率、通道数或通道布局。

-filter_threads nb_threads (global)

Defines how many threads are used to process a filter pipeline. Each pipeline will produce a thread pool with this many threads available for parallel processing. The default is the number of available CPUs.
定义了用于处理过滤器管道的线程数量。每个管道将生成一个线程池,其中包含这些线程以供并行处理使用。默认值为可用 CPU 的数量。

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

Specify the preset for matching stream(s).
指定用于匹配流的预设。

-stats (global)

Print encoding progress/statistics. It is on by default, to explicitly disable it you need to specify -nostats.
打印编码进度/统计信息。默认情况下它是开启的,若要明确禁用它,您需要指定 -nostats

-stats_period time (global)

Set period at which encoding progress/statistics are updated. Default is 0.5 seconds.
设置编码进度/统计信息的更新周期。默认值为 0.5 秒。

-progress url (global)

Send program-friendly progress information to url.
向 URL 发送程序友好的进度信息。

Progress information is written periodically and at the end of the encoding process. It is made of "key=value" lines. key consists of only alphanumeric characters. The last key of a sequence of progress information is always "progress".
进度信息在编码过程的定期和结束时被写入。它由"键=值"行组成。键仅由字母数字字符构成。一系列进度信息中的最后一个键始终是"progress"。

The update period is set using -stats_period.
更新周期通过 -stats_period 进行设置。

-stdin

Enable interaction on standard input. On by default unless standard input is used as an input. To explicitly disable interaction you need to specify -nostdin.
启用标准输入上的交互。默认情况下处于开启状态,除非标准输入被用作输入源。要显式禁用交互,需指定 -nostdin

Disabling interaction on standard input is useful, for example, if ffmpeg is in the background process group. Roughly the same result can be achieved with ffmpeg ... < /dev/null but it requires a shell.
禁用标准输入上的交互功能在某些情况下很有用,例如当 ffmpeg 处于后台进程组时。大致相同的效果可以通过 ffmpeg ... < /dev/null 实现,但需要一个 shell 环境。

-debug_ts (global)

Print timestamp/latency information. It is off by default. This option is mostly useful for testing and debugging purposes, and the output format may change from one version to another, so it should not be employed by portable scripts.
打印时间戳/延迟信息。默认情况下该功能是关闭的。此选项主要用于测试和调试目的,其输出格式可能会在不同版本间发生变化,因此不应被可移植脚本所采用。

See also the option -fdebug ts.
另请参见选项 -fdebug ts

-attach filename (output)

Add an attachment to the output file. This is supported by a few formats like Matroska for e.g. fonts used in rendering subtitles. Attachments are implemented as a specific type of stream, so this option will add a new stream to the file. It is 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 other streams (i.e. those created with -map or automatic mappings).
向输出文件添加附件。某些格式如 Matroska 支持此功能,例如用于渲染字幕的字体。附件作为特定类型的流实现,因此此选项将为文件添加新的流。随后,可以像往常一样对该流使用逐流选项。通过此选项创建的附件流将在所有其他流(即通过 -map 创建或自动映射的流)之后创建。

Note that for Matroska you also have to set the mimetype metadata tag:
请注意,对于 Matroska 格式,您还需要设置 mimetype 元数据标签:

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

(assuming that the attachment stream will be third in the output file).
(假设附件流将在输出文件中排在第三位)。

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

Extract the matching attachment stream into a file named filename. If filename is empty, then the value of the filename metadata tag will be used.
将匹配的附件流提取到名为 filename 的文件中。如果 filename 为空,则将使用 filename 元数据标签的值。

E.g. to extract the first attachment to a file named ’out.ttf’:
例如,提取名为“out.ttf”文件的第一个附件:

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

To extract all attachments to files determined by the filename tag:
要提取由 filename 标签确定的文件中的所有附件:

ffmpeg -dump_attachment:t "" -i INPUT

Technical note – attachments are implemented as codec extradata, so this option can actually be used to extract extradata from any stream, not just attachments.
技术说明 – 附件作为编解码器额外数据实现,因此此选项实际上可用于从任何流中提取额外数据,而不仅仅是附件。

5.5 Video Options 5.5 视频选项

-vframes number (output)

Set the number of video frames to output. This is an obsolete alias for -frames:v, which you should use instead.
设置要输出的视频帧数。这是已过时的别名,请改用 -frames:v

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

Set frame rate (Hz value, fraction or abbreviation).
设置帧率(赫兹值、分数或缩写)。

As an input option, ignore any timestamps stored in the file and instead generate timestamps assuming constant frame rate fps. This is not the same as the -framerate option used for some input formats like image2 or v4l2 (it used to be the same in older versions of FFmpeg). If in doubt use -framerate instead of the input option -r.
作为输入选项,忽略文件中存储的任何时间戳,并假设恒定帧率 fps 生成时间戳。这与某些输入格式(如 image2 或 v4l2)使用的 -framerate 选项不同(在 FFmpeg 的旧版本中,它们曾经是相同的)。如有疑问,请使用 -framerate 代替输入选项 -r

As an output option:
作为输出选项:

video encoding

Duplicate or drop frames right before encoding them to achieve constant output frame rate fps.
在编码前复制或丢弃帧以实现恒定的输出帧率 fps。

video streamcopy

Indicate to the muxer that fps is the stream frame rate. No data is dropped or duplicated in this case. This may produce invalid files if fps does not match the actual stream frame rate as determined by packet timestamps. See also the setts bitstream filter.
指示混流器 fps 为流帧率。在这种情况下,不会丢弃或复制任何数据。如果 fps 与根据数据包时间戳确定的实际流帧率不匹配,可能会生成无效文件。另请参阅 setts 比特流过滤器。

-fpsmax[:stream_specifier] fps (output,per-stream)

Set maximum frame rate (Hz value, fraction or abbreviation).
设置最大帧率(赫兹值、分数或缩写)。

Clamps output frame rate when output framerate is auto-set and is higher than this value. Useful in batch processing or when input framerate is wrongly detected as very high. It cannot be set together with -r. It is ignored during streamcopy.
当输出帧率自动设置且高于此值时,夹具会限制输出帧率。在批处理或输入帧率被错误检测为非常高时很有用。不能与 -r 同时设置。在流复制过程中会被忽略。

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

Set frame size.  设置帧大小。

As an input option, this is a shortcut for the video_size private option, recognized by some demuxers for which the frame size is either not stored in the file or is configurable – e.g. raw video or video grabbers.
作为输入选项,这是 video_size 私有选项的快捷方式,被某些解复用器识别,这些解复用器对于帧大小要么未存储在文件中,要么是可配置的——例如,原始视频或视频捕捉设备。

As an output option, this inserts the scale video filter to the end of the corresponding filtergraph. Please use the scale filter directly to insert it at the beginning or some other place.
作为输出选项,这会将 scale 视频滤镜插入到相应滤镜图的末尾。请直接使用 scale 滤镜来将其插入到开头或其他位置。

The format is ‘wxh’ (default - same as source).
格式为‘ wxh ’(默认 - 与源相同)。

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

Set the video display aspect ratio specified by aspect.
设置由 aspect 指定的视频显示宽高比。

aspect can be a floating point number string, or a string of the form num:den, where num and den are the numerator and denominator of the aspect ratio. For example "4:3", "16:9", "1.3333", and "1.7777" are valid argument values.
宽高比可以是一个浮点数字符串,或者是一个形如 num:den 的字符串,其中 num 和 den 分别是宽高比的分子和分母。例如,"4:3"、"16:9"、"1.3333"和"1.7777"都是有效的参数值。

If used together 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.
如果与 -vcodec copy 一起使用,它将影响存储在容器级别的宽高比,但不会影响存储在编码帧中的宽高比(如果存在)。

-display_rotation[:stream_specifier] rotation (input,per-stream)

Set video rotation metadata.
设置视频旋转元数据。

rotation is a decimal number specifying the amount in degree by which the video should be rotated counter-clockwise before being displayed.
旋转是一个十进制数,用于指定在显示视频之前应逆时针旋转的角度。

This option overrides the rotation/display transform metadata stored in the file, if any. When the video is being transcoded (rather than copied) and -autorotate is enabled, the video will be rotated at the filtering stage. Otherwise, the metadata will be written into the output file if the muxer supports it.
此选项会覆盖文件中存储的旋转/显示变换元数据(如果有)。当视频正在转码(而非复制)且 -autorotate 启用时,视频将在过滤阶段进行旋转。否则,如果复用器支持,元数据将被写入输出文件。

If the -display_hflip and/or -display_vflip options are given, they are applied after the rotation specified by this option.
如果给出了 -display_hflip 和/或 -display_vflip 选项,它们将在应用此选项指定的旋转之后被应用。

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

Set whether on display the image should be horizontally flipped.
设置是否应水平翻转显示的图像。

See the -display_rotation option for more details.
查看 -display_rotation 选项以获取更多详情。

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

Set whether on display the image should be vertically flipped.
设置图像是否应垂直翻转以进行显示。

See the -display_rotation option for more details.
查看 -display_rotation 选项以获取更多详情。

-vn (input/output)

As an input option, blocks all video streams of a file from being filtered or being automatically selected or mapped for any output. See -discard option to disable streams individually.
作为输入选项,阻止文件的所有视频流被过滤、自动选择或映射用于任何输出。请参阅 -discard 选项以单独禁用流。

As an output option, disables video recording i.e. automatic selection or mapping of any video stream. For full manual control see the -map option.
作为输出选项,禁用视频录制,即自动选择或映射任何视频流。如需完全手动控制,请参阅 -map 选项。

-vcodec codec (output)

Set the video codec. This is an alias for -codec:v.
设置视频编解码器。这是对 -codec:v 的别名。

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

Select the pass number (1 or 2). It is used to do two-pass video encoding. The statistics of the video are recorded in the first pass into a log file (see also the option -passlogfile), and in the second pass that log file is used to generate the video at the exact requested bitrate. On pass 1, you may just deactivate audio and set output to null, examples for Windows and Unix:
选择通道编号(1 或 2)。此功能用于执行两遍视频编码。在第一遍中,视频统计数据会被记录到日志文件中(参见选项 -passlogfile),而在第二遍时,该日志文件则用于以精确的请求比特率生成视频。在第一遍时,您可以仅关闭音频并将输出设置为空,以下是 Windows 和 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)

Set two-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
将两遍日志文件名前缀设置为 prefix,默认文件名前缀为“ffmpeg2pass”。完整文件名将为 PREFIX-N.log ,其中 N 是特定于输出流的数字。

-vf filtergraph (output)

Create the filtergraph specified by filtergraph and use it to filter the stream.
创建由 filtergraph 指定的过滤器图,并使用它来过滤流。

This is an alias for -filter:v, see the -filter option.
这是 -filter:v 的别名,请参见-filter 选项。

-autorotate

Automatically rotate the video according to file metadata. Enabled by default, use -noautorotate to disable it.
根据文件元数据自动旋转视频。默认启用,使用 -noautorotate 可禁用此功能。

-autoscale

Automatically scale the video according to the resolution of first frame. Enabled by default, use -noautoscale to disable it. When autoscale is disabled, all output frames of filter graph might not be in the same resolution and may be inadequate for some encoder/muxer. Therefore, it is not recommended to disable it unless you really know what you are doing. Disable autoscale at your own risk.
根据首帧分辨率自动调整视频大小。默认启用,使用 -noautoscale 可禁用此功能。禁用自动缩放后,过滤器图的所有输出帧可能分辨率不一,某些编码器/复用器可能无法处理。因此,除非您确实了解自己在做什么,否则不建议禁用自动缩放。禁用自动缩放需自行承担风险。

5.6 Advanced Video options
5.6 高级视频选项

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

Set pixel format. Use -pix_fmts to show all the supported pixel formats. If the selected pixel format can not be selected, ffmpeg will print a warning and select the best pixel format supported by the encoder. If pix_fmt is prefixed by a +, ffmpeg will exit with an error if the requested pixel format can not be selected, and automatic conversions inside filtergraphs are disabled. If pix_fmt is a single +, ffmpeg selects the same pixel format as the input (or graph output) and automatic conversions are disabled.
设置像素格式。使用 -pix_fmts 显示所有支持的像素格式。如果所选像素格式无法选择,ffmpeg 将打印一条警告并选择编码器支持的最佳像素格式。如果 pix_fmt 以 + 为前缀,ffmpeg 将在请求的像素格式无法选择时退出并报错,且滤镜图内的自动转换将被禁用。如果 pix_fmt 为单个 + ,ffmpeg 将选择与输入(或图输出)相同的像素格式,并禁用自动转换。

-sws_flags flags (input/output)

Set default flags for the libswscale library. These flags are used by automatically inserted scale filters and those within simple filtergraphs, if not overridden within the filtergraph definition.
为 libswscale 库设置默认标志。这些标志用于自动插入的 scale 过滤器以及简单过滤图中的那些过滤器,除非在过滤图定义中被覆盖。

See the (ffmpeg-scaler)ffmpeg-scaler manual for a list of scaler options.
请参阅 (ffmpeg-scaler)ffmpeg-scaler 手册以获取缩放器选项列表。

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

Rate control override for specific intervals, formatted as "int,int,int" list separated with slashes. Two first values are the beginning and end frame numbers, last one is quantizer to use if positive, or quality factor if negative.
特定区间的码率控制覆盖,格式为“int,int,int”列表,以斜杠分隔。前两个值表示起始和结束帧号,最后一个值为正数时表示使用的量化器,为负数时表示质量因子。

-vstats

Dump video coding statistics to vstats_HHMMSS.log. See the vstats file format section for the format description.
将视频编码统计信息输出到 vstats_HHMMSS.log 。有关文件格式的描述,请参阅 vstats 文件格式部分。

-vstats_file file

Dump video coding statistics to file. See the vstats file format section for the format description.
将视频编码统计数据输出到文件。有关文件格式的描述,请参阅 vstats 文件格式部分。

-vstats_version file

Specify which version of the vstats format to use. Default is 2. See the vstats file format section for the format description.
指定要使用的 vstats 格式的版本。默认版本为 2 。有关格式描述,请参阅 vstats 文件格式部分。

-vtag fourcc/tag (output)

Force video tag/fourcc. This is an alias for -tag:v.
强制视频标签/四 CC 码。这是 -tag:v 的别名。

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

force_key_frames can take arguments of the following form:
force_key_frames 可以接受以下形式的参数:

time[,time...]

If the argument consists of timestamps, ffmpeg will round the specified times to the nearest output timestamp as per the encoder time base and force a keyframe at the first frame having timestamp equal or greater than the computed timestamp. Note that if the encoder time base is too coarse, then the keyframes may be forced on frames with timestamps lower than the specified time. The default encoder time base is the inverse of the output framerate but may be set otherwise via -enc_time_base.
如果参数包含时间戳,ffmpeg 将根据编码器时间基准将指定时间四舍五入至最接近的输出时间戳,并在首个时间戳等于或大于计算所得时间戳的帧处强制插入关键帧。请注意,若编码器时间基准过于粗糙,则可能在这些指定时间之前的时间戳帧上强制插入关键帧。默认的编码器时间基准是输出帧率的倒数,但可通过 -enc_time_base 进行其他设置。

If one of the times is "chapters[delta]", it is expanded into the time of the beginning of all chapters in the file, shifted by delta, expressed as a time in seconds. This option can be useful to ensure that a seek point is present at a chapter mark or any other designated place in the output file.
如果其中一个时间设置为“ chapters [delta]”,它将被扩展为文件中所有章节起始时间,并按 delta 偏移,以秒为单位表示。此选项可用于确保在输出文件的章节标记或其他指定位置存在一个查找点。

For example, to insert a key frame at 5 minutes, plus key frames 0.1 second before the beginning of every chapter:
例如,在 5 分钟处插入一个关键帧,并在每个章节开始前 0.1 秒处添加关键帧:

-force_key_frames 0:05:00,chapters-0.1
expr:expr

If the argument is prefixed with expr:, the string expr is interpreted like an expression and is evaluated for each frame. A key frame is forced in case the evaluation is non-zero.
如果参数以 expr: 为前缀,字符串 expr 将被解释为表达式,并在每一帧进行求值。若求值结果非零,则会强制插入关键帧。

The expression in expr can contain the following constants:
表达式中的 expr 可以包含以下常量:

n

the number of current processed frame, starting from 0
当前处理的帧数,从 0 开始计数

n_forced

the number of forced frames
强制帧的数量

prev_forced_n

the number of the previous forced frame, it is NAN when no keyframe was forced yet
上一个强制帧的编号,当尚未强制关键帧时,其值为 NAN

prev_forced_t

the time of the previous forced frame, it is NAN when no keyframe was forced yet
上一个强制帧的时间,当尚未强制关键帧时,其值为 NAN

t

the time of the current processed frame
当前处理帧的时间

For example to force a key frame every 5 seconds, you can specify:
例如,要强制每 5 秒生成一个关键帧,您可以指定:

-force_key_frames expr:gte(t,n_forced*5)

To force a key frame 5 seconds after the time of the last forced one, starting from second 13:
要在上次强制关键帧后的第 5 秒,即从第 13 秒开始,强制插入一个关键帧:

-force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
source

If the argument is source, ffmpeg will force a key frame if the current frame being encoded is marked as a key frame in its source. In cases where this particular source frame has to be dropped, enforce the next available frame to become a key frame instead.
如果参数为 source ,ffmpeg 将在当前编码的帧在其源中被标记为关键帧时强制生成一个关键帧。在必须丢弃此特定源帧的情况下,强制下一个可用帧成为关键帧。

Note that forcing too many keyframes is very harmful for the lookahead algorithms of certain encoders: using fixed-GOP options or similar would be more efficient.
请注意,对某些编码器的预览算法而言,强制过多关键帧非常有害:使用固定 GOP 选项或类似设置将更为高效。

-apply_cropping[:stream_specifier] source (input,per-stream)

Automatically crop the video after decoding according to file metadata. Default is all.
根据文件元数据,在解码后自动裁剪视频。默认为全部。

none (0)

Don’t apply any cropping metadata.
不要应用任何裁剪元数据。

all (1)

Apply both codec and container level croppping. This is the default mode.
应用编解码器和容器级别的裁剪。这是默认模式。

codec (2)

Apply codec level croppping.
应用编解码器级裁剪。

container (3)

Apply container level croppping.
应用容器级裁剪。

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

When doing stream copy, copy also non-key frames found at the beginning.
在进行流复制时,同时复制开头找到的非关键帧。

-init_hw_device type[=name][:device[,key=value...]]

Initialise a new hardware device of type type called name, using the given device parameters. If no name is specified it will receive a default name of the form "type%d".
初始化一个名为 name 的新硬件设备,类型为 type,使用给定的设备参数。如果未指定名称,它将获得一个默认名称,格式为"type%d"。

The meaning of device and the following arguments depends on the device type:
设备的意义及其后续论证取决于设备类型:

cuda

device is the number of the CUDA device.
设备是 CUDA 设备的编号。

The following options are recognized:
以下选项被识别:

primary_ctx

If set to 1, uses the primary device context instead of creating a new one.
如果设置为 1,将使用主设备上下文,而不是创建一个新的。

Examples:  示例:

-init_hw_device cuda:1 -初始化硬件设备 cuda:1

Choose the second device on the system.
选择系统上的第二个设备。

-init_hw_device cuda:0,primary_ctx=1
-初始化硬件设备 cuda:0,主上下文=1

Choose the first device and use the primary device context.
选择第一个设备并使用主设备上下文。

dxva2

device is the number of the Direct3D 9 display adapter.
设备是 Direct3D 9 显示适配器的编号。

d3d11va

device is the number of the Direct3D 11 display adapter. If not specified, it will attempt to use the default Direct3D 11 display adapter or the first Direct3D 11 display adapter whose hardware VendorId is specified by ‘vendor_id’.
设备是指 Direct3D 11 显示适配器的编号。如果未指定,它将尝试使用默认的 Direct3D 11 显示适配器,或者使用硬件 VendorId 由‘ vendor_id ’指定的第一个 Direct3D 11 显示适配器。

Examples:  示例:

-init_hw_device d3d11va -初始化硬件设备 d3d11va

Create a d3d11va device on the default Direct3D 11 display adapter.
在默认的 Direct3D 11 显示适配器上创建一个 d3d11va 设备。

-init_hw_device d3d11va:1
-初始化硬件设备 d3d11va:1

Create a d3d11va device on the Direct3D 11 display adapter specified by index 1.
在索引为 1 的 Direct3D 11 显示适配器上创建一个 d3d11va 设备。

-init_hw_device d3d11va:,vendor_id=0x8086

Create a d3d11va device on the first Direct3D 11 display adapter whose hardware VendorId is 0x8086.
在第一个硬件 VendorId 为 0x8086 的 Direct3D 11 显示适配器上创建一个 d3d11va 设备。

vaapi

device is either an X11 display name, a DRM render node or a DirectX adapter index. If not specified, it will attempt to open the default X11 display ($DISPLAY) and then the first DRM render node (/dev/dri/renderD128), or the default DirectX adapter on Windows.
设备可以是 X11 显示名称、DRM 渲染节点或 DirectX 适配器索引。如果未指定,它将尝试打开默认的 X11 显示($DISPLAY),然后是第一个 DRM 渲染节点(/dev/dri/renderD128),或者在 Windows 上使用默认的 DirectX 适配器。

The following options are recognized:
以下选项被识别:

kernel_driver

When device is not specified, use this option to specify the name of the kernel driver associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled.
当未指定设备时,使用此选项来指定与所需设备关联的内核驱动程序名称。仅当启用了硬件加速方法 drm 和 vaapi 时,此选项才可用。

vendor_id

When device and kernel_driver are not specified, use this option to specify the vendor id associated with the desired device. This option is available only when the hardware acceleration method drm and vaapi are enabled and kernel_driver is not specified.
当未指定设备和内核驱动程序时,使用此选项来指定与所需设备关联的供应商 ID。此选项仅在启用了硬件加速方法 drm 和 vaapi 且未指定内核驱动程序时可用。

Examples:  示例:

-init_hw_device vaapi -初始化硬件设备 vaapi

Create a vaapi device on the default device.
在默认设备上创建一个 VAAPI 设备。

-init_hw_device vaapi:/dev/dri/renderD129

Create a vaapi device on DRM render node /dev/dri/renderD129.
在 DRM 渲染节点 /dev/dri/renderD129 上创建一个 vaapi 设备。

-init_hw_device vaapi:1

Create a vaapi device on DirectX adapter 1.
在 DirectX 适配器 1 上创建一个 VAAPI 设备。

-init_hw_device vaapi:,kernel_driver=i915

Create a vaapi device on a device associated with kernel driver ‘i915’.
在关联于内核驱动‘ i915 ’的设备上创建一个 VAAPI 设备。

-init_hw_device vaapi:,vendor_id=0x8086

Create a vaapi device on a device associated with vendor id ‘0x8086’.
在关联供应商 ID 为‘ 0x8086 ’的设备上创建一个 VAAPI 设备。

vdpau

device is an X11 display name. If not specified, it will attempt to open the default X11 display ($DISPLAY).
设备是一个 X11 显示名称。如果未指定,它将尝试打开默认的 X11 显示($DISPLAY)。

qsv

device selects a value in ‘MFX_IMPL_*’. Allowed values are:
设备在“ MFX_IMPL_* ”中选择一个值。允许的值包括:

auto
sw
hw
auto_any
hw_any
hw2
hw3
hw4

If not specified, ‘auto_any’ is used. (Note that it may be easier to achieve the desired result for QSV by creating the platform-appropriate subdevice (‘dxva2’ or ‘d3d11va’ or ‘vaapi’) and then deriving a QSV device from that.)
如果未指定,则使用‘ auto_any ’。(请注意,通过创建平台适配的子设备(‘ dxva2 ’或‘ d3d11va ’或‘ vaapi ’),然后从中派生一个 QSV 设备,可能会更容易实现所需的 QSV 结果。)

The following options are recognized:
以下选项被识别:

child_device

Specify a DRM render node on Linux or DirectX adapter on Windows.
在 Linux 上指定 DRM 渲染节点或在 Windows 上指定 DirectX 适配器。

child_device_type

Choose platform-appropriate subdevice type. On Windows ‘d3d11va’ is used as default subdevice type when --enable-libvpl is specified at configuration time, ‘dxva2’ is used as default subdevice type when --enable-libmfx is specified at configuration time. On Linux user can use ‘vaapi’ only as subdevice type.
选择平台适配的子设备类型。在 Windows 上,当配置时指定 --enable-libvpl 时,默认使用' d3d11va '作为子设备类型;当配置时指定 --enable-libmfx 时,默认使用' dxva2 '作为子设备类型。在 Linux 上,用户只能使用' vaapi '作为子设备类型。

Examples:  示例:

-init_hw_device qsv:hw,child_device=/dev/dri/renderD129

Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DRM render node /dev/dri/renderD129.
在 DRM 渲染节点 /dev/dri/renderD129 上创建带有‘ MFX_IMPL_HARDWARE ’的 QSV 设备。

-init_hw_device qsv:hw,child_device=1

Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DirectX adapter 1.
在 DirectX 适配器 1 上创建一个带有‘ MFX_IMPL_HARDWARE ’的 QSV 设备。

-init_hw_device qsv:hw,child_device_type=d3d11va

Choose the GPU subdevice with type ‘d3d11va’ and create QSV device with ‘MFX_IMPL_HARDWARE’.
选择类型为‘ d3d11va ’的 GPU 子设备,并使用‘ MFX_IMPL_HARDWARE ’创建 QSV 设备。

-init_hw_device qsv:hw,child_device_type=dxva2

Choose the GPU subdevice with type ‘dxva2’ and create QSV device with ‘MFX_IMPL_HARDWARE’.
选择类型为‘ dxva2 ’的 GPU 子设备,并使用‘ MFX_IMPL_HARDWARE ’创建 QSV 设备。

-init_hw_device qsv:hw,child_device=1,child_device_type=d3d11va

Create a QSV device with ‘MFX_IMPL_HARDWARE’ on DirectX adapter 1 with subdevice type ‘d3d11va’.
在 DirectX 适配器 1 上创建一个带有“ MFX_IMPL_HARDWARE ”的 QSV 设备,子设备类型为“ d3d11va ”。

-init_hw_device vaapi=va:/dev/dri/renderD129 -init_hw_device qsv=hw1@va
-初始化硬件设备 vaapi=va:/dev/dri/renderD129 -初始化硬件设备 qsv=hw1@va

Create a VAAPI device called ‘va’ on /dev/dri/renderD129, then derive a QSV device called ‘hw1’ from device ‘va’.
/dev/dri/renderD129 上创建一个名为‘ va ’的 VAAPI 设备,然后从设备‘ va ’派生出一个名为‘ hw1 ’的 QSV 设备。

opencl

device selects the platform and device as platform_index.device_index.
设备选择平台和设备为 platform_index.device_index。

The set of devices can also be filtered using the key-value pairs to find only devices matching particular platform or device strings.
可以使用键值对对设备集进行筛选,以仅查找与特定平台或设备字符串匹配的设备。

The strings usable as filters are:
可作为过滤器的字符串包括:

platform_profile
platform_version
platform_name
platform_vendor
platform_extensions
device_name
device_vendor
driver_version
device_version
device_profile
device_extensions
device_type

The indices and filters must together uniquely select a device.
索引和过滤器必须共同唯一地选择一个设备。

Examples:  示例:

-init_hw_device opencl:0.1
-初始化硬件设备 opencl:0.1

Choose the second device on the first platform.
选择第一个平台上的第二个设备。

-init_hw_device opencl:,device_name=Foo9000
-初始化硬件设备 opencl:,设备名称=Foo9000

Choose the device with a name containing the string Foo9000.
选择名称中包含字符串 Foo9000 的设备。

-init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16

Choose the GPU device on the second platform supporting the cl_khr_fp16 extension.
在第二个平台上选择支持 cl_khr_fp16 扩展的 GPU 设备。

vulkan

If device is an integer, it selects the device by its index in a system-dependent list of devices. If device is any other string, it selects the first device with a name containing that string as a substring.
如果设备是一个整数,它会根据设备在系统依赖的设备列表中的索引来选择设备。如果设备是任何其他字符串,它会选中名称中包含该字符串作为子串的第一个设备。

The following options are recognized:
以下选项被识别:

debug

If set to 1, enables the validation layer, if installed.
如果设置为 1,将启用验证层(如果已安装)。

linear_images

If set to 1, images allocated by the hwcontext will be linear and locally mappable.
如果设置为 1,由 hwcontext 分配的图像将是线性的且可本地映射。

instance_extensions

A plus separated list of additional instance extensions to enable.
启用其他实例扩展的加号分隔列表。

device_extensions

A plus separated list of additional device extensions to enable.
启用设备的附加扩展列表,以加号分隔。

Examples:  示例:

-init_hw_device vulkan:1 -初始化硬件设备 vulkan:1

Choose the second device on the system.
选择系统中的第二个设备。

-init_hw_device vulkan:RADV
-初始化硬件设备 vulkan:RADV

Choose the first device with a name containing the string RADV.
选择第一个名称包含字符串 RADV 的设备。

-init_hw_device vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface

Choose the first device and enable the Wayland and XCB instance extensions.
选择第一个设备并启用 Wayland 和 XCB 实例扩展。

-init_hw_device type[=name]@source

Initialise a new hardware device of type type called name, deriving it from the existing device with the name source.
初始化一个名为 name 的新硬件设备,其类型为 type,继承自名为 source 的现有设备。

-init_hw_device list

List all hardware device types supported in this build of ffmpeg.
列出此版本 ffmpeg 支持的所有硬件设备类型。

-filter_hw_device name

Pass the hardware device called name to all filters in any filter graph. This can be used to set the device to upload to with the hwupload filter, or the device to map to with the hwmap filter. Other filters may also make use of this parameter when they require a hardware device. Note that this is typically only required when the input is not already in hardware frames - when it is, filters will derive the device they require from the context of the frames they receive as input.
将名为 name 的硬件设备传递给任何滤波器图中的所有滤波器。这可用于设置与 hwupload 滤波器一起上传的设备,或与 hwmap 滤波器一起映射的设备。当其他滤波器需要硬件设备时,也可能使用此参数。请注意,这通常仅在输入尚未处于硬件帧时才需要——如果是硬件帧,滤波器将根据它们接收到的输入帧的上下文推导出所需的设备。

This is a global setting, so all filters will receive the same device.
这是一个全局设置,因此所有过滤器将接收相同的设备。

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

Use hardware acceleration to decode the matching stream(s). The allowed values of hwaccel are:
使用硬件加速来解码匹配的流。hwaccel 允许的值包括:

none

Do not use any hardware acceleration (the default).
请勿使用任何硬件加速(默认设置)。

auto

Automatically select the hardware acceleration method.
自动选择硬件加速方法。

vdpau

Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
使用 VDPAU(面向 Unix 的视频解码与呈现 API)硬件加速。

dxva2

Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
使用 DXVA2(DirectX 视频加速)硬件加速。

d3d11va

Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
使用 D3D11VA(DirectX 视频加速)硬件加速。

vaapi

Use VAAPI (Video Acceleration API) hardware acceleration.
使用 VAAPI(视频加速 API)硬件加速。

qsv

Use the Intel QuickSync Video acceleration for video transcoding.
使用英特尔 QuickSync 视频加速技术进行视频转码。

Unlike most other values, this option does not enable accelerated decoding (that is used automatically whenever a qsv decoder is selected), but accelerated transcoding, without copying the frames into the system memory.
与大多数其他选项不同,此选项不启用加速解码(即在选择 qsv 解码器时自动使用的功能),而是实现加速转码,无需将帧复制到系统内存中。

For it to work, both the decoder and the encoder must support QSV acceleration and no filters must be used.
为了使其正常工作,解码器和编码器都必须支持 QSV 加速,并且不得使用任何滤镜。

This option has no effect if the selected hwaccel is not available or not supported by the chosen decoder.
如果所选的 hwaccel 不可用或不被选定的解码器支持,此选项将无效。

Note that most acceleration methods are intended for playback and will not be faster than software decoding on modern CPUs. Additionally, ffmpeg will usually need to copy the decoded frames from the GPU memory into the system memory, resulting in further performance loss. This option is thus mainly useful for testing.
请注意,大多数加速方法旨在用于播放,并且在现代 CPU 上不会比软件解码更快。此外, ffmpeg 通常需要将解码后的帧从 GPU 内存复制到系统内存,从而导致进一步的性能损失。因此,此选项主要适用于测试。

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

Select a device to use for hardware acceleration.
选择一个设备以用于硬件加速。

This option only makes sense when the -hwaccel option is also specified. It can either refer to an existing device created with -init_hw_device by name, or it can create a new device as if ‘-init_hw_devicetype:hwaccel_device were called immediately before.
仅当同时指定 -hwaccel 选项时,此选项才有意义。它既可以按名称引用通过 -init_hw_device 创建的现有设备,也可以在之前立即调用“ -init_hw_device ”类型:hwaccel_device 来创建一个新设备。

-hwaccels

List all hardware acceleration components enabled in this build of ffmpeg. Actual runtime availability depends on the hardware and its suitable driver being installed.
列出此版本 ffmpeg 中启用的所有硬件加速组件。实际运行时的可用性取决于硬件及其适配的驱动程序是否已安装。

-fix_sub_duration_heartbeat[:stream_specifier]

Set a specific output video stream as the heartbeat stream according to which to split and push through currently in-progress subtitle upon receipt of a random access packet.
根据接收到的随机访问数据包,将特定的输出视频流设置为心跳流,并据此分割和推送当前正在进行的字幕。

This lowers the latency of subtitles for which the end packet or the following subtitle has not yet been received. As a drawback, this will most likely lead to duplication of subtitle events in order to cover the full duration, so when dealing with use cases where latency of when the subtitle event is passed on to output is not relevant this option should not be utilized.
这降低了尚未收到末端数据包或后续字幕的延迟。然而,这一做法很可能导致字幕事件的重复,以覆盖完整时长。因此,在处理那些对字幕事件传递至输出的延迟不敏感的用例时,应避免使用此选项。

Requires -fix_sub_duration to be set for the relevant input subtitle stream for this to have any effect, as well as for the input subtitle stream having to be directly mapped to the same output in which the heartbeat stream resides.
需要为相关输入字幕流设置 -fix_sub_duration ,以使其产生任何效果,同时输入字幕流必须直接映射到心跳流所在的同一输出中。

5.7 Audio Options 5.7 音频选项

-aframes number (output)

Set the number of audio frames to output. This is an obsolete alias for -frames:a, which you should use instead.
设置要输出的音频帧数。这是已过时的别名,请改用 -frames:a

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

Set the audio sampling frequency. For output streams it is set by default to the frequency of the corresponding input stream. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.
设置音频采样频率。对于输出流,默认情况下会设置为相应输入流的频率。对于输入流,此选项仅对音频采集设备和原始解复用器有意义,并映射到相应的解复用器选项。

-aq q (output)

Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
设置音频质量(特定编码器,可变比特率)。这是 -q:a 的别名。

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

Set the number of audio channels. For output streams it is set by default to the number of input audio channels. For input streams this option only makes sense for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer options.
设置音频通道数量。对于输出流,默认设置为输入音频通道的数量。对于输入流,此选项仅对音频采集设备和原始解复用器有意义,并映射到相应的解复用器选项。

-an (input/output)

As an input option, blocks all audio streams of a file from being filtered or being automatically selected or mapped for any output. See -discard option to disable streams individually.
作为输入选项,阻止文件的所有音频流被过滤、自动选择或映射到任何输出。请参阅 -discard 选项以单独禁用流。

As an output option, disables audio recording i.e. automatic selection or mapping of any audio stream. For full manual control see the -map option.
作为输出选项,禁用音频录制,即自动选择或映射任何音频流。如需完全手动控制,请参阅 -map 选项。

-acodec codec (input/output)

Set the audio codec. This is an alias for -codec:a.
设置音频编解码器。这是对 -codec:a 的别名。

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

Set the audio sample format. Use -sample_fmts to get a list of supported sample formats.
设置音频采样格式。使用 -sample_fmts 获取支持的采样格式列表。

-af filtergraph (output)

Create the filtergraph specified by filtergraph and use it to filter the stream.
创建由 filtergraph 指定的过滤器图,并使用它来过滤流。

This is an alias for -filter:a, see the -filter option.
这是 -filter:a 的别名,请参见-filter 选项。

5.8 Advanced Audio options
5.8 高级音频选项

-atag fourcc/tag (output)

Force audio tag/fourcc. This is an alias for -tag:a.
强制音频标签/四 CC 码。这是 -tag:a 的别名。

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

Alias for -channel_layout.
-channel_layout 的别名。

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

Set the audio channel layout. For output streams it is set by default to the input channel layout. For input streams it overrides the channel layout of the input. Not all decoders respect the overridden channel layout. This option also sets the channel layout for audio grabbing devices and raw demuxers and is mapped to the corresponding demuxer option.
设置音频通道布局。对于输出流,默认情况下会设置为输入通道布局。对于输入流,它会覆盖输入的通道布局。并非所有解码器都遵循被覆盖的通道布局。此选项还为音频捕获设备和原始解复用器设置通道布局,并映射到相应的解复用器选项。

-guess_layout_max channels (input,per-stream)

If some input channel layout is not known, try to guess only if it corresponds to at most the specified number of channels. For example, 2 tells to ffmpeg to recognize 1 channel as mono and 2 channels as stereo but not 6 channels as 5.1. The default is to always try to guess. Use 0 to disable all guessing. Using the -channel_layout option to explicitly specify an input layout also disables guessing.
如果某些输入通道布局未知,仅在最多对应指定数量的通道时尝试猜测。例如,2 表示 ffmpeg 将 1 通道识别为单声道,2 通道识别为立体声,但不将 6 通道识别为 5.1 声道。默认情况下总是尝试猜测。使用 0 来禁用所有猜测。通过 -channel_layout 选项明确指定输入布局也会禁用猜测。

5.9 Subtitle options 5.9 字幕选项

-scodec codec (input/output)

Set the subtitle codec. This is an alias for -codec:s.
设置字幕编解码器。这是对 -codec:s 的别名。

-sn (input/output)

As an input option, blocks all subtitle streams of a file from being filtered or being automatically selected or mapped for any output. See -discard option to disable streams individually.
作为输入选项,阻止文件中的所有字幕流被过滤、自动选择或映射到任何输出。如需单独禁用流,请参阅 -discard 选项。

As an output option, disables subtitle recording i.e. automatic selection or mapping of any subtitle stream. For full manual control see the -map option.
作为输出选项,禁用字幕录制,即自动选择或映射任何字幕流。如需完全手动控制,请参阅 -map 选项。

5.10 Advanced Subtitle options
5.10 高级字幕选项

-fix_sub_duration

Fix subtitles durations. For each subtitle, wait for the next packet in the same stream and adjust the duration of the first to avoid overlap. This is necessary with some subtitles codecs, especially DVB subtitles, because the duration in the original packet is only a rough estimate and the end is actually marked by an empty subtitle frame. Failing to use this option when necessary can result in exaggerated durations or muxing failures due to non-monotonic timestamps.
修复字幕时长。对于每个字幕,等待同一流中的下一个数据包,并调整第一个字幕的时长以避免重叠。这在某些字幕编解码器中尤为必要,特别是 DVB 字幕,因为原始数据包中的时长仅为粗略估计,实际结束由一个空字幕帧标记。在必要时未使用此选项可能导致时长过度延长或因时间戳非单调而引发混流失败。

Note that this option will delay the output of all data until the next subtitle packet is decoded: it may increase memory consumption and latency a lot.
请注意,此选项将延迟所有数据的输出,直至下一个字幕包被解码:这可能会大幅增加内存消耗和延迟。

-canvas_size size

Set the size of the canvas used to render subtitles.
设置用于渲染字幕的画布大小。

5.11 Advanced options 5.11 高级选项

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

Create one or more streams in the output file. This option has two forms for specifying the data source(s): the first selects one or more streams from some input file (specified with -i), the second takes an output from some complex filtergraph (specified with -filter_complex).
在输出文件中创建一个或多个流。此选项有两种形式指定数据源:第一种是从某个输入文件(通过 -i 指定)选择一个或多个流;第二种是采用某个复杂滤镜图(通过 -filter_complex 指定)的输出。

In the first form, an output stream is created for every stream from the input file with the index input_file_id. If stream_specifier is given, only those streams that match the specifier are used (see the Stream specifiers section for the stream_specifier syntax).
在第一种形式中,为输入文件中每个带有索引 input_file_id 的流创建一个输出流。如果指定了 stream_specifier,则仅使用那些与指定符匹配的流(有关 stream_specifier 语法,请参阅“流指定符”部分)。

A - character before the stream identifier creates a "negative" mapping. It disables matching streams from already created mappings.
在流标识符前添加 - 字符会创建一个“负向”映射。它会禁用已创建映射中的匹配流。

A trailing ? after the stream index will allow the map to be optional: if the map matches no streams the map will be ignored instead of failing. Note the map will still fail if an invalid input file index is used; such as if the map refers to a non-existent input.
在流索引后添加 ? 将使映射可选:如果映射未匹配任何流,该映射将被忽略而非失败。请注意,若使用了无效的输入文件索引,映射仍会失败;例如,若映射指向一个不存在的输入文件。

An alternative [linklabel] form will map outputs from complex filter graphs (see the -filter_complex option) to the output file. linklabel must correspond to a defined output link label in the graph.
另一种[linklabel]形式将复杂过滤器图(参见 -filter_complex 选项)的输出映射到输出文件。linklabel 必须对应图中定义的输出链接标签。

This option may be specified multiple times, each adding more streams to the output file. Any given input stream may also be mapped any number of times as a source for different output streams, e.g. in order to use different encoding options and/or filters. The streams are created in the output in the same order in which the -map options are given on the commandline.
此选项可多次指定,每次都会向输出文件添加更多流。任何给定的输入流也可以多次映射为不同输出流的源,例如,以便使用不同的编码选项和/或滤镜。输出中的流按照命令行上 -map 选项的顺序创建。

Using this option disables the default mappings for this output file.
使用此选项将禁用此输出文件的默认映射。

Examples:  示例:

map everything 映射一切

To map ALL streams from the first input file to output
将第一个输入文件中的所有流映射到输出

ffmpeg -i INPUT -map 0 output
select specific stream 选择特定流

If you have two audio streams in the first input file, these streams are identified by 0:0 and 0:1. You can use -map to select which streams to place in an output file. For example:
如果第一个输入文件中包含两个音频流,这些流会分别被标识为 0:0 和 0:1。您可以使用 -map 来选择将哪些流放入输出文件中。例如:

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

will map the second input stream in INPUT to the (single) output stream in out.wav.
将第二个输入流在 INPUT 中映射到(单一)输出流在 out.wav 中。

create multiple streams 创建多条流

To select the stream with index 2 from input file a.mov (specified by the identifier 0:2), and stream with index 6 from input b.mov (specified by the identifier 1:6), and copy them to the output file out.mov:
从输入文件 a.mov (由标识符 0:2 指定)中选择索引为 2 的流,以及从输入 b.mov (由标识符 1:6 指定)中选择索引为 6 的流,并将它们复制到输出文件 out.mov 中:

ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
create multiple streams 2
创建多条流 2

To select all video and the third audio stream from an input file:
要从输入文件中选择所有视频和第三音频流:

ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
negative map 负面地图

To map all the streams except the second audio, use negative mappings
要映射除第二个音频外的所有流,请使用负映射

ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
optional map 可选地图

To map the video and audio streams from the first input, and using the trailing ?, ignore the audio mapping if no audio streams exist in the first input:
要映射第一个输入中的视频和音频流,并使用尾随的 ? ,如果第一个输入中不存在音频流,则忽略音频映射:

ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
map by language 按语言绘制的地图

To pick the English audio stream:
选择英语音频流:

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

Ignore input streams with unknown type instead of failing if copying such streams is attempted.
尝试复制未知类型的输入流时,忽略这些流而不是失败。

-copy_unknown

Allow input streams with unknown type to be copied instead of failing if copying such streams is attempted.
允许复制未知类型的输入流,而不是在尝试复制此类流时失败。

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

Set metadata information of the next output file from infile. Note that those are file indices (zero-based), not filenames. Optional metadata_spec_in/out parameters specify, which metadata to copy. A metadata specifier can have the following forms:
从输入文件中设置下一个输出文件的元数据信息。请注意,这些是文件索引(从零开始),而非文件名。可选的 metadata_spec_in/out 参数指定了要复制的元数据。元数据说明符可以采用以下形式:

g

global metadata, i.e. metadata that applies to the whole file
全局元数据,即适用于整个文件的元数据

s[:stream_spec]

per-stream metadata. stream_spec is a stream specifier as described in the Stream specifiers chapter. In an input metadata specifier, the first matching stream is copied from. In an output metadata specifier, all matching streams are copied to.
每流元数据。stream_spec 是一个流说明符,如“流说明符”章节所述。在输入元数据说明符中,第一个匹配的流会被复制。在输出元数据说明符中,所有匹配的流都会被复制到。

c:chapter_index

per-chapter metadata. chapter_index is the zero-based chapter index.
每章元数据。chapter_index 是基于零的章节索引。

p:program_index

per-program metadata. program_index is the zero-based program index.
每节目元数据。program_index 是从零开始的节目索引。

If metadata specifier is omitted, it defaults to global.
如果元数据说明符被省略,它默认是全局的。

By default, global metadata is copied from the first input file, per-stream and per-chapter metadata is copied along with streams/chapters. These default mappings are disabled by creating any mapping of the relevant type. A negative file index can be used to create a dummy mapping that just disables automatic copying.
默认情况下,全局元数据从第一个输入文件复制,每个流和每个章节的元数据随流/章节一同复制。这些默认映射在创建任何相关类型的映射时会被禁用。可以使用负文件索引来创建仅禁用自动复制的虚拟映射。

For example to copy metadata from the first stream of the input file to global metadata of the output file:
例如,将输入文件的第一个流的元数据复制到输出文件的全局元数据中:

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

To do the reverse, i.e. copy global metadata to all audio streams:
要执行相反操作,即将全局元数据复制到所有音频流:

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

Note that simple 0 would work as well in this example, since global metadata is assumed by default.
请注意,在这个例子中,简单的 0 同样适用,因为默认情况下假设了全局元数据。

-map_chapters input_file_index (output)

Copy chapters from input file with index input_file_index to the next output file. If no chapter mapping is specified, then chapters are copied from the first input file with at least one chapter. Use a negative file index to disable any chapter copying.
将索引为 input_file_index 的输入文件中的章节复制到下一个输出文件。如果没有指定章节映射,则从至少包含一个章节的第一个输入文件中复制章节。使用负文件索引可禁用任何章节复制。

-benchmark (global)

Show benchmarking information at the end of an encode. Shows real, system and user time used and maximum memory consumption. Maximum memory consumption is not supported on all systems, it will usually display as 0 if not supported.
在编码结束时显示基准测试信息。展示实际、系统和用户所用时间以及最大内存消耗。并非所有系统都支持最大内存消耗,如果不支持,通常会显示为 0。

-benchmark_all (global)

Show benchmarking information during the encode. Shows real, system and user time used in various steps (audio/video encode/decode).
在编码过程中显示基准测试信息。展示各个步骤(音频/视频编码/解码)所使用的实际、系统和用户时间。

-timelimit duration (global)

Exit after ffmpeg has been running for duration seconds in CPU user time.
在 ffmpeg 运行了指定秒数的 CPU 用户时间后退出。

-dump (global)

Dump each input packet to stderr.
将每个输入数据包转储到标准错误输出。

-hex (global)

When dumping packets, also dump the payload.
在丢弃数据包时,同时丢弃负载。

-readrate speed (input)

Limit input read speed.
限制输入读取速度。

Its value is a floating-point positive number which represents the maximum duration of media, in seconds, that should be ingested in one second of wallclock time. Default value is zero and represents no imposed limitation on speed of ingestion. Value 1 represents real-time speed and is equivalent to -re.
其值是一个浮点正数,表示在实际时间一秒内应摄取的媒体最大时长(以秒为单位)。默认值为零,表示不对摄取速度施加限制。值 1 代表实时速度,等同于 -re

Mainly used to simulate a capture device or live input stream (e.g. when reading from a file). Should not be used with a low value when input is an actual capture device or live stream as it may cause packet loss.
主要用于模拟捕获设备或实时输入流(例如从文件读取时)。当输入为实际捕获设备或实时流时,不应使用低值,以免造成数据包丢失。

It is useful for when flow speed of output packets is important, such as live streaming.
这对于输出数据包的流速至关重要的场景非常有用,例如直播流。

-re (input)

Read input at native frame rate. This is equivalent to setting -readrate 1.
以原生帧率读取输入。这等同于设置 -readrate 1

-readrate_initial_burst seconds

Set an initial read burst time, in seconds, after which -re/-readrate will be enforced.
设置初始读取突发时间,以秒为单位,在此时间后将执行 -re/-readrate

-vsync parameter (global)
-fps_mode[:stream_specifier] parameter (output,per-stream)

Set video sync method / framerate mode. vsync is applied to all output video streams but can be overridden for a stream by setting fps_mode. vsync is deprecated and will be removed in the future.
设置视频同步方法/帧率模式。vsync 应用于所有输出视频流,但可以通过设置 fps_mode 对单个流进行覆盖。vsync 已弃用,并将在未来移除。

For compatibility reasons some of the values for vsync can be specified as numbers (shown in parentheses in the following table).
出于兼容性考虑,某些 vsync 值可以指定为数字(如下表中的括号所示)。

passthrough (0)

Each frame is passed with its timestamp from the demuxer to the muxer.
每个帧都与其时间戳一起从解复用器传递到复用器。

cfr (1)

Frames will be duplicated and dropped to achieve exactly the requested constant frame rate.
帧将被复制和丢弃,以实现所请求的精确恒定帧率。

vfr (2)

Frames are passed through with their timestamp or dropped so as to prevent 2 frames from having the same timestamp.
帧会根据其时间戳传递或丢弃,以防止两帧具有相同的时间戳。

auto (-1)

Chooses between cfr and vfr depending on muxer capabilities. This is the default method.
根据多路复用器的能力,在 cfr 和 vfr 之间进行选择。这是默认方法。

Note that the timestamps may be further modified by the muxer, after this. For example, in the case that the format option avoid_negative_ts is enabled.
请注意,在此之后,时间戳可能会被混合器进一步修改。例如,在启用了格式选项 avoid_negative_ts 的情况下。

With -map you can select from which stream the timestamps should be taken. You can leave either video or audio unchanged and sync the remaining stream(s) to the unchanged one.
使用 -map 选项,您可以选择从哪个流提取时间戳。您可以保持视频或音频不变,并将剩余的流同步到未更改的流上。

-frame_drop_threshold parameter

Frame drop threshold, which specifies how much behind video frames can be before they are dropped. In frame rate units, so 1.0 is one frame. The default is -1.1. One possible usecase is to avoid framedrops in case of noisy timestamps or to increase frame drop precision in case of exact timestamps.
帧丢弃阈值,指定了视频帧落后多少时会被丢弃。以帧率单位表示,因此 1.0 代表一帧。默认值为-1.1。一种可能的应用场景是,在时间戳噪声较大的情况下避免帧丢弃,或在精确时间戳的情况下提高帧丢弃的精度。

-apad parameters (output,per-stream)

Pad the output audio stream(s). This is the same as applying -af apad. Argument is a string of filter parameters composed the same as with the apad filter. -shortest must be set for this output for the option to take effect.
对输出音频流进行填充。这与应用 -af apad 效果相同。参数是一个由过滤器参数组成的字符串,与 apad 过滤器中的参数组成方式相同。必须为该输出设置 -shortest ,以使该选项生效。

-copyts

Do not process input timestamps, but keep their values without trying to sanitize them. In particular, do not remove the initial start time offset value.
不要处理输入的时间戳,而是保持它们的值,不尝试进行净化。特别是,不要移除初始的开始时间偏移值。

Note that, depending on the vsync option or on specific muxer processing (e.g. in case the format option avoid_negative_ts is enabled) the output timestamps may mismatch with the input timestamps even when this option is selected.
请注意,根据 vsync 选项或特定多路复用器处理(例如,当启用格式选项 avoid_negative_ts 时),即使选择了此选项,输出时间戳也可能与输入时间戳不匹配。

-start_at_zero

When used with copyts, shift input timestamps so they start at zero.
copyts 一起使用时,调整输入时间戳使其从零开始。

This means that using e.g. -ss 50 will make output timestamps start at 50 seconds, regardless of what timestamp the input file started at.
这意味着,例如使用 -ss 50 将使输出时间戳从 50 秒开始,无论输入文件的起始时间戳是什么。

-copytb mode

Specify how to set the encoder timebase when stream copying. mode is an integer numeric value, and can assume one of the following values:
指定在流复制时如何设置编码器时间基。mode 是一个整数数值,可以取以下值之一:

1

Use the demuxer timebase.
使用解复用器的时间基准。

The time base is copied to the output encoder from the corresponding input demuxer. This is sometimes required to avoid non monotonically increasing timestamps when copying video streams with variable frame rate.
时间基准从相应的输入解复用器复制到输出编码器。这在复制可变帧率的视频流时有时是必需的,以避免时间戳非单调递增的问题。

0

Use the decoder timebase.
使用解码器时间基准。

The time base is copied to the output encoder from the corresponding input decoder.
时间基准从相应的输入解码器复制到输出编码器。

-1

Try to make the choice automatically, in order to generate a sane output.
尝试自动做出选择,以生成合理的输出。

Default value is -1.
默认值为 -1。

-enc_time_base[:stream_specifier] timebase (output,per-stream)

Set the encoder timebase. timebase can assume one of the following values:
设置编码器时基。时基可取以下值之一:

0

Assign a default value according to the media type.
根据媒体类型分配默认值。

For video - use 1/framerate, for audio - use 1/samplerate.
对于视频 - 使用 1/帧率,对于音频 - 使用 1/采样率。

demux

Use the timebase from the demuxer.
使用解复用器中的时基。

filter

Use the timebase from the filtergraph.
使用来自滤镜图的时间基准。

a positive number

Use the provided number as the timebase.
使用提供的数字作为时间基准。

This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000) or as a decimal number (e.g. 0.04166, 2.0833e-5)
此字段可以表示为两个整数的比率(例如 1:24,1:48000),或者表示为一个十进制数(例如 0.04166,2.0833e-5)

Default value is 0.
默认值为 0。

-bitexact (input/output)

Enable bitexact mode for (de)muxer and (de/en)coder
启用(解)复用器和(解/编)码器的 bitexact 模式

-shortest (output)

Finish encoding when the shortest output stream ends.
在最短输出流结束时完成编码。

Note that this option may require buffering frames, which introduces extra latency. The maximum amount of this latency may be controlled with the -shortest_buf_duration option.
请注意,此选项可能需要缓冲帧,从而引入额外的延迟。此延迟的最大值可通过 -shortest_buf_duration 选项进行控制。

-shortest_buf_duration duration (output)

The -shortest option may require buffering potentially large amounts of data when at least one of the streams is "sparse" (i.e. has large gaps between frames – this is typically the case for subtitles).
-shortest 选项在至少有一个流是“稀疏”的情况下(即帧间存在较大间隔,这种情况通常出现在字幕中),可能需要缓冲大量数据。

This option controls the maximum duration of buffered frames in seconds. Larger values may allow the -shortest option to produce more accurate results, but increase memory use and latency.
此选项控制缓冲帧的最大持续时间,单位为秒。较大的值可能使 -shortest 选项产生更准确的结果,但会增加内存使用和延迟。

The default value is 10 seconds.
默认值为 10 秒。

-dts_delta_threshold threshold

Timestamp discontinuity delta threshold, expressed as a decimal number of seconds.
时间戳不连续增量阈值,以秒的十进制数表示。

The timestamp discontinuity correction enabled by this option is only applied to input formats accepting timestamp discontinuity (for which the AVFMT_TS_DISCONT flag is enabled), e.g. MPEG-TS and HLS, and is automatically disabled when employing the -copyts option (unless wrapping is detected).
此选项启用的时戳不连续校正仅适用于接受时戳不连续的输入格式(即启用了 AVFMT_TS_DISCONT 标志的格式),例如 MPEG-TS 和 HLS,并且在使用 -copyts 选项时会自动禁用(除非检测到封装)。

If a timestamp discontinuity is detected whose absolute value is greater than threshold, ffmpeg will remove the discontinuity by decreasing/increasing the current DTS and PTS by the corresponding delta value.
如果检测到绝对值大于阈值的时间戳不连续,ffmpeg 将通过减少/增加当前 DTS 和 PTS 相应的增量值来消除该不连续。

The default value is 10.
默认值为 10。

-dts_error_threshold threshold

Timestamp error delta threshold, expressed as a decimal number of seconds.
时间戳误差增量阈值,以秒的十进制数表示。

The timestamp correction enabled by this option is only applied to input formats not accepting timestamp discontinuity (for which the AVFMT_TS_DISCONT flag is not enabled).
此选项启用的时戳校正仅适用于不接受时戳不连续的输入格式(即未启用 AVFMT_TS_DISCONT 标志的格式)。

If a timestamp discontinuity is detected whose absolute value is greater than threshold, ffmpeg will drop the PTS/DTS timestamp value.
如果检测到绝对值大于阈值的时间戳不连续,ffmpeg 将丢弃 PTS/DTS 时间戳值。

The default value is 3600*30 (30 hours), which is arbitrarily picked and quite conservative.
默认值为 3600*30 (30 小时),这是随意选择的,且相当保守。

-muxdelay seconds (output)

Set the maximum demux-decode delay.
设置最大解复用解码延迟。

-muxpreload seconds (output)

Set the initial demux-decode delay.
设置初始的解复用-解码延迟。

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

Assign a new stream-id value to an output stream. This option should be specified prior to the output filename to which it applies. For the situation where multiple output files exist, a streamid may be reassigned to a different value.
为输出流分配一个新的流 ID 值。此选项应在应用到的输出文件名之前指定。在存在多个输出文件的情况下,可以将流 ID 重新分配给不同的值。

For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for an output mpegts file:
例如,要将输出 mpegts 文件的流 0 PID 设置为 33,流 1 PID 设置为 36:

ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
-bsf[:stream_specifier] bitstream_filters (input/output,per-stream)

Apply bitstream filters to matching streams. The filters are applied to each packet as it is received from the demuxer (when used as an input option) or before it is sent to the muxer (when used as an output option).
将比特流过滤器应用于匹配的流。这些过滤器在从解复用器接收每个数据包时(作为输入选项使用时)或在其被发送到复用器之前(作为输出选项使用时)应用。

bitstream_filters is a comma-separated list of bitstream filter specifications, each of the form
bitstream_filters 是一个以逗号分隔的比特流过滤器规范列表,每个规范的形式如下

filter[=optname0=optval0:optname1=optval1:...]

Any of the ’,=:’ characters that are to be a part of an option value need to be escaped with a backslash.
任何作为选项值一部分的“,=:”字符都需要用反斜杠进行转义。

Use the -bsfs option to get the list of bitstream filters.
使用 -bsfs 选项获取比特流过滤器列表。

E.g.  例如:

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

applies the h264_mp4toannexb bitstream filter (which converts MP4-encapsulated H.264 stream to Annex B) to the input video stream.
h264_mp4toannexb 比特流过滤器(用于将 MP4 封装的 H.264 流转换为 Annex B 格式)应用于输入视频流。

On the other hand,
另一方面,

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

applies the mov2textsub bitstream filter (which extracts text from MOV subtitles) to the output subtitle stream. Note, however, that since both examples use -c copy, it matters little whether the filters are applied on input or output - that would change if transcoding was happening.
mov2textsub 位流过滤器(用于从 MOV 字幕中提取文本)应用于输出字幕流。但请注意,由于两个示例均使用 -c copy ,因此过滤器应用于输入还是输出影响不大——如果进行转码,情况则会改变。

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

Force a tag/fourcc for matching streams.
强制匹配流的标签/四 CC 码。

-timecode hh:mm:ssSEPff

Specify Timecode for writing. SEP is ’:’ for non drop timecode and ’;’ (or ’.’) for drop.
指定用于编写的时码。SEP 对于非掉帧时码为“:”,对于掉帧时码则为“;”(或“.”)。

ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
-filter_complex filtergraph (global)

Define a complex 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 – see the -filter options. filtergraph is a description of the filtergraph, as described in the “Filtergraph syntax” section of the ffmpeg-filters manual. This option may be specified multiple times - each use creates a new complex filtergraph.
定义一个复杂的过滤器图,即具有任意数量输入和/或输出的图。对于简单的图——那些具有一个输入和一个相同类型输出的图——请参阅 -filter 选项。filtergraph 是对过滤器图的描述,如 ffmpeg-filters 手册的“过滤器图语法”部分所述。此选项可以指定多次——每次使用都会创建一个新的复杂过滤器图。

Inputs to a complex filtergraph may come from different source types, distinguished by the format of the corresponding link label:
复杂滤镜图的输入可能来自不同类型的源,这些源通过相应链接标签的格式进行区分:

  • To connect an input stream, use [file_index:stream_specifier] (i.e. the same syntax as -map). If stream_specifier matches multiple streams, the first one will be used.
    要连接一个输入流,请使用 [file_index:stream_specifier] (即与 -map 相同的语法)。如果 stream_specifier 匹配多个流,将使用第一个匹配的流。
  • To connect a loopback decoder use [dec:dec_idx], where dec_idx is the index of the loopback decoder to be connected to given input.
    要连接一个环回解码器,请使用 [dec:dec_idx],其中 dec_idx 是要连接到指定输入的环回解码器的索引。
  • To connect an output from another complex filtergraph, use its link label. E.g the following example:
    要连接来自另一个复杂滤镜图的输出,请使用其链接标签。例如,以下示例:
    ffmpeg -i input.mkv \
      -filter_complex '[0:v]scale=size=hd1080,split=outputs=2[for_enc][orig_scaled]' \
      -c:v libx264 -map '[for_enc]' output.mkv \
      -dec 0:0 \
      -filter_complex '[dec:0][orig_scaled]hstack[stacked]' \
      -map '[stacked]' -c:v ffv1 comparison.mkv
    

    reads an input video and
    读取一个输入视频并

    • (line 2) uses a complex filtergraph with one input and two outputs to scale the video to 1920x1080 and duplicate the result to both outputs;
      (第 2 行)采用一个具有单输入和双输出的复杂过滤图,将视频缩放至 1920x1080,并将结果复制到两个输出端;
    • (line 3) encodes one scaled output with libx264 and writes the result to output.mkv;
      (第 3 行)将一个缩放后的输出编码为 libx264 ,并将结果写入 output.mkv
    • (line 4) decodes this encoded stream with a loopback decoder;
      (第 4 行)使用回环解码器解码此编码流;
    • (line 5) places the output of the loopback decoder (i.e. the libx264-encoded video) side by side with the scaled original input;
      (第 5 行)将回环解码器的输出(即 libx264 编码的视频)与缩放后的原始输入并排显示;
    • (line 6) combined video is then losslessly encoded and written into comparison.mkv.
      (第 6 行) 合并后的视频随后被无损编码并写入 comparison.mkv

    Note that the two filtergraphs cannot be combined into one, because then there would be a cycle in the transcoding pipeline (filtergraph output goes to encoding, from there to decoding, then back to the same graph), and such cycles are not allowed.
    请注意,这两个滤镜图无法合并为一个,因为这样会在转码流程中形成一个循环(滤镜图输出进入编码,随后解码,再返回到同一图),而此类循环是不被允许的。

An unlabeled input will be connected to the first unused input stream of the matching type.
未标记的输入将连接到匹配类型的第一个未使用的输入流。

Output link labels are referred to with -map. Unlabeled outputs are added to the first output file.
输出链接标签以 -map 表示。未标记的输出会添加到第一个输出文件中。

Note that with this option it is possible to use only lavfi sources without normal input files.
请注意,使用此选项可以仅使用 lavfi 源,而无需常规输入文件。

For example, 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 the first video stream in the second input is linked to the second (overlay) input of overlay.
这里 [0:v] 指的是第一个输入文件中的第一个视频流,它与覆盖滤镜的第一个(主)输入相连。同样,第二个输入文件中的第一个视频流则与覆盖滤镜的第二个(覆盖)输入相连。

Assuming there is only one video stream in each input file, we can omit input labels, so the above is equivalent to
假设每个输入文件中仅包含一个视频流,我们可以省略输入标签,因此上述内容等同于

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

Furthermore we can omit the output label and the single output from the filter graph will be added to the output file automatically, so we can simply write
此外,我们可以省略输出标签,过滤图中的单一输出将自动添加到输出文件中,因此我们可以直接写入

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

As a special exception, you can use a bitmap subtitle stream as input: it will be converted into a video with the same 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 removed once libavfilter has proper support for subtitles.
作为一种特殊例外,您可以使用位图字幕流作为输入:它将被转换为与文件中最大视频相同尺寸的视频,若无视频存在,则尺寸为 720x576。请注意,这是一个实验性的临时解决方案。一旦 libavfilter 对字幕提供适当支持,此功能将被移除。

For example, to hardcode subtitles on top of a DVB-T recording stored in MPEG-TS format, delaying the subtitles by 1 second:
例如,要在存储为 MPEG-TS 格式的 DVB-T 录制视频上硬编码字幕,并将字幕延迟 1 秒:

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 the MPEG-TS PIDs of respectively the video, audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
(0x2d0, 0x2dc 和 0x2ef 分别是视频、音频和字幕流的 MPEG-TS PID;0:0, 0:3 和 0:7 也可以达到同样效果)

To generate 5 seconds of pure red video using lavfi color source:
使用 lavfi color 源生成 5 秒纯红色视频:

ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
-filter_complex_threads nb_threads (global)

Defines how many threads are used to process a filter_complex graph. Similar to filter_threads but used for -filter_complex graphs only. The default is the number of available CPUs.
定义用于处理 filter_complex 图的线程数。类似于 filter_threads,但仅用于 -filter_complex 图。默认值为可用 CPU 的数量。

-lavfi filtergraph (global)

Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or outputs. Equivalent to -filter_complex.
定义一个复杂的过滤图,即具有任意数量输入和/或输出的过滤图。等同于 -filter_complex

-accurate_seek (input)

This option enables or disables accurate seeking in input files with the -ss option. It is enabled by default, so seeking is accurate when transcoding. Use -noaccurate_seek to disable it, which may be useful e.g. when copying some streams and transcoding the others.
此选项启用或禁用在带有 -ss 选项的输入文件中进行精确查找。默认情况下它是启用的,因此在转码时查找是准确的。使用 -noaccurate_seek 来禁用它,这在例如复制某些流并转码其他流时可能有用。

-seek_timestamp (input)

This option enables or disables seeking by timestamp in input files with the -ss option. It is disabled by default. If enabled, the argument to the -ss option is considered an actual timestamp, and is not offset by the start time of the file. This matters only for files which do not start from timestamp 0, such as transport streams.
此选项启用或禁用在带有 -ss 选项的输入文件中按时间戳进行查找。默认情况下是禁用的。如果启用, -ss 选项的参数将被视为实际时间戳,并且不会因文件的开始时间而偏移。这只对那些不从时间戳 0 开始的文件(如传输流)有影响。

-thread_queue_size size (input/output)

For input, this option sets the maximum number of queued packets when reading from the file or device. With low latency / high rate live streams, packets may be discarded if they are not read in a timely manner; setting this value can force ffmpeg to use a separate input thread and read packets as soon as they arrive. By default ffmpeg only does this if multiple inputs are specified.
对于输入,此选项设置从文件或设备读取时队列中的最大数据包数。在低延迟/高频率的实时流中,如果数据包未及时读取,可能会被丢弃;设置此值可强制 ffmpeg 使用单独的输入线程,并在数据包到达时立即读取。默认情况下,ffmpeg 仅在指定多个输入时才会这样做。

For output, this option specified the maximum number of packets that may be queued to each muxing thread.
对于输出,此选项指定了可以为每个多路复用线程排队的最大数据包数量。

-sdp_file file (global)

Print sdp information for an output stream to file. This allows dumping sdp information when at least one output isn’t an rtp stream. (Requires at least one of the output formats to be rtp).
将输出流的 SDP 信息打印到文件中。这允许在至少一个输出不是 RTP 流时转储 SDP 信息。(需要至少一个输出格式为 RTP)。

-discard (input)

Allows discarding specific streams or frames from streams. Any input stream can be fully discarded, using value all whereas selective discarding of frames from a stream occurs at the demuxer and is not supported by all demuxers.
允许从流中丢弃特定流或帧。任何输入流都可以通过使用值 all 完全丢弃,而从流中有选择地丢弃帧则发生在解复用器阶段,并非所有解复用器都支持此功能。

none

Discard no frame.  不要丢弃任何一帧。

default

Default, which discards no frames.
默认设置,不丢弃任何帧。

noref

Discard all non-reference frames.
丢弃所有非参考帧。

bidir

Discard all bidirectional frames.
丢弃所有双向帧。

nokey

Discard all frames excepts keyframes.
丢弃所有非关键帧,仅保留关键帧。

all

Discard all frames.  丢弃所有帧。

-abort_on flags (global)

Stop and abort on various conditions. The following flags are available:
在各种条件下停止和终止。以下标志可供使用:

empty_output

No packets were passed to the muxer, the output is empty.
没有数据包传递给混合器,输出为空。

empty_output_stream

No packets were passed to the muxer in some of the output streams.
某些输出流中没有数据包传递给混合器。

-max_error_rate (global)

Set fraction of decoding frame failures across all inputs which when crossed ffmpeg will return exit code 69. Crossing this threshold does not terminate processing. Range is a floating-point number between 0 to 1. Default is 2/3.
设置所有输入中解码帧失败的比例,一旦超过该阈值,ffmpeg 将返回退出码 69。超过此阈值不会终止处理。范围是 0 到 1 之间的浮点数。默认值为 2/3。

-xerror (global)

Stop and exit on error
遇到错误时停止并退出

-max_muxing_queue_size packets (output,per-stream)

When transcoding audio and/or video streams, ffmpeg will not begin writing into the output until it has one packet for each such stream. While waiting for that to happen, packets for other streams are buffered. This option sets the size of this buffer, in packets, for the matching output stream.
在转码音频和/或视频流时,ffmpeg 直到每个此类流都收到一个数据包后才会开始写入输出。在此等待期间,其他流的数据包会被缓存。此选项为匹配的输出流设置该缓存的大小,以数据包数量为单位。

The default value of this option should be high enough for most uses, so only touch this option if you are sure that you need it.
此选项的默认值应足以满足大多数用途,因此仅在确定需要时才调整此选项。

-muxing_queue_data_threshold bytes (output,per-stream)

This is a minimum threshold until which the muxing queue size is not taken into account. Defaults to 50 megabytes per stream, and is based on the overall size of packets passed to the muxer.
这是一个最低阈值,在此之前,多路复用队列的大小不予考虑。默认每个流为 50 兆字节,并基于传递给多路复用器的包的总大小而定。

-auto_conversion_filters (global)

Enable automatically inserting format conversion filters in all filter graphs, including those defined by -vf, -af, -filter_complex and -lavfi. If filter format negotiation requires a conversion, the initialization of the filters will fail. Conversions can still be performed by inserting the relevant conversion filter (scale, aresample) in the graph. On by default, to explicitly disable it you need to specify -noauto_conversion_filters.
在所有过滤器图中自动插入格式转换过滤器,包括由 -vf-af-filter_complex-lavfi 定义的那些。如果过滤器格式协商需要转换,过滤器的初始化将失败。转换仍可通过在图中插入相关转换过滤器(scale、aresample)来执行。默认开启,若要显式禁用,需指定 -noauto_conversion_filters

-bits_per_raw_sample[:stream_specifier] value (output,per-stream)

Declare the number of bits per raw sample in the given output stream to be value. Note that this option sets the information provided to the encoder/muxer, it does not change the stream to conform to this value. Setting values that do not match the stream properties may result in encoding failures or invalid output files.
声明给定输出流中每个原始样本的位数为指定值。请注意,此选项仅设置提供给编码器/复用器的信息,并不改变流以符合此值。设置与流属性不匹配的值可能导致编码失败或无效的输出文件。

-stats_enc_pre[:stream_specifier] path (output,per-stream)
-stats_enc_post[:stream_specifier] path (output,per-stream)
-stats_mux_pre[:stream_specifier] path (output,per-stream)

Write per-frame encoding information about the matching streams into the file given by path.
将匹配流的逐帧编码信息写入由路径指定的文件中。

-stats_enc_pre writes information about raw video or audio frames right before they are sent for encoding, while -stats_enc_post writes information about encoded packets as they are received from the encoder. -stats_mux_pre writes information about packets just as they are about to be sent to the muxer. Every frame or packet produces one line in the specified file. The format of this line is controlled by -stats_enc_pre_fmt / -stats_enc_post_fmt / -stats_mux_pre_fmt.
-stats_enc_pre 在原始视频或音频帧即将被发送去编码之前记录相关信息,而 -stats_enc_post 则在从编码器接收到编码包时记录信息。 -stats_mux_pre 在数据包即将被发送至混合器时记录相关信息。每一帧或每一个数据包都会在指定文件中生成一行记录。这一行的格式由 -stats_enc_pre_fmt / -stats_enc_post_fmt / -stats_mux_pre_fmt 控制。

When stats for multiple streams are written into a single file, the lines corresponding to different streams will be interleaved. The precise order of this interleaving is not specified and not guaranteed to remain stable between different invocations of the program, even with the same options.
当多个流的统计信息被写入单个文件时,不同流的对应行将会交错排列。这种交错的确切顺序未被规定,并且在程序的不同调用之间,即使使用相同选项,也无法保证其稳定性。

-stats_enc_pre_fmt[:stream_specifier] format_spec (output,per-stream)
-stats_enc_post_fmt[:stream_specifier] format_spec (output,per-stream)
-stats_mux_pre_fmt[:stream_specifier] format_spec (output,per-stream)

Specify the format for the lines written with -stats_enc_pre / -stats_enc_post / -stats_mux_pre.
指定使用 -stats_enc_pre / -stats_enc_post / -stats_mux_pre 编写的行的格式。

format_spec is a string that may contain directives of the form {fmt}. format_spec is backslash-escaped — use \{, \}, and \\ to write a literal {, }, or \, respectively, into the output.
format_spec 是一个字符串,可能包含形如 {fmt} 的指令。format_spec 通过反斜杠进行转义——使用 \{、\} 和 \\ 分别在输出中写入字面量 {、} 或 \。

The directives given with fmt may be one of the following:
使用 fmt 给出的指令可能是以下之一:

fidx

Index of the output file.
输出文件索引。

sidx

Index of the output stream in the file.
文件中输出流的索引。

n

Frame number. Pre-encoding: number of frames sent to the encoder so far. Post-encoding: number of packets received from the encoder so far. Muxing: number of packets submitted to the muxer for this stream so far.
帧编号。编码前:发送到编码器的帧数累计。编码后:从编码器接收到的数据包数累计。复用:为此流提交给复用器的数据包数累计。

ni

Input frame number. Index of the input frame (i.e. output by a decoder) that corresponds to this output frame or packet. -1 if unavailable.
输入帧编号。与该输出帧或数据包对应的输入帧(即解码器输出的)索引。如果不可用,则为-1。

tb

Timebase in which this frame/packet’s timestamps are expressed, as a rational number num/den. Note that encoder and muxer may use different timebases.
此帧/数据包的时间戳所采用的时间基准,以有理数 num/den 表示。请注意,编码器和复用器可能使用不同的时间基准。

tbi

Timebase for ptsi, as a rational number num/den. Available when ptsi is available, 0/1 otherwise.
ptsi 的时间基准,以有理数 num/den 表示。当 ptsi 可用时提供,否则为 0/1。

pts

Presentation timestamp of the frame or packet, as an integer. Should be multiplied by the timebase to compute presentation time.
帧或数据包的呈现时间戳,以整数表示。应乘以时间基准以计算呈现时间。

ptsi

Presentation timestamp of the input frame (see ni), as an integer. Should be multiplied by tbi to compute presentation time. Printed as (2^63 - 1 = 9223372036854775807) when not available.
输入帧的显示时间戳(参见 ni),以整数表示。应乘以 tbi 以计算显示时间。当不可用时,显示为(2^63 - 1 = 9223372036854775807)。

t

Presentation time of the frame or packet, as a decimal number. Equal to pts multiplied by tb.
帧或数据包的呈现时间,以小数形式表示。等于 pts 乘以 tb。

ti

Presentation time of the input frame (see ni), as a decimal number. Equal to ptsi multiplied by tbi. Printed as inf when not available.
输入帧的呈现时间(参见 ni),以小数形式表示。等于 ptsi 乘以 tbi。当不可用时,显示为 inf。

dts (packet)

Decoding timestamp of the packet, as an integer. Should be multiplied by the timebase to compute presentation time.
解码数据包的时间戳,以整数形式表示。应乘以时间基准以计算呈现时间。

dt (packet)

Decoding time of the frame or packet, as a decimal number. Equal to dts multiplied by tb.
帧或数据包的解码时间,以小数形式表示。等于解码时间戳(dts)乘以时间基准(tb)。

sn (frame,audio)

Number of audio samples sent to the encoder so far.
到目前为止发送到编码器的音频样本数量。

samp (frame,audio)

Number of audio samples in the frame.
帧中的音频样本数量。

size (packet)

Size of the encoded packet in bytes.
编码数据包的字节大小。

br (packet)

Current bitrate in bits per second.
当前比特率,以每秒比特数表示。

abr (packet)

Average bitrate for the whole stream so far, in bits per second, -1 if it cannot be determined at this point.
到目前为止整个流的平均比特率,以比特每秒为单位,如果此时无法确定则为-1。

key (packet)

Character ’K’ if the packet contains a keyframe, character ’N’ otherwise.
包中包含关键帧时为字符“K”,否则为字符“N”。

Directives tagged with packet may only be used with -stats_enc_post_fmt and -stats_mux_pre_fmt.
带有 packet 标签的指令只能与 -stats_enc_post_fmt-stats_mux_pre_fmt 一起使用。

Directives tagged with frame may only be used with -stats_enc_pre_fmt.
带有 frame 标签的指令只能与 -stats_enc_pre_fmt 一起使用。

Directives tagged with audio may only be used with audio streams.
带有音频标签的指令仅可用于音频流。

The default format strings are:
默认格式字符串为:

pre-encoding

{fidx} {sidx} {n} {t}

post-encoding

{fidx} {sidx} {n} {t}

In the future, new items may be added to the end of the default formatting strings. Users who depend on the format staying exactly the same, should prescribe it manually.
未来,可能会在默认格式字符串的末尾添加新项目。依赖格式保持完全不变的用户,应手动指定格式。

Note that stats for different streams written into the same file may have different formats.
请注意,写入同一文件的不同流的数据统计可能具有不同的格式。

5.12 Preset files 5.12 预设文件

A preset file contains a sequence of option=value pairs, one for each line, specifying a sequence of options which would be awkward to specify on the command line. Lines starting with the hash (’#’) character are ignored and are used to provide comments. Check the presets directory in the FFmpeg source tree for examples.
预设文件包含一系列 option=value 对,每行一个,用于指定一系列在命令行中指定起来较为繁琐的选项。以井号('#')字符开头的行将被忽略,并用于提供注释。请在 FFmpeg 源码树中的 presets 目录下查看示例。

There are two types of preset files: ffpreset and avpreset files.
预设文件分为两种类型:ffpreset 和 avpreset 文件。

5.12.1 ffpreset files 5.12.1 ffpreset 文件

ffpreset files are specified with the vpre, apre, spre, and fpre options. The fpre option takes the filename of the preset instead of a preset name as input and can be used for any kind of codec. For the vpre, apre, and spre options, the options specified in a preset file are applied to the currently selected codec of the same type as the preset option.
ffpreset 文件通过 vpreapresprefpre 选项指定。 fpre 选项接受预设文件名而非预设名称作为输入,并可用于任何类型的编解码器。对于 vpreaprespre 选项,预设文件中指定的选项会应用于当前选定的与预设选项同类型的编解码器。

The argument passed to the vpre, apre, and spre preset options identifies the preset file to use according to the following rules:
传递给 vpreaprespre 预设选项的参数根据以下规则标识要使用的预设文件:

First ffmpeg searches for a file named arg.ffpreset in the directories $FFMPEG_DATADIR (if set), and $HOME/.ffmpeg, and in the datadir defined at configuration time (usually PREFIX/share/ffmpeg) or in a ffpresets folder along the executable on win32, in that order. For example, if the argument is libvpx-1080p, it will search for the file libvpx-1080p.ffpreset.
首先,ffmpeg 会在以下目录中按顺序查找名为 arg.ffpreset 的文件: $FFMPEG_DATADIR (如果已设置)、 $HOME/.ffmpeg ,以及在配置时定义的 datadir(通常是 PREFIX/share/ffmpeg ),或者在 win32 系统上与可执行文件同路径的 ffpresets 文件夹中。例如,如果参数是 libvpx-1080p ,它将搜索文件 libvpx-1080p.ffpreset

If no such file is found, then ffmpeg will search for a file named codec_name-arg.ffpreset in the above-mentioned directories, where codec_name is the name of the codec to which the preset file options will be applied. For example, if you select the video codec with -vcodec libvpx and use -vpre 1080p, then it will search for the file libvpx-1080p.ffpreset.
如果在上述目录中未找到此类文件,那么 ffmpeg 将搜索名为 codec_name-arg.ffpreset 的文件,其中 codec_name 是预设文件选项将要应用的编解码器名称。例如,如果您选择了视频编解码器 -vcodec libvpx 并使用 -vpre 1080p ,那么它将搜索文件 libvpx-1080p.ffpreset

5.12.2 avpreset files 5.12.2 avpreset 文件

avpreset files are specified with the pre option. They work similar to ffpreset files, but they only allow encoder- specific options. Therefore, an option=value pair specifying an encoder cannot be used.
avpreset 文件通过 pre 选项指定。它们与 ffpreset 文件类似,但仅允许编码器特定的选项。因此,不能使用指定编码器的 option=value 对。

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 at configuration time (usually PREFIX/share/ffmpeg), in that order.
当指定 pre 选项时,ffmpeg 将按顺序查找具有.avpreset 后缀的文件,首先在 $AVCONV_DATADIR 目录(如果已设置)中查找,然后在 $HOME/.avconv 目录中查找,最后在配置时定义的 datadir 目录中查找(通常为 PREFIX/share/ffmpeg )。

First ffmpeg searches for a file named codec_name-arg.avpreset in the above-mentioned directories, where codec_name is the name of the codec to which the preset file options will be applied. For example, if you select the video codec with -vcodec libvpx and use -pre 1080p, then it will search for the file libvpx-1080p.avpreset.
首先,ffmpeg 会在上述目录中查找名为 codec_name-arg.avpreset 的文件,其中 codec_name 是预设文件选项将要应用的编解码器名称。例如,如果您选择视频编解码器为 -vcodec libvpx 并使用 -pre 1080p ,那么它将搜索文件 libvpx-1080p.avpreset

If no such file is found, then ffmpeg will search for a file named arg.avpreset in the same directories.
如果没有找到此类文件,则 ffmpeg 将在相同目录中搜索名为 arg.avpreset 的文件。

5.13 vstats file format
5.13 vstats 文件格式

The -vstats and -vstats_file options enable generation of a file containing statistics about the generated video outputs.
-vstats-vstats_file 选项可生成一个包含所生成视频输出统计信息的文件。

The -vstats_version option controls the format version of the generated file.
-vstats_version 选项控制生成的文件的格式版本。

With version 1 the format is:
在版本 1 中,格式为:

frame= FRAME q= FRAME_QUALITY PSNR= PSNR f_size= FRAME_SIZE s_size= STREAM_SIZEkB time= TIMESTAMP br= BITRATEkbits/s avg_br= AVERAGE_BITRATEkbits/s

With version 2 the format is:
在版本 2 中,格式为:

out= OUT_FILE_INDEX st= OUT_FILE_STREAM_INDEX frame= FRAME_NUMBER q= FRAME_QUALITYf PSNR= PSNR f_size= FRAME_SIZE s_size= STREAM_SIZEkB time= TIMESTAMP br= BITRATEkbits/s avg_br= AVERAGE_BITRATEkbits/s

The value corresponding to each key is described below:
每个键对应的值描述如下:

avg_br

average bitrate expressed in Kbits/s
平均比特率,单位为千比特每秒

br

bitrate expressed in Kbits/s
以 Kbits/s 表示的比特率

frame

number of encoded frame
编码帧数量

out

out file index  输出文件索引

PSNR

Peak Signal to Noise Ratio
峰值信噪比

q

quality of the frame
框架质量

f_size

encoded packet size expressed as number of bytes
编码数据包大小,以字节数表示

s_size

stream size expressed in KiB
流大小以 KiB 表示

st

out file stream index
输出文件流索引

time

time of the packet
数据包的时间

type

picture type  图片类型

See also the -stats_enc options for an alternative way to show encoding statistics.
另请参阅 -stats_enc 选项,以另一种方式显示编码统计信息。

6 Examples 6 个示例

6.1 Video and Audio grabbing
6.1 视频与音频抓取

If you specify the input format and device then ffmpeg can grab video and audio directly.
如果您指定了输入格式和设备,那么 ffmpeg 可以直接抓取视频和音频。

ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg

Or with an ALSA audio source (mono input, card id 1) instead of OSS:
或者使用 ALSA 音频源(单声道输入,声卡 ID 为 1)替代 OSS:

ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg

Note that you must activate the right video source and channel before launching ffmpeg with any TV viewer such as xawtv by Gerd Knorr. You also have to set the audio recording levels correctly with a standard mixer.
请注意,在使用 Gerd Knorr 开发的 xawtv 等电视查看器启动 ffmpeg 之前,您必须激活正确的视频源和频道。同时,您还需要通过标准混音器正确设置音频录制电平。

6.2 X11 grabbing 6.2 X11 抓取

Grab the X11 display with ffmpeg via
通过 ffmpeg 抓取 X11 显示

ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg

0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable.
0.0 是您的 X11 服务器的显示屏幕编号,与 DISPLAY 环境变量相同。

ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg

0.0 is display.screen number of your X11 server, same as the DISPLAY environment variable. 10 is the x-offset and 20 the y-offset for the grabbing.
0.0 表示您的 X11 服务器的屏幕编号,与 DISPLAY 环境变量相同。10 是抓取的 x 偏移量,20 是 y 偏移量。

6.3 Video and Audio file format conversion
6.3 视频与音频文件格式转换

Any supported file format and protocol can serve as input to ffmpeg:
任何受支持的文件格式和协议均可作为 ffmpeg 的输入:

Examples:  示例:

  • You can use YUV files as input:
    您可以使用 YUV 文件作为输入:
    ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
    

    It will use the files:
    它将使用以下文件:

    /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
    /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
    

    The Y files use twice the resolution of the U and V files. They are raw files, without header. They can be generated by all decent video decoders. You must specify the size of the image with the -s option if ffmpeg cannot guess it.
    Y 文件的分辨率是 U 和 V 文件的两倍。它们是未经处理的原始文件,不含头部信息。所有像样的视频解码器都能生成这些文件。如果 ffmpeg 无法自动识别图像尺寸,您必须通过 -s 选项指定图像大小。

  • You can input from a raw YUV420P file:
    您可以从原始的 YUV420P 文件输入:
    ffmpeg -i /tmp/test.yuv /tmp/out.avi
    

    test.yuv is a file containing raw YUV planar data. Each frame is composed of the Y plane followed by the U and V planes at half vertical and horizontal resolution.
    test.yuv 是一个包含原始 YUV 平面数据的文件。每一帧由 Y 平面组成,随后是垂直和水平分辨率减半的 U 和 V 平面。

  • You can output to a raw YUV420P file:
    您可以将输出保存为原始的 YUV420P 文件:
    ffmpeg -i mydivx.avi hugefile.yuv
    
  • You can set several input files and output files:
    您可以设置多个输入文件和输出文件:
    ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
    

    Converts the audio file a.wav and the raw YUV video file a.yuv to MPEG file a.mpg.
    将音频文件 a.wav 和原始 YUV 视频文件 a.yuv 转换为 MPEG 文件 a.mpg。

  • You can also do audio and video conversions at the same time:
    您还可以同时进行音频和视频转换:
    ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
    

    Converts a.wav to MPEG audio at 22050 Hz sample rate.
    将.wav 文件转换为 22050 赫兹采样率的 MPEG 音频格式。

  • You can encode to several formats at the same time and define a mapping from input stream to output streams:
    您可以同时编码为多种格式,并定义从输入流到输出流的映射:
    ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
    

    Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. ’-map file:index’ specifies which input stream is used for each output stream, in the order of the definition of output streams.
    将 a.wav 转换为 64 kbits 的 a.mp2 和 128 kbits 的 b.mp2。'-map file:index'指定按输出流定义顺序,每个输出流使用哪个输入流。

  • You can transcode decrypted VOBs:
    您可以对已解密的 VOB 文件进行转码:
    ffmpeg -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi
    

    This is a typical DVD ripping example; the input is a VOB file, the output an AVI file with MPEG-4 video and MP3 audio. Note that in this command we use B-frames so the MPEG-4 stream is DivX5 compatible, and GOP size is 300 which means one intra frame every 10 seconds for 29.97fps input video. Furthermore, the audio stream is MP3-encoded so you need to enable LAME support by passing --enable-libmp3lame to configure. The mapping is particularly useful for DVD transcoding to get the desired audio language.
    这是一个典型的 DVD 抓取示例;输入为 VOB 文件,输出为包含 MPEG-4 视频和 MP3 音频的 AVI 文件。请注意,在此命令中我们使用了 B 帧,因此 MPEG-4 流与 DivX5 兼容,GOP 大小为 300,意味着对于 29.97fps 的输入视频,每 10 秒有一个内部帧。此外,音频流采用 MP3 编码,因此您需要通过传递 --enable-libmp3lame 给配置来启用 LAME 支持。映射对于获取所需音频语言的 DVD 转码特别有用。

    NOTE: To see the supported input formats, use ffmpeg -demuxers.
    注意:要查看支持的输入格式,请使用 ffmpeg -demuxers

  • You can extract images from a video, or create a video from many images:
    您可以从视频中提取图像,或者用多张图像制作视频:

    For extracting images from a video:
    从视频中提取图像:

    ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
    

    This will extract one video frame per second from the video and will output them in files named foo-001.jpeg, foo-002.jpeg, etc. Images will be rescaled to fit the new WxH values.
    这将每秒从视频中提取一帧,并以 foo-001.jpegfoo-002.jpeg 等文件名输出。图像将重新缩放以适应新的 WxH 尺寸。

    If you want to extract just a limited number of frames, you can use the above command in combination with the -frames:v or -t option, or in combination with -ss to start extracting from a certain point in time.
    如果你想只提取有限数量的帧,可以将上述命令与 -frames:v-t 选项结合使用,或者与-ss 选项结合,从特定时间点开始提取。

    For creating a video from many images:
    从多张图片创建视频:

    ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
    

    The syntax foo-%03d.jpeg specifies to use a decimal number composed of three digits padded with zeroes to express the sequence number. It is the same syntax supported by the C printf function, but only formats accepting a normal integer are suitable.
    语法 foo-%03d.jpeg 指定使用由三位数字组成并以零填充的十进制数来表示序列号。这与 C 语言的 printf 函数所支持的语法相同,但仅适用于接受常规整数的格式。

    When importing an image sequence, -i also supports expanding shell-like wildcard patterns (globbing) internally, by selecting the image2-specific -pattern_type glob option.
    在导入图像序列时,-i 还支持通过选择 image2 特定的 -pattern_type glob 选项,在内部扩展类似 shell 的通配符模式(全局匹配)。

    For example, for creating a video from filenames matching the glob pattern foo-*.jpeg:
    例如,从匹配全局模式 foo-*.jpeg 的文件名创建视频:

    ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
    
  • You can put many streams of the same type in the output:
    您可以在输出中放置多个相同类型的流:
    ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
    

    The resulting output file test12.nut will contain the first four streams from the input files in reverse order.
    生成的输出文件 test12.nut 将包含输入文件中前四个流以相反顺序排列的内容。

  • To force CBR video output:
    强制 CBR 视频输出:
    ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
    
  • The four options lmin, lmax, mblmin and mblmax use ’lambda’ units, but you may use the QP2LAMBDA constant to easily convert from ’q’ units:
    四个选项 lmin、lmax、mblmin 和 mblmax 使用“lambda”单位,但您可以利用 QP2LAMBDA 常数轻松从“q”单位进行转换:
    ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
    

7 See Also 7 参见

ffmpeg-all, ffplay, ffprobe, ffmpeg-utils, ffmpeg-scaler, ffmpeg-resampler, ffmpeg-codecs, ffmpeg-bitstream-filters, ffmpeg-formats, ffmpeg-devices, ffmpeg-protocols, ffmpeg-filters

8 Authors 8 位作者

The FFmpeg developers.  FFmpeg 开发团队。

For details about the authorship, see the Git history of the project (https://git.ffmpeg.org/ffmpeg), e.g. by typing the command git log in the FFmpeg source directory, or browsing the online repository at https://git.ffmpeg.org/ffmpeg.
有关作者身份的详细信息,请参阅项目的 Git 历史记录(https://git.ffmpeg.org/ffmpeg),例如在 FFmpeg 源代码目录中输入命令 git log ,或浏览在线仓库 https://git.ffmpeg.org/ffmpeg。

Maintainers for the specific components are listed in the file MAINTAINERS in the source code tree.
特定组件的维护者在源代码树的 MAINTAINERS 文件中列出。

This document was generated on August 26, 2024 using makeinfo.
本文件生成于 2024 年 8 月 26 日,使用 makeinfo 工具。

Hosting provided by telepoint.bg
由 telepoint.bg 提供的主机服务