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 -itsoffset offset (input)
909 Set the input time offset.
910
911 offset must be a time duration specification, see the Time duration
912 section in the ffmpeg-utils(1) manual.
913
914 The offset is added to the timestamps of the input files.
915 Specifying a positive offset means that the corresponding streams
916 are delayed by the time duration specified in offset.
917
918 -itsscale scale (input,per-stream)
919 Rescale input timestamps. scale should be a floating point number.
920
921 -timestamp date (output)
922 Set the recording timestamp in the container.
923
924 date must be a date specification, see the Date section in the
925 ffmpeg-utils(1) manual.
926
927 -metadata[:metadata_specifier] key=value (output,per-metadata)
928 Set a metadata key/value pair.
929
930 An optional metadata_specifier may be given to set metadata on
931 streams, chapters or programs. See "-map_metadata" documentation
932 for details.
933
934 This option overrides metadata set with "-map_metadata". It is also
935 possible to delete metadata by using an empty value.
936
937 For example, for setting the title in the output file:
938
939 ffmpeg -i in.avi -metadata title="my title" out.flv
940
941 To set the language of the first audio stream:
942
943 ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
944
945 -disposition[:stream_specifier] value (output,per-stream)
946 Sets the disposition for a stream.
947
948 By default, the disposition is copied from the input stream, unless
949 the output stream this option applies to is fed by a complex
950 filtergraph - in that case the disposition is unset by default.
951
952 value is a sequence of items separated by '+' or '-'. The first
953 item may also be prefixed with '+' or '-', in which case this
954 option modifies the default value. Otherwise (the first item is not
955 prefixed) this options overrides the default value. A '+' prefix
956 adds the given disposition, '-' removes it. It is also possible to
957 clear the disposition by setting it to 0.
958
959 If no "-disposition" options were specified for an output file,
960 ffmpeg will automatically set the 'default' disposition on the
961 first stream of each type, when there are multiple streams of this
962 type in the output file and no stream of that type is already
963 marked as default.
964
965 The "-dispositions" option lists the known dispositions.
966
967 For example, to make the second audio stream the default stream:
968
969 ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv
970
971 To make the second subtitle stream the default stream and remove
972 the default disposition from the first subtitle stream:
973
974 ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv
975
976 To add an embedded cover/thumbnail:
977
978 ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
979
980 Not all muxers support embedded thumbnails, and those who do, only
981 support a few formats, like JPEG or PNG.
982
983 -program
984 [title=title:][program_num=program_num:]st=stream[:st=stream...]
985 (output)
986 Creates a program with the specified title, program_num and adds
987 the specified stream(s) to it.
988
989 -target type (output)
990 Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50"). type
991 may be prefixed with "pal-", "ntsc-" or "film-" to use the
992 corresponding standard. All the format options (bitrate, codecs,
993 buffer sizes) are then set automatically. You can just type:
994
995 ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
996
997 Nevertheless you can specify additional options as long as you know
998 they do not conflict with the standard, as in:
999
1000 ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
1001
1002 The parameters set for each target are as follows.
1003
1004 VCD
1005
1006 <pal>:
1007 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1008 -s 352x288 -r 25
1009 -codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
1010 -ar 44100 -ac 2
1011 -codec:a mp2 -b:a 224k
1012
1013 <ntsc>:
1014 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1015 -s 352x240 -r 30000/1001
1016 -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
1017 -ar 44100 -ac 2
1018 -codec:a mp2 -b:a 224k
1019
1020 <film>:
1021 -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
1022 -s 352x240 -r 24000/1001
1023 -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150v -minrate:v 1150k -bufsize:v 327680
1024 -ar 44100 -ac 2
1025 -codec:a mp2 -b:a 224k
1026
1027 SVCD
1028
1029 <pal>:
1030 -f svcd -packetsize 2324
1031 -s 480x576 -pix_fmt yuv420p -r 25
1032 -codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1033 -ar 44100
1034 -codec:a mp2 -b:a 224k
1035
1036 <ntsc>:
1037 -f svcd -packetsize 2324
1038 -s 480x480 -pix_fmt yuv420p -r 30000/1001
1039 -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1040 -ar 44100
1041 -codec:a mp2 -b:a 224k
1042
1043 <film>:
1044 -f svcd -packetsize 2324
1045 -s 480x480 -pix_fmt yuv420p -r 24000/1001
1046 -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
1047 -ar 44100
1048 -codec:a mp2 -b:a 224k
1049
1050 DVD
1051
1052 <pal>:
1053 -f dvd -muxrate 10080k -packetsize 2048
1054 -s 720x576 -pix_fmt yuv420p -r 25
1055 -codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1056 -ar 48000
1057 -codec:a ac3 -b:a 448k
1058
1059 <ntsc>:
1060 -f dvd -muxrate 10080k -packetsize 2048
1061 -s 720x480 -pix_fmt yuv420p -r 30000/1001
1062 -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1063 -ar 48000
1064 -codec:a ac3 -b:a 448k
1065
1066 <film>:
1067 -f dvd -muxrate 10080k -packetsize 2048
1068 -s 720x480 -pix_fmt yuv420p -r 24000/1001
1069 -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
1070 -ar 48000
1071 -codec:a ac3 -b:a 448k
1072
1073 DV
1074
1075 <pal>:
1076 -f dv
1077 -s 720x576 -pix_fmt yuv420p -r 25
1078 -ar 48000 -ac 2
1079
1080 <ntsc>:
1081 -f dv
1082 -s 720x480 -pix_fmt yuv411p -r 30000/1001
1083 -ar 48000 -ac 2
1084
1085 <film>:
1086 -f dv
1087 -s 720x480 -pix_fmt yuv411p -r 24000/1001
1088 -ar 48000 -ac 2
1089
1090 The "dv50" target is identical to the "dv" target except that the
1091 pixel format set is "yuv422p" for all three standards.
1092
1093 Any user-set value for a parameter above will override the target
1094 preset value. In that case, the output may not comply with the
1095 target standard.
1096
1097 -dn (input/output)
1098 As an input option, blocks all data streams of a file from being
1099 filtered or being automatically selected or mapped for any output.
1100 See "-discard" option to disable streams individually.
1101
1102 As an output option, disables data recording i.e. automatic
1103 selection or mapping of any data stream. For full manual control
1104 see the "-map" option.
1105
1106 -dframes number (output)
1107 Set the number of data frames to output. This is an obsolete alias
1108 for "-frames:d", which you should use instead.
1109
1110 -frames[:stream_specifier] framecount (output,per-stream)
1111 Stop writing to the stream after framecount frames.
1112
1113 -q[:stream_specifier] q (output,per-stream)
1114 -qscale[:stream_specifier] q (output,per-stream)
1115 Use fixed quality scale (VBR). The meaning of q/qscale is codec-
1116 dependent. If qscale is used without a stream_specifier then it
1117 applies only to the video stream, this is to maintain compatibility
1118 with previous behavior and as specifying the same codec specific
1119 value to 2 different codecs that is audio and video generally is
1120 not what is intended when no stream_specifier is used.
1121
1122 -filter[:stream_specifier] filtergraph (output,per-stream)
1123 Create the filtergraph specified by filtergraph and use it to
1124 filter the stream.
1125
1126 filtergraph is a description of the filtergraph to apply to the
1127 stream, and must have a single input and a single output of the
1128 same type of the stream. In the filtergraph, the input is
1129 associated to the label "in", and the output to the label "out".
1130 See the ffmpeg-filters manual for more information about the
1131 filtergraph syntax.
1132
1133 See the -filter_complex option if you want to create filtergraphs
1134 with multiple inputs and/or outputs.
1135
1136 -filter_script[:stream_specifier] filename (output,per-stream)
1137 This option is similar to -filter, the only difference is that its
1138 argument is the name of the file from which a filtergraph
1139 description is to be read.
1140
1141 -reinit_filter[:stream_specifier] integer (input,per-stream)
1142 This boolean option determines if the filtergraph(s) to which this
1143 stream is fed gets reinitialized when input frame parameters change
1144 mid-stream. This option is enabled by default as most video and all
1145 audio filters cannot handle deviation in input frame properties.
1146 Upon reinitialization, existing filter state is lost, like e.g. the
1147 frame count "n" reference available in some filters. Any frames
1148 buffered at time of reinitialization are lost. The properties
1149 where a change triggers reinitialization are, for video, frame
1150 resolution or pixel format; for audio, sample format, sample rate,
1151 channel count or channel layout.
1152
1153 -filter_threads nb_threads (global)
1154 Defines how many threads are used to process a filter pipeline.
1155 Each pipeline will produce a thread pool with this many threads
1156 available for parallel processing. The default is the number of
1157 available CPUs.
1158
1159 -pre[:stream_specifier] preset_name (output,per-stream)
1160 Specify the preset for matching stream(s).
1161
1162 -stats (global)
1163 Print encoding progress/statistics. It is on by default, to
1164 explicitly disable it you need to specify "-nostats".
1165
1166 -stats_period time (global)
1167 Set period at which encoding progress/statistics are updated.
1168 Default is 0.5 seconds.
1169
1170 -progress url (global)
1171 Send program-friendly progress information to url.
1172
1173 Progress information is written periodically and at the end of the
1174 encoding process. It is made of "key=value" lines. key consists of
1175 only alphanumeric characters. The last key of a sequence of
1176 progress information is always "progress".
1177
1178 The update period is set using "-stats_period".
1179
1180 -stdin
1181 Enable interaction on standard input. On by default unless standard
1182 input is used as an input. To explicitly disable interaction you
1183 need to specify "-nostdin".
1184
1185 Disabling interaction on standard input is useful, for example, if
1186 ffmpeg is in the background process group. Roughly the same result
1187 can be achieved with "ffmpeg ... < /dev/null" but it requires a
1188 shell.
1189
1190 -debug_ts (global)
1191 Print timestamp information. It is off by default. This option is
1192 mostly useful for testing and debugging purposes, and the output
1193 format may change from one version to another, so it should not be
1194 employed by portable scripts.
1195
1196 See also the option "-fdebug ts".
1197
1198 -attach filename (output)
1199 Add an attachment to the output file. This is supported by a few
1200 formats like Matroska for e.g. fonts used in rendering subtitles.
1201 Attachments are implemented as a specific type of stream, so this
1202 option will add a new stream to the file. It is then possible to
1203 use per-stream options on this stream in the usual way. Attachment
1204 streams created with this option will be created after all the
1205 other streams (i.e. those created with "-map" or automatic
1206 mappings).
1207
1208 Note that for Matroska you also have to set the mimetype metadata
1209 tag:
1210
1211 ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
1212
1213 (assuming that the attachment stream will be third in the output
1214 file).
1215
1216 -dump_attachment[:stream_specifier] filename (input,per-stream)
1217 Extract the matching attachment stream into a file named filename.
1218 If filename is empty, then the value of the "filename" metadata tag
1219 will be used.
1220
1221 E.g. to extract the first attachment to a file named 'out.ttf':
1222
1223 ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
1224
1225 To extract all attachments to files determined by the "filename"
1226 tag:
1227
1228 ffmpeg -dump_attachment:t "" -i INPUT
1229
1230 Technical note -- attachments are implemented as codec extradata,
1231 so this option can actually be used to extract extradata from any
1232 stream, not just attachments.
1233
1234 Video Options
1235 -vframes number (output)
1236 Set the number of video frames to output. This is an obsolete alias
1237 for "-frames:v", which you should use instead.
1238
1239 -r[:stream_specifier] fps (input/output,per-stream)
1240 Set frame rate (Hz value, fraction or abbreviation).
1241
1242 As an input option, ignore any timestamps stored in the file and
1243 instead generate timestamps assuming constant frame rate fps. This
1244 is not the same as the -framerate option used for some input
1245 formats like image2 or v4l2 (it used to be the same in older
1246 versions of FFmpeg). If in doubt use -framerate instead of the
1247 input option -r.
1248
1249 As an output option, duplicate or drop input frames to achieve
1250 constant output frame rate fps.
1251
1252 -fpsmax[:stream_specifier] fps (output,per-stream)
1253 Set maximum frame rate (Hz value, fraction or abbreviation).
1254
1255 Clamps output frame rate when output framerate is auto-set and is
1256 higher than this value. Useful in batch processing or when input
1257 framerate is wrongly detected as very high. It cannot be set
1258 together with "-r". It is ignored during streamcopy.
1259
1260 -s[:stream_specifier] size (input/output,per-stream)
1261 Set frame size.
1262
1263 As an input option, this is a shortcut for the video_size private
1264 option, recognized by some demuxers for which the frame size is
1265 either not stored in the file or is configurable -- e.g. raw video
1266 or video grabbers.
1267
1268 As an output option, this inserts the "scale" video filter to the
1269 end of the corresponding filtergraph. Please use the "scale" filter
1270 directly to insert it at the beginning or some other place.
1271
1272 The format is wxh (default - same as source).
1273
1274 -aspect[:stream_specifier] aspect (output,per-stream)
1275 Set the video display aspect ratio specified by aspect.
1276
1277 aspect can be a floating point number string, or a string of the
1278 form num:den, where num and den are the numerator and denominator
1279 of the aspect ratio. For example "4:3", "16:9", "1.3333", and
1280 "1.7777" are valid argument values.
1281
1282 If used together with -vcodec copy, it will affect the aspect ratio
1283 stored at container level, but not the aspect ratio stored in
1284 encoded frames, if it exists.
1285
1286 -vn (input/output)
1287 As an input option, blocks all video streams of a file from being
1288 filtered or being automatically selected or mapped for any output.
1289 See "-discard" option to disable streams individually.
1290
1291 As an output option, disables video recording i.e. automatic
1292 selection or mapping of any video stream. For full manual control
1293 see the "-map" option.
1294
1295 -vcodec codec (output)
1296 Set the video codec. This is an alias for "-codec:v".
1297
1298 -pass[:stream_specifier] n (output,per-stream)
1299 Select the pass number (1 or 2). It is used to do two-pass video
1300 encoding. The statistics of the video are recorded in the first
1301 pass into a log file (see also the option -passlogfile), and in the
1302 second pass that log file is used to generate the video at the
1303 exact requested bitrate. On pass 1, you may just deactivate audio
1304 and set output to null, examples for Windows and Unix:
1305
1306 ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
1307 ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
1308
1309 -passlogfile[:stream_specifier] prefix (output,per-stream)
1310 Set two-pass log file name prefix to prefix, the default file name
1311 prefix is ``ffmpeg2pass''. The complete file name will be
1312 PREFIX-N.log, where N is a number specific to the output stream
1313
1314 -vf filtergraph (output)
1315 Create the filtergraph specified by filtergraph and use it to
1316 filter the stream.
1317
1318 This is an alias for "-filter:v", see the -filter option.
1319
1320 -autorotate
1321 Automatically rotate the video according to file metadata. Enabled
1322 by default, use -noautorotate to disable it.
1323
1324 -autoscale
1325 Automatically scale the video according to the resolution of first
1326 frame. Enabled by default, use -noautoscale to disable it. When
1327 autoscale is disabled, all output frames of filter graph might not
1328 be in the same resolution and may be inadequate for some
1329 encoder/muxer. Therefore, it is not recommended to disable it
1330 unless you really know what you are doing. Disable autoscale at
1331 your own risk.
1332
1333 Advanced Video options
1334 -pix_fmt[:stream_specifier] format (input/output,per-stream)
1335 Set pixel format. Use "-pix_fmts" to show all the supported pixel
1336 formats. If the selected pixel format can not be selected, ffmpeg
1337 will print a warning and select the best pixel format supported by
1338 the encoder. If pix_fmt is prefixed by a "+", ffmpeg will exit
1339 with an error if the requested pixel format can not be selected,
1340 and automatic conversions inside filtergraphs are disabled. If
1341 pix_fmt is a single "+", ffmpeg selects the same pixel format as
1342 the input (or graph output) and automatic conversions are disabled.
1343
1344 -sws_flags flags (input/output)
1345 Set SwScaler flags.
1346
1347 -rc_override[:stream_specifier] override (output,per-stream)
1348 Rate control override for specific intervals, formatted as
1349 "int,int,int" list separated with slashes. Two first values are the
1350 beginning and end frame numbers, last one is quantizer to use if
1351 positive, or quality factor if negative.
1352
1353 -ilme
1354 Force interlacing support in encoder (MPEG-2 and MPEG-4 only). Use
1355 this option if your input file is interlaced and you want to keep
1356 the interlaced format for minimum losses. The alternative is to
1357 deinterlace the input stream by use of a filter such as "yadif" or
1358 "bwdif", but deinterlacing introduces losses.
1359
1360 -psnr
1361 Calculate PSNR of compressed frames.
1362
1363 -vstats
1364 Dump video coding statistics to vstats_HHMMSS.log.
1365
1366 -vstats_file file
1367 Dump video coding statistics to file.
1368
1369 -vstats_version file
1370 Specifies which version of the vstats format to use. Default is 2.
1371
1372 version = 1 :
1373
1374 "frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time=
1375 %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s"
1376
1377 version > 1:
1378
1379 "out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d
1380 s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s"
1381
1382 -top[:stream_specifier] n (output,per-stream)
1383 top=1/bottom=0/auto=-1 field first
1384
1385 -dc precision
1386 Intra_dc_precision.
1387
1388 -vtag fourcc/tag (output)
1389 Force video tag/fourcc. This is an alias for "-tag:v".
1390
1391 -qphist (global)
1392 Show QP histogram
1393
1394 -vbsf bitstream_filter
1395 Deprecated see -bsf
1396
1397 -force_key_frames[:stream_specifier] time[,time...] (output,per-stream)
1398 -force_key_frames[:stream_specifier] expr:expr (output,per-stream)
1399 -force_key_frames[:stream_specifier] source (output,per-stream)
1400 -force_key_frames[:stream_specifier] source_no_drop (output,per-stream)
1401 force_key_frames can take arguments of the following form:
1402
1403 time[,time...]
1404 If the argument consists of timestamps, ffmpeg will round the
1405 specified times to the nearest output timestamp as per the
1406 encoder time base and force a keyframe at the first frame
1407 having timestamp equal or greater than the computed timestamp.
1408 Note that if the encoder time base is too coarse, then the
1409 keyframes may be forced on frames with timestamps lower than
1410 the specified time. The default encoder time base is the
1411 inverse of the output framerate but may be set otherwise via
1412 "-enc_time_base".
1413
1414 If one of the times is ""chapters"[delta]", it is expanded into
1415 the time of the beginning of all chapters in the file, shifted
1416 by delta, expressed as a time in seconds. This option can be
1417 useful to ensure that a seek point is present at a chapter mark
1418 or any other designated place in the output file.
1419
1420 For example, to insert a key frame at 5 minutes, plus key
1421 frames 0.1 second before the beginning of every chapter:
1422
1423 -force_key_frames 0:05:00,chapters-0.1
1424
1425 expr:expr
1426 If the argument is prefixed with "expr:", the string expr is
1427 interpreted like an expression and is evaluated for each frame.
1428 A key frame is forced in case the evaluation is non-zero.
1429
1430 The expression in expr can contain the following constants:
1431
1432 n the number of current processed frame, starting from 0
1433
1434 n_forced
1435 the number of forced frames
1436
1437 prev_forced_n
1438 the number of the previous forced frame, it is "NAN" when
1439 no keyframe was forced yet
1440
1441 prev_forced_t
1442 the time of the previous forced frame, it is "NAN" when no
1443 keyframe was forced yet
1444
1445 t the time of the current processed frame
1446
1447 For example to force a key frame every 5 seconds, you can
1448 specify:
1449
1450 -force_key_frames expr:gte(t,n_forced*5)
1451
1452 To force a key frame 5 seconds after the time of the last
1453 forced one, starting from second 13:
1454
1455 -force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
1456
1457 source
1458 If the argument is "source", ffmpeg will force a key frame if
1459 the current frame being encoded is marked as a key frame in its
1460 source.
1461
1462 source_no_drop
1463 If the argument is "source_no_drop", ffmpeg will force a key
1464 frame if the current frame being encoded is marked as a key
1465 frame in its source. In cases where this particular source
1466 frame has to be dropped, enforce the next available frame to
1467 become a key frame instead.
1468
1469 Note that forcing too many keyframes is very harmful for the
1470 lookahead algorithms of certain encoders: using fixed-GOP options
1471 or similar would be more efficient.
1472
1473 -copyinkf[:stream_specifier] (output,per-stream)
1474 When doing stream copy, copy also non-key frames found at the
1475 beginning.
1476
1477 -init_hw_device type[=name][:device[,key=value...]]
1478 Initialise a new hardware device of type type called name, using
1479 the given device parameters. If no name is specified it will
1480 receive a default name of the form "type%d".
1481
1482 The meaning of device and the following arguments depends on the
1483 device type:
1484
1485 cuda
1486 device is the number of the CUDA device.
1487
1488 The following options are recognized:
1489
1490 primary_ctx
1491 If set to 1, uses the primary device context instead of
1492 creating a new one.
1493
1494 Examples:
1495
1496 -init_hw_device cuda:1
1497 Choose the second device on the system.
1498
1499 -init_hw_device cuda:0,primary_ctx=1
1500 Choose the first device and use the primary device context.
1501
1502 dxva2
1503 device is the number of the Direct3D 9 display adapter.
1504
1505 d3d11va
1506 device is the number of the Direct3D 11 display adapter.
1507
1508 vaapi
1509 device is either an X11 display name or a DRM render node. If
1510 not specified, it will attempt to open the default X11 display
1511 ($DISPLAY) and then the first DRM render node
1512 (/dev/dri/renderD128).
1513
1514 vdpau
1515 device is an X11 display name. If not specified, it will
1516 attempt to open the default X11 display ($DISPLAY).
1517
1518 qsv device selects a value in MFX_IMPL_*. Allowed values are:
1519
1520 auto
1521 sw
1522 hw
1523 auto_any
1524 hw_any
1525 hw2
1526 hw3
1527 hw4
1528
1529 If not specified, auto_any is used. (Note that it may be
1530 easier to achieve the desired result for QSV by creating the
1531 platform-appropriate subdevice (dxva2 or d3d11va or vaapi) and
1532 then deriving a QSV device from that.)
1533
1534 Alternatively, child_device_type helps to choose platform-
1535 appropriate subdevice type. On Windows d3d11va is used as
1536 default subdevice type.
1537
1538 Examples:
1539
1540 -init_hw_device qsv:hw,child_device_type=d3d11va
1541 Choose the GPU subdevice with type d3d11va and create QSV
1542 device with MFX_IMPL_HARDWARE.
1543
1544 -init_hw_device qsv:hw,child_device_type=dxva2
1545 Choose the GPU subdevice with type dxva2 and create QSV
1546 device with MFX_IMPL_HARDWARE.
1547
1548 opencl
1549 device selects the platform and device as
1550 platform_index.device_index.
1551
1552 The set of devices can also be filtered using the key-value
1553 pairs to find only devices matching particular platform or
1554 device strings.
1555
1556 The strings usable as filters are:
1557
1558 platform_profile
1559 platform_version
1560 platform_name
1561 platform_vendor
1562 platform_extensions
1563 device_name
1564 device_vendor
1565 driver_version
1566 device_version
1567 device_profile
1568 device_extensions
1569 device_type
1570
1571 The indices and filters must together uniquely select a device.
1572
1573 Examples:
1574
1575 -init_hw_device opencl:0.1
1576 Choose the second device on the first platform.
1577
1578 -init_hw_device opencl:,device_name=Foo9000
1579 Choose the device with a name containing the string
1580 Foo9000.
1581
1582 -init_hw_device
1583 opencl:1,device_type=gpu,device_extensions=cl_khr_fp16
1584 Choose the GPU device on the second platform supporting the
1585 cl_khr_fp16 extension.
1586
1587 vulkan
1588 If device is an integer, it selects the device by its index in
1589 a system-dependent list of devices. If device is any other
1590 string, it selects the first device with a name containing that
1591 string as a substring.
1592
1593 The following options are recognized:
1594
1595 debug
1596 If set to 1, enables the validation layer, if installed.
1597
1598 linear_images
1599 If set to 1, images allocated by the hwcontext will be
1600 linear and locally mappable.
1601
1602 instance_extensions
1603 A plus separated list of additional instance extensions to
1604 enable.
1605
1606 device_extensions
1607 A plus separated list of additional device extensions to
1608 enable.
1609
1610 Examples:
1611
1612 -init_hw_device vulkan:1
1613 Choose the second device on the system.
1614
1615 -init_hw_device vulkan:RADV
1616 Choose the first device with a name containing the string
1617 RADV.
1618
1619 -init_hw_device
1620 vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface
1621 Choose the first device and enable the Wayland and XCB
1622 instance extensions.
1623
1624 -init_hw_device type[=name]@source
1625 Initialise a new hardware device of type type called name, deriving
1626 it from the existing device with the name source.
1627
1628 -init_hw_device list
1629 List all hardware device types supported in this build of ffmpeg.
1630
1631 -filter_hw_device name
1632 Pass the hardware device called name to all filters in any filter
1633 graph. This can be used to set the device to upload to with the
1634 "hwupload" filter, or the device to map to with the "hwmap" filter.
1635 Other filters may also make use of this parameter when they require
1636 a hardware device. Note that this is typically only required when
1637 the input is not already in hardware frames - when it is, filters
1638 will derive the device they require from the context of the frames
1639 they receive as input.
1640
1641 This is a global setting, so all filters will receive the same
1642 device.
1643
1644 -hwaccel[:stream_specifier] hwaccel (input,per-stream)
1645 Use hardware acceleration to decode the matching stream(s). The
1646 allowed values of hwaccel are:
1647
1648 none
1649 Do not use any hardware acceleration (the default).
1650
1651 auto
1652 Automatically select the hardware acceleration method.
1653
1654 vdpau
1655 Use VDPAU (Video Decode and Presentation API for Unix) hardware
1656 acceleration.
1657
1658 dxva2
1659 Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
1660
1661 d3d11va
1662 Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
1663
1664 vaapi
1665 Use VAAPI (Video Acceleration API) hardware acceleration.
1666
1667 qsv Use the Intel QuickSync Video acceleration for video
1668 transcoding.
1669
1670 Unlike most other values, this option does not enable
1671 accelerated decoding (that is used automatically whenever a qsv
1672 decoder is selected), but accelerated transcoding, without
1673 copying the frames into the system memory.
1674
1675 For it to work, both the decoder and the encoder must support
1676 QSV acceleration and no filters must be used.
1677
1678 This option has no effect if the selected hwaccel is not available
1679 or not supported by the chosen decoder.
1680
1681 Note that most acceleration methods are intended for playback and
1682 will not be faster than software decoding on modern CPUs.
1683 Additionally, ffmpeg will usually need to copy the decoded frames
1684 from the GPU memory into the system memory, resulting in further
1685 performance loss. This option is thus mainly useful for testing.
1686
1687 -hwaccel_device[:stream_specifier] hwaccel_device (input,per-stream)
1688 Select a device to use for hardware acceleration.
1689
1690 This option only makes sense when the -hwaccel option is also
1691 specified. It can either refer to an existing device created with
1692 -init_hw_device by name, or it can create a new device as if
1693 -init_hw_device type:hwaccel_device were called immediately before.
1694
1695 -hwaccels
1696 List all hardware acceleration components enabled in this build of
1697 ffmpeg. Actual runtime availability depends on the hardware and
1698 its suitable driver being installed.
1699
1700 Audio Options
1701 -aframes number (output)
1702 Set the number of audio frames to output. This is an obsolete alias
1703 for "-frames:a", which you should use instead.
1704
1705 -ar[:stream_specifier] freq (input/output,per-stream)
1706 Set the audio sampling frequency. For output streams it is set by
1707 default to the frequency of the corresponding input stream. For
1708 input streams this option only makes sense for audio grabbing
1709 devices and raw demuxers and is mapped to the corresponding demuxer
1710 options.
1711
1712 -aq q (output)
1713 Set the audio quality (codec-specific, VBR). This is an alias for
1714 -q:a.
1715
1716 -ac[:stream_specifier] channels (input/output,per-stream)
1717 Set the number of audio channels. For output streams it is set by
1718 default to the number of input audio channels. For input streams
1719 this option only makes sense for audio grabbing devices and raw
1720 demuxers and is mapped to the corresponding demuxer options.
1721
1722 -an (input/output)
1723 As an input option, blocks all audio streams of a file from being
1724 filtered or being automatically selected or mapped for any output.
1725 See "-discard" option to disable streams individually.
1726
1727 As an output option, disables audio recording i.e. automatic
1728 selection or mapping of any audio stream. For full manual control
1729 see the "-map" option.
1730
1731 -acodec codec (input/output)
1732 Set the audio codec. This is an alias for "-codec:a".
1733
1734 -sample_fmt[:stream_specifier] sample_fmt (output,per-stream)
1735 Set the audio sample format. Use "-sample_fmts" to get a list of
1736 supported sample formats.
1737
1738 -af filtergraph (output)
1739 Create the filtergraph specified by filtergraph and use it to
1740 filter the stream.
1741
1742 This is an alias for "-filter:a", see the -filter option.
1743
1744 Advanced Audio options
1745 -atag fourcc/tag (output)
1746 Force audio tag/fourcc. This is an alias for "-tag:a".
1747
1748 -absf bitstream_filter
1749 Deprecated, see -bsf
1750
1751 -guess_layout_max channels (input,per-stream)
1752 If some input channel layout is not known, try to guess only if it
1753 corresponds to at most the specified number of channels. For
1754 example, 2 tells to ffmpeg to recognize 1 channel as mono and 2
1755 channels as stereo but not 6 channels as 5.1. The default is to
1756 always try to guess. Use 0 to disable all guessing.
1757
1758 Subtitle options
1759 -scodec codec (input/output)
1760 Set the subtitle codec. This is an alias for "-codec:s".
1761
1762 -sn (input/output)
1763 As an input option, blocks all subtitle streams of a file from
1764 being filtered or being automatically selected or mapped for any
1765 output. See "-discard" option to disable streams individually.
1766
1767 As an output option, disables subtitle recording i.e. automatic
1768 selection or mapping of any subtitle stream. For full manual
1769 control see the "-map" option.
1770
1771 -sbsf bitstream_filter
1772 Deprecated, see -bsf
1773
1774 Advanced Subtitle options
1775 -fix_sub_duration
1776 Fix subtitles durations. For each subtitle, wait for the next
1777 packet in the same stream and adjust the duration of the first to
1778 avoid overlap. This is necessary with some subtitles codecs,
1779 especially DVB subtitles, because the duration in the original
1780 packet is only a rough estimate and the end is actually marked by
1781 an empty subtitle frame. Failing to use this option when necessary
1782 can result in exaggerated durations or muxing failures due to non-
1783 monotonic timestamps.
1784
1785 Note that this option will delay the output of all data until the
1786 next subtitle packet is decoded: it may increase memory consumption
1787 and latency a lot.
1788
1789 -canvas_size size
1790 Set the size of the canvas used to render subtitles.
1791
1792 Advanced options
1793 -map
1794 [-]input_file_id[:stream_specifier][?][,sync_file_id[:stream_specifier]]
1795 | [linklabel] (output)
1796 Designate one or more input streams as a source for the output
1797 file. Each input stream is identified by the input file index
1798 input_file_id and the input stream index input_stream_id within the
1799 input file. Both indices start at 0. If specified,
1800 sync_file_id:stream_specifier sets which input stream is used as a
1801 presentation sync reference.
1802
1803 The first "-map" option on the command line specifies the source
1804 for output stream 0, the second "-map" option specifies the source
1805 for output stream 1, etc.
1806
1807 A "-" character before the stream identifier creates a "negative"
1808 mapping. It disables matching streams from already created
1809 mappings.
1810
1811 A trailing "?" after the stream index will allow the map to be
1812 optional: if the map matches no streams the map will be ignored
1813 instead of failing. Note the map will still fail if an invalid
1814 input file index is used; such as if the map refers to a non-
1815 existent input.
1816
1817 An alternative [linklabel] form will map outputs from complex
1818 filter graphs (see the -filter_complex option) to the output file.
1819 linklabel must correspond to a defined output link label in the
1820 graph.
1821
1822 For example, to map ALL streams from the first input file to output
1823
1824 ffmpeg -i INPUT -map 0 output
1825
1826 For example, if you have two audio streams in the first input file,
1827 these streams are identified by "0:0" and "0:1". You can use "-map"
1828 to select which streams to place in an output file. For example:
1829
1830 ffmpeg -i INPUT -map 0:1 out.wav
1831
1832 will map the input stream in INPUT identified by "0:1" to the
1833 (single) output stream in out.wav.
1834
1835 For example, to select the stream with index 2 from input file
1836 a.mov (specified by the identifier "0:2"), and stream with index 6
1837 from input b.mov (specified by the identifier "1:6"), and copy them
1838 to the output file out.mov:
1839
1840 ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
1841
1842 To select all video and the third audio stream from an input file:
1843
1844 ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
1845
1846 To map all the streams except the second audio, use negative
1847 mappings
1848
1849 ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
1850
1851 To map the video and audio streams from the first input, and using
1852 the trailing "?", ignore the audio mapping if no audio streams
1853 exist in the first input:
1854
1855 ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
1856
1857 To pick the English audio stream:
1858
1859 ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
1860
1861 Note that using this option disables the default mappings for this
1862 output file.
1863
1864 -ignore_unknown
1865 Ignore input streams with unknown type instead of failing if
1866 copying such streams is attempted.
1867
1868 -copy_unknown
1869 Allow input streams with unknown type to be copied instead of
1870 failing if copying such streams is attempted.
1871
1872 -map_channel
1873 [input_file_id.stream_specifier.channel_id|-1][?][:output_file_id.stream_specifier]
1874 Map an audio channel from a given input to an output. If
1875 output_file_id.stream_specifier is not set, the audio channel will
1876 be mapped on all the audio streams.
1877
1878 Using "-1" instead of input_file_id.stream_specifier.channel_id
1879 will map a muted channel.
1880
1881 A trailing "?" will allow the map_channel to be optional: if the
1882 map_channel matches no channel the map_channel will be ignored
1883 instead of failing.
1884
1885 For example, assuming INPUT is a stereo audio file, you can switch
1886 the two audio channels with the following command:
1887
1888 ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
1889
1890 If you want to mute the first channel and keep the second:
1891
1892 ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
1893
1894 The order of the "-map_channel" option specifies the order of the
1895 channels in the output stream. The output channel layout is guessed
1896 from the number of channels mapped (mono if one "-map_channel",
1897 stereo if two, etc.). Using "-ac" in combination of "-map_channel"
1898 makes the channel gain levels to be updated if input and output
1899 channel layouts don't match (for instance two "-map_channel"
1900 options and "-ac 6").
1901
1902 You can also extract each channel of an input to specific outputs;
1903 the following command extracts two channels of the INPUT audio
1904 stream (file 0, stream 0) to the respective OUTPUT_CH0 and
1905 OUTPUT_CH1 outputs:
1906
1907 ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
1908
1909 The following example splits the channels of a stereo input into
1910 two separate streams, which are put into the same output file:
1911
1912 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
1913
1914 Note that currently each output stream can only contain channels
1915 from a single input stream; you can't for example use
1916 "-map_channel" to pick multiple input audio channels contained in
1917 different streams (from the same or different files) and merge them
1918 into a single output stream. It is therefore not currently
1919 possible, for example, to turn two separate mono streams into a
1920 single stereo stream. However splitting a stereo stream into two
1921 single channel mono streams is possible.
1922
1923 If you need this feature, a possible workaround is to use the
1924 amerge filter. For example, if you need to merge a media (here
1925 input.mkv) with 2 mono audio streams into one single stereo channel
1926 audio stream (and keep the video stream), you can use the following
1927 command:
1928
1929 ffmpeg -i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:v copy output.mkv
1930
1931 To map the first two audio channels from the first input, and using
1932 the trailing "?", ignore the audio channel mapping if the first
1933 input is mono instead of stereo:
1934
1935 ffmpeg -i INPUT -map_channel 0.0.0 -map_channel 0.0.1? OUTPUT
1936
1937 -map_metadata[:metadata_spec_out] infile[:metadata_spec_in]
1938 (output,per-metadata)
1939 Set metadata information of the next output file from infile. Note
1940 that those are file indices (zero-based), not filenames. Optional
1941 metadata_spec_in/out parameters specify, which metadata to copy. A
1942 metadata specifier can have the following forms:
1943
1944 g global metadata, i.e. metadata that applies to the whole file
1945
1946 s[:stream_spec]
1947 per-stream metadata. stream_spec is a stream specifier as
1948 described in the Stream specifiers chapter. In an input
1949 metadata specifier, the first matching stream is copied from.
1950 In an output metadata specifier, all matching streams are
1951 copied to.
1952
1953 c:chapter_index
1954 per-chapter metadata. chapter_index is the zero-based chapter
1955 index.
1956
1957 p:program_index
1958 per-program metadata. program_index is the zero-based program
1959 index.
1960
1961 If metadata specifier is omitted, it defaults to global.
1962
1963 By default, global metadata is copied from the first input file,
1964 per-stream and per-chapter metadata is copied along with
1965 streams/chapters. These default mappings are disabled by creating
1966 any mapping of the relevant type. A negative file index can be used
1967 to create a dummy mapping that just disables automatic copying.
1968
1969 For example to copy metadata from the first stream of the input
1970 file to global metadata of the output file:
1971
1972 ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
1973
1974 To do the reverse, i.e. copy global metadata to all audio streams:
1975
1976 ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
1977
1978 Note that simple 0 would work as well in this example, since global
1979 metadata is assumed by default.
1980
1981 -map_chapters input_file_index (output)
1982 Copy chapters from input file with index input_file_index to the
1983 next output file. If no chapter mapping is specified, then chapters
1984 are copied from the first input file with at least one chapter. Use
1985 a negative file index to disable any chapter copying.
1986
1987 -benchmark (global)
1988 Show benchmarking information at the end of an encode. Shows real,
1989 system and user time used and maximum memory consumption. Maximum
1990 memory consumption is not supported on all systems, it will usually
1991 display as 0 if not supported.
1992
1993 -benchmark_all (global)
1994 Show benchmarking information during the encode. Shows real,
1995 system and user time used in various steps (audio/video
1996 encode/decode).
1997
1998 -timelimit duration (global)
1999 Exit after ffmpeg has been running for duration seconds in CPU user
2000 time.
2001
2002 -dump (global)
2003 Dump each input packet to stderr.
2004
2005 -hex (global)
2006 When dumping packets, also dump the payload.
2007
2008 -readrate speed (input)
2009 Limit input read speed.
2010
2011 Its value is a floating-point positive number which represents the
2012 maximum duration of media, in seconds, that should be ingested in
2013 one second of wallclock time. Default value is zero and represents
2014 no imposed limitation on speed of ingestion. Value 1 represents
2015 real-time speed and is equivalent to "-re".
2016
2017 Mainly used to simulate a capture device or live input stream (e.g.
2018 when reading from a file). Should not be used with a low value
2019 when input is an actual capture device or live stream as it may
2020 cause packet loss.
2021
2022 It is useful for when flow speed of output packets is important,
2023 such as live streaming.
2024
2025 -re (input)
2026 Read input at native frame rate. This is equivalent to setting
2027 "-readrate 1".
2028
2029 -vsync parameter
2030 Video sync method.
2031
2032 For compatibility reasons some of the values can be specified as
2033 numbers (shown in parentheses in the following table). This is
2034 deprecated and will stop working in the future.
2035
2036 passthrough (0)
2037 Each frame is passed with its timestamp from the demuxer to the
2038 muxer.
2039
2040 cfr (1)
2041 Frames will be duplicated and dropped to achieve exactly the
2042 requested constant frame rate.
2043
2044 vfr (2)
2045 Frames are passed through with their timestamp or dropped so as
2046 to prevent 2 frames from having the same timestamp.
2047
2048 drop
2049 As passthrough but destroys all timestamps, making the muxer
2050 generate fresh timestamps based on frame-rate.
2051
2052 auto (-1)
2053 Chooses between cfr and vfr depending on muxer capabilities.
2054 This is the default method.
2055
2056 Note that the timestamps may be further modified by the muxer,
2057 after this. For example, in the case that the format option
2058 avoid_negative_ts is enabled.
2059
2060 With -map you can select from which stream the timestamps should be
2061 taken. You can leave either video or audio unchanged and sync the
2062 remaining stream(s) to the unchanged one.
2063
2064 -frame_drop_threshold parameter
2065 Frame drop threshold, which specifies how much behind video frames
2066 can be before they are dropped. In frame rate units, so 1.0 is one
2067 frame. The default is -1.1. One possible usecase is to avoid
2068 framedrops in case of noisy timestamps or to increase frame drop
2069 precision in case of exact timestamps.
2070
2071 -async samples_per_second
2072 Audio sync method. "Stretches/squeezes" the audio stream to match
2073 the timestamps, the parameter is the maximum samples per second by
2074 which the audio is changed. -async 1 is a special case where only
2075 the start of the audio stream is corrected without any later
2076 correction.
2077
2078 Note that the timestamps may be further modified by the muxer,
2079 after this. For example, in the case that the format option
2080 avoid_negative_ts is enabled.
2081
2082 This option has been deprecated. Use the "aresample" audio filter
2083 instead.
2084
2085 -adrift_threshold time
2086 Set the minimum difference between timestamps and audio data (in
2087 seconds) to trigger adding/dropping samples to make it match the
2088 timestamps. This option effectively is a threshold to select
2089 between hard (add/drop) and soft (squeeze/stretch) compensation.
2090 "-async" must be set to a positive value.
2091
2092 -apad parameters (output,per-stream)
2093 Pad the output audio stream(s). This is the same as applying "-af
2094 apad". Argument is a string of filter parameters composed the same
2095 as with the "apad" filter. "-shortest" must be set for this output
2096 for the option to take effect.
2097
2098 -copyts
2099 Do not process input timestamps, but keep their values without
2100 trying to sanitize them. In particular, do not remove the initial
2101 start time offset value.
2102
2103 Note that, depending on the vsync option or on specific muxer
2104 processing (e.g. in case the format option avoid_negative_ts is
2105 enabled) the output timestamps may mismatch with the input
2106 timestamps even when this option is selected.
2107
2108 -start_at_zero
2109 When used with copyts, shift input timestamps so they start at
2110 zero.
2111
2112 This means that using e.g. "-ss 50" will make output timestamps
2113 start at 50 seconds, regardless of what timestamp the input file
2114 started at.
2115
2116 -copytb mode
2117 Specify how to set the encoder timebase when stream copying. mode
2118 is an integer numeric value, and can assume one of the following
2119 values:
2120
2121 1 Use the demuxer timebase.
2122
2123 The time base is copied to the output encoder from the
2124 corresponding input demuxer. This is sometimes required to
2125 avoid non monotonically increasing timestamps when copying
2126 video streams with variable frame rate.
2127
2128 0 Use the decoder timebase.
2129
2130 The time base is copied to the output encoder from the
2131 corresponding input decoder.
2132
2133 -1 Try to make the choice automatically, in order to generate a
2134 sane output.
2135
2136 Default value is -1.
2137
2138 -enc_time_base[:stream_specifier] timebase (output,per-stream)
2139 Set the encoder timebase. timebase is a floating point number, and
2140 can assume one of the following values:
2141
2142 0 Assign a default value according to the media type.
2143
2144 For video - use 1/framerate, for audio - use 1/samplerate.
2145
2146 -1 Use the input stream timebase when possible.
2147
2148 If an input stream is not available, the default timebase will
2149 be used.
2150
2151 >0 Use the provided number as the timebase.
2152
2153 This field can be provided as a ratio of two integers (e.g.
2154 1:24, 1:48000) or as a floating point number (e.g. 0.04166,
2155 2.0833e-5)
2156
2157 Default value is 0.
2158
2159 -bitexact (input/output)
2160 Enable bitexact mode for (de)muxer and (de/en)coder
2161
2162 -shortest (output)
2163 Finish encoding when the shortest input stream ends.
2164
2165 -dts_delta_threshold
2166 Timestamp discontinuity delta threshold.
2167
2168 -dts_error_threshold seconds
2169 Timestamp error delta threshold. This threshold use to discard
2170 crazy/damaged timestamps and the default is 30 hours which is
2171 arbitrarily picked and quite conservative.
2172
2173 -muxdelay seconds (output)
2174 Set the maximum demux-decode delay.
2175
2176 -muxpreload seconds (output)
2177 Set the initial demux-decode delay.
2178
2179 -streamid output-stream-index:new-value (output)
2180 Assign a new stream-id value to an output stream. This option
2181 should be specified prior to the output filename to which it
2182 applies. For the situation where multiple output files exist, a
2183 streamid may be reassigned to a different value.
2184
2185 For example, to set the stream 0 PID to 33 and the stream 1 PID to
2186 36 for an output mpegts file:
2187
2188 ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
2189
2190 -bsf[:stream_specifier] bitstream_filters (output,per-stream)
2191 Set bitstream filters for matching streams. bitstream_filters is a
2192 comma-separated list of bitstream filters. Use the "-bsfs" option
2193 to get the list of bitstream filters.
2194
2195 ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
2196
2197
2198 ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
2199
2200 -tag[:stream_specifier] codec_tag (input/output,per-stream)
2201 Force a tag/fourcc for matching streams.
2202
2203 -timecode hh:mm:ssSEPff
2204 Specify Timecode for writing. SEP is ':' for non drop timecode and
2205 ';' (or '.') for drop.
2206
2207 ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
2208
2209 -filter_complex filtergraph (global)
2210 Define a complex filtergraph, i.e. one with arbitrary number of
2211 inputs and/or outputs. For simple graphs -- those with one input
2212 and one output of the same type -- see the -filter options.
2213 filtergraph is a description of the filtergraph, as described in
2214 the ``Filtergraph syntax'' section of the ffmpeg-filters manual.
2215
2216 Input link labels must refer to input streams using the
2217 "[file_index:stream_specifier]" syntax (i.e. the same as -map
2218 uses). If stream_specifier matches multiple streams, the first one
2219 will be used. An unlabeled input will be connected to the first
2220 unused input stream of the matching type.
2221
2222 Output link labels are referred to with -map. Unlabeled outputs are
2223 added to the first output file.
2224
2225 Note that with this option it is possible to use only lavfi sources
2226 without normal input files.
2227
2228 For example, to overlay an image over video
2229
2230 ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
2231 '[out]' out.mkv
2232
2233 Here "[0:v]" refers to the first video stream in the first input
2234 file, which is linked to the first (main) input of the overlay
2235 filter. Similarly the first video stream in the second input is
2236 linked to the second (overlay) input of overlay.
2237
2238 Assuming there is only one video stream in each input file, we can
2239 omit input labels, so the above is equivalent to
2240
2241 ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
2242 '[out]' out.mkv
2243
2244 Furthermore we can omit the output label and the single output from
2245 the filter graph will be added to the output file automatically, so
2246 we can simply write
2247
2248 ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
2249
2250 As a special exception, you can use a bitmap subtitle stream as
2251 input: it will be converted into a video with the same size as the
2252 largest video in the file, or 720x576 if no video is present. Note
2253 that this is an experimental and temporary solution. It will be
2254 removed once libavfilter has proper support for subtitles.
2255
2256 For example, to hardcode subtitles on top of a DVB-T recording
2257 stored in MPEG-TS format, delaying the subtitles by 1 second:
2258
2259 ffmpeg -i input.ts -filter_complex \
2260 '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
2261 -sn -map '#0x2dc' output.mkv
2262
2263 (0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the
2264 video, audio and subtitles streams; 0:0, 0:3 and 0:7 would have
2265 worked too)
2266
2267 To generate 5 seconds of pure red video using lavfi "color" source:
2268
2269 ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
2270
2271 -filter_complex_threads nb_threads (global)
2272 Defines how many threads are used to process a filter_complex
2273 graph. Similar to filter_threads but used for "-filter_complex"
2274 graphs only. The default is the number of available CPUs.
2275
2276 -lavfi filtergraph (global)
2277 Define a complex filtergraph, i.e. one with arbitrary number of
2278 inputs and/or outputs. Equivalent to -filter_complex.
2279
2280 -filter_complex_script filename (global)
2281 This option is similar to -filter_complex, the only difference is
2282 that its argument is the name of the file from which a complex
2283 filtergraph description is to be read.
2284
2285 -accurate_seek (input)
2286 This option enables or disables accurate seeking in input files
2287 with the -ss option. It is enabled by default, so seeking is
2288 accurate when transcoding. Use -noaccurate_seek to disable it,
2289 which may be useful e.g. when copying some streams and transcoding
2290 the others.
2291
2292 -seek_timestamp (input)
2293 This option enables or disables seeking by timestamp in input files
2294 with the -ss option. It is disabled by default. If enabled, the
2295 argument to the -ss option is considered an actual timestamp, and
2296 is not offset by the start time of the file. This matters only for
2297 files which do not start from timestamp 0, such as transport
2298 streams.
2299
2300 -thread_queue_size size (input)
2301 This option sets the maximum number of queued packets when reading
2302 from the file or device. With low latency / high rate live streams,
2303 packets may be discarded if they are not read in a timely manner;
2304 setting this value can force ffmpeg to use a separate input thread
2305 and read packets as soon as they arrive. By default ffmpeg only do
2306 this if multiple inputs are specified.
2307
2308 -sdp_file file (global)
2309 Print sdp information for an output stream to file. This allows
2310 dumping sdp information when at least one output isn't an rtp
2311 stream. (Requires at least one of the output formats to be rtp).
2312
2313 -discard (input)
2314 Allows discarding specific streams or frames from streams. Any
2315 input stream can be fully discarded, using value "all" whereas
2316 selective discarding of frames from a stream occurs at the demuxer
2317 and is not supported by all demuxers.
2318
2319 none
2320 Discard no frame.
2321
2322 default
2323 Default, which discards no frames.
2324
2325 noref
2326 Discard all non-reference frames.
2327
2328 bidir
2329 Discard all bidirectional frames.
2330
2331 nokey
2332 Discard all frames excepts keyframes.
2333
2334 all Discard all frames.
2335
2336 -abort_on flags (global)
2337 Stop and abort on various conditions. The following flags are
2338 available:
2339
2340 empty_output
2341 No packets were passed to the muxer, the output is empty.
2342
2343 empty_output_stream
2344 No packets were passed to the muxer in some of the output
2345 streams.
2346
2347 -max_error_rate (global)
2348 Set fraction of decoding frame failures across all inputs which
2349 when crossed ffmpeg will return exit code 69. Crossing this
2350 threshold does not terminate processing. Range is a floating-point
2351 number between 0 to 1. Default is 2/3.
2352
2353 -xerror (global)
2354 Stop and exit on error
2355
2356 -max_muxing_queue_size packets (output,per-stream)
2357 When transcoding audio and/or video streams, ffmpeg will not begin
2358 writing into the output until it has one packet for each such
2359 stream. While waiting for that to happen, packets for other streams
2360 are buffered. This option sets the size of this buffer, in packets,
2361 for the matching output stream.
2362
2363 The default value of this option should be high enough for most
2364 uses, so only touch this option if you are sure that you need it.
2365
2366 -muxing_queue_data_threshold bytes (output,per-stream)
2367 This is a minimum threshold until which the muxing queue size is
2368 not taken into account. Defaults to 50 megabytes per stream, and is
2369 based on the overall size of packets passed to the muxer.
2370
2371 -auto_conversion_filters (global)
2372 Enable automatically inserting format conversion filters in all
2373 filter graphs, including those defined by -vf, -af, -filter_complex
2374 and -lavfi. If filter format negotiation requires a conversion, the
2375 initialization of the filters will fail. Conversions can still be
2376 performed by inserting the relevant conversion filter (scale,
2377 aresample) in the graph. On by default, to explicitly disable it
2378 you need to specify "-noauto_conversion_filters".
2379
2380 -bits_per_raw_sample[:stream_specifier] value (output,per-stream)
2381 Declare the number of bits per raw sample in the given output
2382 stream to be value. Note that this option sets the information
2383 provided to the encoder/muxer, it does not change the stream to
2384 conform to this value. Setting values that do not match the stream
2385 properties may result in encoding failures or invalid output files.
2386
2387 Preset files
2388 A preset file contains a sequence of option=value pairs, one for each
2389 line, specifying a sequence of options which would be awkward to
2390 specify on the command line. Lines starting with the hash ('#')
2391 character are ignored and are used to provide comments. Check the
2392 presets directory in the FFmpeg source tree for examples.
2393
2394 There are two types of preset files: ffpreset and avpreset files.
2395
2396 ffpreset files
2397
2398 ffpreset files are specified with the "vpre", "apre", "spre", and
2399 "fpre" options. The "fpre" option takes the filename of the preset
2400 instead of a preset name as input and can be used for any kind of
2401 codec. For the "vpre", "apre", and "spre" options, the options
2402 specified in a preset file are applied to the currently selected codec
2403 of the same type as the preset option.
2404
2405 The argument passed to the "vpre", "apre", and "spre" preset options
2406 identifies the preset file to use according to the following rules:
2407
2408 First ffmpeg searches for a file named arg.ffpreset in the directories
2409 $FFMPEG_DATADIR (if set), and $HOME/.ffmpeg, and in the datadir defined
2410 at configuration time (usually PREFIX/share/ffmpeg) or in a ffpresets
2411 folder along the executable on win32, in that order. For example, if
2412 the argument is "libvpx-1080p", it will search for the file
2413 libvpx-1080p.ffpreset.
2414
2415 If no such file is found, then ffmpeg will search for a file named
2416 codec_name-arg.ffpreset in the above-mentioned directories, where
2417 codec_name is the name of the codec to which the preset file options
2418 will be applied. For example, if you select the video codec with
2419 "-vcodec libvpx" and use "-vpre 1080p", then it will search for the
2420 file libvpx-1080p.ffpreset.
2421
2422 avpreset files
2423
2424 avpreset files are specified with the "pre" option. They work similar
2425 to ffpreset files, but they only allow encoder- specific options.
2426 Therefore, an option=value pair specifying an encoder cannot be used.
2427
2428 When the "pre" option is specified, ffmpeg will look for files with the
2429 suffix .avpreset in the directories $AVCONV_DATADIR (if set), and
2430 $HOME/.avconv, and in the datadir defined at configuration time
2431 (usually PREFIX/share/ffmpeg), in that order.
2432
2433 First ffmpeg searches for a file named codec_name-arg.avpreset in the
2434 above-mentioned directories, where codec_name is the name of the codec
2435 to which the preset file options will be applied. For example, if you
2436 select the video codec with "-vcodec libvpx" and use "-pre 1080p", then
2437 it will search for the file libvpx-1080p.avpreset.
2438
2439 If no such file is found, then ffmpeg will search for a file named
2440 arg.avpreset in the same directories.
2441
2443 Video and Audio grabbing
2444 If you specify the input format and device then ffmpeg can grab video
2445 and audio directly.
2446
2447 ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
2448
2449 Or with an ALSA audio source (mono input, card id 1) instead of OSS:
2450
2451 ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
2452
2453 Note that you must activate the right video source and channel before
2454 launching ffmpeg with any TV viewer such as
2455 <http://linux.bytesex.org/xawtv/> by Gerd Knorr. You also have to set
2456 the audio recording levels correctly with a standard mixer.
2457
2458 X11 grabbing
2459 Grab the X11 display with ffmpeg via
2460
2461 ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
2462
2463 0.0 is display.screen number of your X11 server, same as the DISPLAY
2464 environment variable.
2465
2466 ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
2467
2468 0.0 is display.screen number of your X11 server, same as the DISPLAY
2469 environment variable. 10 is the x-offset and 20 the y-offset for the
2470 grabbing.
2471
2472 Video and Audio file format conversion
2473 Any supported file format and protocol can serve as input to ffmpeg:
2474
2475 Examples:
2476
2477 • You can use YUV files as input:
2478
2479 ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
2480
2481 It will use the files:
2482
2483 /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
2484 /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
2485
2486 The Y files use twice the resolution of the U and V files. They are
2487 raw files, without header. They can be generated by all decent
2488 video decoders. You must specify the size of the image with the -s
2489 option if ffmpeg cannot guess it.
2490
2491 • You can input from a raw YUV420P file:
2492
2493 ffmpeg -i /tmp/test.yuv /tmp/out.avi
2494
2495 test.yuv is a file containing raw YUV planar data. Each frame is
2496 composed of the Y plane followed by the U and V planes at half
2497 vertical and horizontal resolution.
2498
2499 • You can output to a raw YUV420P file:
2500
2501 ffmpeg -i mydivx.avi hugefile.yuv
2502
2503 • You can set several input files and output files:
2504
2505 ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
2506
2507 Converts the audio file a.wav and the raw YUV video file a.yuv to
2508 MPEG file a.mpg.
2509
2510 • You can also do audio and video conversions at the same time:
2511
2512 ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
2513
2514 Converts a.wav to MPEG audio at 22050 Hz sample rate.
2515
2516 • You can encode to several formats at the same time and define a
2517 mapping from input stream to output streams:
2518
2519 ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
2520
2521 Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits.
2522 '-map file:index' specifies which input stream is used for each
2523 output stream, in the order of the definition of output streams.
2524
2525 • You can transcode decrypted VOBs:
2526
2527 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
2528
2529 This is a typical DVD ripping example; the input is a VOB file, the
2530 output an AVI file with MPEG-4 video and MP3 audio. Note that in
2531 this command we use B-frames so the MPEG-4 stream is DivX5
2532 compatible, and GOP size is 300 which means one intra frame every
2533 10 seconds for 29.97fps input video. Furthermore, the audio stream
2534 is MP3-encoded so you need to enable LAME support by passing
2535 "--enable-libmp3lame" to configure. The mapping is particularly
2536 useful for DVD transcoding to get the desired audio language.
2537
2538 NOTE: To see the supported input formats, use "ffmpeg -demuxers".
2539
2540 • You can extract images from a video, or create a video from many
2541 images:
2542
2543 For extracting images from a video:
2544
2545 ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
2546
2547 This will extract one video frame per second from the video and
2548 will output them in files named foo-001.jpeg, foo-002.jpeg, etc.
2549 Images will be rescaled to fit the new WxH values.
2550
2551 If you want to extract just a limited number of frames, you can use
2552 the above command in combination with the "-frames:v" or "-t"
2553 option, or in combination with -ss to start extracting from a
2554 certain point in time.
2555
2556 For creating a video from many images:
2557
2558 ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
2559
2560 The syntax "foo-%03d.jpeg" specifies to use a decimal number
2561 composed of three digits padded with zeroes to express the sequence
2562 number. It is the same syntax supported by the C printf function,
2563 but only formats accepting a normal integer are suitable.
2564
2565 When importing an image sequence, -i also supports expanding shell-
2566 like wildcard patterns (globbing) internally, by selecting the
2567 image2-specific "-pattern_type glob" option.
2568
2569 For example, for creating a video from filenames matching the glob
2570 pattern "foo-*.jpeg":
2571
2572 ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
2573
2574 • You can put many streams of the same type in the output:
2575
2576 ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
2577
2578 The resulting output file test12.nut will contain the first four
2579 streams from the input files in reverse order.
2580
2581 • To force CBR video output:
2582
2583 ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
2584
2585 • The four options lmin, lmax, mblmin and mblmax use 'lambda' units,
2586 but you may use the QP2LAMBDA constant to easily convert from 'q'
2587 units:
2588
2589 ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
2590
2592 ffmpeg-all(1), ffplay(1), ffprobe(1), ffmpeg-utils(1),
2593 ffmpeg-scaler(1), ffmpeg-resampler(1), ffmpeg-codecs(1),
2594 ffmpeg-bitstream-filters(1), ffmpeg-formats(1), ffmpeg-devices(1),
2595 ffmpeg-protocols(1), ffmpeg-filters(1)
2596
2598 The FFmpeg developers.
2599
2600 For details about the authorship, see the Git history of the project
2601 (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command git log in
2602 the FFmpeg source directory, or browsing the online repository at
2603 <http://source.ffmpeg.org>.
2604
2605 Maintainers for the specific components are listed in the file
2606 MAINTAINERS in the source code tree.
2607
2608
2609
2610 FFMPEG(1)