1FFMPEG(1) FFMPEG(1)
2
3
4
6 ffmpeg - ffmpeg video converter
7
9 ffmpeg [global_options] {[input_file_options] -i input_url} ...
10 {[output_file_options] output_url} ...
11
13 ffmpeg is a very fast video and audio converter that can also grab from
14 a live audio/video source. It can also convert between arbitrary sample
15 rates and resize video on the fly with a high quality polyphase filter.
16
17 ffmpeg reads from an arbitrary number of input "files" (which can be
18 regular files, pipes, network streams, grabbing devices, etc.),
19 specified by the "-i" option, and writes to an arbitrary number of
20 output "files", which are specified by a plain output url. Anything
21 found on the command line which cannot be interpreted as an option is
22 considered to be an output url.
23
24 Each input or output url can, in principle, contain any number of
25 streams of different types (video/audio/subtitle/attachment/data). The
26 allowed number and/or types of streams may be limited by the container
27 format. Selecting which streams from which inputs will go into which
28 output is either done automatically or with the "-map" option (see the
29 Stream selection chapter).
30
31 To refer to input files in options, you must use their indices
32 (0-based). E.g. the first input file is 0, the second is 1, etc.
33 Similarly, streams within a file are referred to by their indices. E.g.
34 "2:3" refers to the fourth stream in the third input file. Also see the
35 Stream specifiers chapter.
36
37 As a general rule, options are applied to the next specified file.
38 Therefore, order is important, and you can have the same option on the
39 command line multiple times. Each occurrence is then applied to the
40 next input or output file. Exceptions from this rule are the global
41 options (e.g. verbosity level), which should be specified first.
42
43 Do not mix input and output files -- first specify all input files,
44 then all output files. Also do not mix options which belong to
45 different files. All options apply ONLY to the next input or output
46 file and are reset between files.
47
48 • To set the video bitrate of the output file to 64 kbit/s:
49
50 ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
51
52 • To force the frame rate of the output file to 24 fps:
53
54 ffmpeg -i input.avi -r 24 output.avi
55
56 • To force the frame rate of the input file (valid for raw formats
57 only) to 1 fps and the frame rate of the output file to 24 fps:
58
59 ffmpeg -r 1 -i input.m2v -r 24 output.avi
60
61 The format option may be needed for raw input files.
62
64 The transcoding process in ffmpeg for each output can be described by
65 the following diagram:
66
67 _______ ______________
68 | | | |
69 | input | demuxer | encoded data | decoder
70 | file | ---------> | packets | -----+
71 |_______| |______________| |
72 v
73 _________
74 | |
75 | decoded |
76 | frames |
77 |_________|
78 ________ ______________ |
79 | | | | |
80 | output | <-------- | encoded data | <----+
81 | file | muxer | packets | encoder
82 |________| |______________|
83
84 ffmpeg calls the libavformat library (containing demuxers) to read
85 input files and get packets containing encoded data from them. When
86 there are multiple input files, ffmpeg tries to keep them synchronized
87 by tracking lowest timestamp on any active input stream.
88
89 Encoded packets are then passed to the decoder (unless streamcopy is
90 selected for the stream, see further for a description). The decoder
91 produces uncompressed frames (raw video/PCM audio/...) which can be
92 processed further by filtering (see next section). After filtering, the
93 frames are passed to the encoder, which encodes them and outputs
94 encoded packets. Finally those are passed to the muxer, which writes
95 the encoded packets to the output file.
96
97 Filtering
98 Before encoding, ffmpeg can process raw audio and video frames using
99 filters from the libavfilter library. Several chained filters form a
100 filter graph. ffmpeg distinguishes between two types of filtergraphs:
101 simple and complex.
102
103 Simple filtergraphs
104
105 Simple filtergraphs are those that have exactly one input and output,
106 both of the same type. In the above diagram they can be represented by
107 simply inserting an additional step between decoding and encoding:
108
109 _________ ______________
110 | | | |
111 | decoded | | encoded data |
112 | frames |\ _ | packets |
113 |_________| \ /||______________|
114 \ __________ /
115 simple _\|| | / encoder
116 filtergraph | filtered |/
117 | frames |
118 |__________|
119
120 Simple filtergraphs are configured with the per-stream -filter option
121 (with -vf and -af aliases for video and audio respectively). A simple
122 filtergraph for video can look for example like this:
123
124 _______ _____________ _______ ________
125 | | | | | | | |
126 | input | ---> | deinterlace | ---> | scale | ---> | output |
127 |_______| |_____________| |_______| |________|
128
129 Note that some filters change frame properties but not frame contents.
130 E.g. the "fps" filter in the example above changes number of frames,
131 but does not touch the frame contents. Another example is the "setpts"
132 filter, which only sets timestamps and otherwise passes the frames
133 unchanged.
134
135 Complex filtergraphs
136
137 Complex filtergraphs are those which cannot be described as simply a
138 linear processing chain applied to one stream. This is the case, for
139 example, when the graph has more than one input and/or output, or when
140 output stream type is different from input. They can be represented
141 with the following diagram:
142
143 _________
144 | |
145 | input 0 |\ __________
146 |_________| \ | |
147 \ _________ /| output 0 |
148 \ | | / |__________|
149 _________ \| complex | /
150 | | | |/
151 | input 1 |---->| filter |\
152 |_________| | | \ __________
153 /| graph | \ | |
154 / | | \| output 1 |
155 _________ / |_________| |__________|
156 | | /
157 | input 2 |/
158 |_________|
159
160 Complex filtergraphs are configured with the -filter_complex option.
161 Note that this option is global, since a complex filtergraph, by its
162 nature, cannot be unambiguously associated with a single stream or
163 file.
164
165 The -lavfi option is equivalent to -filter_complex.
166
167 A trivial example of a complex filtergraph is the "overlay" filter,
168 which has two video inputs and one video output, containing one video
169 overlaid on top of the other. Its audio counterpart is the "amix"
170 filter.
171
172 Stream copy
173 Stream copy is a mode selected by supplying the "copy" parameter to the
174 -codec option. It makes ffmpeg omit the decoding and encoding step for
175 the specified stream, so it does only demuxing and muxing. It is useful
176 for changing the container format or modifying container-level
177 metadata. The diagram above will, in this case, simplify to this:
178
179 _______ ______________ ________
180 | | | | | |
181 | input | demuxer | encoded data | muxer | output |
182 | file | ---------> | packets | -------> | file |
183 |_______| |______________| |________|
184
185 Since there is no decoding or encoding, it is very fast and there is no
186 quality loss. However, it might not work in some cases because of many
187 factors. Applying filters is obviously also impossible, since filters
188 work on uncompressed data.
189
191 ffmpeg provides the "-map" option for manual control of stream
192 selection in each output file. Users can skip "-map" and let ffmpeg
193 perform automatic stream selection as described below. The "-vn / -an /
194 -sn / -dn" options can be used to skip inclusion of video, audio,
195 subtitle and data streams respectively, whether manually mapped or
196 automatically selected, except for those streams which are outputs of
197 complex filtergraphs.
198
199 Description
200 The sub-sections that follow describe the various rules that are
201 involved in stream selection. The examples that follow next show how
202 these rules are applied in practice.
203
204 While every effort is made to accurately reflect the behavior of the
205 program, FFmpeg is under continuous development and the code may have
206 changed since the time of this writing.
207
208 Automatic stream selection
209
210 In the absence of any map options for a particular output file, ffmpeg
211 inspects the output format to check which type of streams can be
212 included in it, viz. video, audio and/or subtitles. For each acceptable
213 stream type, ffmpeg will pick one stream, when available, from among
214 all the inputs.
215
216 It will select that stream based upon the following criteria:
217
218 • for video, it is the stream with the highest resolution,
219
220 • for audio, it is the stream with the most channels,
221
222 • for subtitles, it is the first subtitle stream found but there's a
223 caveat. The output format's default subtitle encoder can be either
224 text-based or image-based, and only a subtitle stream of the same
225 type will be chosen.
226
227 In the case where several streams of the same type rate equally, the
228 stream with the lowest index is chosen.
229
230 Data or attachment streams are not automatically selected and can only
231 be included using "-map".
232
233 Manual stream selection
234
235 When "-map" is used, only user-mapped streams are included in that
236 output file, with one possible exception for filtergraph outputs
237 described below.
238
239 Complex filtergraphs
240
241 If there are any complex filtergraph output streams with unlabeled
242 pads, they will be added to the first output file. This will lead to a
243 fatal error if the stream type is not supported by the output format.
244 In the absence of the map option, the inclusion of these streams leads
245 to the automatic stream selection of their types being skipped. If map
246 options are present, these filtergraph streams are included in addition
247 to the mapped streams.
248
249 Complex filtergraph output streams with labeled pads must be mapped
250 once and exactly once.
251
252 Stream handling
253
254 Stream handling is independent of stream selection, with an exception
255 for subtitles described below. Stream handling is set via the "-codec"
256 option addressed to streams within a specific output file. In
257 particular, codec options are applied by ffmpeg after the stream
258 selection process and thus do not influence the latter. If no "-codec"
259 option is specified for a stream type, ffmpeg will select the default
260 encoder registered by the output file muxer.
261
262 An exception exists for subtitles. If a subtitle encoder is specified
263 for an output file, the first subtitle stream found of any type, text
264 or image, will be included. ffmpeg does not validate if the specified
265 encoder can convert the selected stream or if the converted stream is
266 acceptable within the output format. This applies generally as well:
267 when the user sets an encoder manually, the stream selection process
268 cannot check if the encoded stream can be muxed into the output file.
269 If it cannot, ffmpeg will abort and all output files will fail to be
270 processed.
271
272 Examples
273 The following examples illustrate the behavior, quirks and limitations
274 of ffmpeg's stream selection methods.
275
276 They assume the following three input files.
277
278 input file 'A.avi'
279 stream 0: video 640x360
280 stream 1: audio 2 channels
281
282 input file 'B.mp4'
283 stream 0: video 1920x1080
284 stream 1: audio 2 channels
285 stream 2: subtitles (text)
286 stream 3: audio 5.1 channels
287 stream 4: subtitles (text)
288
289 input file 'C.mkv'
290 stream 0: video 1280x720
291 stream 1: audio 2 channels
292 stream 2: subtitles (image)
293
294 Example: automatic stream selection
295
296 ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov
297
298 There are three output files specified, and for the first two, no
299 "-map" options are set, so ffmpeg will select streams for these two
300 files automatically.
301
302 out1.mkv is a Matroska container file and accepts video, audio and
303 subtitle streams, so ffmpeg will try to select one of each type.For
304 video, it will select "stream 0" from B.mp4, which has the highest
305 resolution among all the input video streams.For audio, it will select
306 "stream 3" from B.mp4, since it has the greatest number of channels.For
307 subtitles, it will select "stream 2" from B.mp4, which is the first
308 subtitle stream from among A.avi and B.mp4.
309
310 out2.wav accepts only audio streams, so only "stream 3" from B.mp4 is
311 selected.
312
313 For out3.mov, since a "-map" option is set, no automatic stream
314 selection will occur. The "-map 1:a" option will select all audio
315 streams from the second input B.mp4. No other streams will be included
316 in this output file.
317
318 For the first two outputs, all included streams will be transcoded. The
319 encoders chosen will be the default ones registered by each output
320 format, which may not match the codec of the selected input streams.
321
322 For the third output, codec option for audio streams has been set to
323 "copy", so no decoding-filtering-encoding operations will occur, or can
324 occur. Packets of selected streams shall be conveyed from the input
325 file and muxed within the output file.
326
327 Example: automatic subtitles selection
328
329 ffmpeg -i C.mkv out1.mkv -c:s dvdsub -an out2.mkv
330
331 Although out1.mkv is a Matroska container file which accepts subtitle
332 streams, only a video and audio stream shall be selected. The subtitle
333 stream of C.mkv is image-based and the default subtitle encoder of the
334 Matroska muxer is text-based, so a transcode operation for the
335 subtitles is expected to fail and hence the stream isn't selected.
336 However, in out2.mkv, a subtitle encoder is specified in the command
337 and so, the subtitle stream is selected, in addition to the video
338 stream. The presence of "-an" disables audio stream selection for
339 out2.mkv.
340
341 Example: unlabeled filtergraph outputs
342
343 ffmpeg -i A.avi -i C.mkv -i B.mp4 -filter_complex "overlay" out1.mp4 out2.srt
344
345 A filtergraph is setup here using the "-filter_complex" option and
346 consists of a single video filter. The "overlay" filter requires
347 exactly two video inputs, but none are specified, so the first two
348 available video streams are used, those of A.avi and C.mkv. The output
349 pad of the filter has no label and so is sent to the first output file
350 out1.mp4. Due to this, automatic selection of the video stream is
351 skipped, which would have selected the stream in B.mp4. The audio
352 stream with most channels viz. "stream 3" in B.mp4, is chosen
353 automatically. No subtitle stream is chosen however, since the MP4
354 format has no default subtitle encoder registered, and the user hasn't
355 specified a subtitle encoder.
356
357 The 2nd output file, out2.srt, only accepts text-based subtitle
358 streams. So, even though the first subtitle stream available belongs to
359 C.mkv, it is image-based and hence skipped. The selected stream,
360 "stream 2" in B.mp4, is the first text-based subtitle stream.
361
362 Example: labeled filtergraph outputs
363
364 ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
365 -map '[outv]' -an out1.mp4 \
366 out2.mkv \
367 -map '[outv]' -map 1:a:0 out3.mkv
368
369 The above command will fail, as the output pad labelled "[outv]" has
370 been mapped twice. None of the output files shall be processed.
371
372 ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
373 -an out1.mp4 \
374 out2.mkv \
375 -map 1:a:0 out3.mkv
376
377 This command above will also fail as the hue filter output has a label,
378 "[outv]", and hasn't been mapped anywhere.
379
380 The command should be modified as follows,
381
382 ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0,split=2[outv1][outv2];overlay;aresample" \
383 -map '[outv1]' -an out1.mp4 \
384 out2.mkv \
385 -map '[outv2]' -map 1:a:0 out3.mkv
386
387 The video stream from B.mp4 is sent to the hue filter, whose output is
388 cloned once using the split filter, and both outputs labelled. Then a
389 copy each is mapped to the first and third output files.
390
391 The overlay filter, requiring two video inputs, uses the first two
392 unused video streams. Those are the streams from A.avi and C.mkv. The
393 overlay output isn't labelled, so it is sent to the first output file
394 out1.mp4, regardless of the presence of the "-map" option.
395
396 The aresample filter is sent the first unused audio stream, that of
397 A.avi. Since this filter output is also unlabelled, it too is mapped to
398 the first output file. The presence of "-an" only suppresses automatic
399 or manual stream selection of audio streams, not outputs sent from
400 filtergraphs. Both these mapped streams shall be ordered before the
401 mapped stream in out1.mp4.
402
403 The video, audio and subtitle streams mapped to "out2.mkv" are entirely
404 determined by automatic stream selection.
405
406 out3.mkv consists of the cloned video output from the hue filter and
407 the first audio stream from B.mp4.
408
410 All the numerical options, if not specified otherwise, accept a string
411 representing a number as input, which may be followed by one of the SI
412 unit prefixes, for example: 'K', 'M', or 'G'.
413
414 If 'i' is appended to the SI unit prefix, the complete prefix will be
415 interpreted as a unit prefix for binary multiples, which are based on
416 powers of 1024 instead of powers of 1000. Appending 'B' to the SI unit
417 prefix multiplies the value by 8. This allows using, for example: 'KB',
418 'MiB', 'G' and 'B' as number suffixes.
419
420 Options which do not take arguments are boolean options, and set the
421 corresponding value to true. They can be set to false by prefixing the
422 option name with "no". For example using "-nofoo" will set the boolean
423 option with name "foo" to false.
424
425 Stream specifiers
426 Some options are applied per-stream, e.g. bitrate or codec. Stream
427 specifiers are used to precisely specify which stream(s) a given option
428 belongs to.
429
430 A stream specifier is a string generally appended to the option name
431 and separated from it by a colon. E.g. "-codec:a:1 ac3" contains the
432 "a:1" stream specifier, which matches the second audio stream.
433 Therefore, it would select the ac3 codec for the second audio stream.
434
435 A stream specifier can match several streams, so that the option is
436 applied to all of them. E.g. the stream specifier in "-b:a 128k"
437 matches all audio streams.
438
439 An empty stream specifier matches all streams. For example, "-codec
440 copy" or "-codec: copy" would copy all the streams without reencoding.
441
442 Possible forms of stream specifiers are:
443
444 stream_index
445 Matches the stream with this index. E.g. "-threads:1 4" would set
446 the thread count for the second stream to 4. If stream_index is
447 used as an additional stream specifier (see below), then it selects
448 stream number stream_index from the matching streams. Stream
449 numbering is based on the order of the streams as detected by
450 libavformat except when a program ID is also specified. In this
451 case it is based on the ordering of the streams in the program.
452
453 stream_type[:additional_stream_specifier]
454 stream_type is one of following: 'v' or 'V' for video, 'a' for
455 audio, 's' for subtitle, 'd' for data, and 't' for attachments. 'v'
456 matches all video streams, 'V' only matches video streams which are
457 not attached pictures, video thumbnails or cover arts. If
458 additional_stream_specifier is used, then it matches streams which
459 both have this type and match the additional_stream_specifier.
460 Otherwise, it matches all streams of the specified type.
461
462 p:program_id[:additional_stream_specifier]
463 Matches streams which are in the program with the id program_id. If
464 additional_stream_specifier is used, then it matches streams which
465 both are part of the program and match the
466 additional_stream_specifier.
467
468 #stream_id or i:stream_id
469 Match the stream by stream id (e.g. PID in MPEG-TS container).
470
471 m:key[:value]
472 Matches streams with the metadata tag key having the specified
473 value. If value is not given, matches streams that contain the
474 given tag with any value.
475
476 u Matches streams with usable configuration, the codec must be
477 defined and the essential information such as video dimension or
478 audio sample rate must be present.
479
480 Note that in ffmpeg, matching by metadata will only work properly
481 for input files.
482
483 Generic options
484 These options are shared amongst the ff* tools.
485
486 -L Show license.
487
488 -h, -?, -help, --help [arg]
489 Show help. An optional parameter may be specified to print help
490 about a specific item. If no argument is specified, only basic (non
491 advanced) tool options are shown.
492
493 Possible values of arg are:
494
495 long
496 Print advanced tool options in addition to the basic tool
497 options.
498
499 full
500 Print complete list of options, including shared and private
501 options for encoders, decoders, demuxers, muxers, filters, etc.
502
503 decoder=decoder_name
504 Print detailed information about the decoder named
505 decoder_name. Use the -decoders option to get a list of all
506 decoders.
507
508 encoder=encoder_name
509 Print detailed information about the encoder named
510 encoder_name. Use the -encoders option to get a list of all
511 encoders.
512
513 demuxer=demuxer_name
514 Print detailed information about the demuxer named
515 demuxer_name. Use the -formats option to get a list of all
516 demuxers and muxers.
517
518 muxer=muxer_name
519 Print detailed information about the muxer named muxer_name.
520 Use the -formats option to get a list of all muxers and
521 demuxers.
522
523 filter=filter_name
524 Print detailed information about the filter named filter_name.
525 Use the -filters option to get a list of all filters.
526
527 bsf=bitstream_filter_name
528 Print detailed information about the bitstream filter named
529 bitstream_filter_name. Use the -bsfs option to get a list of
530 all bitstream filters.
531
532 protocol=protocol_name
533 Print detailed information about the protocol named
534 protocol_name. Use the -protocols option to get a list of all
535 protocols.
536
537 -version
538 Show version.
539
540 -buildconf
541 Show the build configuration, one option per line.
542
543 -formats
544 Show available formats (including devices).
545
546 -demuxers
547 Show available demuxers.
548
549 -muxers
550 Show available muxers.
551
552 -devices
553 Show available devices.
554
555 -codecs
556 Show all codecs known to libavcodec.
557
558 Note that the term 'codec' is used throughout this documentation as
559 a shortcut for what is more correctly called a media bitstream
560 format.
561
562 -decoders
563 Show available decoders.
564
565 -encoders
566 Show all available encoders.
567
568 -bsfs
569 Show available bitstream filters.
570
571 -protocols
572 Show available protocols.
573
574 -filters
575 Show available libavfilter filters.
576
577 -pix_fmts
578 Show available pixel formats.
579
580 -sample_fmts
581 Show available sample formats.
582
583 -layouts
584 Show channel names and standard channel layouts.
585
586 -dispositions
587 Show stream dispositions.
588
589 -colors
590 Show recognized color names.
591
592 -sources device[,opt1=val1[,opt2=val2]...]
593 Show autodetected sources of the input device. Some devices may
594 provide system-dependent source names that cannot be autodetected.
595 The returned list cannot be assumed to be always complete.
596
597 ffmpeg -sources pulse,server=192.168.0.4
598
599 -sinks device[,opt1=val1[,opt2=val2]...]
600 Show autodetected sinks of the output device. Some devices may
601 provide system-dependent sink names that cannot be autodetected.
602 The returned list cannot be assumed to be always complete.
603
604 ffmpeg -sinks pulse,server=192.168.0.4
605
606 -loglevel [flags+]loglevel | -v [flags+]loglevel
607 Set logging level and flags used by the library.
608
609 The optional flags prefix can consist of the following values:
610
611 repeat
612 Indicates that repeated log output should not be compressed to
613 the first line and the "Last message repeated n times" line
614 will be omitted.
615
616 level
617 Indicates that log output should add a "[level]" prefix to each
618 message line. This can be used as an alternative to log
619 coloring, e.g. when dumping the log to file.
620
621 Flags can also be used alone by adding a '+'/'-' prefix to
622 set/reset a single flag without affecting other flags or changing
623 loglevel. When setting both flags and loglevel, a '+' separator is
624 expected between the last flags value and before loglevel.
625
626 loglevel is a string or a number containing one of the following
627 values:
628
629 quiet, -8
630 Show nothing at all; be silent.
631
632 panic, 0
633 Only show fatal errors which could lead the process to crash,
634 such as an assertion failure. This is not currently used for
635 anything.
636
637 fatal, 8
638 Only show fatal errors. These are errors after which the
639 process absolutely cannot continue.
640
641 error, 16
642 Show all errors, including ones which can be recovered from.
643
644 warning, 24
645 Show all warnings and errors. Any message related to possibly
646 incorrect or unexpected events will be shown.
647
648 info, 32
649 Show informative messages during processing. This is in
650 addition to warnings and errors. This is the default value.
651
652 verbose, 40
653 Same as "info", except more verbose.
654
655 debug, 48
656 Show everything, including debugging information.
657
658 trace, 56
659
660 For example to enable repeated log output, add the "level" prefix,
661 and set loglevel to "verbose":
662
663 ffmpeg -loglevel repeat+level+verbose -i input output
664
665 Another example that enables repeated log output without affecting
666 current state of "level" prefix flag or loglevel:
667
668 ffmpeg [...] -loglevel +repeat
669
670 By default the program logs to stderr. If coloring is supported by
671 the terminal, colors are used to mark errors and warnings. Log
672 coloring can be disabled setting the environment variable
673 AV_LOG_FORCE_NOCOLOR, or can be forced setting the environment
674 variable AV_LOG_FORCE_COLOR.
675
676 -report
677 Dump full command line and log output to a file named
678 "program-YYYYMMDD-HHMMSS.log" in the current directory. This file
679 can be useful for bug reports. It also implies "-loglevel debug".
680
681 Setting the environment variable FFREPORT to any value has the same
682 effect. If the value is a ':'-separated key=value sequence, these
683 options will affect the report; option values must be escaped if
684 they contain special characters or the options delimiter ':' (see
685 the ``Quoting and escaping'' section in the ffmpeg-utils manual).
686
687 The following options are recognized:
688
689 file
690 set the file name to use for the report; %p is expanded to the
691 name of the program, %t is expanded to a timestamp, "%%" is
692 expanded to a plain "%"
693
694 level
695 set the log verbosity level using a numerical value (see
696 "-loglevel").
697
698 For example, to output a report to a file named ffreport.log using
699 a log level of 32 (alias for log level "info"):
700
701 FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
702
703 Errors in parsing the environment variable are not fatal, and will
704 not appear in the report.
705
706 -hide_banner
707 Suppress printing banner.
708
709 All FFmpeg tools will normally show a copyright notice, build
710 options and library versions. This option can be used to suppress
711 printing this information.
712
713 -cpuflags flags (global)
714 Allows setting and clearing cpu flags. This option is intended for
715 testing. Do not use it unless you know what you're doing.
716
717 ffmpeg -cpuflags -sse+mmx ...
718 ffmpeg -cpuflags mmx ...
719 ffmpeg -cpuflags 0 ...
720
721 Possible flags for this option are:
722
723 x86
724 mmx
725 mmxext
726 sse
727 sse2
728 sse2slow
729 sse3
730 sse3slow
731 ssse3
732 atom
733 sse4.1
734 sse4.2
735 avx
736 avx2
737 xop
738 fma3
739 fma4
740 3dnow
741 3dnowext
742 bmi1
743 bmi2
744 cmov
745 ARM
746 armv5te
747 armv6
748 armv6t2
749 vfp
750 vfpv3
751 neon
752 setend
753 AArch64
754 armv8
755 vfp
756 neon
757 PowerPC
758 altivec
759 Specific Processors
760 pentium2
761 pentium3
762 pentium4
763 k6
764 k62
765 athlon
766 athlonxp
767 k8
768 -cpucount count (global)
769 Override detection of CPU count. This option is intended for
770 testing. Do not use it unless you know what you're doing.
771
772 ffmpeg -cpucount 2
773
774 -max_alloc bytes
775 Set the maximum size limit for allocating a block on the heap by
776 ffmpeg's family of malloc functions. Exercise extreme caution when
777 using this option. Don't use if you do not understand the full
778 consequence of doing so. Default is INT_MAX.
779
780 AVOptions
781 These options are provided directly by the libavformat, libavdevice and
782 libavcodec libraries. To see the list of available AVOptions, use the
783 -help option. They are separated into two categories:
784
785 generic
786 These options can be set for any container, codec or device.
787 Generic options are listed under AVFormatContext options for
788 containers/devices and under AVCodecContext options for codecs.
789
790 private
791 These options are specific to the given container, device or codec.
792 Private options are listed under their corresponding
793 containers/devices/codecs.
794
795 For example to write an ID3v2.3 header instead of a default ID3v2.4 to
796 an MP3 file, use the id3v2_version private option of the MP3 muxer:
797
798 ffmpeg -i input.flac -id3v2_version 3 out.mp3
799
800 All codec AVOptions are per-stream, and thus a stream specifier should
801 be attached to them:
802
803 ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4
804
805 In the above example, a multichannel audio stream is mapped twice for
806 output. The first instance is encoded with codec ac3 and bitrate 640k.
807 The second instance is downmixed to 2 channels and encoded with codec
808 aac. A bitrate of 128k is specified for it using absolute index of the
809 output stream.
810
811 Note: the -nooption syntax cannot be used for boolean AVOptions, use
812 -option 0/-option 1.
813
814 Note: the old undocumented way of specifying per-stream AVOptions by
815 prepending v/a/s to the options name is now obsolete and will be
816 removed soon.
817
818 Main options
819 -f fmt (input/output)
820 Force input or output file format. The format is normally auto
821 detected for input files and guessed from the file extension for
822 output files, so this option is not needed in most cases.
823
824 -i url (input)
825 input file url
826
827 -y (global)
828 Overwrite output files without asking.
829
830 -n (global)
831 Do not overwrite output files, and exit immediately if a specified
832 output file already exists.
833
834 -stream_loop number (input)
835 Set number of times input stream shall be looped. Loop 0 means no
836 loop, loop -1 means infinite loop.
837
838 -recast_media (global)
839 Allow forcing a decoder of a different media type than the one
840 detected or designated by the demuxer. Useful for decoding media
841 data muxed as data streams.
842
843 -c[:stream_specifier] codec (input/output,per-stream)
844 -codec[:stream_specifier] codec (input/output,per-stream)
845 Select an encoder (when used before an output file) or a decoder
846 (when used before an input file) for one or more streams. codec is
847 the name of a decoder/encoder or a special value "copy" (output
848 only) to indicate that the stream is not to be re-encoded.
849
850 For example
851
852 ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
853
854 encodes all video streams with libx264 and copies all audio
855 streams.
856
857 For each stream, the last matching "c" option is applied, so
858
859 ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
860
861 will copy all the streams except the second video, which will be
862 encoded with libx264, and the 138th audio, which will be encoded
863 with libvorbis.
864
865 -t duration (input/output)
866 When used as an input option (before "-i"), limit the duration of
867 data read from the input file.
868
869 When used as an output option (before an output url), stop writing
870 the output after its duration reaches duration.
871
872 duration must be a time duration specification, see the Time
873 duration section in the ffmpeg-utils(1) manual.
874
875 -to and -t are mutually exclusive and -t has priority.
876
877 -to position (input/output)
878 Stop writing the output or reading the input at position. position
879 must be a time duration specification, see the Time duration
880 section in the ffmpeg-utils(1) manual.
881
882 -to and -t are mutually exclusive and -t has priority.
883
884 -fs limit_size (output)
885 Set the file size limit, expressed in bytes. No further chunk of
886 bytes is written after the limit is exceeded. The size of the
887 output file is slightly more than the requested file size.
888
889 -ss position (input/output)
890 When used as an input option (before "-i"), seeks in this input
891 file to position. Note that in most formats it is not possible to
892 seek exactly, so ffmpeg will seek to the closest seek point before
893 position. When transcoding and -accurate_seek is enabled (the
894 default), this extra segment between the seek point and position
895 will be decoded and discarded. When doing stream copy or when
896 -noaccurate_seek is used, it will be preserved.
897
898 When used as an output option (before an output url), decodes but
899 discards input until the timestamps reach position.
900
901 position must be a time duration specification, see the Time
902 duration section in the ffmpeg-utils(1) manual.
903
904 -sseof position (input)
905 Like the "-ss" option but relative to the "end of file". That is
906 negative values are earlier in the file, 0 is at EOF.
907
908 -isync input_index (input)
909 Assign an input as a sync source.
910
911 This will take the difference between the start times of the target
912 and reference inputs and offset the timestamps of the target file
913 by that difference. The source timestamps of the two inputs should
914 derive from the same clock source for expected results. If "copyts"
915 is set then "start_at_zero" must also be set. If either of the
916 inputs has no starting timestamp then no sync adjustment is made.
917
918 Acceptable values are those that refer to a valid ffmpeg input
919 index. If the sync reference is the target index itself or -1, then
920 no adjustment is made to target timestamps. A sync reference may
921 not itself be synced to any other input.
922
923 Default value is -1.
924
925 -itsoffset offset (input)
926 Set the input time offset.
927
928 offset must be a time duration specification, see the Time duration
929 section in the ffmpeg-utils(1) manual.
930
931 The offset is added to the timestamps of the input files.
932 Specifying a positive offset means that the corresponding streams
933 are delayed by the time duration specified in offset.
934
935 -itsscale scale (input,per-stream)
936 Rescale input timestamps. scale should be a floating point number.
937
938 -timestamp date (output)
939 Set the recording timestamp in the container.
940
941 date must be a date specification, see the Date section in the
942 ffmpeg-utils(1) manual.
943
944 -metadata[:metadata_specifier] key=value (output,per-metadata)
945 Set a metadata key/value pair.
946
947 An optional metadata_specifier may be given to set metadata on
948 streams, chapters or programs. See "-map_metadata" documentation
949 for details.
950
951 This option overrides metadata set with "-map_metadata". It is also
952 possible to delete metadata by using an empty value.
953
954 For example, for setting the title in the output file:
955
956 ffmpeg -i in.avi -metadata title="my title" out.flv
957
958 To set the language of the first audio stream:
959
960 ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
961
962 -disposition[:stream_specifier] value (output,per-stream)
963 Sets the disposition for a stream.
964
965 By default, the disposition is copied from the input stream, unless
966 the output stream this option applies to is fed by a complex
967 filtergraph - in that case the disposition is unset by default.
968
969 value is a sequence of items separated by '+' or '-'. The first
970 item may also be prefixed with '+' or '-', in which case this
971 option modifies the default value. Otherwise (the first item is not
972 prefixed) this options overrides the default value. A '+' prefix
973 adds the given disposition, '-' removes it. It is also possible to
974 clear the disposition by setting it to 0.
975
976 If no "-disposition" options were specified for an output file,
977 ffmpeg will automatically set the 'default' disposition on the
978 first stream of each type, when there are multiple streams of this
979 type in the output file and no stream of that type is already
980 marked as default.
981
982 The "-dispositions" option lists the known dispositions.
983
984 For example, to make the second audio stream the default stream:
985
986 ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv
987
988 To make the second subtitle stream the default stream and remove
989 the default disposition from the first subtitle stream:
990
991 ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv
992
993 To add an embedded cover/thumbnail:
994
995 ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
996
997 Not all muxers support embedded thumbnails, and those who do, only
998 support a few formats, like JPEG or PNG.
999
1000 -program
1001 [title=title:][program_num=program_num:]st=stream[:st=stream...]
1002 (output)
1003 Creates a program with the specified title, program_num and adds
1004 the specified stream(s) to it.
1005
1006 -target type (output)
1007 Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50"). type
1008 may be prefixed with "pal-", "ntsc-" or "film-" to use the
1009 corresponding standard. All the format options (bitrate, codecs,
1010 buffer sizes) are then set automatically. You can just type:
1011
1012 ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
1013
1014 Nevertheless you can specify additional options as long as you know
1015 they do not conflict with the standard, as in:
1016
1017 ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
1018
1019 The parameters set for each target are as follows.
1020
1021 VCD
1022
1023 <pal>:
1024 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1025 -s 352x288 -r 25
1026 -codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
1027 -ar 44100 -ac 2
1028 -codec:a mp2 -b:a 224k
1029
1030 <ntsc>:
1031 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1032 -s 352x240 -r 30000/1001
1033 -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
1034 -ar 44100 -ac 2
1035 -codec:a mp2 -b:a 224k
1036
1037 <film>:
1038 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1039 -s 352x240 -r 24000/1001
1040 -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
1041 -ar 44100 -ac 2
1042 -codec:a mp2 -b:a 224k
1043
1044 SVCD
1045
1046 <pal>:
1047 -f svcd -packetsize 2324
1048 -s 480x576 -pix_fmt yuv420p -r 25
1049 -codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1050 -ar 44100
1051 -codec:a mp2 -b:a 224k
1052
1053 <ntsc>:
1054 -f svcd -packetsize 2324
1055 -s 480x480 -pix_fmt yuv420p -r 30000/1001
1056 -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1057 -ar 44100
1058 -codec:a mp2 -b:a 224k
1059
1060 <film>:
1061 -f svcd -packetsize 2324
1062 -s 480x480 -pix_fmt yuv420p -r 24000/1001
1063 -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1064 -ar 44100
1065 -codec:a mp2 -b:a 224k
1066
1067 DVD
1068
1069 <pal>:
1070 -f dvd -muxrate 10080k -packetsize 2048
1071 -s 720x576 -pix_fmt yuv420p -r 25
1072 -codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1073 -ar 48000
1074 -codec:a ac3 -b:a 448k
1075
1076 <ntsc>:
1077 -f dvd -muxrate 10080k -packetsize 2048
1078 -s 720x480 -pix_fmt yuv420p -r 30000/1001
1079 -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1080 -ar 48000
1081 -codec:a ac3 -b:a 448k
1082
1083 <film>:
1084 -f dvd -muxrate 10080k -packetsize 2048
1085 -s 720x480 -pix_fmt yuv420p -r 24000/1001
1086 -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1087 -ar 48000
1088 -codec:a ac3 -b:a 448k
1089
1090 DV
1091
1092 <pal>:
1093 -f dv
1094 -s 720x576 -pix_fmt yuv420p -r 25
1095 -ar 48000 -ac 2
1096
1097 <ntsc>:
1098 -f dv
1099 -s 720x480 -pix_fmt yuv411p -r 30000/1001
1100 -ar 48000 -ac 2
1101
1102 <film>:
1103 -f dv
1104 -s 720x480 -pix_fmt yuv411p -r 24000/1001
1105 -ar 48000 -ac 2
1106
1107 The "dv50" target is identical to the "dv" target except that the
1108 pixel format set is "yuv422p" for all three standards.
1109
1110 Any user-set value for a parameter above will override the target
1111 preset value. In that case, the output may not comply with the
1112 target standard.
1113
1114 -dn (input/output)
1115 As an input option, blocks all data streams of a file from being
1116 filtered or being automatically selected or mapped for any output.
1117 See "-discard" option to disable streams individually.
1118
1119 As an output option, disables data recording i.e. automatic
1120 selection or mapping of any data stream. For full manual control
1121 see the "-map" option.
1122
1123 -dframes number (output)
1124 Set the number of data frames to output. This is an obsolete alias
1125 for "-frames:d", which you should use instead.
1126
1127 -frames[:stream_specifier] framecount (output,per-stream)
1128 Stop writing to the stream after framecount frames.
1129
1130 -q[:stream_specifier] q (output,per-stream)
1131 -qscale[:stream_specifier] q (output,per-stream)
1132 Use fixed quality scale (VBR). The meaning of q/qscale is codec-
1133 dependent. If qscale is used without a stream_specifier then it
1134 applies only to the video stream, this is to maintain compatibility
1135 with previous behavior and as specifying the same codec specific
1136 value to 2 different codecs that is audio and video generally is
1137 not what is intended when no stream_specifier is used.
1138
1139 -filter[:stream_specifier] filtergraph (output,per-stream)
1140 Create the filtergraph specified by filtergraph and use it to
1141 filter the stream.
1142
1143 filtergraph is a description of the filtergraph to apply to the
1144 stream, and must have a single input and a single output of the
1145 same type of the stream. In the filtergraph, the input is
1146 associated to the label "in", and the output to the label "out".
1147 See the ffmpeg-filters manual for more information about the
1148 filtergraph syntax.
1149
1150 See the -filter_complex option if you want to create filtergraphs
1151 with multiple inputs and/or outputs.
1152
1153 -filter_script[:stream_specifier] filename (output,per-stream)
1154 This option is similar to -filter, the only difference is that its
1155 argument is the name of the file from which a filtergraph
1156 description is to be read.
1157
1158 -reinit_filter[:stream_specifier] integer (input,per-stream)
1159 This boolean option determines if the filtergraph(s) to which this
1160 stream is fed gets reinitialized when input frame parameters change
1161 mid-stream. This option is enabled by default as most video and all
1162 audio filters cannot handle deviation in input frame properties.
1163 Upon reinitialization, existing filter state is lost, like e.g. the
1164 frame count "n" reference available in some filters. Any frames
1165 buffered at time of reinitialization are lost. The properties
1166 where a change triggers reinitialization are, for video, frame
1167 resolution or pixel format; for audio, sample format, sample rate,
1168 channel count or channel layout.
1169
1170 -filter_threads nb_threads (global)
1171 Defines how many threads are used to process a filter pipeline.
1172 Each pipeline will produce a thread pool with this many threads
1173 available for parallel processing. The default is the number of
1174 available CPUs.
1175
1176 -pre[:stream_specifier] preset_name (output,per-stream)
1177 Specify the preset for matching stream(s).
1178
1179 -stats (global)
1180 Print encoding progress/statistics. It is on by default, to
1181 explicitly disable it you need to specify "-nostats".
1182
1183 -stats_period time (global)
1184 Set period at which encoding progress/statistics are updated.
1185 Default is 0.5 seconds.
1186
1187 -progress url (global)
1188 Send program-friendly progress information to url.
1189
1190 Progress information is written periodically and at the end of the
1191 encoding process. It is made of "key=value" lines. key consists of
1192 only alphanumeric characters. The last key of a sequence of
1193 progress information is always "progress".
1194
1195 The update period is set using "-stats_period".
1196
1197 -stdin
1198 Enable interaction on standard input. On by default unless standard
1199 input is used as an input. To explicitly disable interaction you
1200 need to specify "-nostdin".
1201
1202 Disabling interaction on standard input is useful, for example, if
1203 ffmpeg is in the background process group. Roughly the same result
1204 can be achieved with "ffmpeg ... < /dev/null" but it requires a
1205 shell.
1206
1207 -debug_ts (global)
1208 Print timestamp information. It is off by default. This option is
1209 mostly useful for testing and debugging purposes, and the output
1210 format may change from one version to another, so it should not be
1211 employed by portable scripts.
1212
1213 See also the option "-fdebug ts".
1214
1215 -attach filename (output)
1216 Add an attachment to the output file. This is supported by a few
1217 formats like Matroska for e.g. fonts used in rendering subtitles.
1218 Attachments are implemented as a specific type of stream, so this
1219 option will add a new stream to the file. It is then possible to
1220 use per-stream options on this stream in the usual way. Attachment
1221 streams created with this option will be created after all the
1222 other streams (i.e. those created with "-map" or automatic
1223 mappings).
1224
1225 Note that for Matroska you also have to set the mimetype metadata
1226 tag:
1227
1228 ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
1229
1230 (assuming that the attachment stream will be third in the output
1231 file).
1232
1233 -dump_attachment[:stream_specifier] filename (input,per-stream)
1234 Extract the matching attachment stream into a file named filename.
1235 If filename is empty, then the value of the "filename" metadata tag
1236 will be used.
1237
1238 E.g. to extract the first attachment to a file named 'out.ttf':
1239
1240 ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
1241
1242 To extract all attachments to files determined by the "filename"
1243 tag:
1244
1245 ffmpeg -dump_attachment:t "" -i INPUT
1246
1247 Technical note -- attachments are implemented as codec extradata,
1248 so this option can actually be used to extract extradata from any
1249 stream, not just attachments.
1250
1251 Video Options
1252 -vframes number (output)
1253 Set the number of video frames to output. This is an obsolete alias
1254 for "-frames:v", which you should use instead.
1255
1256 -r[:stream_specifier] fps (input/output,per-stream)
1257 Set frame rate (Hz value, fraction or abbreviation).
1258
1259 As an input option, ignore any timestamps stored in the file and
1260 instead generate timestamps assuming constant frame rate fps. This
1261 is not the same as the -framerate option used for some input
1262 formats like image2 or v4l2 (it used to be the same in older
1263 versions of FFmpeg). If in doubt use -framerate instead of the
1264 input option -r.
1265
1266 As an output option, duplicate or drop input frames to achieve
1267 constant output frame rate fps.
1268
1269 -fpsmax[:stream_specifier] fps (output,per-stream)
1270 Set maximum frame rate (Hz value, fraction or abbreviation).
1271
1272 Clamps output frame rate when output framerate is auto-set and is
1273 higher than this value. Useful in batch processing or when input
1274 framerate is wrongly detected as very high. It cannot be set
1275 together with "-r". It is ignored during streamcopy.
1276
1277 -s[:stream_specifier] size (input/output,per-stream)
1278 Set frame size.
1279
1280 As an input option, this is a shortcut for the video_size private
1281 option, recognized by some demuxers for which the frame size is
1282 either not stored in the file or is configurable -- e.g. raw video
1283 or video grabbers.
1284
1285 As an output option, this inserts the "scale" video filter to the
1286 end of the corresponding filtergraph. Please use the "scale" filter
1287 directly to insert it at the beginning or some other place.
1288
1289 The format is wxh (default - same as source).
1290
1291 -aspect[:stream_specifier] aspect (output,per-stream)
1292 Set the video display aspect ratio specified by aspect.
1293
1294 aspect can be a floating point number string, or a string of the
1295 form num:den, where num and den are the numerator and denominator
1296 of the aspect ratio. For example "4:3", "16:9", "1.3333", and
1297 "1.7777" are valid argument values.
1298
1299 If used together with -vcodec copy, it will affect the aspect ratio
1300 stored at container level, but not the aspect ratio stored in
1301 encoded frames, if it exists.
1302
1303 -vn (input/output)
1304 As an input option, blocks all video streams of a file from being
1305 filtered or being automatically selected or mapped for any output.
1306 See "-discard" option to disable streams individually.
1307
1308 As an output option, disables video recording i.e. automatic
1309 selection or mapping of any video stream. For full manual control
1310 see the "-map" option.
1311
1312 -vcodec codec (output)
1313 Set the video codec. This is an alias for "-codec:v".
1314
1315 -pass[:stream_specifier] n (output,per-stream)
1316 Select the pass number (1 or 2). It is used to do two-pass video
1317 encoding. The statistics of the video are recorded in the first
1318 pass into a log file (see also the option -passlogfile), and in the
1319 second pass that log file is used to generate the video at the
1320 exact requested bitrate. On pass 1, you may just deactivate audio
1321 and set output to null, examples for Windows and Unix:
1322
1323 ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
1324 ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
1325
1326 -passlogfile[:stream_specifier] prefix (output,per-stream)
1327 Set two-pass log file name prefix to prefix, the default file name
1328 prefix is ``ffmpeg2pass''. The complete file name will be
1329 PREFIX-N.log, where N is a number specific to the output stream
1330
1331 -vf filtergraph (output)
1332 Create the filtergraph specified by filtergraph and use it to
1333 filter the stream.
1334
1335 This is an alias for "-filter:v", see the -filter option.
1336
1337 -autorotate
1338 Automatically rotate the video according to file metadata. Enabled
1339 by default, use -noautorotate to disable it.
1340
1341 -autoscale
1342 Automatically scale the video according to the resolution of first
1343 frame. Enabled by default, use -noautoscale to disable it. When
1344 autoscale is disabled, all output frames of filter graph might not
1345 be in the same resolution and may be inadequate for some
1346 encoder/muxer. Therefore, it is not recommended to disable it
1347 unless you really know what you are doing. Disable autoscale at
1348 your own risk.
1349
1350 Advanced Video options
1351 -pix_fmt[:stream_specifier] format (input/output,per-stream)
1352 Set pixel format. Use "-pix_fmts" to show all the supported pixel
1353 formats. If the selected pixel format can not be selected, ffmpeg
1354 will print a warning and select the best pixel format supported by
1355 the encoder. If pix_fmt is prefixed by a "+", ffmpeg will exit
1356 with an error if the requested pixel format can not be selected,
1357 and automatic conversions inside filtergraphs are disabled. If
1358 pix_fmt is a single "+", ffmpeg selects the same pixel format as
1359 the input (or graph output) and automatic conversions are disabled.
1360
1361 -sws_flags flags (input/output)
1362 Set SwScaler flags.
1363
1364 -rc_override[:stream_specifier] override (output,per-stream)
1365 Rate control override for specific intervals, formatted as
1366 "int,int,int" list separated with slashes. Two first values are the
1367 beginning and end frame numbers, last one is quantizer to use if
1368 positive, or quality factor if negative.
1369
1370 -ilme
1371 Force interlacing support in encoder (MPEG-2 and MPEG-4 only). Use
1372 this option if your input file is interlaced and you want to keep
1373 the interlaced format for minimum losses. The alternative is to
1374 deinterlace the input stream by use of a filter such as "yadif" or
1375 "bwdif", but deinterlacing introduces losses.
1376
1377 -psnr
1378 Calculate PSNR of compressed frames.
1379
1380 -vstats
1381 Dump video coding statistics to vstats_HHMMSS.log.
1382
1383 -vstats_file file
1384 Dump video coding statistics to file.
1385
1386 -vstats_version file
1387 Specifies which version of the vstats format to use. Default is 2.
1388
1389 version = 1 :
1390
1391 "frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time=
1392 %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s"
1393
1394 version > 1:
1395
1396 "out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d
1397 s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s"
1398
1399 -top[:stream_specifier] n (output,per-stream)
1400 top=1/bottom=0/auto=-1 field first
1401
1402 -dc precision
1403 Intra_dc_precision.
1404
1405 -vtag fourcc/tag (output)
1406 Force video tag/fourcc. This is an alias for "-tag:v".
1407
1408 -qphist (global)
1409 Show QP histogram
1410
1411 -vbsf bitstream_filter
1412 Deprecated see -bsf
1413
1414 -force_key_frames[:stream_specifier] time[,time...] (output,per-stream)
1415 -force_key_frames[:stream_specifier] expr:expr (output,per-stream)
1416 -force_key_frames[:stream_specifier] source (output,per-stream)
1417 -force_key_frames[:stream_specifier] source_no_drop (output,per-stream)
1418 force_key_frames can take arguments of the following form:
1419
1420 time[,time...]
1421 If the argument consists of timestamps, ffmpeg will round the
1422 specified times to the nearest output timestamp as per the
1423 encoder time base and force a keyframe at the first frame
1424 having timestamp equal or greater than the computed timestamp.
1425 Note that if the encoder time base is too coarse, then the
1426 keyframes may be forced on frames with timestamps lower than
1427 the specified time. The default encoder time base is the
1428 inverse of the output framerate but may be set otherwise via
1429 "-enc_time_base".
1430
1431 If one of the times is ""chapters"[delta]", it is expanded into
1432 the time of the beginning of all chapters in the file, shifted
1433 by delta, expressed as a time in seconds. This option can be
1434 useful to ensure that a seek point is present at a chapter mark
1435 or any other designated place in the output file.
1436
1437 For example, to insert a key frame at 5 minutes, plus key
1438 frames 0.1 second before the beginning of every chapter:
1439
1440 -force_key_frames 0:05:00,chapters-0.1
1441
1442 expr:expr
1443 If the argument is prefixed with "expr:", the string expr is
1444 interpreted like an expression and is evaluated for each frame.
1445 A key frame is forced in case the evaluation is non-zero.
1446
1447 The expression in expr can contain the following constants:
1448
1449 n the number of current processed frame, starting from 0
1450
1451 n_forced
1452 the number of forced frames
1453
1454 prev_forced_n
1455 the number of the previous forced frame, it is "NAN" when
1456 no keyframe was forced yet
1457
1458 prev_forced_t
1459 the time of the previous forced frame, it is "NAN" when no
1460 keyframe was forced yet
1461
1462 t the time of the current processed frame
1463
1464 For example to force a key frame every 5 seconds, you can
1465 specify:
1466
1467 -force_key_frames expr:gte(t,n_forced*5)
1468
1469 To force a key frame 5 seconds after the time of the last
1470 forced one, starting from second 13:
1471
1472 -force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
1473
1474 source
1475 If the argument is "source", ffmpeg will force a key frame if
1476 the current frame being encoded is marked as a key frame in its
1477 source.
1478
1479 source_no_drop
1480 If the argument is "source_no_drop", ffmpeg will force a key
1481 frame if the current frame being encoded is marked as a key
1482 frame in its source. In cases where this particular source
1483 frame has to be dropped, enforce the next available frame to
1484 become a key frame instead.
1485
1486 Note that forcing too many keyframes is very harmful for the
1487 lookahead algorithms of certain encoders: using fixed-GOP options
1488 or similar would be more efficient.
1489
1490 -copyinkf[:stream_specifier] (output,per-stream)
1491 When doing stream copy, copy also non-key frames found at the
1492 beginning.
1493
1494 -init_hw_device type[=name][:device[,key=value...]]
1495 Initialise a new hardware device of type type called name, using
1496 the given device parameters. If no name is specified it will
1497 receive a default name of the form "type%d".
1498
1499 The meaning of device and the following arguments depends on the
1500 device type:
1501
1502 cuda
1503 device is the number of the CUDA device.
1504
1505 The following options are recognized:
1506
1507 primary_ctx
1508 If set to 1, uses the primary device context instead of
1509 creating a new one.
1510
1511 Examples:
1512
1513 -init_hw_device cuda:1
1514 Choose the second device on the system.
1515
1516 -init_hw_device cuda:0,primary_ctx=1
1517 Choose the first device and use the primary device context.
1518
1519 dxva2
1520 device is the number of the Direct3D 9 display adapter.
1521
1522 d3d11va
1523 device is the number of the Direct3D 11 display adapter.
1524
1525 vaapi
1526 device is either an X11 display name or a DRM render node. If
1527 not specified, it will attempt to open the default X11 display
1528 ($DISPLAY) and then the first DRM render node
1529 (/dev/dri/renderD128).
1530
1531 vdpau
1532 device is an X11 display name. If not specified, it will
1533 attempt to open the default X11 display ($DISPLAY).
1534
1535 qsv device selects a value in MFX_IMPL_*. Allowed values are:
1536
1537 auto
1538 sw
1539 hw
1540 auto_any
1541 hw_any
1542 hw2
1543 hw3
1544 hw4
1545
1546 If not specified, auto_any is used. (Note that it may be
1547 easier to achieve the desired result for QSV by creating the
1548 platform-appropriate subdevice (dxva2 or d3d11va or vaapi) and
1549 then deriving a QSV device from that.)
1550
1551 Alternatively, child_device_type helps to choose platform-
1552 appropriate subdevice type. On Windows d3d11va is used as
1553 default subdevice type.
1554
1555 Examples:
1556
1557 -init_hw_device qsv:hw,child_device_type=d3d11va
1558 Choose the GPU subdevice with type d3d11va and create QSV
1559 device with MFX_IMPL_HARDWARE.
1560
1561 -init_hw_device qsv:hw,child_device_type=dxva2
1562 Choose the GPU subdevice with type dxva2 and create QSV
1563 device with MFX_IMPL_HARDWARE.
1564
1565 opencl
1566 device selects the platform and device as
1567 platform_index.device_index.
1568
1569 The set of devices can also be filtered using the key-value
1570 pairs to find only devices matching particular platform or
1571 device strings.
1572
1573 The strings usable as filters are:
1574
1575 platform_profile
1576 platform_version
1577 platform_name
1578 platform_vendor
1579 platform_extensions
1580 device_name
1581 device_vendor
1582 driver_version
1583 device_version
1584 device_profile
1585 device_extensions
1586 device_type
1587
1588 The indices and filters must together uniquely select a device.
1589
1590 Examples:
1591
1592 -init_hw_device opencl:0.1
1593 Choose the second device on the first platform.
1594
1595 -init_hw_device opencl:,device_name=Foo9000
1596 Choose the device with a name containing the string
1597 Foo9000.
1598
1599 -init_hw_device
1600 opencl:1,device_type=gpu,device_extensions=cl_khr_fp16
1601 Choose the GPU device on the second platform supporting the
1602 cl_khr_fp16 extension.
1603
1604 vulkan
1605 If device is an integer, it selects the device by its index in
1606 a system-dependent list of devices. If device is any other
1607 string, it selects the first device with a name containing that
1608 string as a substring.
1609
1610 The following options are recognized:
1611
1612 debug
1613 If set to 1, enables the validation layer, if installed.
1614
1615 linear_images
1616 If set to 1, images allocated by the hwcontext will be
1617 linear and locally mappable.
1618
1619 instance_extensions
1620 A plus separated list of additional instance extensions to
1621 enable.
1622
1623 device_extensions
1624 A plus separated list of additional device extensions to
1625 enable.
1626
1627 Examples:
1628
1629 -init_hw_device vulkan:1
1630 Choose the second device on the system.
1631
1632 -init_hw_device vulkan:RADV
1633 Choose the first device with a name containing the string
1634 RADV.
1635
1636 -init_hw_device
1637 vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface
1638 Choose the first device and enable the Wayland and XCB
1639 instance extensions.
1640
1641 -init_hw_device type[=name]@source
1642 Initialise a new hardware device of type type called name, deriving
1643 it from the existing device with the name source.
1644
1645 -init_hw_device list
1646 List all hardware device types supported in this build of ffmpeg.
1647
1648 -filter_hw_device name
1649 Pass the hardware device called name to all filters in any filter
1650 graph. This can be used to set the device to upload to with the
1651 "hwupload" filter, or the device to map to with the "hwmap" filter.
1652 Other filters may also make use of this parameter when they require
1653 a hardware device. Note that this is typically only required when
1654 the input is not already in hardware frames - when it is, filters
1655 will derive the device they require from the context of the frames
1656 they receive as input.
1657
1658 This is a global setting, so all filters will receive the same
1659 device.
1660
1661 -hwaccel[:stream_specifier] hwaccel (input,per-stream)
1662 Use hardware acceleration to decode the matching stream(s). The
1663 allowed values of hwaccel are:
1664
1665 none
1666 Do not use any hardware acceleration (the default).
1667
1668 auto
1669 Automatically select the hardware acceleration method.
1670
1671 vdpau
1672 Use VDPAU (Video Decode and Presentation API for Unix) hardware
1673 acceleration.
1674
1675 dxva2
1676 Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
1677
1678 d3d11va
1679 Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
1680
1681 vaapi
1682 Use VAAPI (Video Acceleration API) hardware acceleration.
1683
1684 qsv Use the Intel QuickSync Video acceleration for video
1685 transcoding.
1686
1687 Unlike most other values, this option does not enable
1688 accelerated decoding (that is used automatically whenever a qsv
1689 decoder is selected), but accelerated transcoding, without
1690 copying the frames into the system memory.
1691
1692 For it to work, both the decoder and the encoder must support
1693 QSV acceleration and no filters must be used.
1694
1695 This option has no effect if the selected hwaccel is not available
1696 or not supported by the chosen decoder.
1697
1698 Note that most acceleration methods are intended for playback and
1699 will not be faster than software decoding on modern CPUs.
1700 Additionally, ffmpeg will usually need to copy the decoded frames
1701 from the GPU memory into the system memory, resulting in further
1702 performance loss. This option is thus mainly useful for testing.
1703
1704 -hwaccel_device[:stream_specifier] hwaccel_device (input,per-stream)
1705 Select a device to use for hardware acceleration.
1706
1707 This option only makes sense when the -hwaccel option is also
1708 specified. It can either refer to an existing device created with
1709 -init_hw_device by name, or it can create a new device as if
1710 -init_hw_device type:hwaccel_device were called immediately before.
1711
1712 -hwaccels
1713 List all hardware acceleration components enabled in this build of
1714 ffmpeg. Actual runtime availability depends on the hardware and
1715 its suitable driver being installed.
1716
1717 Audio Options
1718 -aframes number (output)
1719 Set the number of audio frames to output. This is an obsolete alias
1720 for "-frames:a", which you should use instead.
1721
1722 -ar[:stream_specifier] freq (input/output,per-stream)
1723 Set the audio sampling frequency. For output streams it is set by
1724 default to the frequency of the corresponding input stream. For
1725 input streams this option only makes sense for audio grabbing
1726 devices and raw demuxers and is mapped to the corresponding demuxer
1727 options.
1728
1729 -aq q (output)
1730 Set the audio quality (codec-specific, VBR). This is an alias for
1731 -q:a.
1732
1733 -ac[:stream_specifier] channels (input/output,per-stream)
1734 Set the number of audio channels. For output streams it is set by
1735 default to the number of input audio channels. For input streams
1736 this option only makes sense for audio grabbing devices and raw
1737 demuxers and is mapped to the corresponding demuxer options.
1738
1739 -an (input/output)
1740 As an input option, blocks all audio streams of a file from being
1741 filtered or being automatically selected or mapped for any output.
1742 See "-discard" option to disable streams individually.
1743
1744 As an output option, disables audio recording i.e. automatic
1745 selection or mapping of any audio stream. For full manual control
1746 see the "-map" option.
1747
1748 -acodec codec (input/output)
1749 Set the audio codec. This is an alias for "-codec:a".
1750
1751 -sample_fmt[:stream_specifier] sample_fmt (output,per-stream)
1752 Set the audio sample format. Use "-sample_fmts" to get a list of
1753 supported sample formats.
1754
1755 -af filtergraph (output)
1756 Create the filtergraph specified by filtergraph and use it to
1757 filter the stream.
1758
1759 This is an alias for "-filter:a", see the -filter option.
1760
1761 Advanced Audio options
1762 -atag fourcc/tag (output)
1763 Force audio tag/fourcc. This is an alias for "-tag:a".
1764
1765 -absf bitstream_filter
1766 Deprecated, see -bsf
1767
1768 -guess_layout_max channels (input,per-stream)
1769 If some input channel layout is not known, try to guess only if it
1770 corresponds to at most the specified number of channels. For
1771 example, 2 tells to ffmpeg to recognize 1 channel as mono and 2
1772 channels as stereo but not 6 channels as 5.1. The default is to
1773 always try to guess. Use 0 to disable all guessing.
1774
1775 Subtitle options
1776 -scodec codec (input/output)
1777 Set the subtitle codec. This is an alias for "-codec:s".
1778
1779 -sn (input/output)
1780 As an input option, blocks all subtitle streams of a file from
1781 being filtered or being automatically selected or mapped for any
1782 output. See "-discard" option to disable streams individually.
1783
1784 As an output option, disables subtitle recording i.e. automatic
1785 selection or mapping of any subtitle stream. For full manual
1786 control see the "-map" option.
1787
1788 -sbsf bitstream_filter
1789 Deprecated, see -bsf
1790
1791 Advanced Subtitle options
1792 -fix_sub_duration
1793 Fix subtitles durations. For each subtitle, wait for the next
1794 packet in the same stream and adjust the duration of the first to
1795 avoid overlap. This is necessary with some subtitles codecs,
1796 especially DVB subtitles, because the duration in the original
1797 packet is only a rough estimate and the end is actually marked by
1798 an empty subtitle frame. Failing to use this option when necessary
1799 can result in exaggerated durations or muxing failures due to non-
1800 monotonic timestamps.
1801
1802 Note that this option will delay the output of all data until the
1803 next subtitle packet is decoded: it may increase memory consumption
1804 and latency a lot.
1805
1806 -canvas_size size
1807 Set the size of the canvas used to render subtitles.
1808
1809 Advanced options
1810 -map
1811 [-]input_file_id[:stream_specifier][?][,sync_file_id[:stream_specifier]]
1812 | [linklabel] (output)
1813 Designate one or more input streams as a source for the output
1814 file. Each input stream is identified by the input file index
1815 input_file_id and the input stream index input_stream_id within the
1816 input file. Both indices start at 0. If specified,
1817 sync_file_id:stream_specifier sets which input stream is used as a
1818 presentation sync reference.
1819
1820 The first "-map" option on the command line specifies the source
1821 for output stream 0, the second "-map" option specifies the source
1822 for output stream 1, etc.
1823
1824 A "-" character before the stream identifier creates a "negative"
1825 mapping. It disables matching streams from already created
1826 mappings.
1827
1828 A trailing "?" after the stream index will allow the map to be
1829 optional: if the map matches no streams the map will be ignored
1830 instead of failing. Note the map will still fail if an invalid
1831 input file index is used; such as if the map refers to a non-
1832 existent input.
1833
1834 An alternative [linklabel] form will map outputs from complex
1835 filter graphs (see the -filter_complex option) to the output file.
1836 linklabel must correspond to a defined output link label in the
1837 graph.
1838
1839 For example, to map ALL streams from the first input file to output
1840
1841 ffmpeg -i INPUT -map 0 output
1842
1843 For example, if you have two audio streams in the first input file,
1844 these streams are identified by "0:0" and "0:1". You can use "-map"
1845 to select which streams to place in an output file. For example:
1846
1847 ffmpeg -i INPUT -map 0:1 out.wav
1848
1849 will map the input stream in INPUT identified by "0:1" to the
1850 (single) output stream in out.wav.
1851
1852 For example, to select the stream with index 2 from input file
1853 a.mov (specified by the identifier "0:2"), and stream with index 6
1854 from input b.mov (specified by the identifier "1:6"), and copy them
1855 to the output file out.mov:
1856
1857 ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
1858
1859 To select all video and the third audio stream from an input file:
1860
1861 ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
1862
1863 To map all the streams except the second audio, use negative
1864 mappings
1865
1866 ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
1867
1868 To map the video and audio streams from the first input, and using
1869 the trailing "?", ignore the audio mapping if no audio streams
1870 exist in the first input:
1871
1872 ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
1873
1874 To pick the English audio stream:
1875
1876 ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
1877
1878 Note that using this option disables the default mappings for this
1879 output file.
1880
1881 -ignore_unknown
1882 Ignore input streams with unknown type instead of failing if
1883 copying such streams is attempted.
1884
1885 -copy_unknown
1886 Allow input streams with unknown type to be copied instead of
1887 failing if copying such streams is attempted.
1888
1889 -map_channel
1890 [input_file_id.stream_specifier.channel_id|-1][?][:output_file_id.stream_specifier]
1891 Map an audio channel from a given input to an output. If
1892 output_file_id.stream_specifier is not set, the audio channel will
1893 be mapped on all the audio streams.
1894
1895 Using "-1" instead of input_file_id.stream_specifier.channel_id
1896 will map a muted channel.
1897
1898 A trailing "?" will allow the map_channel to be optional: if the
1899 map_channel matches no channel the map_channel will be ignored
1900 instead of failing.
1901
1902 For example, assuming INPUT is a stereo audio file, you can switch
1903 the two audio channels with the following command:
1904
1905 ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
1906
1907 If you want to mute the first channel and keep the second:
1908
1909 ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
1910
1911 The order of the "-map_channel" option specifies the order of the
1912 channels in the output stream. The output channel layout is guessed
1913 from the number of channels mapped (mono if one "-map_channel",
1914 stereo if two, etc.). Using "-ac" in combination of "-map_channel"
1915 makes the channel gain levels to be updated if input and output
1916 channel layouts don't match (for instance two "-map_channel"
1917 options and "-ac 6").
1918
1919 You can also extract each channel of an input to specific outputs;
1920 the following command extracts two channels of the INPUT audio
1921 stream (file 0, stream 0) to the respective OUTPUT_CH0 and
1922 OUTPUT_CH1 outputs:
1923
1924 ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
1925
1926 The following example splits the channels of a stereo input into
1927 two separate streams, which are put into the same output file:
1928
1929 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
1930
1931 Note that currently each output stream can only contain channels
1932 from a single input stream; you can't for example use
1933 "-map_channel" to pick multiple input audio channels contained in
1934 different streams (from the same or different files) and merge them
1935 into a single output stream. It is therefore not currently
1936 possible, for example, to turn two separate mono streams into a
1937 single stereo stream. However splitting a stereo stream into two
1938 single channel mono streams is possible.
1939
1940 If you need this feature, a possible workaround is to use the
1941 amerge filter. For example, if you need to merge a media (here
1942 input.mkv) with 2 mono audio streams into one single stereo channel
1943 audio stream (and keep the video stream), you can use the following
1944 command:
1945
1946 ffmpeg -i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:v copy output.mkv
1947
1948 To map the first two audio channels from the first input, and using
1949 the trailing "?", ignore the audio channel mapping if the first
1950 input is mono instead of stereo:
1951
1952 ffmpeg -i INPUT -map_channel 0.0.0 -map_channel 0.0.1? OUTPUT
1953
1954 -map_metadata[:metadata_spec_out] infile[:metadata_spec_in]
1955 (output,per-metadata)
1956 Set metadata information of the next output file from infile. Note
1957 that those are file indices (zero-based), not filenames. Optional
1958 metadata_spec_in/out parameters specify, which metadata to copy. A
1959 metadata specifier can have the following forms:
1960
1961 g global metadata, i.e. metadata that applies to the whole file
1962
1963 s[:stream_spec]
1964 per-stream metadata. stream_spec is a stream specifier as
1965 described in the Stream specifiers chapter. In an input
1966 metadata specifier, the first matching stream is copied from.
1967 In an output metadata specifier, all matching streams are
1968 copied to.
1969
1970 c:chapter_index
1971 per-chapter metadata. chapter_index is the zero-based chapter
1972 index.
1973
1974 p:program_index
1975 per-program metadata. program_index is the zero-based program
1976 index.
1977
1978 If metadata specifier is omitted, it defaults to global.
1979
1980 By default, global metadata is copied from the first input file,
1981 per-stream and per-chapter metadata is copied along with
1982 streams/chapters. These default mappings are disabled by creating
1983 any mapping of the relevant type. A negative file index can be used
1984 to create a dummy mapping that just disables automatic copying.
1985
1986 For example to copy metadata from the first stream of the input
1987 file to global metadata of the output file:
1988
1989 ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
1990
1991 To do the reverse, i.e. copy global metadata to all audio streams:
1992
1993 ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
1994
1995 Note that simple 0 would work as well in this example, since global
1996 metadata is assumed by default.
1997
1998 -map_chapters input_file_index (output)
1999 Copy chapters from input file with index input_file_index to the
2000 next output file. If no chapter mapping is specified, then chapters
2001 are copied from the first input file with at least one chapter. Use
2002 a negative file index to disable any chapter copying.
2003
2004 -benchmark (global)
2005 Show benchmarking information at the end of an encode. Shows real,
2006 system and user time used and maximum memory consumption. Maximum
2007 memory consumption is not supported on all systems, it will usually
2008 display as 0 if not supported.
2009
2010 -benchmark_all (global)
2011 Show benchmarking information during the encode. Shows real,
2012 system and user time used in various steps (audio/video
2013 encode/decode).
2014
2015 -timelimit duration (global)
2016 Exit after ffmpeg has been running for duration seconds in CPU user
2017 time.
2018
2019 -dump (global)
2020 Dump each input packet to stderr.
2021
2022 -hex (global)
2023 When dumping packets, also dump the payload.
2024
2025 -readrate speed (input)
2026 Limit input read speed.
2027
2028 Its value is a floating-point positive number which represents the
2029 maximum duration of media, in seconds, that should be ingested in
2030 one second of wallclock time. Default value is zero and represents
2031 no imposed limitation on speed of ingestion. Value 1 represents
2032 real-time speed and is equivalent to "-re".
2033
2034 Mainly used to simulate a capture device or live input stream (e.g.
2035 when reading from a file). Should not be used with a low value
2036 when input is an actual capture device or live stream as it may
2037 cause packet loss.
2038
2039 It is useful for when flow speed of output packets is important,
2040 such as live streaming.
2041
2042 -re (input)
2043 Read input at native frame rate. This is equivalent to setting
2044 "-readrate 1".
2045
2046 -vsync parameter (global)
2047 -fps_mode[:stream_specifier] parameter (output,per-stream)
2048 Set video sync method / framerate mode. vsync is applied to all
2049 output video streams but can be overridden for a stream by setting
2050 fps_mode. vsync is deprecated and will be removed in the future.
2051
2052 For compatibility reasons some of the values for vsync can be
2053 specified as numbers (shown in parentheses in the following table).
2054
2055 passthrough (0)
2056 Each frame is passed with its timestamp from the demuxer to the
2057 muxer.
2058
2059 cfr (1)
2060 Frames will be duplicated and dropped to achieve exactly the
2061 requested constant frame rate.
2062
2063 vfr (2)
2064 Frames are passed through with their timestamp or dropped so as
2065 to prevent 2 frames from having the same timestamp.
2066
2067 drop
2068 As passthrough but destroys all timestamps, making the muxer
2069 generate fresh timestamps based on frame-rate.
2070
2071 auto (-1)
2072 Chooses between cfr and vfr depending on muxer capabilities.
2073 This is the default method.
2074
2075 Note that the timestamps may be further modified by the muxer,
2076 after this. For example, in the case that the format option
2077 avoid_negative_ts is enabled.
2078
2079 With -map you can select from which stream the timestamps should be
2080 taken. You can leave either video or audio unchanged and sync the
2081 remaining stream(s) to the unchanged one.
2082
2083 -frame_drop_threshold parameter
2084 Frame drop threshold, which specifies how much behind video frames
2085 can be before they are dropped. In frame rate units, so 1.0 is one
2086 frame. The default is -1.1. One possible usecase is to avoid
2087 framedrops in case of noisy timestamps or to increase frame drop
2088 precision in case of exact timestamps.
2089
2090 -async samples_per_second
2091 Audio sync method. "Stretches/squeezes" the audio stream to match
2092 the timestamps, the parameter is the maximum samples per second by
2093 which the audio is changed. -async 1 is a special case where only
2094 the start of the audio stream is corrected without any later
2095 correction.
2096
2097 Note that the timestamps may be further modified by the muxer,
2098 after this. For example, in the case that the format option
2099 avoid_negative_ts is enabled.
2100
2101 This option has been deprecated. Use the "aresample" audio filter
2102 instead.
2103
2104 -adrift_threshold time
2105 Set the minimum difference between timestamps and audio data (in
2106 seconds) to trigger adding/dropping samples to make it match the
2107 timestamps. This option effectively is a threshold to select
2108 between hard (add/drop) and soft (squeeze/stretch) compensation.
2109 "-async" must be set to a positive value.
2110
2111 -apad parameters (output,per-stream)
2112 Pad the output audio stream(s). This is the same as applying "-af
2113 apad". Argument is a string of filter parameters composed the same
2114 as with the "apad" filter. "-shortest" must be set for this output
2115 for the option to take effect.
2116
2117 -copyts
2118 Do not process input timestamps, but keep their values without
2119 trying to sanitize them. In particular, do not remove the initial
2120 start time offset value.
2121
2122 Note that, depending on the vsync option or on specific muxer
2123 processing (e.g. in case the format option avoid_negative_ts is
2124 enabled) the output timestamps may mismatch with the input
2125 timestamps even when this option is selected.
2126
2127 -start_at_zero
2128 When used with copyts, shift input timestamps so they start at
2129 zero.
2130
2131 This means that using e.g. "-ss 50" will make output timestamps
2132 start at 50 seconds, regardless of what timestamp the input file
2133 started at.
2134
2135 -copytb mode
2136 Specify how to set the encoder timebase when stream copying. mode
2137 is an integer numeric value, and can assume one of the following
2138 values:
2139
2140 1 Use the demuxer timebase.
2141
2142 The time base is copied to the output encoder from the
2143 corresponding input demuxer. This is sometimes required to
2144 avoid non monotonically increasing timestamps when copying
2145 video streams with variable frame rate.
2146
2147 0 Use the decoder timebase.
2148
2149 The time base is copied to the output encoder from the
2150 corresponding input decoder.
2151
2152 -1 Try to make the choice automatically, in order to generate a
2153 sane output.
2154
2155 Default value is -1.
2156
2157 -enc_time_base[:stream_specifier] timebase (output,per-stream)
2158 Set the encoder timebase. timebase is a floating point number, and
2159 can assume one of the following values:
2160
2161 0 Assign a default value according to the media type.
2162
2163 For video - use 1/framerate, for audio - use 1/samplerate.
2164
2165 -1 Use the input stream timebase when possible.
2166
2167 If an input stream is not available, the default timebase will
2168 be used.
2169
2170 >0 Use the provided number as the timebase.
2171
2172 This field can be provided as a ratio of two integers (e.g.
2173 1:24, 1:48000) or as a floating point number (e.g. 0.04166,
2174 2.0833e-5)
2175
2176 Default value is 0.
2177
2178 -bitexact (input/output)
2179 Enable bitexact mode for (de)muxer and (de/en)coder
2180
2181 -shortest (output)
2182 Finish encoding when the shortest output stream ends.
2183
2184 -dts_delta_threshold
2185 Timestamp discontinuity delta threshold.
2186
2187 -dts_error_threshold seconds
2188 Timestamp error delta threshold. This threshold use to discard
2189 crazy/damaged timestamps and the default is 30 hours which is
2190 arbitrarily picked and quite conservative.
2191
2192 -muxdelay seconds (output)
2193 Set the maximum demux-decode delay.
2194
2195 -muxpreload seconds (output)
2196 Set the initial demux-decode delay.
2197
2198 -streamid output-stream-index:new-value (output)
2199 Assign a new stream-id value to an output stream. This option
2200 should be specified prior to the output filename to which it
2201 applies. For the situation where multiple output files exist, a
2202 streamid may be reassigned to a different value.
2203
2204 For example, to set the stream 0 PID to 33 and the stream 1 PID to
2205 36 for an output mpegts file:
2206
2207 ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
2208
2209 -bsf[:stream_specifier] bitstream_filters (output,per-stream)
2210 Set bitstream filters for matching streams. bitstream_filters is a
2211 comma-separated list of bitstream filters. Use the "-bsfs" option
2212 to get the list of bitstream filters.
2213
2214 ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
2215
2216
2217 ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
2218
2219 -tag[:stream_specifier] codec_tag (input/output,per-stream)
2220 Force a tag/fourcc for matching streams.
2221
2222 -timecode hh:mm:ssSEPff
2223 Specify Timecode for writing. SEP is ':' for non drop timecode and
2224 ';' (or '.') for drop.
2225
2226 ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
2227
2228 -filter_complex filtergraph (global)
2229 Define a complex filtergraph, i.e. one with arbitrary number of
2230 inputs and/or outputs. For simple graphs -- those with one input
2231 and one output of the same type -- see the -filter options.
2232 filtergraph is a description of the filtergraph, as described in
2233 the ``Filtergraph syntax'' section of the ffmpeg-filters manual.
2234
2235 Input link labels must refer to input streams using the
2236 "[file_index:stream_specifier]" syntax (i.e. the same as -map
2237 uses). If stream_specifier matches multiple streams, the first one
2238 will be used. An unlabeled input will be connected to the first
2239 unused input stream of the matching type.
2240
2241 Output link labels are referred to with -map. Unlabeled outputs are
2242 added to the first output file.
2243
2244 Note that with this option it is possible to use only lavfi sources
2245 without normal input files.
2246
2247 For example, to overlay an image over video
2248
2249 ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
2250 '[out]' out.mkv
2251
2252 Here "[0:v]" refers to the first video stream in the first input
2253 file, which is linked to the first (main) input of the overlay
2254 filter. Similarly the first video stream in the second input is
2255 linked to the second (overlay) input of overlay.
2256
2257 Assuming there is only one video stream in each input file, we can
2258 omit input labels, so the above is equivalent to
2259
2260 ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
2261 '[out]' out.mkv
2262
2263 Furthermore we can omit the output label and the single output from
2264 the filter graph will be added to the output file automatically, so
2265 we can simply write
2266
2267 ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
2268
2269 As a special exception, you can use a bitmap subtitle stream as
2270 input: it will be converted into a video with the same size as the
2271 largest video in the file, or 720x576 if no video is present. Note
2272 that this is an experimental and temporary solution. It will be
2273 removed once libavfilter has proper support for subtitles.
2274
2275 For example, to hardcode subtitles on top of a DVB-T recording
2276 stored in MPEG-TS format, delaying the subtitles by 1 second:
2277
2278 ffmpeg -i input.ts -filter_complex \
2279 '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
2280 -sn -map '#0x2dc' output.mkv
2281
2282 (0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the
2283 video, audio and subtitles streams; 0:0, 0:3 and 0:7 would have
2284 worked too)
2285
2286 To generate 5 seconds of pure red video using lavfi "color" source:
2287
2288 ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
2289
2290 -filter_complex_threads nb_threads (global)
2291 Defines how many threads are used to process a filter_complex
2292 graph. Similar to filter_threads but used for "-filter_complex"
2293 graphs only. The default is the number of available CPUs.
2294
2295 -lavfi filtergraph (global)
2296 Define a complex filtergraph, i.e. one with arbitrary number of
2297 inputs and/or outputs. Equivalent to -filter_complex.
2298
2299 -filter_complex_script filename (global)
2300 This option is similar to -filter_complex, the only difference is
2301 that its argument is the name of the file from which a complex
2302 filtergraph description is to be read.
2303
2304 -accurate_seek (input)
2305 This option enables or disables accurate seeking in input files
2306 with the -ss option. It is enabled by default, so seeking is
2307 accurate when transcoding. Use -noaccurate_seek to disable it,
2308 which may be useful e.g. when copying some streams and transcoding
2309 the others.
2310
2311 -seek_timestamp (input)
2312 This option enables or disables seeking by timestamp in input files
2313 with the -ss option. It is disabled by default. If enabled, the
2314 argument to the -ss option is considered an actual timestamp, and
2315 is not offset by the start time of the file. This matters only for
2316 files which do not start from timestamp 0, such as transport
2317 streams.
2318
2319 -thread_queue_size size (input)
2320 This option sets the maximum number of queued packets when reading
2321 from the file or device. With low latency / high rate live streams,
2322 packets may be discarded if they are not read in a timely manner;
2323 setting this value can force ffmpeg to use a separate input thread
2324 and read packets as soon as they arrive. By default ffmpeg only
2325 does this if multiple inputs are specified.
2326
2327 -sdp_file file (global)
2328 Print sdp information for an output stream to file. This allows
2329 dumping sdp information when at least one output isn't an rtp
2330 stream. (Requires at least one of the output formats to be rtp).
2331
2332 -discard (input)
2333 Allows discarding specific streams or frames from streams. Any
2334 input stream can be fully discarded, using value "all" whereas
2335 selective discarding of frames from a stream occurs at the demuxer
2336 and is not supported by all demuxers.
2337
2338 none
2339 Discard no frame.
2340
2341 default
2342 Default, which discards no frames.
2343
2344 noref
2345 Discard all non-reference frames.
2346
2347 bidir
2348 Discard all bidirectional frames.
2349
2350 nokey
2351 Discard all frames excepts keyframes.
2352
2353 all Discard all frames.
2354
2355 -abort_on flags (global)
2356 Stop and abort on various conditions. The following flags are
2357 available:
2358
2359 empty_output
2360 No packets were passed to the muxer, the output is empty.
2361
2362 empty_output_stream
2363 No packets were passed to the muxer in some of the output
2364 streams.
2365
2366 -max_error_rate (global)
2367 Set fraction of decoding frame failures across all inputs which
2368 when crossed ffmpeg will return exit code 69. Crossing this
2369 threshold does not terminate processing. Range is a floating-point
2370 number between 0 to 1. Default is 2/3.
2371
2372 -xerror (global)
2373 Stop and exit on error
2374
2375 -max_muxing_queue_size packets (output,per-stream)
2376 When transcoding audio and/or video streams, ffmpeg will not begin
2377 writing into the output until it has one packet for each such
2378 stream. While waiting for that to happen, packets for other streams
2379 are buffered. This option sets the size of this buffer, in packets,
2380 for the matching output stream.
2381
2382 The default value of this option should be high enough for most
2383 uses, so only touch this option if you are sure that you need it.
2384
2385 -muxing_queue_data_threshold bytes (output,per-stream)
2386 This is a minimum threshold until which the muxing queue size is
2387 not taken into account. Defaults to 50 megabytes per stream, and is
2388 based on the overall size of packets passed to the muxer.
2389
2390 -auto_conversion_filters (global)
2391 Enable automatically inserting format conversion filters in all
2392 filter graphs, including those defined by -vf, -af, -filter_complex
2393 and -lavfi. If filter format negotiation requires a conversion, the
2394 initialization of the filters will fail. Conversions can still be
2395 performed by inserting the relevant conversion filter (scale,
2396 aresample) in the graph. On by default, to explicitly disable it
2397 you need to specify "-noauto_conversion_filters".
2398
2399 -bits_per_raw_sample[:stream_specifier] value (output,per-stream)
2400 Declare the number of bits per raw sample in the given output
2401 stream to be value. Note that this option sets the information
2402 provided to the encoder/muxer, it does not change the stream to
2403 conform to this value. Setting values that do not match the stream
2404 properties may result in encoding failures or invalid output files.
2405
2406 Preset files
2407 A preset file contains a sequence of option=value pairs, one for each
2408 line, specifying a sequence of options which would be awkward to
2409 specify on the command line. Lines starting with the hash ('#')
2410 character are ignored and are used to provide comments. Check the
2411 presets directory in the FFmpeg source tree for examples.
2412
2413 There are two types of preset files: ffpreset and avpreset files.
2414
2415 ffpreset files
2416
2417 ffpreset files are specified with the "vpre", "apre", "spre", and
2418 "fpre" options. The "fpre" option takes the filename of the preset
2419 instead of a preset name as input and can be used for any kind of
2420 codec. For the "vpre", "apre", and "spre" options, the options
2421 specified in a preset file are applied to the currently selected codec
2422 of the same type as the preset option.
2423
2424 The argument passed to the "vpre", "apre", and "spre" preset options
2425 identifies the preset file to use according to the following rules:
2426
2427 First ffmpeg searches for a file named arg.ffpreset in the directories
2428 $FFMPEG_DATADIR (if set), and $HOME/.ffmpeg, and in the datadir defined
2429 at configuration time (usually PREFIX/share/ffmpeg) or in a ffpresets
2430 folder along the executable on win32, in that order. For example, if
2431 the argument is "libvpx-1080p", it will search for the file
2432 libvpx-1080p.ffpreset.
2433
2434 If no such file is found, then ffmpeg will search for a file named
2435 codec_name-arg.ffpreset in the above-mentioned directories, where
2436 codec_name is the name of the codec to which the preset file options
2437 will be applied. For example, if you select the video codec with
2438 "-vcodec libvpx" and use "-vpre 1080p", then it will search for the
2439 file libvpx-1080p.ffpreset.
2440
2441 avpreset files
2442
2443 avpreset files are specified with the "pre" option. They work similar
2444 to ffpreset files, but they only allow encoder- specific options.
2445 Therefore, an option=value pair specifying an encoder cannot be used.
2446
2447 When the "pre" option is specified, ffmpeg will look for files with the
2448 suffix .avpreset in the directories $AVCONV_DATADIR (if set), and
2449 $HOME/.avconv, and in the datadir defined at configuration time
2450 (usually PREFIX/share/ffmpeg), in that order.
2451
2452 First ffmpeg searches for a file named codec_name-arg.avpreset in the
2453 above-mentioned directories, where codec_name is the name of the codec
2454 to which the preset file options will be applied. For example, if you
2455 select the video codec with "-vcodec libvpx" and use "-pre 1080p", then
2456 it will search for the file libvpx-1080p.avpreset.
2457
2458 If no such file is found, then ffmpeg will search for a file named
2459 arg.avpreset in the same directories.
2460
2462 Video and Audio grabbing
2463 If you specify the input format and device then ffmpeg can grab video
2464 and audio directly.
2465
2466 ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
2467
2468 Or with an ALSA audio source (mono input, card id 1) instead of OSS:
2469
2470 ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
2471
2472 Note that you must activate the right video source and channel before
2473 launching ffmpeg with any TV viewer such as
2474 <http://linux.bytesex.org/xawtv/> by Gerd Knorr. You also have to set
2475 the audio recording levels correctly with a standard mixer.
2476
2477 X11 grabbing
2478 Grab the X11 display with ffmpeg via
2479
2480 ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
2481
2482 0.0 is display.screen number of your X11 server, same as the DISPLAY
2483 environment variable.
2484
2485 ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
2486
2487 0.0 is display.screen number of your X11 server, same as the DISPLAY
2488 environment variable. 10 is the x-offset and 20 the y-offset for the
2489 grabbing.
2490
2491 Video and Audio file format conversion
2492 Any supported file format and protocol can serve as input to ffmpeg:
2493
2494 Examples:
2495
2496 • You can use YUV files as input:
2497
2498 ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
2499
2500 It will use the files:
2501
2502 /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
2503 /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
2504
2505 The Y files use twice the resolution of the U and V files. They are
2506 raw files, without header. They can be generated by all decent
2507 video decoders. You must specify the size of the image with the -s
2508 option if ffmpeg cannot guess it.
2509
2510 • You can input from a raw YUV420P file:
2511
2512 ffmpeg -i /tmp/test.yuv /tmp/out.avi
2513
2514 test.yuv is a file containing raw YUV planar data. Each frame is
2515 composed of the Y plane followed by the U and V planes at half
2516 vertical and horizontal resolution.
2517
2518 • You can output to a raw YUV420P file:
2519
2520 ffmpeg -i mydivx.avi hugefile.yuv
2521
2522 • You can set several input files and output files:
2523
2524 ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
2525
2526 Converts the audio file a.wav and the raw YUV video file a.yuv to
2527 MPEG file a.mpg.
2528
2529 • You can also do audio and video conversions at the same time:
2530
2531 ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
2532
2533 Converts a.wav to MPEG audio at 22050 Hz sample rate.
2534
2535 • You can encode to several formats at the same time and define a
2536 mapping from input stream to output streams:
2537
2538 ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
2539
2540 Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits.
2541 '-map file:index' specifies which input stream is used for each
2542 output stream, in the order of the definition of output streams.
2543
2544 • You can transcode decrypted VOBs:
2545
2546 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
2547
2548 This is a typical DVD ripping example; the input is a VOB file, the
2549 output an AVI file with MPEG-4 video and MP3 audio. Note that in
2550 this command we use B-frames so the MPEG-4 stream is DivX5
2551 compatible, and GOP size is 300 which means one intra frame every
2552 10 seconds for 29.97fps input video. Furthermore, the audio stream
2553 is MP3-encoded so you need to enable LAME support by passing
2554 "--enable-libmp3lame" to configure. The mapping is particularly
2555 useful for DVD transcoding to get the desired audio language.
2556
2557 NOTE: To see the supported input formats, use "ffmpeg -demuxers".
2558
2559 • You can extract images from a video, or create a video from many
2560 images:
2561
2562 For extracting images from a video:
2563
2564 ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
2565
2566 This will extract one video frame per second from the video and
2567 will output them in files named foo-001.jpeg, foo-002.jpeg, etc.
2568 Images will be rescaled to fit the new WxH values.
2569
2570 If you want to extract just a limited number of frames, you can use
2571 the above command in combination with the "-frames:v" or "-t"
2572 option, or in combination with -ss to start extracting from a
2573 certain point in time.
2574
2575 For creating a video from many images:
2576
2577 ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
2578
2579 The syntax "foo-%03d.jpeg" specifies to use a decimal number
2580 composed of three digits padded with zeroes to express the sequence
2581 number. It is the same syntax supported by the C printf function,
2582 but only formats accepting a normal integer are suitable.
2583
2584 When importing an image sequence, -i also supports expanding shell-
2585 like wildcard patterns (globbing) internally, by selecting the
2586 image2-specific "-pattern_type glob" option.
2587
2588 For example, for creating a video from filenames matching the glob
2589 pattern "foo-*.jpeg":
2590
2591 ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
2592
2593 • You can put many streams of the same type in the output:
2594
2595 ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
2596
2597 The resulting output file test12.nut will contain the first four
2598 streams from the input files in reverse order.
2599
2600 • To force CBR video output:
2601
2602 ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
2603
2604 • The four options lmin, lmax, mblmin and mblmax use 'lambda' units,
2605 but you may use the QP2LAMBDA constant to easily convert from 'q'
2606 units:
2607
2608 ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
2609
2611 ffmpeg-all(1), ffplay(1), ffprobe(1), ffmpeg-utils(1),
2612 ffmpeg-scaler(1), ffmpeg-resampler(1), ffmpeg-codecs(1),
2613 ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-devices(1),
2614 ffmpeg-protocols(1), ffmpeg-filters(1)
2615
2617 The FFmpeg developers.
2618
2619 For details about the authorship, see the Git history of the project
2620 (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command git log in
2621 the FFmpeg source directory, or browsing the online repository at
2622 <http://source.ffmpeg.org>.
2623
2624 Maintainers for the specific components are listed in the file
2625 MAINTAINERS in the source code tree.
2626
2627
2628
2629 FFMPEG(1)