]> git.sesse.net Git - casparcg/blob - dependencies64/ffmpeg/doc/ffmpeg.html
Fixed bug in server shut down.
[casparcg] / dependencies64 / ffmpeg / doc / ffmpeg.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
4   <head>
5     <meta charset="utf-8">
6     <title>
7       ffmpeg Documentation
8     </title>
9     <meta name="viewport" content="width=device-width,initial-scale=1.0">
10     <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
11     <link rel="stylesheet" type="text/css" href="style.min.css">
12   </head>
13   <body>
14     <div style="width: 95%; margin: auto">
15       <h1>
16       ffmpeg Documentation
17       </h1>
18 <div align="center">
19 </div>
20
21
22 <a name="SEC_Top"></a>
23
24 <a name="SEC_Contents"></a>
25 <h2 class="contents-heading">Table of Contents</h2>
26
27 <div class="contents">
28
29 <ul class="no-bullet">
30   <li><a name="toc-Synopsis" href="#Synopsis">1 Synopsis</a></li>
31   <li><a name="toc-Description" href="#Description">2 Description</a></li>
32   <li><a name="toc-Detailed-description" href="#Detailed-description">3 Detailed description</a>
33   <ul class="no-bullet">
34     <li><a name="toc-Filtering" href="#Filtering">3.1 Filtering</a>
35     <ul class="no-bullet">
36       <li><a name="toc-Simple-filtergraphs" href="#Simple-filtergraphs">3.1.1 Simple filtergraphs</a></li>
37       <li><a name="toc-Complex-filtergraphs" href="#Complex-filtergraphs">3.1.2 Complex filtergraphs</a></li>
38     </ul></li>
39     <li><a name="toc-Stream-copy" href="#Stream-copy">3.2 Stream copy</a></li>
40   </ul></li>
41   <li><a name="toc-Stream-selection" href="#Stream-selection">4 Stream selection</a></li>
42   <li><a name="toc-Options" href="#Options">5 Options</a>
43   <ul class="no-bullet">
44     <li><a name="toc-Stream-specifiers-1" href="#Stream-specifiers-1">5.1 Stream specifiers</a></li>
45     <li><a name="toc-Generic-options" href="#Generic-options">5.2 Generic options</a></li>
46     <li><a name="toc-AVOptions" href="#AVOptions">5.3 AVOptions</a></li>
47     <li><a name="toc-Main-options" href="#Main-options">5.4 Main options</a></li>
48     <li><a name="toc-Video-Options" href="#Video-Options">5.5 Video Options</a></li>
49     <li><a name="toc-Advanced-Video-options" href="#Advanced-Video-options">5.6 Advanced Video options</a></li>
50     <li><a name="toc-Audio-Options" href="#Audio-Options">5.7 Audio Options</a></li>
51     <li><a name="toc-Advanced-Audio-options" href="#Advanced-Audio-options">5.8 Advanced Audio options</a></li>
52     <li><a name="toc-Subtitle-options" href="#Subtitle-options">5.9 Subtitle options</a></li>
53     <li><a name="toc-Advanced-Subtitle-options" href="#Advanced-Subtitle-options">5.10 Advanced Subtitle options</a></li>
54     <li><a name="toc-Advanced-options" href="#Advanced-options">5.11 Advanced options</a></li>
55     <li><a name="toc-Preset-files" href="#Preset-files">5.12 Preset files</a>
56     <ul class="no-bullet">
57       <li><a name="toc-ffpreset-files" href="#ffpreset-files">5.12.1 ffpreset files</a></li>
58       <li><a name="toc-avpreset-files" href="#avpreset-files">5.12.2 avpreset files</a></li>
59     </ul></li>
60   </ul></li>
61   <li><a name="toc-Tips" href="#Tips">6 Tips</a></li>
62   <li><a name="toc-Examples" href="#Examples">7 Examples</a>
63   <ul class="no-bullet">
64     <li><a name="toc-Video-and-Audio-grabbing" href="#Video-and-Audio-grabbing">7.1 Video and Audio grabbing</a></li>
65     <li><a name="toc-X11-grabbing" href="#X11-grabbing">7.2 X11 grabbing</a></li>
66     <li><a name="toc-Video-and-Audio-file-format-conversion" href="#Video-and-Audio-file-format-conversion">7.3 Video and Audio file format conversion</a></li>
67   </ul></li>
68   <li><a name="toc-See-Also" href="#See-Also">8 See Also</a></li>
69   <li><a name="toc-Authors" href="#Authors">9 Authors</a></li>
70 </ul>
71 </div>
72
73
74 <a name="Synopsis"></a>
75 <h2 class="chapter">1 Synopsis<span class="pull-right"><a class="anchor hidden-xs" href="#Synopsis" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Synopsis" aria-hidden="true">TOC</a></span></h2>
76
77 <p>ffmpeg [<var>global_options</var>] {[<var>input_file_options</var>] -i <samp>input_file</samp>} ... {[<var>output_file_options</var>] <samp>output_file</samp>} ...
78 </p>
79 <a name="Description"></a>
80 <h2 class="chapter">2 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
81
82 <p><code>ffmpeg</code> is a very fast video and audio converter that can also grab from
83 a live audio/video source. It can also convert between arbitrary sample
84 rates and resize video on the fly with a high quality polyphase filter.
85 </p>
86 <p><code>ffmpeg</code> reads from an arbitrary number of input &quot;files&quot; (which can be regular
87 files, pipes, network streams, grabbing devices, etc.), specified by the
88 <code>-i</code> option, and writes to an arbitrary number of output &quot;files&quot;, which are
89 specified by a plain output filename. Anything found on the command line which
90 cannot be interpreted as an option is considered to be an output filename.
91 </p>
92 <p>Each input or output file can, in principle, contain any number of streams of
93 different types (video/audio/subtitle/attachment/data). The allowed number and/or
94 types of streams may be limited by the container format. Selecting which
95 streams from which inputs will go into which output is either done automatically
96 or with the <code>-map</code> option (see the Stream selection chapter).
97 </p>
98 <p>To refer to input files in options, you must use their indices (0-based). E.g.
99 the first input file is <code>0</code>, the second is <code>1</code>, etc. Similarly, streams
100 within a file are referred to by their indices. E.g. <code>2:3</code> refers to the
101 fourth stream in the third input file. Also see the Stream specifiers chapter.
102 </p>
103 <p>As a general rule, options are applied to the next specified
104 file. Therefore, order is important, and you can have the same
105 option on the command line multiple times. Each occurrence is
106 then applied to the next input or output file.
107 Exceptions from this rule are the global options (e.g. verbosity level),
108 which should be specified first.
109 </p>
110 <p>Do not mix input and output files &ndash; first specify all input files, then all
111 output files. Also do not mix options which belong to different files. All
112 options apply ONLY to the next input or output file and are reset between files.
113 </p>
114 <ul>
115 <li> To set the video bitrate of the output file to 64 kbit/s:
116 <div class="example">
117 <pre class="example">ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
118 </pre></div>
119
120 </li><li> To force the frame rate of the output file to 24 fps:
121 <div class="example">
122 <pre class="example">ffmpeg -i input.avi -r 24 output.avi
123 </pre></div>
124
125 </li><li> To force the frame rate of the input file (valid for raw formats only)
126 to 1 fps and the frame rate of the output file to 24 fps:
127 <div class="example">
128 <pre class="example">ffmpeg -r 1 -i input.m2v -r 24 output.avi
129 </pre></div>
130 </li></ul>
131
132 <p>The format option may be needed for raw input files.
133 </p>
134
135 <a name="Detailed-description"></a>
136 <h2 class="chapter">3 Detailed description<span class="pull-right"><a class="anchor hidden-xs" href="#Detailed-description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Detailed-description" aria-hidden="true">TOC</a></span></h2>
137
138 <p>The transcoding process in <code>ffmpeg</code> for each output can be described by
139 the following diagram:
140 </p>
141 <pre class="verbatim"> _______              ______________
142 |       |            |              |
143 | input |  demuxer   | encoded data |   decoder
144 | file  | ---------&gt; | packets      | -----+
145 |_______|            |______________|      |
146                                            v
147                                        _________
148                                       |         |
149                                       | decoded |
150                                       | frames  |
151                                       |_________|
152  ________             ______________       |
153 |        |           |              |      |
154 | output | &lt;-------- | encoded data | &lt;----+
155 | file   |   muxer   | packets      |   encoder
156 |________|           |______________|
157
158
159 </pre>
160 <p><code>ffmpeg</code> calls the libavformat library (containing demuxers) to read
161 input files and get packets containing encoded data from them. When there are
162 multiple input files, <code>ffmpeg</code> tries to keep them synchronized by
163 tracking lowest timestamp on any active input stream.
164 </p>
165 <p>Encoded packets are then passed to the decoder (unless streamcopy is selected
166 for the stream, see further for a description). The decoder produces
167 uncompressed frames (raw video/PCM audio/...) which can be processed further by
168 filtering (see next section). After filtering, the frames are passed to the
169 encoder, which encodes them and outputs encoded packets. Finally those are
170 passed to the muxer, which writes the encoded packets to the output file.
171 </p>
172 <a name="Filtering"></a>
173 <h3 class="section">3.1 Filtering<span class="pull-right"><a class="anchor hidden-xs" href="#Filtering" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Filtering" aria-hidden="true">TOC</a></span></h3>
174 <p>Before encoding, <code>ffmpeg</code> can process raw audio and video frames using
175 filters from the libavfilter library. Several chained filters form a filter
176 graph. <code>ffmpeg</code> distinguishes between two types of filtergraphs:
177 simple and complex.
178 </p>
179 <a name="Simple-filtergraphs"></a>
180 <h4 class="subsection">3.1.1 Simple filtergraphs<span class="pull-right"><a class="anchor hidden-xs" href="#Simple-filtergraphs" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Simple-filtergraphs" aria-hidden="true">TOC</a></span></h4>
181 <p>Simple filtergraphs are those that have exactly one input and output, both of
182 the same type. In the above diagram they can be represented by simply inserting
183 an additional step between decoding and encoding:
184 </p>
185 <pre class="verbatim"> _________                        ______________
186 |         |                      |              |
187 | decoded |                      | encoded data |
188 | frames  |\                   _ | packets      |
189 |_________| \                  /||______________|
190              \   __________   /
191   simple     _\||          | /  encoder
192   filtergraph   | filtered |/
193                 | frames   |
194                 |__________|
195
196 </pre>
197 <p>Simple filtergraphs are configured with the per-stream <samp>-filter</samp> option
198 (with <samp>-vf</samp> and <samp>-af</samp> aliases for video and audio respectively).
199 A simple filtergraph for video can look for example like this:
200 </p>
201 <pre class="verbatim"> _______        _____________        _______        ________
202 |       |      |             |      |       |      |        |
203 | input | ---&gt; | deinterlace | ---&gt; | scale | ---&gt; | output |
204 |_______|      |_____________|      |_______|      |________|
205
206 </pre>
207 <p>Note that some filters change frame properties but not frame contents. E.g. the
208 <code>fps</code> filter in the example above changes number of frames, but does not
209 touch the frame contents. Another example is the <code>setpts</code> filter, which
210 only sets timestamps and otherwise passes the frames unchanged.
211 </p>
212 <a name="Complex-filtergraphs"></a>
213 <h4 class="subsection">3.1.2 Complex filtergraphs<span class="pull-right"><a class="anchor hidden-xs" href="#Complex-filtergraphs" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Complex-filtergraphs" aria-hidden="true">TOC</a></span></h4>
214 <p>Complex filtergraphs are those which cannot be described as simply a linear
215 processing chain applied to one stream. This is the case, for example, when the graph has
216 more than one input and/or output, or when output stream type is different from
217 input. They can be represented with the following diagram:
218 </p>
219 <pre class="verbatim"> _________
220 |         |
221 | input 0 |\                    __________
222 |_________| \                  |          |
223              \   _________    /| output 0 |
224               \ |         |  / |__________|
225  _________     \| complex | /
226 |         |     |         |/
227 | input 1 |----&gt;| filter  |\
228 |_________|     |         | \   __________
229                /| graph   |  \ |          |
230               / |         |   \| output 1 |
231  _________   /  |_________|    |__________|
232 |         | /
233 | input 2 |/
234 |_________|
235
236 </pre>
237 <p>Complex filtergraphs are configured with the <samp>-filter_complex</samp> option.
238 Note that this option is global, since a complex filtergraph, by its nature,
239 cannot be unambiguously associated with a single stream or file.
240 </p>
241 <p>The <samp>-lavfi</samp> option is equivalent to <samp>-filter_complex</samp>.
242 </p>
243 <p>A trivial example of a complex filtergraph is the <code>overlay</code> filter, which
244 has two video inputs and one video output, containing one video overlaid on top
245 of the other. Its audio counterpart is the <code>amix</code> filter.
246 </p>
247 <a name="Stream-copy"></a>
248 <h3 class="section">3.2 Stream copy<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-copy" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-copy" aria-hidden="true">TOC</a></span></h3>
249 <p>Stream copy is a mode selected by supplying the <code>copy</code> parameter to the
250 <samp>-codec</samp> option. It makes <code>ffmpeg</code> omit the decoding and encoding
251 step for the specified stream, so it does only demuxing and muxing. It is useful
252 for changing the container format or modifying container-level metadata. The
253 diagram above will, in this case, simplify to this:
254 </p>
255 <pre class="verbatim"> _______              ______________            ________
256 |       |            |              |          |        |
257 | input |  demuxer   | encoded data |  muxer   | output |
258 | file  | ---------&gt; | packets      | -------&gt; | file   |
259 |_______|            |______________|          |________|
260
261 </pre>
262 <p>Since there is no decoding or encoding, it is very fast and there is no quality
263 loss. However, it might not work in some cases because of many factors. Applying
264 filters is obviously also impossible, since filters work on uncompressed data.
265 </p>
266
267 <a name="Stream-selection"></a>
268 <h2 class="chapter">4 Stream selection<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-selection" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-selection" aria-hidden="true">TOC</a></span></h2>
269
270 <p>By default, <code>ffmpeg</code> includes only one stream of each type (video, audio, subtitle)
271 present in the input files and adds them to each output file.  It picks the
272 &quot;best&quot; of each based upon the following criteria: for video, it is the stream
273 with the highest resolution, for audio, it is the stream with the most channels, for
274 subtitles, it is the first subtitle stream. In the case where several streams of
275 the same type rate equally, the stream with the lowest index is chosen.
276 </p>
277 <p>You can disable some of those defaults by using the <code>-vn/-an/-sn</code> options. For
278 full manual control, use the <code>-map</code> option, which disables the defaults just
279 described.
280 </p>
281
282 <a name="Options"></a>
283 <h2 class="chapter">5 Options<span class="pull-right"><a class="anchor hidden-xs" href="#Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Options" aria-hidden="true">TOC</a></span></h2>
284
285 <p>All the numerical options, if not specified otherwise, accept a string
286 representing a number as input, which may be followed by one of the SI
287 unit prefixes, for example: &rsquo;K&rsquo;, &rsquo;M&rsquo;, or &rsquo;G&rsquo;.
288 </p>
289 <p>If &rsquo;i&rsquo; is appended to the SI unit prefix, the complete prefix will be
290 interpreted as a unit prefix for binary multiples, which are based on
291 powers of 1024 instead of powers of 1000. Appending &rsquo;B&rsquo; to the SI unit
292 prefix multiplies the value by 8. This allows using, for example:
293 &rsquo;KB&rsquo;, &rsquo;MiB&rsquo;, &rsquo;G&rsquo; and &rsquo;B&rsquo; as number suffixes.
294 </p>
295 <p>Options which do not take arguments are boolean options, and set the
296 corresponding value to true. They can be set to false by prefixing
297 the option name with &quot;no&quot;. For example using &quot;-nofoo&quot;
298 will set the boolean option with name &quot;foo&quot; to false.
299 </p>
300 <a name="Stream-specifiers"></a><a name="Stream-specifiers-1"></a>
301 <h3 class="section">5.1 Stream specifiers<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-specifiers-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-specifiers-1" aria-hidden="true">TOC</a></span></h3>
302 <p>Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
303 are used to precisely specify which stream(s) a given option belongs to.
304 </p>
305 <p>A stream specifier is a string generally appended to the option name and
306 separated from it by a colon. E.g. <code>-codec:a:1 ac3</code> contains the
307 <code>a:1</code> stream specifier, which matches the second audio stream. Therefore, it
308 would select the ac3 codec for the second audio stream.
309 </p>
310 <p>A stream specifier can match several streams, so that the option is applied to all
311 of them. E.g. the stream specifier in <code>-b:a 128k</code> matches all audio
312 streams.
313 </p>
314 <p>An empty stream specifier matches all streams. For example, <code>-codec copy</code>
315 or <code>-codec: copy</code> would copy all the streams without reencoding.
316 </p>
317 <p>Possible forms of stream specifiers are:
318 </p><dl compact="compact">
319 <dt><samp><var>stream_index</var></samp></dt>
320 <dd><p>Matches the stream with this index. E.g. <code>-threads:1 4</code> would set the
321 thread count for the second stream to 4.
322 </p></dd>
323 <dt><samp><var>stream_type</var>[:<var>stream_index</var>]</samp></dt>
324 <dd><p><var>stream_type</var> is one of following: &rsquo;v&rsquo; for video, &rsquo;a&rsquo; for audio, &rsquo;s&rsquo; for subtitle,
325 &rsquo;d&rsquo; for data, and &rsquo;t&rsquo; for attachments. If <var>stream_index</var> is given, then it matches
326 stream number <var>stream_index</var> of this type. Otherwise, it matches all
327 streams of this type.
328 </p></dd>
329 <dt><samp>p:<var>program_id</var>[:<var>stream_index</var>]</samp></dt>
330 <dd><p>If <var>stream_index</var> is given, then it matches the stream with number <var>stream_index</var>
331 in the program with the id <var>program_id</var>. Otherwise, it matches all streams in the
332 program.
333 </p></dd>
334 <dt><samp>#<var>stream_id</var> or i:<var>stream_id</var></samp></dt>
335 <dd><p>Match the stream by stream id (e.g. PID in MPEG-TS container).
336 </p></dd>
337 <dt><samp>m:<var>key</var>[:<var>value</var>]</samp></dt>
338 <dd><p>Matches streams with the metadata tag <var>key</var> having the specified value. If
339 <var>value</var> is not given, matches streams that contain the given tag with any
340 value.
341 </p></dd>
342 <dt><samp>u</samp></dt>
343 <dd><p>Matches streams with usable configuration, the codec must be defined and the
344 essential information such as video dimension or audio sample rate must be present.
345 </p>
346 <p>Note that in <code>ffmpeg</code>, matching by metadata will only work properly for
347 input files.
348 </p></dd>
349 </dl>
350
351 <a name="Generic-options"></a>
352 <h3 class="section">5.2 Generic options<span class="pull-right"><a class="anchor hidden-xs" href="#Generic-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Generic-options" aria-hidden="true">TOC</a></span></h3>
353
354 <p>These options are shared amongst the ff* tools.
355 </p>
356 <dl compact="compact">
357 <dt><samp>-L</samp></dt>
358 <dd><p>Show license.
359 </p>
360 </dd>
361 <dt><samp>-h, -?, -help, --help [<var>arg</var>]</samp></dt>
362 <dd><p>Show help. An optional parameter may be specified to print help about a specific
363 item. If no argument is specified, only basic (non advanced) tool
364 options are shown.
365 </p>
366 <p>Possible values of <var>arg</var> are:
367 </p><dl compact="compact">
368 <dt><samp>long</samp></dt>
369 <dd><p>Print advanced tool options in addition to the basic tool options.
370 </p>
371 </dd>
372 <dt><samp>full</samp></dt>
373 <dd><p>Print complete list of options, including shared and private options
374 for encoders, decoders, demuxers, muxers, filters, etc.
375 </p>
376 </dd>
377 <dt><samp>decoder=<var>decoder_name</var></samp></dt>
378 <dd><p>Print detailed information about the decoder named <var>decoder_name</var>. Use the
379 <samp>-decoders</samp> option to get a list of all decoders.
380 </p>
381 </dd>
382 <dt><samp>encoder=<var>encoder_name</var></samp></dt>
383 <dd><p>Print detailed information about the encoder named <var>encoder_name</var>. Use the
384 <samp>-encoders</samp> option to get a list of all encoders.
385 </p>
386 </dd>
387 <dt><samp>demuxer=<var>demuxer_name</var></samp></dt>
388 <dd><p>Print detailed information about the demuxer named <var>demuxer_name</var>. Use the
389 <samp>-formats</samp> option to get a list of all demuxers and muxers.
390 </p>
391 </dd>
392 <dt><samp>muxer=<var>muxer_name</var></samp></dt>
393 <dd><p>Print detailed information about the muxer named <var>muxer_name</var>. Use the
394 <samp>-formats</samp> option to get a list of all muxers and demuxers.
395 </p>
396 </dd>
397 <dt><samp>filter=<var>filter_name</var></samp></dt>
398 <dd><p>Print detailed information about the filter name <var>filter_name</var>. Use the
399 <samp>-filters</samp> option to get a list of all filters.
400 </p></dd>
401 </dl>
402
403 </dd>
404 <dt><samp>-version</samp></dt>
405 <dd><p>Show version.
406 </p>
407 </dd>
408 <dt><samp>-formats</samp></dt>
409 <dd><p>Show available formats (including devices).
410 </p>
411 </dd>
412 <dt><samp>-devices</samp></dt>
413 <dd><p>Show available devices.
414 </p>
415 </dd>
416 <dt><samp>-codecs</samp></dt>
417 <dd><p>Show all codecs known to libavcodec.
418 </p>
419 <p>Note that the term &rsquo;codec&rsquo; is used throughout this documentation as a shortcut
420 for what is more correctly called a media bitstream format.
421 </p>
422 </dd>
423 <dt><samp>-decoders</samp></dt>
424 <dd><p>Show available decoders.
425 </p>
426 </dd>
427 <dt><samp>-encoders</samp></dt>
428 <dd><p>Show all available encoders.
429 </p>
430 </dd>
431 <dt><samp>-bsfs</samp></dt>
432 <dd><p>Show available bitstream filters.
433 </p>
434 </dd>
435 <dt><samp>-protocols</samp></dt>
436 <dd><p>Show available protocols.
437 </p>
438 </dd>
439 <dt><samp>-filters</samp></dt>
440 <dd><p>Show available libavfilter filters.
441 </p>
442 </dd>
443 <dt><samp>-pix_fmts</samp></dt>
444 <dd><p>Show available pixel formats.
445 </p>
446 </dd>
447 <dt><samp>-sample_fmts</samp></dt>
448 <dd><p>Show available sample formats.
449 </p>
450 </dd>
451 <dt><samp>-layouts</samp></dt>
452 <dd><p>Show channel names and standard channel layouts.
453 </p>
454 </dd>
455 <dt><samp>-colors</samp></dt>
456 <dd><p>Show recognized color names.
457 </p>
458 </dd>
459 <dt><samp>-sources <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
460 <dd><p>Show autodetected sources of the intput device.
461 Some devices may provide system-dependent source names that cannot be autodetected.
462 The returned list cannot be assumed to be always complete.
463 </p><div class="example">
464 <pre class="example">ffmpeg -sources pulse,server=192.168.0.4
465 </pre></div>
466
467 </dd>
468 <dt><samp>-sinks <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
469 <dd><p>Show autodetected sinks of the output device.
470 Some devices may provide system-dependent sink names that cannot be autodetected.
471 The returned list cannot be assumed to be always complete.
472 </p><div class="example">
473 <pre class="example">ffmpeg -sinks pulse,server=192.168.0.4
474 </pre></div>
475
476 </dd>
477 <dt><samp>-loglevel [repeat+]<var>loglevel</var> | -v [repeat+]<var>loglevel</var></samp></dt>
478 <dd><p>Set the logging level used by the library.
479 Adding &quot;repeat+&quot; indicates that repeated log output should not be compressed
480 to the first line and the &quot;Last message repeated n times&quot; line will be
481 omitted. &quot;repeat&quot; can also be used alone.
482 If &quot;repeat&quot; is used alone, and with no prior loglevel set, the default
483 loglevel will be used. If multiple loglevel parameters are given, using
484 &rsquo;repeat&rsquo; will not change the loglevel.
485 <var>loglevel</var> is a string or a number containing one of the following values:
486 </p><dl compact="compact">
487 <dt>&lsquo;<samp>quiet, -8</samp>&rsquo;</dt>
488 <dd><p>Show nothing at all; be silent.
489 </p></dd>
490 <dt>&lsquo;<samp>panic, 0</samp>&rsquo;</dt>
491 <dd><p>Only show fatal errors which could lead the process to crash, such as
492 and assert failure. This is not currently used for anything.
493 </p></dd>
494 <dt>&lsquo;<samp>fatal, 8</samp>&rsquo;</dt>
495 <dd><p>Only show fatal errors. These are errors after which the process absolutely
496 cannot continue after.
497 </p></dd>
498 <dt>&lsquo;<samp>error, 16</samp>&rsquo;</dt>
499 <dd><p>Show all errors, including ones which can be recovered from.
500 </p></dd>
501 <dt>&lsquo;<samp>warning, 24</samp>&rsquo;</dt>
502 <dd><p>Show all warnings and errors. Any message related to possibly
503 incorrect or unexpected events will be shown.
504 </p></dd>
505 <dt>&lsquo;<samp>info, 32</samp>&rsquo;</dt>
506 <dd><p>Show informative messages during processing. This is in addition to
507 warnings and errors. This is the default value.
508 </p></dd>
509 <dt>&lsquo;<samp>verbose, 40</samp>&rsquo;</dt>
510 <dd><p>Same as <code>info</code>, except more verbose.
511 </p></dd>
512 <dt>&lsquo;<samp>debug, 48</samp>&rsquo;</dt>
513 <dd><p>Show everything, including debugging information.
514 </p></dd>
515 <dt>&lsquo;<samp>trace, 56</samp>&rsquo;</dt>
516 </dl>
517
518 <p>By default the program logs to stderr, if coloring is supported by the
519 terminal, colors are used to mark errors and warnings. Log coloring
520 can be disabled setting the environment variable
521 <code>AV_LOG_FORCE_NOCOLOR</code> or <code>NO_COLOR</code>, or can be forced setting
522 the environment variable <code>AV_LOG_FORCE_COLOR</code>.
523 The use of the environment variable <code>NO_COLOR</code> is deprecated and
524 will be dropped in a following FFmpeg version.
525 </p>
526 </dd>
527 <dt><samp>-report</samp></dt>
528 <dd><p>Dump full command line and console output to a file named
529 <code><var>program</var>-<var>YYYYMMDD</var>-<var>HHMMSS</var>.log</code> in the current
530 directory.
531 This file can be useful for bug reports.
532 It also implies <code>-loglevel verbose</code>.
533 </p>
534 <p>Setting the environment variable <code>FFREPORT</code> to any value has the
535 same effect. If the value is a &rsquo;:&rsquo;-separated key=value sequence, these
536 options will affect the report; option values must be escaped if they
537 contain special characters or the options delimiter &rsquo;:&rsquo; (see the
538 &ldquo;Quoting and escaping&rdquo; section in the ffmpeg-utils manual).
539 </p>
540 <p>The following options are recognized:
541 </p><dl compact="compact">
542 <dt><samp>file</samp></dt>
543 <dd><p>set the file name to use for the report; <code>%p</code> is expanded to the name
544 of the program, <code>%t</code> is expanded to a timestamp, <code>%%</code> is expanded
545 to a plain <code>%</code>
546 </p></dd>
547 <dt><samp>level</samp></dt>
548 <dd><p>set the log verbosity level using a numerical value (see <code>-loglevel</code>).
549 </p></dd>
550 </dl>
551
552 <p>For example, to output a report to a file named <samp>ffreport.log</samp>
553 using a log level of <code>32</code> (alias for log level <code>info</code>):
554 </p>
555 <div class="example">
556 <pre class="example">FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
557 </pre></div>
558
559 <p>Errors in parsing the environment variable are not fatal, and will not
560 appear in the report.
561 </p>
562 </dd>
563 <dt><samp>-hide_banner</samp></dt>
564 <dd><p>Suppress printing banner.
565 </p>
566 <p>All FFmpeg tools will normally show a copyright notice, build options
567 and library versions. This option can be used to suppress printing
568 this information.
569 </p>
570 </dd>
571 <dt><samp>-cpuflags flags (<em>global</em>)</samp></dt>
572 <dd><p>Allows setting and clearing cpu flags. This option is intended
573 for testing. Do not use it unless you know what you&rsquo;re doing.
574 </p><div class="example">
575 <pre class="example">ffmpeg -cpuflags -sse+mmx ...
576 ffmpeg -cpuflags mmx ...
577 ffmpeg -cpuflags 0 ...
578 </pre></div>
579 <p>Possible flags for this option are:
580 </p><dl compact="compact">
581 <dt>&lsquo;<samp>x86</samp>&rsquo;</dt>
582 <dd><dl compact="compact">
583 <dt>&lsquo;<samp>mmx</samp>&rsquo;</dt>
584 <dt>&lsquo;<samp>mmxext</samp>&rsquo;</dt>
585 <dt>&lsquo;<samp>sse</samp>&rsquo;</dt>
586 <dt>&lsquo;<samp>sse2</samp>&rsquo;</dt>
587 <dt>&lsquo;<samp>sse2slow</samp>&rsquo;</dt>
588 <dt>&lsquo;<samp>sse3</samp>&rsquo;</dt>
589 <dt>&lsquo;<samp>sse3slow</samp>&rsquo;</dt>
590 <dt>&lsquo;<samp>ssse3</samp>&rsquo;</dt>
591 <dt>&lsquo;<samp>atom</samp>&rsquo;</dt>
592 <dt>&lsquo;<samp>sse4.1</samp>&rsquo;</dt>
593 <dt>&lsquo;<samp>sse4.2</samp>&rsquo;</dt>
594 <dt>&lsquo;<samp>avx</samp>&rsquo;</dt>
595 <dt>&lsquo;<samp>avx2</samp>&rsquo;</dt>
596 <dt>&lsquo;<samp>xop</samp>&rsquo;</dt>
597 <dt>&lsquo;<samp>fma3</samp>&rsquo;</dt>
598 <dt>&lsquo;<samp>fma4</samp>&rsquo;</dt>
599 <dt>&lsquo;<samp>3dnow</samp>&rsquo;</dt>
600 <dt>&lsquo;<samp>3dnowext</samp>&rsquo;</dt>
601 <dt>&lsquo;<samp>bmi1</samp>&rsquo;</dt>
602 <dt>&lsquo;<samp>bmi2</samp>&rsquo;</dt>
603 <dt>&lsquo;<samp>cmov</samp>&rsquo;</dt>
604 </dl>
605 </dd>
606 <dt>&lsquo;<samp>ARM</samp>&rsquo;</dt>
607 <dd><dl compact="compact">
608 <dt>&lsquo;<samp>armv5te</samp>&rsquo;</dt>
609 <dt>&lsquo;<samp>armv6</samp>&rsquo;</dt>
610 <dt>&lsquo;<samp>armv6t2</samp>&rsquo;</dt>
611 <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
612 <dt>&lsquo;<samp>vfpv3</samp>&rsquo;</dt>
613 <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
614 <dt>&lsquo;<samp>setend</samp>&rsquo;</dt>
615 </dl>
616 </dd>
617 <dt>&lsquo;<samp>AArch64</samp>&rsquo;</dt>
618 <dd><dl compact="compact">
619 <dt>&lsquo;<samp>armv8</samp>&rsquo;</dt>
620 <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
621 <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
622 </dl>
623 </dd>
624 <dt>&lsquo;<samp>PowerPC</samp>&rsquo;</dt>
625 <dd><dl compact="compact">
626 <dt>&lsquo;<samp>altivec</samp>&rsquo;</dt>
627 </dl>
628 </dd>
629 <dt>&lsquo;<samp>Specific Processors</samp>&rsquo;</dt>
630 <dd><dl compact="compact">
631 <dt>&lsquo;<samp>pentium2</samp>&rsquo;</dt>
632 <dt>&lsquo;<samp>pentium3</samp>&rsquo;</dt>
633 <dt>&lsquo;<samp>pentium4</samp>&rsquo;</dt>
634 <dt>&lsquo;<samp>k6</samp>&rsquo;</dt>
635 <dt>&lsquo;<samp>k62</samp>&rsquo;</dt>
636 <dt>&lsquo;<samp>athlon</samp>&rsquo;</dt>
637 <dt>&lsquo;<samp>athlonxp</samp>&rsquo;</dt>
638 <dt>&lsquo;<samp>k8</samp>&rsquo;</dt>
639 </dl>
640 </dd>
641 </dl>
642
643 </dd>
644 <dt><samp>-opencl_bench</samp></dt>
645 <dd><p>This option is used to benchmark all available OpenCL devices and print the
646 results. This option is only available when FFmpeg has been compiled with
647 <code>--enable-opencl</code>.
648 </p>
649 <p>When FFmpeg is configured with <code>--enable-opencl</code>, the options for the
650 global OpenCL context are set via <samp>-opencl_options</samp>. See the
651 &quot;OpenCL Options&quot; section in the ffmpeg-utils manual for the complete list of
652 supported options. Amongst others, these options include the ability to select
653 a specific platform and device to run the OpenCL code on. By default, FFmpeg
654 will run on the first device of the first platform. While the options for the
655 global OpenCL context provide flexibility to the user in selecting the OpenCL
656 device of their choice, most users would probably want to select the fastest
657 OpenCL device for their system.
658 </p>
659 <p>This option assists the selection of the most efficient configuration by
660 identifying the appropriate device for the user&rsquo;s system. The built-in
661 benchmark is run on all the OpenCL devices and the performance is measured for
662 each device. The devices in the results list are sorted based on their
663 performance with the fastest device listed first. The user can subsequently
664 invoke <code>ffmpeg</code> using the device deemed most appropriate via
665 <samp>-opencl_options</samp> to obtain the best performance for the OpenCL
666 accelerated code.
667 </p>
668 <p>Typical usage to use the fastest OpenCL device involve the following steps.
669 </p>
670 <p>Run the command:
671 </p><div class="example">
672 <pre class="example">ffmpeg -opencl_bench
673 </pre></div>
674 <p>Note down the platform ID (<var>pidx</var>) and device ID (<var>didx</var>) of the first
675 i.e. fastest device in the list.
676 Select the platform and device using the command:
677 </p><div class="example">
678 <pre class="example">ffmpeg -opencl_options platform_idx=<var>pidx</var>:device_idx=<var>didx</var> ...
679 </pre></div>
680
681 </dd>
682 <dt><samp>-opencl_options options (<em>global</em>)</samp></dt>
683 <dd><p>Set OpenCL environment options. This option is only available when
684 FFmpeg has been compiled with <code>--enable-opencl</code>.
685 </p>
686 <p><var>options</var> must be a list of <var>key</var>=<var>value</var> option pairs
687 separated by &rsquo;:&rsquo;. See the &ldquo;OpenCL Options&rdquo; section in the
688 ffmpeg-utils manual for the list of supported options.
689 </p></dd>
690 </dl>
691
692 <a name="AVOptions"></a>
693 <h3 class="section">5.3 AVOptions<span class="pull-right"><a class="anchor hidden-xs" href="#AVOptions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-AVOptions" aria-hidden="true">TOC</a></span></h3>
694
695 <p>These options are provided directly by the libavformat, libavdevice and
696 libavcodec libraries. To see the list of available AVOptions, use the
697 <samp>-help</samp> option. They are separated into two categories:
698 </p><dl compact="compact">
699 <dt><samp>generic</samp></dt>
700 <dd><p>These options can be set for any container, codec or device. Generic options
701 are listed under AVFormatContext options for containers/devices and under
702 AVCodecContext options for codecs.
703 </p></dd>
704 <dt><samp>private</samp></dt>
705 <dd><p>These options are specific to the given container, device or codec. Private
706 options are listed under their corresponding containers/devices/codecs.
707 </p></dd>
708 </dl>
709
710 <p>For example to write an ID3v2.3 header instead of a default ID3v2.4 to
711 an MP3 file, use the <samp>id3v2_version</samp> private option of the MP3
712 muxer:
713 </p><div class="example">
714 <pre class="example">ffmpeg -i input.flac -id3v2_version 3 out.mp3
715 </pre></div>
716
717 <p>All codec AVOptions are per-stream, and thus a stream specifier
718 should be attached to them.
719 </p>
720 <p>Note: the <samp>-nooption</samp> syntax cannot be used for boolean
721 AVOptions, use <samp>-option 0</samp>/<samp>-option 1</samp>.
722 </p>
723 <p>Note: the old undocumented way of specifying per-stream AVOptions by
724 prepending v/a/s to the options name is now obsolete and will be
725 removed soon.
726 </p>
727 <a name="Main-options"></a>
728 <h3 class="section">5.4 Main options<span class="pull-right"><a class="anchor hidden-xs" href="#Main-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Main-options" aria-hidden="true">TOC</a></span></h3>
729
730 <dl compact="compact">
731 <dt><samp>-f <var>fmt</var> (<em>input/output</em>)</samp></dt>
732 <dd><p>Force input or output file format. The format is normally auto detected for input
733 files and guessed from the file extension for output files, so this option is not
734 needed in most cases.
735 </p>
736 </dd>
737 <dt><samp>-i <var>filename</var> (<em>input</em>)</samp></dt>
738 <dd><p>input file name
739 </p>
740 </dd>
741 <dt><samp>-y (<em>global</em>)</samp></dt>
742 <dd><p>Overwrite output files without asking.
743 </p>
744 </dd>
745 <dt><samp>-n (<em>global</em>)</samp></dt>
746 <dd><p>Do not overwrite output files, and exit immediately if a specified
747 output file already exists.
748 </p>
749 </dd>
750 <dt><samp>-c[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp></dt>
751 <dt><samp>-codec[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp></dt>
752 <dd><p>Select an encoder (when used before an output file) or a decoder (when used
753 before an input file) for one or more streams. <var>codec</var> is the name of a
754 decoder/encoder or a special value <code>copy</code> (output only) to indicate that
755 the stream is not to be re-encoded.
756 </p>
757 <p>For example
758 </p><div class="example">
759 <pre class="example">ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
760 </pre></div>
761 <p>encodes all video streams with libx264 and copies all audio streams.
762 </p>
763 <p>For each stream, the last matching <code>c</code> option is applied, so
764 </p><div class="example">
765 <pre class="example">ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
766 </pre></div>
767 <p>will copy all the streams except the second video, which will be encoded with
768 libx264, and the 138th audio, which will be encoded with libvorbis.
769 </p>
770 </dd>
771 <dt><samp>-t <var>duration</var> (<em>input/output</em>)</samp></dt>
772 <dd><p>When used as an input option (before <code>-i</code>), limit the <var>duration</var> of
773 data read from the input file.
774 </p>
775 <p>When used as an output option (before an output filename), stop writing the
776 output after its duration reaches <var>duration</var>.
777 </p>
778 <p><var>duration</var> may be a number in seconds, or in <code>hh:mm:ss[.xxx]</code> form.
779 </p>
780 <p>-to and -t are mutually exclusive and -t has priority.
781 </p>
782 </dd>
783 <dt><samp>-to <var>position</var> (<em>output</em>)</samp></dt>
784 <dd><p>Stop writing the output at <var>position</var>.
785 <var>position</var> may be a number in seconds, or in <code>hh:mm:ss[.xxx]</code> form.
786 </p>
787 <p>-to and -t are mutually exclusive and -t has priority.
788 </p>
789 </dd>
790 <dt><samp>-fs <var>limit_size</var> (<em>output</em>)</samp></dt>
791 <dd><p>Set the file size limit, expressed in bytes.
792 </p>
793 </dd>
794 <dt><samp>-ss <var>position</var> (<em>input/output</em>)</samp></dt>
795 <dd><p>When used as an input option (before <code>-i</code>), seeks in this input file to
796 <var>position</var>. Note the in most formats it is not possible to seek exactly, so
797 <code>ffmpeg</code> will seek to the closest seek point before <var>position</var>.
798 When transcoding and <samp>-accurate_seek</samp> is enabled (the default), this
799 extra segment between the seek point and <var>position</var> will be decoded and
800 discarded. When doing stream copy or when <samp>-noaccurate_seek</samp> is used, it
801 will be preserved.
802 </p>
803 <p>When used as an output option (before an output filename), decodes but discards
804 input until the timestamps reach <var>position</var>.
805 </p>
806 <p><var>position</var> may be either in seconds or in <code>hh:mm:ss[.xxx]</code> form.
807 </p>
808 </dd>
809 <dt><samp>-itsoffset <var>offset</var> (<em>input</em>)</samp></dt>
810 <dd><p>Set the input time offset.
811 </p>
812 <p><var>offset</var> must be a time duration specification,
813 see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
814 </p>
815 <p>The offset is added to the timestamps of the input files. Specifying
816 a positive offset means that the corresponding streams are delayed by
817 the time duration specified in <var>offset</var>.
818 </p>
819 </dd>
820 <dt><samp>-timestamp <var>date</var> (<em>output</em>)</samp></dt>
821 <dd><p>Set the recording timestamp in the container.
822 </p>
823 <p><var>date</var> must be a time duration specification,
824 see <a href="ffmpeg-utils.html#date-syntax">(ffmpeg-utils)the Date section in the ffmpeg-utils(1) manual</a>.
825 </p>
826 </dd>
827 <dt><samp>-metadata[:metadata_specifier] <var>key</var>=<var>value</var> (<em>output,per-metadata</em>)</samp></dt>
828 <dd><p>Set a metadata key/value pair.
829 </p>
830 <p>An optional <var>metadata_specifier</var> may be given to set metadata
831 on streams or chapters. See <code>-map_metadata</code> documentation for
832 details.
833 </p>
834 <p>This option overrides metadata set with <code>-map_metadata</code>. It is
835 also possible to delete metadata by using an empty value.
836 </p>
837 <p>For example, for setting the title in the output file:
838 </p><div class="example">
839 <pre class="example">ffmpeg -i in.avi -metadata title=&quot;my title&quot; out.flv
840 </pre></div>
841
842 <p>To set the language of the first audio stream:
843 </p><div class="example">
844 <pre class="example">ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
845 </pre></div>
846
847 </dd>
848 <dt><samp>-target <var>type</var> (<em>output</em>)</samp></dt>
849 <dd><p>Specify target file type (<code>vcd</code>, <code>svcd</code>, <code>dvd</code>, <code>dv</code>,
850 <code>dv50</code>). <var>type</var> may be prefixed with <code>pal-</code>, <code>ntsc-</code> or
851 <code>film-</code> to use the corresponding standard. All the format options
852 (bitrate, codecs, buffer sizes) are then set automatically. You can just type:
853 </p>
854 <div class="example">
855 <pre class="example">ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
856 </pre></div>
857
858 <p>Nevertheless you can specify additional options as long as you know
859 they do not conflict with the standard, as in:
860 </p>
861 <div class="example">
862 <pre class="example">ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
863 </pre></div>
864
865 </dd>
866 <dt><samp>-dframes <var>number</var> (<em>output</em>)</samp></dt>
867 <dd><p>Set the number of data frames to output. This is an alias for <code>-frames:d</code>.
868 </p>
869 </dd>
870 <dt><samp>-frames[:<var>stream_specifier</var>] <var>framecount</var> (<em>output,per-stream</em>)</samp></dt>
871 <dd><p>Stop writing to the stream after <var>framecount</var> frames.
872 </p>
873 </dd>
874 <dt><samp>-q[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp></dt>
875 <dt><samp>-qscale[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp></dt>
876 <dd><p>Use fixed quality scale (VBR). The meaning of <var>q</var>/<var>qscale</var> is
877 codec-dependent.
878 If <var>qscale</var> is used without a <var>stream_specifier</var> then it applies only
879 to the video stream, this is to maintain compatibility with previous behavior
880 and as specifying the same codec specific value to 2 different codecs that is
881 audio and video generally is not what is intended when no stream_specifier is
882 used.
883 </p>
884 <a name="filter_005foption"></a></dd>
885 <dt><samp>-filter[:<var>stream_specifier</var>] <var>filtergraph</var> (<em>output,per-stream</em>)</samp></dt>
886 <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
887 filter the stream.
888 </p>
889 <p><var>filtergraph</var> is a description of the filtergraph to apply to
890 the stream, and must have a single input and a single output of the
891 same type of the stream. In the filtergraph, the input is associated
892 to the label <code>in</code>, and the output to the label <code>out</code>. See
893 the ffmpeg-filters manual for more information about the filtergraph
894 syntax.
895 </p>
896 <p>See the <a href="#filter_005fcomplex_005foption">-filter_complex option</a> if you
897 want to create filtergraphs with multiple inputs and/or outputs.
898 </p>
899 </dd>
900 <dt><samp>-filter_script[:<var>stream_specifier</var>] <var>filename</var> (<em>output,per-stream</em>)</samp></dt>
901 <dd><p>This option is similar to <samp>-filter</samp>, the only difference is that its
902 argument is the name of the file from which a filtergraph description is to be
903 read.
904 </p>
905 </dd>
906 <dt><samp>-pre[:<var>stream_specifier</var>] <var>preset_name</var> (<em>output,per-stream</em>)</samp></dt>
907 <dd><p>Specify the preset for matching stream(s).
908 </p>
909 </dd>
910 <dt><samp>-stats (<em>global</em>)</samp></dt>
911 <dd><p>Print encoding progress/statistics. It is on by default, to explicitly
912 disable it you need to specify <code>-nostats</code>.
913 </p>
914 </dd>
915 <dt><samp>-progress <var>url</var> (<em>global</em>)</samp></dt>
916 <dd><p>Send program-friendly progress information to <var>url</var>.
917 </p>
918 <p>Progress information is written approximately every second and at the end of
919 the encoding process. It is made of &quot;<var>key</var>=<var>value</var>&quot; lines. <var>key</var>
920 consists of only alphanumeric characters. The last key of a sequence of
921 progress information is always &quot;progress&quot;.
922 </p>
923 </dd>
924 <dt><samp>-stdin</samp></dt>
925 <dd><p>Enable interaction on standard input. On by default unless standard input is
926 used as an input. To explicitly disable interaction you need to specify
927 <code>-nostdin</code>.
928 </p>
929 <p>Disabling interaction on standard input is useful, for example, if
930 ffmpeg is in the background process group. Roughly the same result can
931 be achieved with <code>ffmpeg ... &lt; /dev/null</code> but it requires a
932 shell.
933 </p>
934 </dd>
935 <dt><samp>-debug_ts (<em>global</em>)</samp></dt>
936 <dd><p>Print timestamp information. It is off by default. This option is
937 mostly useful for testing and debugging purposes, and the output
938 format may change from one version to another, so it should not be
939 employed by portable scripts.
940 </p>
941 <p>See also the option <code>-fdebug ts</code>.
942 </p>
943 </dd>
944 <dt><samp>-attach <var>filename</var> (<em>output</em>)</samp></dt>
945 <dd><p>Add an attachment to the output file. This is supported by a few formats
946 like Matroska for e.g. fonts used in rendering subtitles. Attachments
947 are implemented as a specific type of stream, so this option will add
948 a new stream to the file. It is then possible to use per-stream options
949 on this stream in the usual way. Attachment streams created with this
950 option will be created after all the other streams (i.e. those created
951 with <code>-map</code> or automatic mappings).
952 </p>
953 <p>Note that for Matroska you also have to set the mimetype metadata tag:
954 </p><div class="example">
955 <pre class="example">ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
956 </pre></div>
957 <p>(assuming that the attachment stream will be third in the output file).
958 </p>
959 </dd>
960 <dt><samp>-dump_attachment[:<var>stream_specifier</var>] <var>filename</var> (<em>input,per-stream</em>)</samp></dt>
961 <dd><p>Extract the matching attachment stream into a file named <var>filename</var>. If
962 <var>filename</var> is empty, then the value of the <code>filename</code> metadata tag
963 will be used.
964 </p>
965 <p>E.g. to extract the first attachment to a file named &rsquo;out.ttf&rsquo;:
966 </p><div class="example">
967 <pre class="example">ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
968 </pre></div>
969 <p>To extract all attachments to files determined by the <code>filename</code> tag:
970 </p><div class="example">
971 <pre class="example">ffmpeg -dump_attachment:t &quot;&quot; -i INPUT
972 </pre></div>
973
974 <p>Technical note &ndash; attachments are implemented as codec extradata, so this
975 option can actually be used to extract extradata from any stream, not just
976 attachments.
977 </p>
978 </dd>
979 <dt><samp>-noautorotate</samp></dt>
980 <dd><p>Disable automatically rotating video based on file metadata.
981 </p>
982 </dd>
983 </dl>
984
985 <a name="Video-Options"></a>
986 <h3 class="section">5.5 Video Options<span class="pull-right"><a class="anchor hidden-xs" href="#Video-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-Options" aria-hidden="true">TOC</a></span></h3>
987
988 <dl compact="compact">
989 <dt><samp>-vframes <var>number</var> (<em>output</em>)</samp></dt>
990 <dd><p>Set the number of video frames to output. This is an alias for <code>-frames:v</code>.
991 </p></dd>
992 <dt><samp>-r[:<var>stream_specifier</var>] <var>fps</var> (<em>input/output,per-stream</em>)</samp></dt>
993 <dd><p>Set frame rate (Hz value, fraction or abbreviation).
994 </p>
995 <p>As an input option, ignore any timestamps stored in the file and instead
996 generate timestamps assuming constant frame rate <var>fps</var>.
997 This is not the same as the <samp>-framerate</samp> option used for some input formats
998 like image2 or v4l2 (it used to be the same in older versions of FFmpeg).
999 If in doubt use <samp>-framerate</samp> instead of the input option <samp>-r</samp>.
1000 </p>
1001 <p>As an output option, duplicate or drop input frames to achieve constant output
1002 frame rate <var>fps</var>.
1003 </p>
1004 </dd>
1005 <dt><samp>-s[:<var>stream_specifier</var>] <var>size</var> (<em>input/output,per-stream</em>)</samp></dt>
1006 <dd><p>Set frame size.
1007 </p>
1008 <p>As an input option, this is a shortcut for the <samp>video_size</samp> private
1009 option, recognized by some demuxers for which the frame size is either not
1010 stored in the file or is configurable &ndash; e.g. raw video or video grabbers.
1011 </p>
1012 <p>As an output option, this inserts the <code>scale</code> video filter to the
1013 <em>end</em> of the corresponding filtergraph. Please use the <code>scale</code> filter
1014 directly to insert it at the beginning or some other place.
1015 </p>
1016 <p>The format is &lsquo;<samp>wxh</samp>&rsquo; (default - same as source).
1017 </p>
1018 </dd>
1019 <dt><samp>-aspect[:<var>stream_specifier</var>] <var>aspect</var> (<em>output,per-stream</em>)</samp></dt>
1020 <dd><p>Set the video display aspect ratio specified by <var>aspect</var>.
1021 </p>
1022 <p><var>aspect</var> can be a floating point number string, or a string of the
1023 form <var>num</var>:<var>den</var>, where <var>num</var> and <var>den</var> are the
1024 numerator and denominator of the aspect ratio. For example &quot;4:3&quot;,
1025 &quot;16:9&quot;, &quot;1.3333&quot;, and &quot;1.7777&quot; are valid argument values.
1026 </p>
1027 <p>If used together with <samp>-vcodec copy</samp>, it will affect the aspect ratio
1028 stored at container level, but not the aspect ratio stored in encoded
1029 frames, if it exists.
1030 </p>
1031 </dd>
1032 <dt><samp>-vn (<em>output</em>)</samp></dt>
1033 <dd><p>Disable video recording.
1034 </p>
1035 </dd>
1036 <dt><samp>-vcodec <var>codec</var> (<em>output</em>)</samp></dt>
1037 <dd><p>Set the video codec. This is an alias for <code>-codec:v</code>.
1038 </p>
1039 </dd>
1040 <dt><samp>-pass[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp></dt>
1041 <dd><p>Select the pass number (1 or 2). It is used to do two-pass
1042 video encoding. The statistics of the video are recorded in the first
1043 pass into a log file (see also the option -passlogfile),
1044 and in the second pass that log file is used to generate the video
1045 at the exact requested bitrate.
1046 On pass 1, you may just deactivate audio and set output to null,
1047 examples for Windows and Unix:
1048 </p><div class="example">
1049 <pre class="example">ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
1050 ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
1051 </pre></div>
1052
1053 </dd>
1054 <dt><samp>-passlogfile[:<var>stream_specifier</var>] <var>prefix</var> (<em>output,per-stream</em>)</samp></dt>
1055 <dd><p>Set two-pass log file name prefix to <var>prefix</var>, the default file name
1056 prefix is &ldquo;ffmpeg2pass&rdquo;. The complete file name will be
1057 <samp>PREFIX-N.log</samp>, where N is a number specific to the output
1058 stream
1059 </p>
1060 </dd>
1061 <dt><samp>-vf <var>filtergraph</var> (<em>output</em>)</samp></dt>
1062 <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
1063 filter the stream.
1064 </p>
1065 <p>This is an alias for <code>-filter:v</code>, see the <a href="#filter_005foption">-filter option</a>.
1066 </p></dd>
1067 </dl>
1068
1069 <a name="Advanced-Video-options"></a>
1070 <h3 class="section">5.6 Advanced Video options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Video-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Video-options" aria-hidden="true">TOC</a></span></h3>
1071
1072 <dl compact="compact">
1073 <dt><samp>-pix_fmt[:<var>stream_specifier</var>] <var>format</var> (<em>input/output,per-stream</em>)</samp></dt>
1074 <dd><p>Set pixel format. Use <code>-pix_fmts</code> to show all the supported
1075 pixel formats.
1076 If the selected pixel format can not be selected, ffmpeg will print a
1077 warning and select the best pixel format supported by the encoder.
1078 If <var>pix_fmt</var> is prefixed by a <code>+</code>, ffmpeg will exit with an error
1079 if the requested pixel format can not be selected, and automatic conversions
1080 inside filtergraphs are disabled.
1081 If <var>pix_fmt</var> is a single <code>+</code>, ffmpeg selects the same pixel format
1082 as the input (or graph output) and automatic conversions are disabled.
1083 </p>
1084 </dd>
1085 <dt><samp>-sws_flags <var>flags</var> (<em>input/output</em>)</samp></dt>
1086 <dd><p>Set SwScaler flags.
1087 </p></dd>
1088 <dt><samp>-vdt <var>n</var></samp></dt>
1089 <dd><p>Discard threshold.
1090 </p>
1091 </dd>
1092 <dt><samp>-rc_override[:<var>stream_specifier</var>] <var>override</var> (<em>output,per-stream</em>)</samp></dt>
1093 <dd><p>Rate control override for specific intervals, formatted as &quot;int,int,int&quot;
1094 list separated with slashes. Two first values are the beginning and
1095 end frame numbers, last one is quantizer to use if positive, or quality
1096 factor if negative.
1097 </p>
1098 </dd>
1099 <dt><samp>-ilme</samp></dt>
1100 <dd><p>Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
1101 Use this option if your input file is interlaced and you want
1102 to keep the interlaced format for minimum losses.
1103 The alternative is to deinterlace the input stream with
1104 <samp>-deinterlace</samp>, but deinterlacing introduces losses.
1105 </p></dd>
1106 <dt><samp>-psnr</samp></dt>
1107 <dd><p>Calculate PSNR of compressed frames.
1108 </p></dd>
1109 <dt><samp>-vstats</samp></dt>
1110 <dd><p>Dump video coding statistics to <samp>vstats_HHMMSS.log</samp>.
1111 </p></dd>
1112 <dt><samp>-vstats_file <var>file</var></samp></dt>
1113 <dd><p>Dump video coding statistics to <var>file</var>.
1114 </p></dd>
1115 <dt><samp>-top[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp></dt>
1116 <dd><p>top=1/bottom=0/auto=-1 field first
1117 </p></dd>
1118 <dt><samp>-dc <var>precision</var></samp></dt>
1119 <dd><p>Intra_dc_precision.
1120 </p></dd>
1121 <dt><samp>-vtag <var>fourcc/tag</var> (<em>output</em>)</samp></dt>
1122 <dd><p>Force video tag/fourcc. This is an alias for <code>-tag:v</code>.
1123 </p></dd>
1124 <dt><samp>-qphist (<em>global</em>)</samp></dt>
1125 <dd><p>Show QP histogram
1126 </p></dd>
1127 <dt><samp>-vbsf <var>bitstream_filter</var></samp></dt>
1128 <dd><p>Deprecated see -bsf
1129 </p>
1130 </dd>
1131 <dt><samp>-force_key_frames[:<var>stream_specifier</var>] <var>time</var>[,<var>time</var>...] (<em>output,per-stream</em>)</samp></dt>
1132 <dt><samp>-force_key_frames[:<var>stream_specifier</var>] expr:<var>expr</var> (<em>output,per-stream</em>)</samp></dt>
1133 <dd><p>Force key frames at the specified timestamps, more precisely at the first
1134 frames after each specified time.
1135 </p>
1136 <p>If the argument is prefixed with <code>expr:</code>, the string <var>expr</var>
1137 is interpreted like an expression and is evaluated for each frame. A
1138 key frame is forced in case the evaluation is non-zero.
1139 </p>
1140 <p>If one of the times is &quot;<code>chapters</code>[<var>delta</var>]&quot;, it is expanded into
1141 the time of the beginning of all chapters in the file, shifted by
1142 <var>delta</var>, expressed as a time in seconds.
1143 This option can be useful to ensure that a seek point is present at a
1144 chapter mark or any other designated place in the output file.
1145 </p>
1146 <p>For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
1147 before the beginning of every chapter:
1148 </p><div class="example">
1149 <pre class="example">-force_key_frames 0:05:00,chapters-0.1
1150 </pre></div>
1151
1152 <p>The expression in <var>expr</var> can contain the following constants:
1153 </p><dl compact="compact">
1154 <dt><samp>n</samp></dt>
1155 <dd><p>the number of current processed frame, starting from 0
1156 </p></dd>
1157 <dt><samp>n_forced</samp></dt>
1158 <dd><p>the number of forced frames
1159 </p></dd>
1160 <dt><samp>prev_forced_n</samp></dt>
1161 <dd><p>the number of the previous forced frame, it is <code>NAN</code> when no
1162 keyframe was forced yet
1163 </p></dd>
1164 <dt><samp>prev_forced_t</samp></dt>
1165 <dd><p>the time of the previous forced frame, it is <code>NAN</code> when no
1166 keyframe was forced yet
1167 </p></dd>
1168 <dt><samp>t</samp></dt>
1169 <dd><p>the time of the current processed frame
1170 </p></dd>
1171 </dl>
1172
1173 <p>For example to force a key frame every 5 seconds, you can specify:
1174 </p><div class="example">
1175 <pre class="example">-force_key_frames expr:gte(t,n_forced*5)
1176 </pre></div>
1177
1178 <p>To force a key frame 5 seconds after the time of the last forced one,
1179 starting from second 13:
1180 </p><div class="example">
1181 <pre class="example">-force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
1182 </pre></div>
1183
1184 <p>Note that forcing too many keyframes is very harmful for the lookahead
1185 algorithms of certain encoders: using fixed-GOP options or similar
1186 would be more efficient.
1187 </p>
1188 </dd>
1189 <dt><samp>-copyinkf[:<var>stream_specifier</var>] (<em>output,per-stream</em>)</samp></dt>
1190 <dd><p>When doing stream copy, copy also non-key frames found at the
1191 beginning.
1192 </p>
1193 </dd>
1194 <dt><samp>-hwaccel[:<var>stream_specifier</var>] <var>hwaccel</var> (<em>input,per-stream</em>)</samp></dt>
1195 <dd><p>Use hardware acceleration to decode the matching stream(s). The allowed values
1196 of <var>hwaccel</var> are:
1197 </p><dl compact="compact">
1198 <dt><samp>none</samp></dt>
1199 <dd><p>Do not use any hardware acceleration (the default).
1200 </p>
1201 </dd>
1202 <dt><samp>auto</samp></dt>
1203 <dd><p>Automatically select the hardware acceleration method.
1204 </p>
1205 </dd>
1206 <dt><samp>vda</samp></dt>
1207 <dd><p>Use Apple VDA hardware acceleration.
1208 </p>
1209 </dd>
1210 <dt><samp>vdpau</samp></dt>
1211 <dd><p>Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
1212 </p>
1213 </dd>
1214 <dt><samp>dxva2</samp></dt>
1215 <dd><p>Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
1216 </p></dd>
1217 </dl>
1218
1219 <p>This option has no effect if the selected hwaccel is not available or not
1220 supported by the chosen decoder.
1221 </p>
1222 <p>Note that most acceleration methods are intended for playback and will not be
1223 faster than software decoding on modern CPUs. Additionally, <code>ffmpeg</code>
1224 will usually need to copy the decoded frames from the GPU memory into the system
1225 memory, resulting in further performance loss. This option is thus mainly
1226 useful for testing.
1227 </p>
1228 </dd>
1229 <dt><samp>-hwaccel_device[:<var>stream_specifier</var>] <var>hwaccel_device</var> (<em>input,per-stream</em>)</samp></dt>
1230 <dd><p>Select a device to use for hardware acceleration.
1231 </p>
1232 <p>This option only makes sense when the <samp>-hwaccel</samp> option is also
1233 specified. Its exact meaning depends on the specific hardware acceleration
1234 method chosen.
1235 </p>
1236 <dl compact="compact">
1237 <dt><samp>vdpau</samp></dt>
1238 <dd><p>For VDPAU, this option specifies the X11 display/screen to use. If this option
1239 is not specified, the value of the <var>DISPLAY</var> environment variable is used
1240 </p>
1241 </dd>
1242 <dt><samp>dxva2</samp></dt>
1243 <dd><p>For DXVA2, this option should contain the number of the display adapter to use.
1244 If this option is not specified, the default adapter is used.
1245 </p></dd>
1246 </dl>
1247 </dd>
1248 </dl>
1249
1250 <a name="Audio-Options"></a>
1251 <h3 class="section">5.7 Audio Options<span class="pull-right"><a class="anchor hidden-xs" href="#Audio-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Audio-Options" aria-hidden="true">TOC</a></span></h3>
1252
1253 <dl compact="compact">
1254 <dt><samp>-aframes <var>number</var> (<em>output</em>)</samp></dt>
1255 <dd><p>Set the number of audio frames to output. This is an alias for <code>-frames:a</code>.
1256 </p></dd>
1257 <dt><samp>-ar[:<var>stream_specifier</var>] <var>freq</var> (<em>input/output,per-stream</em>)</samp></dt>
1258 <dd><p>Set the audio sampling frequency. For output streams it is set by
1259 default to the frequency of the corresponding input stream. For input
1260 streams this option only makes sense for audio grabbing devices and raw
1261 demuxers and is mapped to the corresponding demuxer options.
1262 </p></dd>
1263 <dt><samp>-aq <var>q</var> (<em>output</em>)</samp></dt>
1264 <dd><p>Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
1265 </p></dd>
1266 <dt><samp>-ac[:<var>stream_specifier</var>] <var>channels</var> (<em>input/output,per-stream</em>)</samp></dt>
1267 <dd><p>Set the number of audio channels. For output streams it is set by
1268 default to the number of input audio channels. For input streams
1269 this option only makes sense for audio grabbing devices and raw demuxers
1270 and is mapped to the corresponding demuxer options.
1271 </p></dd>
1272 <dt><samp>-an (<em>output</em>)</samp></dt>
1273 <dd><p>Disable audio recording.
1274 </p></dd>
1275 <dt><samp>-acodec <var>codec</var> (<em>input/output</em>)</samp></dt>
1276 <dd><p>Set the audio codec. This is an alias for <code>-codec:a</code>.
1277 </p></dd>
1278 <dt><samp>-sample_fmt[:<var>stream_specifier</var>] <var>sample_fmt</var> (<em>output,per-stream</em>)</samp></dt>
1279 <dd><p>Set the audio sample format. Use <code>-sample_fmts</code> to get a list
1280 of supported sample formats.
1281 </p>
1282 </dd>
1283 <dt><samp>-af <var>filtergraph</var> (<em>output</em>)</samp></dt>
1284 <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
1285 filter the stream.
1286 </p>
1287 <p>This is an alias for <code>-filter:a</code>, see the <a href="#filter_005foption">-filter option</a>.
1288 </p></dd>
1289 </dl>
1290
1291 <a name="Advanced-Audio-options"></a>
1292 <h3 class="section">5.8 Advanced Audio options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Audio-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Audio-options" aria-hidden="true">TOC</a></span></h3>
1293
1294 <dl compact="compact">
1295 <dt><samp>-atag <var>fourcc/tag</var> (<em>output</em>)</samp></dt>
1296 <dd><p>Force audio tag/fourcc. This is an alias for <code>-tag:a</code>.
1297 </p></dd>
1298 <dt><samp>-absf <var>bitstream_filter</var></samp></dt>
1299 <dd><p>Deprecated, see -bsf
1300 </p></dd>
1301 <dt><samp>-guess_layout_max <var>channels</var> (<em>input,per-stream</em>)</samp></dt>
1302 <dd><p>If some input channel layout is not known, try to guess only if it
1303 corresponds to at most the specified number of channels. For example, 2
1304 tells to <code>ffmpeg</code> to recognize 1 channel as mono and 2 channels as
1305 stereo but not 6 channels as 5.1. The default is to always try to guess. Use
1306 0 to disable all guessing.
1307 </p></dd>
1308 </dl>
1309
1310 <a name="Subtitle-options"></a>
1311 <h3 class="section">5.9 Subtitle options<span class="pull-right"><a class="anchor hidden-xs" href="#Subtitle-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Subtitle-options" aria-hidden="true">TOC</a></span></h3>
1312
1313 <dl compact="compact">
1314 <dt><samp>-scodec <var>codec</var> (<em>input/output</em>)</samp></dt>
1315 <dd><p>Set the subtitle codec. This is an alias for <code>-codec:s</code>.
1316 </p></dd>
1317 <dt><samp>-sn (<em>output</em>)</samp></dt>
1318 <dd><p>Disable subtitle recording.
1319 </p></dd>
1320 <dt><samp>-sbsf <var>bitstream_filter</var></samp></dt>
1321 <dd><p>Deprecated, see -bsf
1322 </p></dd>
1323 </dl>
1324
1325 <a name="Advanced-Subtitle-options"></a>
1326 <h3 class="section">5.10 Advanced Subtitle options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Subtitle-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Subtitle-options" aria-hidden="true">TOC</a></span></h3>
1327
1328 <dl compact="compact">
1329 <dt><samp>-fix_sub_duration</samp></dt>
1330 <dd><p>Fix subtitles durations. For each subtitle, wait for the next packet in the
1331 same stream and adjust the duration of the first to avoid overlap. This is
1332 necessary with some subtitles codecs, especially DVB subtitles, because the
1333 duration in the original packet is only a rough estimate and the end is
1334 actually marked by an empty subtitle frame. Failing to use this option when
1335 necessary can result in exaggerated durations or muxing failures due to
1336 non-monotonic timestamps.
1337 </p>
1338 <p>Note that this option will delay the output of all data until the next
1339 subtitle packet is decoded: it may increase memory consumption and latency a
1340 lot.
1341 </p>
1342 </dd>
1343 <dt><samp>-canvas_size <var>size</var></samp></dt>
1344 <dd><p>Set the size of the canvas used to render subtitles.
1345 </p>
1346 </dd>
1347 </dl>
1348
1349 <a name="Advanced-options"></a>
1350 <h3 class="section">5.11 Advanced options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-options" aria-hidden="true">TOC</a></span></h3>
1351
1352 <dl compact="compact">
1353 <dt><samp>-map [-]<var>input_file_id</var>[:<var>stream_specifier</var>][,<var>sync_file_id</var>[:<var>stream_specifier</var>]] | <var>[linklabel]</var> (<em>output</em>)</samp></dt>
1354 <dd>
1355 <p>Designate one or more input streams as a source for the output file. Each input
1356 stream is identified by the input file index <var>input_file_id</var> and
1357 the input stream index <var>input_stream_id</var> within the input
1358 file. Both indices start at 0. If specified,
1359 <var>sync_file_id</var>:<var>stream_specifier</var> sets which input stream
1360 is used as a presentation sync reference.
1361 </p>
1362 <p>The first <code>-map</code> option on the command line specifies the
1363 source for output stream 0, the second <code>-map</code> option specifies
1364 the source for output stream 1, etc.
1365 </p>
1366 <p>A <code>-</code> character before the stream identifier creates a &quot;negative&quot; mapping.
1367 It disables matching streams from already created mappings.
1368 </p>
1369 <p>An alternative <var>[linklabel]</var> form will map outputs from complex filter
1370 graphs (see the <samp>-filter_complex</samp> option) to the output file.
1371 <var>linklabel</var> must correspond to a defined output link label in the graph.
1372 </p>
1373 <p>For example, to map ALL streams from the first input file to output
1374 </p><div class="example">
1375 <pre class="example">ffmpeg -i INPUT -map 0 output
1376 </pre></div>
1377
1378 <p>For example, if you have two audio streams in the first input file,
1379 these streams are identified by &quot;0:0&quot; and &quot;0:1&quot;. You can use
1380 <code>-map</code> to select which streams to place in an output file. For
1381 example:
1382 </p><div class="example">
1383 <pre class="example">ffmpeg -i INPUT -map 0:1 out.wav
1384 </pre></div>
1385 <p>will map the input stream in <samp>INPUT</samp> identified by &quot;0:1&quot; to
1386 the (single) output stream in <samp>out.wav</samp>.
1387 </p>
1388 <p>For example, to select the stream with index 2 from input file
1389 <samp>a.mov</samp> (specified by the identifier &quot;0:2&quot;), and stream with
1390 index 6 from input <samp>b.mov</samp> (specified by the identifier &quot;1:6&quot;),
1391 and copy them to the output file <samp>out.mov</samp>:
1392 </p><div class="example">
1393 <pre class="example">ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
1394 </pre></div>
1395
1396 <p>To select all video and the third audio stream from an input file:
1397 </p><div class="example">
1398 <pre class="example">ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
1399 </pre></div>
1400
1401 <p>To map all the streams except the second audio, use negative mappings
1402 </p><div class="example">
1403 <pre class="example">ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
1404 </pre></div>
1405
1406 <p>To pick the English audio stream:
1407 </p><div class="example">
1408 <pre class="example">ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
1409 </pre></div>
1410
1411 <p>Note that using this option disables the default mappings for this output file.
1412 </p>
1413 </dd>
1414 <dt><samp>-ignore_unknown</samp></dt>
1415 <dd><p>Ignore input streams with unknown type instead of failing if copying
1416 such streams is attempted.
1417 </p>
1418 </dd>
1419 <dt><samp>-copy_unknown</samp></dt>
1420 <dd><p>Allow input streams with unknown type to be copied instead of failing if copying
1421 such streams is attempted.
1422 </p>
1423 </dd>
1424 <dt><samp>-map_channel [<var>input_file_id</var>.<var>stream_specifier</var>.<var>channel_id</var>|-1][:<var>output_file_id</var>.<var>stream_specifier</var>]</samp></dt>
1425 <dd><p>Map an audio channel from a given input to an output. If
1426 <var>output_file_id</var>.<var>stream_specifier</var> is not set, the audio channel will
1427 be mapped on all the audio streams.
1428 </p>
1429 <p>Using &quot;-1&quot; instead of
1430 <var>input_file_id</var>.<var>stream_specifier</var>.<var>channel_id</var> will map a muted
1431 channel.
1432 </p>
1433 <p>For example, assuming <var>INPUT</var> is a stereo audio file, you can switch the
1434 two audio channels with the following command:
1435 </p><div class="example">
1436 <pre class="example">ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
1437 </pre></div>
1438
1439 <p>If you want to mute the first channel and keep the second:
1440 </p><div class="example">
1441 <pre class="example">ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
1442 </pre></div>
1443
1444 <p>The order of the &quot;-map_channel&quot; option specifies the order of the channels in
1445 the output stream. The output channel layout is guessed from the number of
1446 channels mapped (mono if one &quot;-map_channel&quot;, stereo if two, etc.). Using &quot;-ac&quot;
1447 in combination of &quot;-map_channel&quot; makes the channel gain levels to be updated if
1448 input and output channel layouts don&rsquo;t match (for instance two &quot;-map_channel&quot;
1449 options and &quot;-ac 6&quot;).
1450 </p>
1451 <p>You can also extract each channel of an input to specific outputs; the following
1452 command extracts two channels of the <var>INPUT</var> audio stream (file 0, stream 0)
1453 to the respective <var>OUTPUT_CH0</var> and <var>OUTPUT_CH1</var> outputs:
1454 </p><div class="example">
1455 <pre class="example">ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
1456 </pre></div>
1457
1458 <p>The following example splits the channels of a stereo input into two separate
1459 streams, which are put into the same output file:
1460 </p><div class="example">
1461 <pre class="example">ffmpeg -i stereo.wav -map 0:0 -map 0:0 -map_channel 0.0.0:0.0 -map_channel 0.0.1:0.1 -y out.ogg
1462 </pre></div>
1463
1464 <p>Note that currently each output stream can only contain channels from a single
1465 input stream; you can&rsquo;t for example use &quot;-map_channel&quot; to pick multiple input
1466 audio channels contained in different streams (from the same or different files)
1467 and merge them into a single output stream. It is therefore not currently
1468 possible, for example, to turn two separate mono streams into a single stereo
1469 stream. However splitting a stereo stream into two single channel mono streams
1470 is possible.
1471 </p>
1472 <p>If you need this feature, a possible workaround is to use the <em>amerge</em>
1473 filter. For example, if you need to merge a media (here <samp>input.mkv</samp>) with 2
1474 mono audio streams into one single stereo channel audio stream (and keep the
1475 video stream), you can use the following command:
1476 </p><div class="example">
1477 <pre class="example">ffmpeg -i input.mkv -filter_complex &quot;[0:1] [0:2] amerge&quot; -c:a pcm_s16le -c:v copy output.mkv
1478 </pre></div>
1479
1480 </dd>
1481 <dt><samp>-map_metadata[:<var>metadata_spec_out</var>] <var>infile</var>[:<var>metadata_spec_in</var>] (<em>output,per-metadata</em>)</samp></dt>
1482 <dd><p>Set metadata information of the next output file from <var>infile</var>. Note that
1483 those are file indices (zero-based), not filenames.
1484 Optional <var>metadata_spec_in/out</var> parameters specify, which metadata to copy.
1485 A metadata specifier can have the following forms:
1486 </p><dl compact="compact">
1487 <dt><samp><var>g</var></samp></dt>
1488 <dd><p>global metadata, i.e. metadata that applies to the whole file
1489 </p>
1490 </dd>
1491 <dt><samp><var>s</var>[:<var>stream_spec</var>]</samp></dt>
1492 <dd><p>per-stream metadata. <var>stream_spec</var> is a stream specifier as described
1493 in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. In an input metadata specifier, the first
1494 matching stream is copied from. In an output metadata specifier, all matching
1495 streams are copied to.
1496 </p>
1497 </dd>
1498 <dt><samp><var>c</var>:<var>chapter_index</var></samp></dt>
1499 <dd><p>per-chapter metadata. <var>chapter_index</var> is the zero-based chapter index.
1500 </p>
1501 </dd>
1502 <dt><samp><var>p</var>:<var>program_index</var></samp></dt>
1503 <dd><p>per-program metadata. <var>program_index</var> is the zero-based program index.
1504 </p></dd>
1505 </dl>
1506 <p>If metadata specifier is omitted, it defaults to global.
1507 </p>
1508 <p>By default, global metadata is copied from the first input file,
1509 per-stream and per-chapter metadata is copied along with streams/chapters. These
1510 default mappings are disabled by creating any mapping of the relevant type. A negative
1511 file index can be used to create a dummy mapping that just disables automatic copying.
1512 </p>
1513 <p>For example to copy metadata from the first stream of the input file to global metadata
1514 of the output file:
1515 </p><div class="example">
1516 <pre class="example">ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
1517 </pre></div>
1518
1519 <p>To do the reverse, i.e. copy global metadata to all audio streams:
1520 </p><div class="example">
1521 <pre class="example">ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
1522 </pre></div>
1523 <p>Note that simple <code>0</code> would work as well in this example, since global
1524 metadata is assumed by default.
1525 </p>
1526 </dd>
1527 <dt><samp>-map_chapters <var>input_file_index</var> (<em>output</em>)</samp></dt>
1528 <dd><p>Copy chapters from input file with index <var>input_file_index</var> to the next
1529 output file. If no chapter mapping is specified, then chapters are copied from
1530 the first input file with at least one chapter. Use a negative file index to
1531 disable any chapter copying.
1532 </p>
1533 </dd>
1534 <dt><samp>-benchmark (<em>global</em>)</samp></dt>
1535 <dd><p>Show benchmarking information at the end of an encode.
1536 Shows CPU time used and maximum memory consumption.
1537 Maximum memory consumption is not supported on all systems,
1538 it will usually display as 0 if not supported.
1539 </p></dd>
1540 <dt><samp>-benchmark_all (<em>global</em>)</samp></dt>
1541 <dd><p>Show benchmarking information during the encode.
1542 Shows CPU time used in various steps (audio/video encode/decode).
1543 </p></dd>
1544 <dt><samp>-timelimit <var>duration</var> (<em>global</em>)</samp></dt>
1545 <dd><p>Exit after ffmpeg has been running for <var>duration</var> seconds.
1546 </p></dd>
1547 <dt><samp>-dump (<em>global</em>)</samp></dt>
1548 <dd><p>Dump each input packet to stderr.
1549 </p></dd>
1550 <dt><samp>-hex (<em>global</em>)</samp></dt>
1551 <dd><p>When dumping packets, also dump the payload.
1552 </p></dd>
1553 <dt><samp>-re (<em>input</em>)</samp></dt>
1554 <dd><p>Read input at native frame rate. Mainly used to simulate a grab device.
1555 or live input stream (e.g. when reading from a file). Should not be used
1556 with actual grab devices or live input streams (where it can cause packet
1557 loss).
1558 By default <code>ffmpeg</code> attempts to read the input(s) as fast as possible.
1559 This option will slow down the reading of the input(s) to the native frame rate
1560 of the input(s). It is useful for real-time output (e.g. live streaming).
1561 </p></dd>
1562 <dt><samp>-loop_input</samp></dt>
1563 <dd><p>Loop over the input stream. Currently it works only for image
1564 streams. This option is used for automatic FFserver testing.
1565 This option is deprecated, use -loop 1.
1566 </p></dd>
1567 <dt><samp>-loop_output <var>number_of_times</var></samp></dt>
1568 <dd><p>Repeatedly loop output for formats that support looping such as animated GIF
1569 (0 will loop the output infinitely).
1570 This option is deprecated, use -loop.
1571 </p></dd>
1572 <dt><samp>-vsync <var>parameter</var></samp></dt>
1573 <dd><p>Video sync method.
1574 For compatibility reasons old values can be specified as numbers.
1575 Newly added values will have to be specified as strings always.
1576 </p>
1577 <dl compact="compact">
1578 <dt><samp>0, passthrough</samp></dt>
1579 <dd><p>Each frame is passed with its timestamp from the demuxer to the muxer.
1580 </p></dd>
1581 <dt><samp>1, cfr</samp></dt>
1582 <dd><p>Frames will be duplicated and dropped to achieve exactly the requested
1583 constant frame rate.
1584 </p></dd>
1585 <dt><samp>2, vfr</samp></dt>
1586 <dd><p>Frames are passed through with their timestamp or dropped so as to
1587 prevent 2 frames from having the same timestamp.
1588 </p></dd>
1589 <dt><samp>drop</samp></dt>
1590 <dd><p>As passthrough but destroys all timestamps, making the muxer generate
1591 fresh timestamps based on frame-rate.
1592 </p></dd>
1593 <dt><samp>-1, auto</samp></dt>
1594 <dd><p>Chooses between 1 and 2 depending on muxer capabilities. This is the
1595 default method.
1596 </p></dd>
1597 </dl>
1598
1599 <p>Note that the timestamps may be further modified by the muxer, after this.
1600 For example, in the case that the format option <samp>avoid_negative_ts</samp>
1601 is enabled.
1602 </p>
1603 <p>With -map you can select from which stream the timestamps should be
1604 taken. You can leave either video or audio unchanged and sync the
1605 remaining stream(s) to the unchanged one.
1606 </p>
1607 </dd>
1608 <dt><samp>-frame_drop_threshold <var>parameter</var></samp></dt>
1609 <dd><p>Frame drop threshold, which specifies how much behind video frames can
1610 be before they are dropped. In frame rate units, so 1.0 is one frame.
1611 The default is -1.1. One possible usecase is to avoid framedrops in case
1612 of noisy timestamps or to increase frame drop precision in case of exact
1613 timestamps.
1614 </p>
1615 </dd>
1616 <dt><samp>-async <var>samples_per_second</var></samp></dt>
1617 <dd><p>Audio sync method. &quot;Stretches/squeezes&quot; the audio stream to match the timestamps,
1618 the parameter is the maximum samples per second by which the audio is changed.
1619 -async 1 is a special case where only the start of the audio stream is corrected
1620 without any later correction.
1621 </p>
1622 <p>Note that the timestamps may be further modified by the muxer, after this.
1623 For example, in the case that the format option <samp>avoid_negative_ts</samp>
1624 is enabled.
1625 </p>
1626 <p>This option has been deprecated. Use the <code>aresample</code> audio filter instead.
1627 </p>
1628 </dd>
1629 <dt><samp>-copyts</samp></dt>
1630 <dd><p>Do not process input timestamps, but keep their values without trying
1631 to sanitize them. In particular, do not remove the initial start time
1632 offset value.
1633 </p>
1634 <p>Note that, depending on the <samp>vsync</samp> option or on specific muxer
1635 processing (e.g. in case the format option <samp>avoid_negative_ts</samp>
1636 is enabled) the output timestamps may mismatch with the input
1637 timestamps even when this option is selected.
1638 </p>
1639 </dd>
1640 <dt><samp>-start_at_zero</samp></dt>
1641 <dd><p>When used with <samp>copyts</samp>, shift input timestamps so they start at zero.
1642 </p>
1643 <p>This means that using e.g. <code>-ss 50</code> will make output timestamps start at
1644 50 seconds, regardless of what timestamp the input file started at.
1645 </p>
1646 </dd>
1647 <dt><samp>-copytb <var>mode</var></samp></dt>
1648 <dd><p>Specify how to set the encoder timebase when stream copying.  <var>mode</var> is an
1649 integer numeric value, and can assume one of the following values:
1650 </p>
1651 <dl compact="compact">
1652 <dt><samp>1</samp></dt>
1653 <dd><p>Use the demuxer timebase.
1654 </p>
1655 <p>The time base is copied to the output encoder from the corresponding input
1656 demuxer. This is sometimes required to avoid non monotonically increasing
1657 timestamps when copying video streams with variable frame rate.
1658 </p>
1659 </dd>
1660 <dt><samp>0</samp></dt>
1661 <dd><p>Use the decoder timebase.
1662 </p>
1663 <p>The time base is copied to the output encoder from the corresponding input
1664 decoder.
1665 </p>
1666 </dd>
1667 <dt><samp>-1</samp></dt>
1668 <dd><p>Try to make the choice automatically, in order to generate a sane output.
1669 </p></dd>
1670 </dl>
1671
1672 <p>Default value is -1.
1673 </p>
1674 </dd>
1675 <dt><samp>-shortest (<em>output</em>)</samp></dt>
1676 <dd><p>Finish encoding when the shortest input stream ends.
1677 </p></dd>
1678 <dt><samp>-dts_delta_threshold</samp></dt>
1679 <dd><p>Timestamp discontinuity delta threshold.
1680 </p></dd>
1681 <dt><samp>-muxdelay <var>seconds</var> (<em>input</em>)</samp></dt>
1682 <dd><p>Set the maximum demux-decode delay.
1683 </p></dd>
1684 <dt><samp>-muxpreload <var>seconds</var> (<em>input</em>)</samp></dt>
1685 <dd><p>Set the initial demux-decode delay.
1686 </p></dd>
1687 <dt><samp>-streamid <var>output-stream-index</var>:<var>new-value</var> (<em>output</em>)</samp></dt>
1688 <dd><p>Assign a new stream-id value to an output stream. This option should be
1689 specified prior to the output filename to which it applies.
1690 For the situation where multiple output files exist, a streamid
1691 may be reassigned to a different value.
1692 </p>
1693 <p>For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
1694 an output mpegts file:
1695 </p><div class="example">
1696 <pre class="example">ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
1697 </pre></div>
1698
1699 </dd>
1700 <dt><samp>-bsf[:<var>stream_specifier</var>] <var>bitstream_filters</var> (<em>output,per-stream</em>)</samp></dt>
1701 <dd><p>Set bitstream filters for matching streams. <var>bitstream_filters</var> is
1702 a comma-separated list of bitstream filters. Use the <code>-bsfs</code> option
1703 to get the list of bitstream filters.
1704 </p><div class="example">
1705 <pre class="example">ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
1706 </pre></div>
1707 <div class="example">
1708 <pre class="example">ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
1709 </pre></div>
1710
1711 </dd>
1712 <dt><samp>-tag[:<var>stream_specifier</var>] <var>codec_tag</var> (<em>input/output,per-stream</em>)</samp></dt>
1713 <dd><p>Force a tag/fourcc for matching streams.
1714 </p>
1715 </dd>
1716 <dt><samp>-timecode <var>hh</var>:<var>mm</var>:<var>ss</var>SEP<var>ff</var></samp></dt>
1717 <dd><p>Specify Timecode for writing. <var>SEP</var> is &rsquo;:&rsquo; for non drop timecode and &rsquo;;&rsquo;
1718 (or &rsquo;.&rsquo;) for drop.
1719 </p><div class="example">
1720 <pre class="example">ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
1721 </pre></div>
1722
1723 <a name="filter_005fcomplex_005foption"></a></dd>
1724 <dt><samp>-filter_complex <var>filtergraph</var> (<em>global</em>)</samp></dt>
1725 <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
1726 outputs. For simple graphs &ndash; those with one input and one output of the same
1727 type &ndash; see the <samp>-filter</samp> options. <var>filtergraph</var> is a description of
1728 the filtergraph, as described in the &ldquo;Filtergraph syntax&rdquo; section of the
1729 ffmpeg-filters manual.
1730 </p>
1731 <p>Input link labels must refer to input streams using the
1732 <code>[file_index:stream_specifier]</code> syntax (i.e. the same as <samp>-map</samp>
1733 uses). If <var>stream_specifier</var> matches multiple streams, the first one will be
1734 used. An unlabeled input will be connected to the first unused input stream of
1735 the matching type.
1736 </p>
1737 <p>Output link labels are referred to with <samp>-map</samp>. Unlabeled outputs are
1738 added to the first output file.
1739 </p>
1740 <p>Note that with this option it is possible to use only lavfi sources without
1741 normal input files.
1742 </p>
1743 <p>For example, to overlay an image over video
1744 </p><div class="example">
1745 <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
1746 '[out]' out.mkv
1747 </pre></div>
1748 <p>Here <code>[0:v]</code> refers to the first video stream in the first input file,
1749 which is linked to the first (main) input of the overlay filter. Similarly the
1750 first video stream in the second input is linked to the second (overlay) input
1751 of overlay.
1752 </p>
1753 <p>Assuming there is only one video stream in each input file, we can omit input
1754 labels, so the above is equivalent to
1755 </p><div class="example">
1756 <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
1757 '[out]' out.mkv
1758 </pre></div>
1759
1760 <p>Furthermore we can omit the output label and the single output from the filter
1761 graph will be added to the output file automatically, so we can simply write
1762 </p><div class="example">
1763 <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
1764 </pre></div>
1765
1766 <p>To generate 5 seconds of pure red video using lavfi <code>color</code> source:
1767 </p><div class="example">
1768 <pre class="example">ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
1769 </pre></div>
1770
1771 </dd>
1772 <dt><samp>-lavfi <var>filtergraph</var> (<em>global</em>)</samp></dt>
1773 <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
1774 outputs. Equivalent to <samp>-filter_complex</samp>.
1775 </p>
1776 </dd>
1777 <dt><samp>-filter_complex_script <var>filename</var> (<em>global</em>)</samp></dt>
1778 <dd><p>This option is similar to <samp>-filter_complex</samp>, the only difference is that
1779 its argument is the name of the file from which a complex filtergraph
1780 description is to be read.
1781 </p>
1782 </dd>
1783 <dt><samp>-accurate_seek (<em>input</em>)</samp></dt>
1784 <dd><p>This option enables or disables accurate seeking in input files with the
1785 <samp>-ss</samp> option. It is enabled by default, so seeking is accurate when
1786 transcoding. Use <samp>-noaccurate_seek</samp> to disable it, which may be useful
1787 e.g. when copying some streams and transcoding the others.
1788 </p>
1789 </dd>
1790 <dt><samp>-seek_timestamp (<em>input</em>)</samp></dt>
1791 <dd><p>This option enables or disables seeking by timestamp in input files with the
1792 <samp>-ss</samp> option. It is disabled by default. If enabled, the argument
1793 to the <samp>-ss</samp> option is considered an actual timestamp, and is not
1794 offset by the start time of the file. This matters only for files which do
1795 not start from timestamp 0, such as transport streams.
1796 </p>
1797 </dd>
1798 <dt><samp>-thread_queue_size <var>size</var> (<em>input</em>)</samp></dt>
1799 <dd><p>This option sets the maximum number of queued packets when reading from the
1800 file or device. With low latency / high rate live streams, packets may be
1801 discarded if they are not read in a timely manner; raising this value can
1802 avoid it.
1803 </p>
1804 </dd>
1805 <dt><samp>-override_ffserver (<em>global</em>)</samp></dt>
1806 <dd><p>Overrides the input specifications from <code>ffserver</code>. Using this
1807 option you can map any input stream to <code>ffserver</code> and control
1808 many aspects of the encoding from <code>ffmpeg</code>. Without this
1809 option <code>ffmpeg</code> will transmit to <code>ffserver</code> what is
1810 requested by <code>ffserver</code>.
1811 </p>
1812 <p>The option is intended for cases where features are needed that cannot be
1813 specified to <code>ffserver</code> but can be to <code>ffmpeg</code>.
1814 </p>
1815 </dd>
1816 <dt><samp>-sdp_file <var>file</var> (<em>global</em>)</samp></dt>
1817 <dd><p>Print sdp information to <var>file</var>.
1818 This allows dumping sdp information when at least one output isn&rsquo;t an
1819 rtp stream.
1820 </p>
1821 </dd>
1822 <dt><samp>-discard (<em>input</em>)</samp></dt>
1823 <dd><p>Allows discarding specific streams or frames of streams at the demuxer.
1824 Not all demuxers support this.
1825 </p>
1826 <dl compact="compact">
1827 <dt><samp>none</samp></dt>
1828 <dd><p>Discard no frame.
1829 </p>
1830 </dd>
1831 <dt><samp>default</samp></dt>
1832 <dd><p>Default, which discards no frames.
1833 </p>
1834 </dd>
1835 <dt><samp>noref</samp></dt>
1836 <dd><p>Discard all non-reference frames.
1837 </p>
1838 </dd>
1839 <dt><samp>bidir</samp></dt>
1840 <dd><p>Discard all bidirectional frames.
1841 </p>
1842 </dd>
1843 <dt><samp>nokey</samp></dt>
1844 <dd><p>Discard all frames excepts keyframes.
1845 </p>
1846 </dd>
1847 <dt><samp>all</samp></dt>
1848 <dd><p>Discard all frames.
1849 </p></dd>
1850 </dl>
1851
1852 </dd>
1853 <dt><samp>-xerror (<em>global</em>)</samp></dt>
1854 <dd><p>Stop and exit on error
1855 </p>
1856 </dd>
1857 </dl>
1858
1859 <p>As a special exception, you can use a bitmap subtitle stream as input: it
1860 will be converted into a video with the same size as the largest video in
1861 the file, or 720x576 if no video is present. Note that this is an
1862 experimental and temporary solution. It will be removed once libavfilter has
1863 proper support for subtitles.
1864 </p>
1865 <p>For example, to hardcode subtitles on top of a DVB-T recording stored in
1866 MPEG-TS format, delaying the subtitles by 1 second:
1867 </p><div class="example">
1868 <pre class="example">ffmpeg -i input.ts -filter_complex \
1869   '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
1870   -sn -map '#0x2dc' output.mkv
1871 </pre></div>
1872 <p>(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
1873 audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
1874 </p>
1875 <a name="Preset-files"></a>
1876 <h3 class="section">5.12 Preset files<span class="pull-right"><a class="anchor hidden-xs" href="#Preset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Preset-files" aria-hidden="true">TOC</a></span></h3>
1877 <p>A preset file contains a sequence of <var>option</var>=<var>value</var> pairs,
1878 one for each line, specifying a sequence of options which would be
1879 awkward to specify on the command line. Lines starting with the hash
1880 (&rsquo;#&rsquo;) character are ignored and are used to provide comments. Check
1881 the <samp>presets</samp> directory in the FFmpeg source tree for examples.
1882 </p>
1883 <p>There are two types of preset files: ffpreset and avpreset files.
1884 </p>
1885 <a name="ffpreset-files"></a>
1886 <h4 class="subsection">5.12.1 ffpreset files<span class="pull-right"><a class="anchor hidden-xs" href="#ffpreset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-ffpreset-files" aria-hidden="true">TOC</a></span></h4>
1887 <p>ffpreset files are specified with the <code>vpre</code>, <code>apre</code>,
1888 <code>spre</code>, and <code>fpre</code> options. The <code>fpre</code> option takes the
1889 filename of the preset instead of a preset name as input and can be
1890 used for any kind of codec. For the <code>vpre</code>, <code>apre</code>, and
1891 <code>spre</code> options, the options specified in a preset file are
1892 applied to the currently selected codec of the same type as the preset
1893 option.
1894 </p>
1895 <p>The argument passed to the <code>vpre</code>, <code>apre</code>, and <code>spre</code>
1896 preset options identifies the preset file to use according to the
1897 following rules:
1898 </p>
1899 <p>First ffmpeg searches for a file named <var>arg</var>.ffpreset in the
1900 directories <samp>$FFMPEG_DATADIR</samp> (if set), and <samp>$HOME/.ffmpeg</samp>, and in
1901 the datadir defined at configuration time (usually <samp>PREFIX/share/ffmpeg</samp>)
1902 or in a <samp>ffpresets</samp> folder along the executable on win32,
1903 in that order. For example, if the argument is <code>libvpx-1080p</code>, it will
1904 search for the file <samp>libvpx-1080p.ffpreset</samp>.
1905 </p>
1906 <p>If no such file is found, then ffmpeg will search for a file named
1907 <var>codec_name</var>-<var>arg</var>.ffpreset in the above-mentioned
1908 directories, where <var>codec_name</var> is the name of the codec to which
1909 the preset file options will be applied. For example, if you select
1910 the video codec with <code>-vcodec libvpx</code> and use <code>-vpre 1080p</code>,
1911 then it will search for the file <samp>libvpx-1080p.ffpreset</samp>.
1912 </p>
1913 <a name="avpreset-files"></a>
1914 <h4 class="subsection">5.12.2 avpreset files<span class="pull-right"><a class="anchor hidden-xs" href="#avpreset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-avpreset-files" aria-hidden="true">TOC</a></span></h4>
1915 <p>avpreset files are specified with the <code>pre</code> option. They work similar to
1916 ffpreset files, but they only allow encoder- specific options. Therefore, an
1917 <var>option</var>=<var>value</var> pair specifying an encoder cannot be used.
1918 </p>
1919 <p>When the <code>pre</code> option is specified, ffmpeg will look for files with the
1920 suffix .avpreset in the directories <samp>$AVCONV_DATADIR</samp> (if set), and
1921 <samp>$HOME/.avconv</samp>, and in the datadir defined at configuration time (usually
1922 <samp>PREFIX/share/ffmpeg</samp>), in that order.
1923 </p>
1924 <p>First ffmpeg searches for a file named <var>codec_name</var>-<var>arg</var>.avpreset in
1925 the above-mentioned directories, where <var>codec_name</var> is the name of the codec
1926 to which the preset file options will be applied. For example, if you select the
1927 video codec with <code>-vcodec libvpx</code> and use <code>-pre 1080p</code>, then it will
1928 search for the file <samp>libvpx-1080p.avpreset</samp>.
1929 </p>
1930 <p>If no such file is found, then ffmpeg will search for a file named
1931 <var>arg</var>.avpreset in the same directories.
1932 </p>
1933
1934 <a name="Tips"></a>
1935 <h2 class="chapter">6 Tips<span class="pull-right"><a class="anchor hidden-xs" href="#Tips" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Tips" aria-hidden="true">TOC</a></span></h2>
1936
1937 <ul>
1938 <li> For streaming at very low bitrates, use a low frame rate
1939 and a small GOP size. This is especially true for RealVideo where
1940 the Linux player does not seem to be very fast, so it can miss
1941 frames. An example is:
1942
1943 <div class="example">
1944 <pre class="example">ffmpeg -g 3 -r 3 -t 10 -b:v 50k -s qcif -f rv10 /tmp/b.rm
1945 </pre></div>
1946
1947 </li><li> The parameter &rsquo;q&rsquo; which is displayed while encoding is the current
1948 quantizer. The value 1 indicates that a very good quality could
1949 be achieved. The value 31 indicates the worst quality. If q=31 appears
1950 too often, it means that the encoder cannot compress enough to meet
1951 your bitrate. You must either increase the bitrate, decrease the
1952 frame rate or decrease the frame size.
1953
1954 </li><li> If your computer is not fast enough, you can speed up the
1955 compression at the expense of the compression ratio. You can use
1956 &rsquo;-me zero&rsquo; to speed up motion estimation, and &rsquo;-g 0&rsquo; to disable
1957 motion estimation completely (you have only I-frames, which means it
1958 is about as good as JPEG compression).
1959
1960 </li><li> To have very low audio bitrates, reduce the sampling frequency
1961 (down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
1962
1963 </li><li> To have a constant quality (but a variable bitrate), use the option
1964 &rsquo;-qscale n&rsquo; when &rsquo;n&rsquo; is between 1 (excellent quality) and 31 (worst
1965 quality).
1966
1967 </li></ul>
1968
1969 <a name="Examples"></a>
1970 <h2 class="chapter">7 Examples<span class="pull-right"><a class="anchor hidden-xs" href="#Examples" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Examples" aria-hidden="true">TOC</a></span></h2>
1971
1972 <a name="Video-and-Audio-grabbing"></a>
1973 <h3 class="section">7.1 Video and Audio grabbing<span class="pull-right"><a class="anchor hidden-xs" href="#Video-and-Audio-grabbing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-and-Audio-grabbing" aria-hidden="true">TOC</a></span></h3>
1974
1975 <p>If you specify the input format and device then ffmpeg can grab video
1976 and audio directly.
1977 </p>
1978 <div class="example">
1979 <pre class="example">ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
1980 </pre></div>
1981
1982 <p>Or with an ALSA audio source (mono input, card id 1) instead of OSS:
1983 </p><div class="example">
1984 <pre class="example">ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
1985 </pre></div>
1986
1987 <p>Note that you must activate the right video source and channel before
1988 launching ffmpeg with any TV viewer such as
1989 <a href="http://linux.bytesex.org/xawtv/">xawtv</a> by Gerd Knorr. You also
1990 have to set the audio recording levels correctly with a
1991 standard mixer.
1992 </p>
1993 <a name="X11-grabbing"></a>
1994 <h3 class="section">7.2 X11 grabbing<span class="pull-right"><a class="anchor hidden-xs" href="#X11-grabbing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-X11-grabbing" aria-hidden="true">TOC</a></span></h3>
1995
1996 <p>Grab the X11 display with ffmpeg via
1997 </p>
1998 <div class="example">
1999 <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
2000 </pre></div>
2001
2002 <p>0.0 is display.screen number of your X11 server, same as
2003 the DISPLAY environment variable.
2004 </p>
2005 <div class="example">
2006 <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
2007 </pre></div>
2008
2009 <p>0.0 is display.screen number of your X11 server, same as the DISPLAY environment
2010 variable. 10 is the x-offset and 20 the y-offset for the grabbing.
2011 </p>
2012 <a name="Video-and-Audio-file-format-conversion"></a>
2013 <h3 class="section">7.3 Video and Audio file format conversion<span class="pull-right"><a class="anchor hidden-xs" href="#Video-and-Audio-file-format-conversion" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-and-Audio-file-format-conversion" aria-hidden="true">TOC</a></span></h3>
2014
2015 <p>Any supported file format and protocol can serve as input to ffmpeg:
2016 </p>
2017 <p>Examples:
2018 </p><ul>
2019 <li> You can use YUV files as input:
2020
2021 <div class="example">
2022 <pre class="example">ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
2023 </pre></div>
2024
2025 <p>It will use the files:
2026 </p><div class="example">
2027 <pre class="example">/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
2028 /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
2029 </pre></div>
2030
2031 <p>The Y files use twice the resolution of the U and V files. They are
2032 raw files, without header. They can be generated by all decent video
2033 decoders. You must specify the size of the image with the <samp>-s</samp> option
2034 if ffmpeg cannot guess it.
2035 </p>
2036 </li><li> You can input from a raw YUV420P file:
2037
2038 <div class="example">
2039 <pre class="example">ffmpeg -i /tmp/test.yuv /tmp/out.avi
2040 </pre></div>
2041
2042 <p>test.yuv is a file containing raw YUV planar data. Each frame is composed
2043 of the Y plane followed by the U and V planes at half vertical and
2044 horizontal resolution.
2045 </p>
2046 </li><li> You can output to a raw YUV420P file:
2047
2048 <div class="example">
2049 <pre class="example">ffmpeg -i mydivx.avi hugefile.yuv
2050 </pre></div>
2051
2052 </li><li> You can set several input files and output files:
2053
2054 <div class="example">
2055 <pre class="example">ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
2056 </pre></div>
2057
2058 <p>Converts the audio file a.wav and the raw YUV video file a.yuv
2059 to MPEG file a.mpg.
2060 </p>
2061 </li><li> You can also do audio and video conversions at the same time:
2062
2063 <div class="example">
2064 <pre class="example">ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
2065 </pre></div>
2066
2067 <p>Converts a.wav to MPEG audio at 22050 Hz sample rate.
2068 </p>
2069 </li><li> You can encode to several formats at the same time and define a
2070 mapping from input stream to output streams:
2071
2072 <div class="example">
2073 <pre class="example">ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
2074 </pre></div>
2075
2076 <p>Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. &rsquo;-map
2077 file:index&rsquo; specifies which input stream is used for each output
2078 stream, in the order of the definition of output streams.
2079 </p>
2080 </li><li> You can transcode decrypted VOBs:
2081
2082 <div class="example">
2083 <pre class="example">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
2084 </pre></div>
2085
2086 <p>This is a typical DVD ripping example; the input is a VOB file, the
2087 output an AVI file with MPEG-4 video and MP3 audio. Note that in this
2088 command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
2089 GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
2090 input video. Furthermore, the audio stream is MP3-encoded so you need
2091 to enable LAME support by passing <code>--enable-libmp3lame</code> to configure.
2092 The mapping is particularly useful for DVD transcoding
2093 to get the desired audio language.
2094 </p>
2095 <p>NOTE: To see the supported input formats, use <code>ffmpeg -formats</code>.
2096 </p>
2097 </li><li> You can extract images from a video, or create a video from many images:
2098
2099 <p>For extracting images from a video:
2100 </p><div class="example">
2101 <pre class="example">ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
2102 </pre></div>
2103
2104 <p>This will extract one video frame per second from the video and will
2105 output them in files named <samp>foo-001.jpeg</samp>, <samp>foo-002.jpeg</samp>,
2106 etc. Images will be rescaled to fit the new WxH values.
2107 </p>
2108 <p>If you want to extract just a limited number of frames, you can use the
2109 above command in combination with the -vframes or -t option, or in
2110 combination with -ss to start extracting from a certain point in time.
2111 </p>
2112 <p>For creating a video from many images:
2113 </p><div class="example">
2114 <pre class="example">ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
2115 </pre></div>
2116
2117 <p>The syntax <code>foo-%03d.jpeg</code> specifies to use a decimal number
2118 composed of three digits padded with zeroes to express the sequence
2119 number. It is the same syntax supported by the C printf function, but
2120 only formats accepting a normal integer are suitable.
2121 </p>
2122 <p>When importing an image sequence, -i also supports expanding
2123 shell-like wildcard patterns (globbing) internally, by selecting the
2124 image2-specific <code>-pattern_type glob</code> option.
2125 </p>
2126 <p>For example, for creating a video from filenames matching the glob pattern
2127 <code>foo-*.jpeg</code>:
2128 </p><div class="example">
2129 <pre class="example">ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
2130 </pre></div>
2131
2132 </li><li> You can put many streams of the same type in the output:
2133
2134 <div class="example">
2135 <pre class="example">ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
2136 </pre></div>
2137
2138 <p>The resulting output file <samp>test12.nut</samp> will contain the first four streams
2139 from the input files in reverse order.
2140 </p>
2141 </li><li> To force CBR video output:
2142 <div class="example">
2143 <pre class="example">ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
2144 </pre></div>
2145
2146 </li><li> The four options lmin, lmax, mblmin and mblmax use &rsquo;lambda&rsquo; units,
2147 but you may use the QP2LAMBDA constant to easily convert from &rsquo;q&rsquo; units:
2148 <div class="example">
2149 <pre class="example">ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
2150 </pre></div>
2151
2152 </li></ul>
2153
2154
2155 <a name="See-Also"></a>
2156 <h2 class="chapter">8 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
2157
2158 <p><a href="ffmpeg-all.html">ffmpeg-all</a>,
2159 <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
2160 <a href="ffmpeg-utils.html">ffmpeg-utils</a>,
2161 <a href="ffmpeg-scaler.html">ffmpeg-scaler</a>,
2162 <a href="ffmpeg-resampler.html">ffmpeg-resampler</a>,
2163 <a href="ffmpeg-codecs.html">ffmpeg-codecs</a>,
2164 <a href="ffmpeg-bitstream-filters.html">ffmpeg-bitstream-filters</a>,
2165 <a href="ffmpeg-formats.html">ffmpeg-formats</a>,
2166 <a href="ffmpeg-devices.html">ffmpeg-devices</a>,
2167 <a href="ffmpeg-protocols.html">ffmpeg-protocols</a>,
2168 <a href="ffmpeg-filters.html">ffmpeg-filters</a>
2169 </p>
2170
2171 <a name="Authors"></a>
2172 <h2 class="chapter">9 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
2173
2174 <p>The FFmpeg developers.
2175 </p>
2176 <p>For details about the authorship, see the Git history of the project
2177 (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
2178 <code>git log</code> in the FFmpeg source directory, or browsing the
2179 online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
2180 </p>
2181 <p>Maintainers for the specific components are listed in the file
2182 <samp>MAINTAINERS</samp> in the source code tree.
2183 </p>
2184
2185
2186       <p style="font-size: small;">
2187         This document was generated using <a href="http://www.gnu.org/software/texinfo/"><em>makeinfo</em></a>.
2188       </p>
2189     </div>
2190   </body>
2191 </html>