view ffmpeg/doc/ffmpeg.1 @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
line wrap: on
line source
.\" Automatically generated by Pod::Man 2.23 (Pod::Simple 3.14)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.el \{\
.    de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "FFMPEG 1"
.TH FFMPEG 1 "2013-04-21" " " " "
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
ffmpeg \- ffmpeg video converter
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
ffmpeg [\fIglobal_options\fR] {[\fIinput_file_options\fR] \-i \fIinput_file\fR} ... {[\fIoutput_file_options\fR] \fIoutput_file\fR} ...
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\fBffmpeg\fR is a very fast video and audio converter that can also grab from
a live audio/video source. It can also convert between arbitrary sample
rates and resize video on the fly with a high quality polyphase filter.
.PP
\&\fBffmpeg\fR reads from an arbitrary number of input \*(L"files\*(R" (which can be regular
files, pipes, network streams, grabbing devices, etc.), specified by the
\&\f(CW\*(C`\-i\*(C'\fR option, and writes to an arbitrary number of output \*(L"files\*(R", which are
specified by a plain output filename. Anything found on the command line which
cannot be interpreted as an option is considered to be an output filename.
.PP
Each input or output file can, in principle, contain any number of streams of
different types (video/audio/subtitle/attachment/data). The allowed number and/or
types of streams may be limited by the container format. Selecting which
streams from which inputs will go into which output is either done automatically
or with the \f(CW\*(C`\-map\*(C'\fR option (see the Stream selection chapter).
.PP
To refer to input files in options, you must use their indices (0\-based). E.g.
the first input file is \f(CW0\fR, the second is \f(CW1\fR, etc. Similarly, streams
within a file are referred to by their indices. E.g. \f(CW\*(C`2:3\*(C'\fR refers to the
fourth stream in the third input file. Also see the Stream specifiers chapter.
.PP
As a general rule, options are applied to the next specified
file. Therefore, order is important, and you can have the same
option on the command line multiple times. Each occurrence is
then applied to the next input or output file.
Exceptions from this rule are the global options (e.g. verbosity level),
which should be specified first.
.PP
Do not mix input and output files \*(-- first specify all input files, then all
output files. Also do not mix options which belong to different files. All
options apply \s-1ONLY\s0 to the next input or output file and are reset between files.
.IP "\(bu" 4
To set the video bitrate of the output file to 64 kbit/s:
.Sp
.Vb 1
\&        ffmpeg \-i input.avi \-b:v 64k \-bufsize 64k output.avi
.Ve
.IP "\(bu" 4
To force the frame rate of the output file to 24 fps:
.Sp
.Vb 1
\&        ffmpeg \-i input.avi \-r 24 output.avi
.Ve
.IP "\(bu" 4
To force the frame rate of the input file (valid for raw formats only)
to 1 fps and the frame rate of the output file to 24 fps:
.Sp
.Vb 1
\&        ffmpeg \-r 1 \-i input.m2v \-r 24 output.avi
.Ve
.PP
The format option may be needed for raw input files.
.SH "DETAILED DESCRIPTION"
.IX Header "DETAILED DESCRIPTION"
The transcoding process in \fBffmpeg\fR for each output can be described by
the following diagram:
.PP
.Vb 5
\&         _\|_\|_\|_\|_\|_\|_              _\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_               _\|_\|_\|_\|_\|_\|_\|_\|_              _\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_            _\|_\|_\|_\|_\|_\|_\|_
\&        |       |            |              |             |         |            |              |          |        |
\&        | input |  demuxer   | encoded data |   decoder   | decoded |  encoder   | encoded data |  muxer   | output |
\&        | file  | \-\-\-\-\-\-\-\-\-> | packets      |  \-\-\-\-\-\-\-\-\-> | frames  | \-\-\-\-\-\-\-\-\-> | packets      | \-\-\-\-\-\-\-> | file   |
\&        |_\|_\|_\|_\|_\|_\|_|            |_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_|             |_\|_\|_\|_\|_\|_\|_\|_\|_|            |_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_|          |_\|_\|_\|_\|_\|_\|_\|_|
.Ve
.PP
\&\fBffmpeg\fR calls the libavformat library (containing demuxers) to read
input files and get packets containing encoded data from them. When there are
multiple input files, \fBffmpeg\fR tries to keep them synchronized by
tracking lowest timestamp on any active input stream.
.PP
Encoded packets are then passed to the decoder (unless streamcopy is selected
for the stream, see further for a description). The decoder produces
uncompressed frames (raw video/PCM audio/...) which can be processed further by
filtering (see next section). After filtering, the frames are passed to the
encoder, which encodes them and outputs encoded packets. Finally those are
passed to the muxer, which writes the encoded packets to the output file.
.SS "Filtering"
.IX Subsection "Filtering"
Before encoding, \fBffmpeg\fR can process raw audio and video frames using
filters from the libavfilter library. Several chained filters form a filter
graph. \fBffmpeg\fR distinguishes between two types of filtergraphs:
simple and complex.
.PP
\fISimple filtergraphs\fR
.IX Subsection "Simple filtergraphs"
.PP
Simple filtergraphs are those that have exactly one input and output, both of
the same type. In the above diagram they can be represented by simply inserting
an additional step between decoding and encoding:
.PP
.Vb 5
\&         _\|_\|_\|_\|_\|_\|_\|_\|_                        _\|_\|_\|_\|_\|_\|_\|_\|_\|_              _\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_
\&        |         |                      |          |            |              |
\&        | decoded |  simple filtergraph  | filtered |  encoder   | encoded data |
\&        | frames  | \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-> | frames   | \-\-\-\-\-\-\-\-\-> | packets      |
\&        |_\|_\|_\|_\|_\|_\|_\|_\|_|                      |_\|_\|_\|_\|_\|_\|_\|_\|_\|_|            |_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_|
.Ve
.PP
Simple filtergraphs are configured with the per-stream \fB\-filter\fR option
(with \fB\-vf\fR and \fB\-af\fR aliases for video and audio respectively).
A simple filtergraph for video can look for example like this:
.PP
.Vb 4
\&         _\|_\|_\|_\|_\|_\|_        _\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_        _\|_\|_\|_\|_\|_\|_        _\|_\|_\|_\|_        _\|_\|_\|_\|_\|_\|_\|_
\&        |       |      |             |      |       |      |     |      |        |
\&        | input | \-\-\-> | deinterlace | \-\-\-> | scale | \-\-\-> | fps | \-\-\-> | output |
\&        |_\|_\|_\|_\|_\|_\|_|      |_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_|      |_\|_\|_\|_\|_\|_\|_|      |_\|_\|_\|_\|_|      |_\|_\|_\|_\|_\|_\|_\|_|
.Ve
.PP
Note that some filters change frame properties but not frame contents. E.g. the
\&\f(CW\*(C`fps\*(C'\fR filter in the example above changes number of frames, but does not
touch the frame contents. Another example is the \f(CW\*(C`setpts\*(C'\fR filter, which
only sets timestamps and otherwise passes the frames unchanged.
.PP
\fIComplex filtergraphs\fR
.IX Subsection "Complex filtergraphs"
.PP
Complex filtergraphs are those which cannot be described as simply a linear
processing chain applied to one stream. This is the case, for example, when the graph has
more than one input and/or output, or when output stream type is different from
input. They can be represented with the following diagram:
.PP
.Vb 10
\&         _\|_\|_\|_\|_\|_\|_\|_\|_
\&        |         |
\&        | input 0 |\e                    _\|_\|_\|_\|_\|_\|_\|_\|_\|_
\&        |_\|_\|_\|_\|_\|_\|_\|_\|_| \e                  |          |
\&                     \e   _\|_\|_\|_\|_\|_\|_\|_\|_    /| output 0 |
\&                      \e |         |  / |_\|_\|_\|_\|_\|_\|_\|_\|_\|_|
\&         _\|_\|_\|_\|_\|_\|_\|_\|_     \e| complex | /
\&        |         |     |         |/
\&        | input 1 |\-\-\-\->| filter  |\e
\&        |_\|_\|_\|_\|_\|_\|_\|_\|_|     |         | \e   _\|_\|_\|_\|_\|_\|_\|_\|_\|_
\&                       /| graph   |  \e |          |
\&                      / |         |   \e| output 1 |
\&         _\|_\|_\|_\|_\|_\|_\|_\|_   /  |_\|_\|_\|_\|_\|_\|_\|_\|_|    |_\|_\|_\|_\|_\|_\|_\|_\|_\|_|
\&        |         | /
\&        | input 2 |/
\&        |_\|_\|_\|_\|_\|_\|_\|_\|_|
.Ve
.PP
Complex filtergraphs are configured with the \fB\-filter_complex\fR option.
Note that this option is global, since a complex filtergraph, by its nature,
cannot be unambiguously associated with a single stream or file.
.PP
The \fB\-lavfi\fR option is equivalent to \fB\-filter_complex\fR.
.PP
A trivial example of a complex filtergraph is the \f(CW\*(C`overlay\*(C'\fR filter, which
has two video inputs and one video output, containing one video overlaid on top
of the other. Its audio counterpart is the \f(CW\*(C`amix\*(C'\fR filter.
.SS "Stream copy"
.IX Subsection "Stream copy"
Stream copy is a mode selected by supplying the \f(CW\*(C`copy\*(C'\fR parameter to the
\&\fB\-codec\fR option. It makes \fBffmpeg\fR omit the decoding and encoding
step for the specified stream, so it does only demuxing and muxing. It is useful
for changing the container format or modifying container-level metadata. The
diagram above will, in this case, simplify to this:
.PP
.Vb 5
\&         _\|_\|_\|_\|_\|_\|_              _\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_            _\|_\|_\|_\|_\|_\|_\|_
\&        |       |            |              |          |        |
\&        | input |  demuxer   | encoded data |  muxer   | output |
\&        | file  | \-\-\-\-\-\-\-\-\-> | packets      | \-\-\-\-\-\-\-> | file   |
\&        |_\|_\|_\|_\|_\|_\|_|            |_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_\|_|          |_\|_\|_\|_\|_\|_\|_\|_|
.Ve
.PP
Since there is no decoding or encoding, it is very fast and there is no quality
loss. However, it might not work in some cases because of many factors. Applying
filters is obviously also impossible, since filters work on uncompressed data.
.SH "STREAM SELECTION"
.IX Header "STREAM SELECTION"
By default, \fBffmpeg\fR includes only one stream of each type (video, audio, subtitle)
present in the input files and adds them to each output file.  It picks the
\&\*(L"best\*(R" of each based upon the following criteria: for video, it is the stream
with the highest resolution, for audio, it is the stream with the most channels, for
subtitles, it is the first subtitle stream. In the case where several streams of
the same type rate equally, the stream with the lowest index is chosen.
.PP
You can disable some of those defaults by using the \f(CW\*(C`\-vn/\-an/\-sn\*(C'\fR options. For
full manual control, use the \f(CW\*(C`\-map\*(C'\fR option, which disables the defaults just
described.
.SH "OPTIONS"
.IX Header "OPTIONS"
All the numerical options, if not specified otherwise, accept a string
representing a number as input, which may be followed by one of the \s-1SI\s0
unit prefixes, for example: 'K', 'M', or 'G'.
.PP
If 'i' is appended to the \s-1SI\s0 unit prefix, the complete prefix will be
interpreted as a unit prefix for binary multiplies, which are based on
powers of 1024 instead of powers of 1000. Appending 'B' to the \s-1SI\s0 unit
prefix multiplies the value by 8. This allows using, for example:
\&'\s-1KB\s0', 'MiB', 'G' and 'B' as number suffixes.
.PP
Options which do not take arguments are boolean options, and set the
corresponding value to true. They can be set to false by prefixing
the option name with \*(L"no\*(R". For example using \*(L"\-nofoo\*(R"
will set the boolean option with name \*(L"foo\*(R" to false.
.SS "Stream specifiers"
.IX Subsection "Stream specifiers"
Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
are used to precisely specify which stream(s) a given option belongs to.
.PP
A stream specifier is a string generally appended to the option name and
separated from it by a colon. E.g. \f(CW\*(C`\-codec:a:1 ac3\*(C'\fR contains the
\&\f(CW\*(C`a:1\*(C'\fR stream specifier, which matches the second audio stream. Therefore, it
would select the ac3 codec for the second audio stream.
.PP
A stream specifier can match several streams, so that the option is applied to all
of them. E.g. the stream specifier in \f(CW\*(C`\-b:a 128k\*(C'\fR matches all audio
streams.
.PP
An empty stream specifier matches all streams. For example, \f(CW\*(C`\-codec copy\*(C'\fR
or \f(CW\*(C`\-codec: copy\*(C'\fR would copy all the streams without reencoding.
.PP
Possible forms of stream specifiers are:
.IP "\fIstream_index\fR" 4
.IX Item "stream_index"
Matches the stream with this index. E.g. \f(CW\*(C`\-threads:1 4\*(C'\fR would set the
thread count for the second stream to 4.
.IP "\fIstream_type\fR\fB[:\fR\fIstream_index\fR\fB]\fR" 4
.IX Item "stream_type[:stream_index]"
\&\fIstream_type\fR is one of following: 'v' for video, 'a' for audio, 's' for subtitle,
\&'d' for data, and 't' for attachments. If \fIstream_index\fR is given, then it matches
stream number \fIstream_index\fR of this type. Otherwise, it matches all
streams of this type.
.IP "\fBp:\fR\fIprogram_id\fR\fB[:\fR\fIstream_index\fR\fB]\fR" 4
.IX Item "p:program_id[:stream_index]"
If \fIstream_index\fR is given, then it matches the stream with number \fIstream_index\fR
in the program with the id \fIprogram_id\fR. Otherwise, it matches all streams in the
program.
.IP "\fB#\fR\fIstream_id\fR" 4
.IX Item "#stream_id"
Matches the stream by a format-specific \s-1ID\s0.
.SS "Generic options"
.IX Subsection "Generic options"
These options are shared amongst the ff* tools.
.IP "\fB\-L\fR" 4
.IX Item "-L"
Show license.
.IP "\fB\-h, \-?, \-help, \-\-help [\fR\fIarg\fR\fB]\fR" 4
.IX Item "-h, -?, -help, --help [arg]"
Show help. An optional parameter may be specified to print help about a specific
item.
.Sp
Possible values of \fIarg\fR are:
.RS 4
.IP "\fBdecoder=\fR\fIdecoder_name\fR" 4
.IX Item "decoder=decoder_name"
Print detailed information about the decoder named \fIdecoder_name\fR. Use the
\&\fB\-decoders\fR option to get a list of all decoders.
.IP "\fBencoder=\fR\fIencoder_name\fR" 4
.IX Item "encoder=encoder_name"
Print detailed information about the encoder named \fIencoder_name\fR. Use the
\&\fB\-encoders\fR option to get a list of all encoders.
.IP "\fBdemuxer=\fR\fIdemuxer_name\fR" 4
.IX Item "demuxer=demuxer_name"
Print detailed information about the demuxer named \fIdemuxer_name\fR. Use the
\&\fB\-formats\fR option to get a list of all demuxers and muxers.
.IP "\fBmuxer=\fR\fImuxer_name\fR" 4
.IX Item "muxer=muxer_name"
Print detailed information about the muxer named \fImuxer_name\fR. Use the
\&\fB\-formats\fR option to get a list of all muxers and demuxers.
.IP "\fBfilter=\fR\fIfilter_name\fR" 4
.IX Item "filter=filter_name"
Print detailed information about the filter name \fIfilter_name\fR. Use the
\&\fB\-filters\fR option to get a list of all filters.
.RE
.RS 4
.RE
.IP "\fB\-version\fR" 4
.IX Item "-version"
Show version.
.IP "\fB\-formats\fR" 4
.IX Item "-formats"
Show available formats.
.IP "\fB\-codecs\fR" 4
.IX Item "-codecs"
Show all codecs known to libavcodec.
.Sp
Note that the term 'codec' is used throughout this documentation as a shortcut
for what is more correctly called a media bitstream format.
.IP "\fB\-decoders\fR" 4
.IX Item "-decoders"
Show available decoders.
.IP "\fB\-encoders\fR" 4
.IX Item "-encoders"
Show all available encoders.
.IP "\fB\-bsfs\fR" 4
.IX Item "-bsfs"
Show available bitstream filters.
.IP "\fB\-protocols\fR" 4
.IX Item "-protocols"
Show available protocols.
.IP "\fB\-filters\fR" 4
.IX Item "-filters"
Show available libavfilter filters.
.IP "\fB\-pix_fmts\fR" 4
.IX Item "-pix_fmts"
Show available pixel formats.
.IP "\fB\-sample_fmts\fR" 4
.IX Item "-sample_fmts"
Show available sample formats.
.IP "\fB\-layouts\fR" 4
.IX Item "-layouts"
Show channel names and standard channel layouts.
.IP "\fB\-loglevel [repeat+]\fR\fIloglevel\fR \fB| \-v [repeat+]\fR\fIloglevel\fR" 4
.IX Item "-loglevel [repeat+]loglevel | -v [repeat+]loglevel"
Set the logging level used by the library.
Adding \*(L"repeat+\*(R" indicates that repeated log output should not be compressed
to the first line and the \*(L"Last message repeated n times\*(R" line will be
omitted. \*(L"repeat\*(R" can also be used alone.
If \*(L"repeat\*(R" is used alone, and with no prior loglevel set, the default
loglevel will be used. If multiple loglevel parameters are given, using
\&'repeat' will not change the loglevel.
\&\fIloglevel\fR is a number or a string containing one of the following values:
.RS 4
.IP "\fBquiet\fR" 4
.IX Item "quiet"
Show nothing at all; be silent.
.IP "\fBpanic\fR" 4
.IX Item "panic"
Only show fatal errors which could lead the process to crash, such as
and assert failure. This is not currently used for anything.
.IP "\fBfatal\fR" 4
.IX Item "fatal"
Only show fatal errors. These are errors after which the process absolutely
cannot continue after.
.IP "\fBerror\fR" 4
.IX Item "error"
Show all errors, including ones which can be recovered from.
.IP "\fBwarning\fR" 4
.IX Item "warning"
Show all warnings and errors. Any message related to possibly
incorrect or unexpected events will be shown.
.IP "\fBinfo\fR" 4
.IX Item "info"
Show informative messages during processing. This is in addition to
warnings and errors. This is the default value.
.IP "\fBverbose\fR" 4
.IX Item "verbose"
Same as \f(CW\*(C`info\*(C'\fR, except more verbose.
.IP "\fBdebug\fR" 4
.IX Item "debug"
Show everything, including debugging information.
.RE
.RS 4
.Sp
By default the program logs to stderr, if coloring is supported by the
terminal, colors are used to mark errors and warnings. Log coloring
can be disabled setting the environment variable
\&\fB\s-1AV_LOG_FORCE_NOCOLOR\s0\fR or \fB\s-1NO_COLOR\s0\fR, or can be forced setting
the environment variable \fB\s-1AV_LOG_FORCE_COLOR\s0\fR.
The use of the environment variable \fB\s-1NO_COLOR\s0\fR is deprecated and
will be dropped in a following FFmpeg version.
.RE
.IP "\fB\-report\fR" 4
.IX Item "-report"
Dump full command line and console output to a file named
\&\f(CW\*(C`\f(CIprogram\f(CW\-\f(CIYYYYMMDD\f(CW\-\f(CIHHMMSS\f(CW.log\*(C'\fR in the current
directory.
This file can be useful for bug reports.
It also implies \f(CW\*(C`\-loglevel verbose\*(C'\fR.
.Sp
Setting the environment variable \f(CW\*(C`FFREPORT\*(C'\fR to any value has the
same effect. If the value is a ':'\-separated key=value sequence, these
options will affect the report; options values must be escaped if they
contain special characters or the options delimiter ':' (see the
``Quoting and escaping'' section in the ffmpeg-utils manual). The
following option is recognized:
.RS 4
.IP "\fBfile\fR" 4
.IX Item "file"
set the file name to use for the report; \f(CW%p\fR is expanded to the name
of the program, \f(CW%t\fR is expanded to a timestamp, \f(CW\*(C`%%\*(C'\fR is expanded
to a plain \f(CW\*(C`%\*(C'\fR
.RE
.RS 4
.Sp
Errors in parsing the environment variable are not fatal, and will not
appear in the report.
.RE
.IP "\fB\-cpuflags flags (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-cpuflags flags (global)"
Allows setting and clearing cpu flags. This option is intended
for testing. Do not use it unless you know what you're doing.
.Sp
.Vb 3
\&        ffmpeg \-cpuflags \-sse+mmx ...
\&        ffmpeg \-cpuflags mmx ...
\&        ffmpeg \-cpuflags 0 ...
.Ve
.Sp
Possible flags for this option are:
.RS 4
.IP "\fBx86\fR" 4
.IX Item "x86"
.RS 4
.PD 0
.IP "\fBmmx\fR" 4
.IX Item "mmx"
.IP "\fBmmxext\fR" 4
.IX Item "mmxext"
.IP "\fBsse\fR" 4
.IX Item "sse"
.IP "\fBsse2\fR" 4
.IX Item "sse2"
.IP "\fBsse2slow\fR" 4
.IX Item "sse2slow"
.IP "\fBsse3\fR" 4
.IX Item "sse3"
.IP "\fBsse3slow\fR" 4
.IX Item "sse3slow"
.IP "\fBssse3\fR" 4
.IX Item "ssse3"
.IP "\fBatom\fR" 4
.IX Item "atom"
.IP "\fBsse4.1\fR" 4
.IX Item "sse4.1"
.IP "\fBsse4.2\fR" 4
.IX Item "sse4.2"
.IP "\fBavx\fR" 4
.IX Item "avx"
.IP "\fBxop\fR" 4
.IX Item "xop"
.IP "\fBfma4\fR" 4
.IX Item "fma4"
.IP "\fB3dnow\fR" 4
.IX Item "3dnow"
.IP "\fB3dnowext\fR" 4
.IX Item "3dnowext"
.IP "\fBcmov\fR" 4
.IX Item "cmov"
.RE
.RS 4
.RE
.IP "\fB\s-1ARM\s0\fR" 4
.IX Item "ARM"
.RS 4
.IP "\fBarmv5te\fR" 4
.IX Item "armv5te"
.IP "\fBarmv6\fR" 4
.IX Item "armv6"
.IP "\fBarmv6t2\fR" 4
.IX Item "armv6t2"
.IP "\fBvfp\fR" 4
.IX Item "vfp"
.IP "\fBvfpv3\fR" 4
.IX Item "vfpv3"
.IP "\fBneon\fR" 4
.IX Item "neon"
.RE
.RS 4
.RE
.IP "\fBPowerPC\fR" 4
.IX Item "PowerPC"
.RS 4
.IP "\fBaltivec\fR" 4
.IX Item "altivec"
.RE
.RS 4
.RE
.IP "\fBSpecific Processors\fR" 4
.IX Item "Specific Processors"
.RS 4
.IP "\fBpentium2\fR" 4
.IX Item "pentium2"
.IP "\fBpentium3\fR" 4
.IX Item "pentium3"
.IP "\fBpentium4\fR" 4
.IX Item "pentium4"
.IP "\fBk6\fR" 4
.IX Item "k6"
.IP "\fBk62\fR" 4
.IX Item "k62"
.IP "\fBathlon\fR" 4
.IX Item "athlon"
.IP "\fBathlonxp\fR" 4
.IX Item "athlonxp"
.IP "\fBk8\fR" 4
.IX Item "k8"
.RE
.RS 4
.RE
.RE
.RS 4
.RE
.IP "\fB\-opencl_options options (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-opencl_options options (global)"
.PD
Set OpenCL environment options. This option is only available when
FFmpeg has been compiled with \f(CW\*(C`\-\-enable\-opencl\*(C'\fR.
.Sp
\&\fIoptions\fR must be a list of \fIkey\fR=\fIvalue\fR option pairs
separated by ':'. See the ``OpenCL Options'' section in the
ffmpeg-utils manual for the list of supported options.
.SS "AVOptions"
.IX Subsection "AVOptions"
These options are provided directly by the libavformat, libavdevice and
libavcodec libraries. To see the list of available AVOptions, use the
\&\fB\-help\fR option. They are separated into two categories:
.IP "\fBgeneric\fR" 4
.IX Item "generic"
These options can be set for any container, codec or device. Generic options
are listed under AVFormatContext options for containers/devices and under
AVCodecContext options for codecs.
.IP "\fBprivate\fR" 4
.IX Item "private"
These options are specific to the given container, device or codec. Private
options are listed under their corresponding containers/devices/codecs.
.PP
For example to write an ID3v2.3 header instead of a default ID3v2.4 to
an \s-1MP3\s0 file, use the \fBid3v2_version\fR private option of the \s-1MP3\s0
muxer:
.PP
.Vb 1
\&        ffmpeg \-i input.flac \-id3v2_version 3 out.mp3
.Ve
.PP
All codec AVOptions are obviously per-stream, so the chapter on stream
specifiers applies to them
.PP
Note \fB\-nooption\fR syntax cannot be used for boolean AVOptions,
use \fB\-option 0\fR/\fB\-option 1\fR.
.PP
Note2 old undocumented way of specifying per-stream AVOptions by prepending
v/a/s to the options name is now obsolete and will be removed soon.
.SS "Main options"
.IX Subsection "Main options"
.IP "\fB\-f\fR \fIfmt\fR \fB(\fR\fIinput/output\fR\fB)\fR" 4
.IX Item "-f fmt (input/output)"
Force input or output file format. The format is normally auto detected for input
files and guessed from the file extension for output files, so this option is not
needed in most cases.
.IP "\fB\-i\fR \fIfilename\fR \fB(\fR\fIinput\fR\fB)\fR" 4
.IX Item "-i filename (input)"
input file name
.IP "\fB\-y (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-y (global)"
Overwrite output files without asking.
.IP "\fB\-n (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-n (global)"
Do not overwrite output files, and exit immediately if a specified
output file already exists.
.IP "\fB\-c[:\fR\fIstream_specifier\fR\fB]\fR \fIcodec\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-c[:stream_specifier] codec (input/output,per-stream)"
.PD 0
.IP "\fB\-codec[:\fR\fIstream_specifier\fR\fB]\fR \fIcodec\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-codec[:stream_specifier] codec (input/output,per-stream)"
.PD
Select an encoder (when used before an output file) or a decoder (when used
before an input file) for one or more streams. \fIcodec\fR is the name of a
decoder/encoder or a special value \f(CW\*(C`copy\*(C'\fR (output only) to indicate that
the stream is not to be re-encoded.
.Sp
For example
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0 \-c:v libx264 \-c:a copy OUTPUT
.Ve
.Sp
encodes all video streams with libx264 and copies all audio streams.
.Sp
For each stream, the last matching \f(CW\*(C`c\*(C'\fR option is applied, so
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0 \-c copy \-c:v:1 libx264 \-c:a:137 libvorbis OUTPUT
.Ve
.Sp
will copy all the streams except the second video, which will be encoded with
libx264, and the 138th audio, which will be encoded with libvorbis.
.IP "\fB\-t\fR \fIduration\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-t duration (output)"
Stop writing the output after its duration reaches \fIduration\fR.
\&\fIduration\fR may be a number in seconds, or in \f(CW\*(C`hh:mm:ss[.xxx]\*(C'\fR form.
.Sp
\&\-to and \-t are mutually exclusive and \-t has priority.
.IP "\fB\-to\fR \fIposition\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-to position (output)"
Stop writing the output at \fIposition\fR.
\&\fIposition\fR may be a number in seconds, or in \f(CW\*(C`hh:mm:ss[.xxx]\*(C'\fR form.
.Sp
\&\-to and \-t are mutually exclusive and \-t has priority.
.IP "\fB\-fs\fR \fIlimit_size\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-fs limit_size (output)"
Set the file size limit, expressed in bytes.
.IP "\fB\-ss\fR \fIposition\fR \fB(\fR\fIinput/output\fR\fB)\fR" 4
.IX Item "-ss position (input/output)"
When used as an input option (before \f(CW\*(C`\-i\*(C'\fR), seeks in this input file to
\&\fIposition\fR. When used as an output option (before an output filename),
decodes but discards input until the timestamps reach \fIposition\fR. This is
slower, but more accurate.
.Sp
\&\fIposition\fR may be either in seconds or in \f(CW\*(C`hh:mm:ss[.xxx]\*(C'\fR form.
.IP "\fB\-itsoffset\fR \fIoffset\fR \fB(\fR\fIinput\fR\fB)\fR" 4
.IX Item "-itsoffset offset (input)"
Set the input time offset in seconds.
\&\f(CW\*(C`[\-]hh:mm:ss[.xxx]\*(C'\fR syntax is also supported.
The offset is added to the timestamps of the input files.
Specifying a positive offset means that the corresponding
streams are delayed by \fIoffset\fR seconds.
.IP "\fB\-timestamp\fR \fItime\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-timestamp time (output)"
Set the recording timestamp in the container.
The syntax for \fItime\fR is:
.Sp
.Vb 1
\&        now|([(YYYY\-MM\-DD|YYYYMMDD)[T|t| ]]((HH:MM:SS[.m...])|(HHMMSS[.m...]))[Z|z])
.Ve
.Sp
If the value is \*(L"now\*(R" it takes the current time.
Time is local time unless 'Z' or 'z' is appended, in which case it is
interpreted as \s-1UTC\s0.
If the year-month-day part is not specified it takes the current
year-month-day.
.IP "\fB\-metadata[:metadata_specifier]\fR \fIkey\fR\fB=\fR\fIvalue\fR \fB(\fR\fIoutput,per\-metadata\fR\fB)\fR" 4
.IX Item "-metadata[:metadata_specifier] key=value (output,per-metadata)"
Set a metadata key/value pair.
.Sp
An optional \fImetadata_specifier\fR may be given to set metadata
on streams or chapters. See \f(CW\*(C`\-map_metadata\*(C'\fR documentation for
details.
.Sp
This option overrides metadata set with \f(CW\*(C`\-map_metadata\*(C'\fR. It is
also possible to delete metadata by using an empty value.
.Sp
For example, for setting the title in the output file:
.Sp
.Vb 1
\&        ffmpeg \-i in.avi \-metadata title="my title" out.flv
.Ve
.Sp
To set the language of the first audio stream:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-metadata:s:a:1 language=eng OUTPUT
.Ve
.IP "\fB\-target\fR \fItype\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-target type (output)"
Specify target file type (\f(CW\*(C`vcd\*(C'\fR, \f(CW\*(C`svcd\*(C'\fR, \f(CW\*(C`dvd\*(C'\fR, \f(CW\*(C`dv\*(C'\fR,
\&\f(CW\*(C`dv50\*(C'\fR). \fItype\fR may be prefixed with \f(CW\*(C`pal\-\*(C'\fR, \f(CW\*(C`ntsc\-\*(C'\fR or
\&\f(CW\*(C`film\-\*(C'\fR to use the corresponding standard. All the format options
(bitrate, codecs, buffer sizes) are then set automatically. You can just type:
.Sp
.Vb 1
\&        ffmpeg \-i myfile.avi \-target vcd /tmp/vcd.mpg
.Ve
.Sp
Nevertheless you can specify additional options as long as you know
they do not conflict with the standard, as in:
.Sp
.Vb 1
\&        ffmpeg \-i myfile.avi \-target vcd \-bf 2 /tmp/vcd.mpg
.Ve
.IP "\fB\-dframes\fR \fInumber\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-dframes number (output)"
Set the number of data frames to record. This is an alias for \f(CW\*(C`\-frames:d\*(C'\fR.
.IP "\fB\-frames[:\fR\fIstream_specifier\fR\fB]\fR \fIframecount\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-frames[:stream_specifier] framecount (output,per-stream)"
Stop writing to the stream after \fIframecount\fR frames.
.IP "\fB\-q[:\fR\fIstream_specifier\fR\fB]\fR \fIq\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-q[:stream_specifier] q (output,per-stream)"
.PD 0
.IP "\fB\-qscale[:\fR\fIstream_specifier\fR\fB]\fR \fIq\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-qscale[:stream_specifier] q (output,per-stream)"
.PD
Use fixed quality scale (\s-1VBR\s0). The meaning of \fIq\fR is
codec-dependent.
.IP "\fB\-filter[:\fR\fIstream_specifier\fR\fB]\fR \fIfiltergraph\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-filter[:stream_specifier] filtergraph (output,per-stream)"
Create the filtergraph specified by \fIfiltergraph\fR and use it to
filter the stream.
.Sp
\&\fIfiltergraph\fR is a description of the filtergraph to apply to
the stream, and must have a single input and a single output of the
same type of the stream. In the filtergraph, the input is associated
to the label \f(CW\*(C`in\*(C'\fR, and the output to the label \f(CW\*(C`out\*(C'\fR. See
the ffmpeg-filters manual for more information about the filtergraph
syntax.
.Sp
See the \-filter_complex option if you
want to create filtergraphs with multiple inputs and/or outputs.
.IP "\fB\-filter_script[:\fR\fIstream_specifier\fR\fB]\fR \fIfilename\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-filter_script[:stream_specifier] filename (output,per-stream)"
This option is similar to \fB\-filter\fR, the only difference is that its
argument is the name of the file from which a filtergraph description is to be
read.
.IP "\fB\-pre[:\fR\fIstream_specifier\fR\fB]\fR \fIpreset_name\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-pre[:stream_specifier] preset_name (output,per-stream)"
Specify the preset for matching stream(s).
.IP "\fB\-stats (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-stats (global)"
Print encoding progress/statistics. It is on by default, to explicitly
disable it you need to specify \f(CW\*(C`\-nostats\*(C'\fR.
.IP "\fB\-progress\fR \fIurl\fR \fB(\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-progress url (global)"
Send program-friendly progress information to \fIurl\fR.
.Sp
Progress information is written approximately every second and at the end of
the encoding process. It is made of "\fIkey\fR=\fIvalue\fR" lines. \fIkey\fR
consists of only alphanumeric characters. The last key of a sequence of
progress information is always \*(L"progress\*(R".
.IP "\fB\-stdin\fR" 4
.IX Item "-stdin"
Enable interaction on standard input. On by default unless standard input is
used as an input. To explicitly disable interaction you need to specify
\&\f(CW\*(C`\-nostdin\*(C'\fR.
.Sp
Disabling interaction on standard input is useful, for example, if
ffmpeg is in the background process group. Roughly the same result can
be achieved with \f(CW\*(C`ffmpeg ... < /dev/null\*(C'\fR but it requires a
shell.
.IP "\fB\-debug_ts (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-debug_ts (global)"
Print timestamp information. It is off by default. This option is
mostly useful for testing and debugging purposes, and the output
format may change from one version to another, so it should not be
employed by portable scripts.
.Sp
See also the option \f(CW\*(C`\-fdebug ts\*(C'\fR.
.IP "\fB\-attach\fR \fIfilename\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-attach filename (output)"
Add an attachment to the output file. This is supported by a few formats
like Matroska for e.g. fonts used in rendering subtitles. Attachments
are implemented as a specific type of stream, so this option will add
a new stream to the file. It is then possible to use per-stream options
on this stream in the usual way. Attachment streams created with this
option will be created after all the other streams (i.e. those created
with \f(CW\*(C`\-map\*(C'\fR or automatic mappings).
.Sp
Note that for Matroska you also have to set the mimetype metadata tag:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-attach DejaVuSans.ttf \-metadata:s:2 mimetype=application/x\-truetype\-font out.mkv
.Ve
.Sp
(assuming that the attachment stream will be third in the output file).
.IP "\fB\-dump_attachment[:\fR\fIstream_specifier\fR\fB]\fR \fIfilename\fR \fB(\fR\fIinput,per\-stream\fR\fB)\fR" 4
.IX Item "-dump_attachment[:stream_specifier] filename (input,per-stream)"
Extract the matching attachment stream into a file named \fIfilename\fR. If
\&\fIfilename\fR is empty, then the value of the \f(CW\*(C`filename\*(C'\fR metadata tag
will be used.
.Sp
E.g. to extract the first attachment to a file named 'out.ttf':
.Sp
.Vb 1
\&        ffmpeg \-dump_attachment:t:0 out.ttf \-i INPUT
.Ve
.Sp
To extract all attachments to files determined by the \f(CW\*(C`filename\*(C'\fR tag:
.Sp
.Vb 1
\&        ffmpeg \-dump_attachment:t "" \-i INPUT
.Ve
.Sp
Technical note \*(-- attachments are implemented as codec extradata, so this
option can actually be used to extract extradata from any stream, not just
attachments.
.SS "Video Options"
.IX Subsection "Video Options"
.IP "\fB\-vframes\fR \fInumber\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-vframes number (output)"
Set the number of video frames to record. This is an alias for \f(CW\*(C`\-frames:v\*(C'\fR.
.IP "\fB\-r[:\fR\fIstream_specifier\fR\fB]\fR \fIfps\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-r[:stream_specifier] fps (input/output,per-stream)"
Set frame rate (Hz value, fraction or abbreviation).
.Sp
As an input option, ignore any timestamps stored in the file and instead
generate timestamps assuming constant frame rate \fIfps\fR.
.Sp
As an output option, duplicate or drop input frames to achieve constant output
frame rate \fIfps\fR.
.IP "\fB\-s[:\fR\fIstream_specifier\fR\fB]\fR \fIsize\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-s[:stream_specifier] size (input/output,per-stream)"
Set frame size.
.Sp
As an input option, this is a shortcut for the \fBvideo_size\fR private
option, recognized by some demuxers for which the frame size is either not
stored in the file or is configurable \*(-- e.g. raw video or video grabbers.
.Sp
As an output option, this inserts the \f(CW\*(C`scale\*(C'\fR video filter to the
\&\fIend\fR of the corresponding filtergraph. Please use the \f(CW\*(C`scale\*(C'\fR filter
directly to insert it at the beginning or some other place.
.Sp
The format is \fBwxh\fR (default \- same as source).
.IP "\fB\-aspect[:\fR\fIstream_specifier\fR\fB]\fR \fIaspect\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-aspect[:stream_specifier] aspect (output,per-stream)"
Set the video display aspect ratio specified by \fIaspect\fR.
.Sp
\&\fIaspect\fR can be a floating point number string, or a string of the
form \fInum\fR:\fIden\fR, where \fInum\fR and \fIden\fR are the
numerator and denominator of the aspect ratio. For example \*(L"4:3\*(R",
\&\*(L"16:9\*(R", \*(L"1.3333\*(R", and \*(L"1.7777\*(R" are valid argument values.
.Sp
If used together with \fB\-vcodec copy\fR, it will affect the aspect ratio
stored at container level, but not the aspect ratio stored in encoded
frames, if it exists.
.IP "\fB\-vn (\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-vn (output)"
Disable video recording.
.IP "\fB\-vcodec\fR \fIcodec\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-vcodec codec (output)"
Set the video codec. This is an alias for \f(CW\*(C`\-codec:v\*(C'\fR.
.IP "\fB\-pass[:\fR\fIstream_specifier\fR\fB]\fR \fIn\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-pass[:stream_specifier] n (output,per-stream)"
Select the pass number (1 or 2). It is used to do two-pass
video encoding. The statistics of the video are recorded in the first
pass into a log file (see also the option \-passlogfile),
and in the second pass that log file is used to generate the video
at the exact requested bitrate.
On pass 1, you may just deactivate audio and set output to null,
examples for Windows and Unix:
.Sp
.Vb 2
\&        ffmpeg \-i foo.mov \-c:v libxvid \-pass 1 \-an \-f rawvideo \-y NUL
\&        ffmpeg \-i foo.mov \-c:v libxvid \-pass 1 \-an \-f rawvideo \-y /dev/null
.Ve
.IP "\fB\-passlogfile[:\fR\fIstream_specifier\fR\fB]\fR \fIprefix\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-passlogfile[:stream_specifier] prefix (output,per-stream)"
Set two-pass log file name prefix to \fIprefix\fR, the default file name
prefix is ``ffmpeg2pass''. The complete file name will be
\&\fI\s-1PREFIX\-N\s0.log\fR, where N is a number specific to the output
stream
.IP "\fB\-vlang\fR \fIcode\fR" 4
.IX Item "-vlang code"
Set the \s-1ISO\s0 639 language code (3 letters) of the current video stream.
.IP "\fB\-vf\fR \fIfiltergraph\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-vf filtergraph (output)"
Create the filtergraph specified by \fIfiltergraph\fR and use it to
filter the stream.
.Sp
This is an alias for \f(CW\*(C`\-filter:v\*(C'\fR, see the \-filter option.
.SS "Advanced Video Options"
.IX Subsection "Advanced Video Options"
.IP "\fB\-pix_fmt[:\fR\fIstream_specifier\fR\fB]\fR \fIformat\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-pix_fmt[:stream_specifier] format (input/output,per-stream)"
Set pixel format. Use \f(CW\*(C`\-pix_fmts\*(C'\fR to show all the supported
pixel formats.
If the selected pixel format can not be selected, ffmpeg will print a
warning and select the best pixel format supported by the encoder.
If \fIpix_fmt\fR is prefixed by a \f(CW\*(C`+\*(C'\fR, ffmpeg will exit with an error
if the requested pixel format can not be selected, and automatic conversions
inside filtergraphs are disabled.
If \fIpix_fmt\fR is a single \f(CW\*(C`+\*(C'\fR, ffmpeg selects the same pixel format
as the input (or graph output) and automatic conversions are disabled.
.IP "\fB\-sws_flags\fR \fIflags\fR \fB(\fR\fIinput/output\fR\fB)\fR" 4
.IX Item "-sws_flags flags (input/output)"
Set SwScaler flags.
.IP "\fB\-vdt\fR \fIn\fR" 4
.IX Item "-vdt n"
Discard threshold.
.IP "\fB\-rc_override[:\fR\fIstream_specifier\fR\fB]\fR \fIoverride\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-rc_override[:stream_specifier] override (output,per-stream)"
Rate control override for specific intervals, formatted as \*(L"int,int,int\*(R"
list separated with slashes. Two first values are the beginning and
end frame numbers, last one is quantizer to use if positive, or quality
factor if negative.
.IP "\fB\-deinterlace\fR" 4
.IX Item "-deinterlace"
Deinterlace pictures.
This option is deprecated since the deinterlacing is very low quality.
Use the yadif filter with \f(CW\*(C`\-filter:v yadif\*(C'\fR.
.IP "\fB\-ilme\fR" 4
.IX Item "-ilme"
Force interlacing support in encoder (\s-1MPEG\-2\s0 and \s-1MPEG\-4\s0 only).
Use this option if your input file is interlaced and you want
to keep the interlaced format for minimum losses.
The alternative is to deinterlace the input stream with
\&\fB\-deinterlace\fR, but deinterlacing introduces losses.
.IP "\fB\-psnr\fR" 4
.IX Item "-psnr"
Calculate \s-1PSNR\s0 of compressed frames.
.IP "\fB\-vstats\fR" 4
.IX Item "-vstats"
Dump video coding statistics to \fIvstats_HHMMSS.log\fR.
.IP "\fB\-vstats_file\fR \fIfile\fR" 4
.IX Item "-vstats_file file"
Dump video coding statistics to \fIfile\fR.
.IP "\fB\-top[:\fR\fIstream_specifier\fR\fB]\fR \fIn\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-top[:stream_specifier] n (output,per-stream)"
top=1/bottom=0/auto=\-1 field first
.IP "\fB\-dc\fR \fIprecision\fR" 4
.IX Item "-dc precision"
Intra_dc_precision.
.IP "\fB\-vtag\fR \fIfourcc/tag\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-vtag fourcc/tag (output)"
Force video tag/fourcc. This is an alias for \f(CW\*(C`\-tag:v\*(C'\fR.
.IP "\fB\-qphist (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-qphist (global)"
Show \s-1QP\s0 histogram
.IP "\fB\-vbsf\fR \fIbitstream_filter\fR" 4
.IX Item "-vbsf bitstream_filter"
Deprecated see \-bsf
.IP "\fB\-force_key_frames[:\fR\fIstream_specifier\fR\fB]\fR \fItime\fR\fB[,\fR\fItime\fR\fB...] (\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-force_key_frames[:stream_specifier] time[,time...] (output,per-stream)"
.PD 0
.IP "\fB\-force_key_frames[:\fR\fIstream_specifier\fR\fB] expr:\fR\fIexpr\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-force_key_frames[:stream_specifier] expr:expr (output,per-stream)"
.PD
Force key frames at the specified timestamps, more precisely at the first
frames after each specified time.
.Sp
If the argument is prefixed with \f(CW\*(C`expr:\*(C'\fR, the string \fIexpr\fR
is interpreted like an expression and is evaluated for each frame. A
key frame is forced in case the evaluation is non-zero.
.Sp
If one of the times is "\f(CW\*(C`chapters\*(C'\fR[\fIdelta\fR]", it is expanded into
the time of the beginning of all chapters in the file, shifted by
\&\fIdelta\fR, expressed as a time in seconds.
This option can be useful to ensure that a seek point is present at a
chapter mark or any other designated place in the output file.
.Sp
For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
before the beginning of every chapter:
.Sp
.Vb 1
\&        \-force_key_frames 0:05:00,chapters\-0.1
.Ve
.Sp
The expression in \fIexpr\fR can contain the following constants:
.RS 4
.IP "\fBn\fR" 4
.IX Item "n"
the number of current processed frame, starting from 0
.IP "\fBn_forced\fR" 4
.IX Item "n_forced"
the number of forced frames
.IP "\fBprev_forced_n\fR" 4
.IX Item "prev_forced_n"
the number of the previous forced frame, it is \f(CW\*(C`NAN\*(C'\fR when no
keyframe was forced yet
.IP "\fBprev_forced_t\fR" 4
.IX Item "prev_forced_t"
the time of the previous forced frame, it is \f(CW\*(C`NAN\*(C'\fR when no
keyframe was forced yet
.IP "\fBt\fR" 4
.IX Item "t"
the time of the current processed frame
.RE
.RS 4
.Sp
For example to force a key frame every 5 seconds, you can specify:
.Sp
.Vb 1
\&        \-force_key_frames expr:gte(t,n_forced*5)
.Ve
.Sp
To force a key frame 5 seconds after the time of the last forced one,
starting from second 13:
.Sp
.Vb 1
\&        \-force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
.Ve
.Sp
Note that forcing too many keyframes is very harmful for the lookahead
algorithms of certain encoders: using fixed-GOP options or similar
would be more efficient.
.RE
.IP "\fB\-copyinkf[:\fR\fIstream_specifier\fR\fB] (\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-copyinkf[:stream_specifier] (output,per-stream)"
When doing stream copy, copy also non-key frames found at the
beginning.
.SS "Audio Options"
.IX Subsection "Audio Options"
.IP "\fB\-aframes\fR \fInumber\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-aframes number (output)"
Set the number of audio frames to record. This is an alias for \f(CW\*(C`\-frames:a\*(C'\fR.
.IP "\fB\-ar[:\fR\fIstream_specifier\fR\fB]\fR \fIfreq\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-ar[:stream_specifier] freq (input/output,per-stream)"
Set the audio sampling frequency. For output streams it is set by
default to the frequency of the corresponding input stream. For input
streams this option only makes sense for audio grabbing devices and raw
demuxers and is mapped to the corresponding demuxer options.
.IP "\fB\-aq\fR \fIq\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-aq q (output)"
Set the audio quality (codec-specific, \s-1VBR\s0). This is an alias for \-q:a.
.IP "\fB\-ac[:\fR\fIstream_specifier\fR\fB]\fR \fIchannels\fR \fB(\fR\fIinput/output,per\-stream\fR\fB)\fR" 4
.IX Item "-ac[:stream_specifier] channels (input/output,per-stream)"
Set the number of audio channels. For output streams it is set by
default to the number of input audio channels. For input streams
this option only makes sense for audio grabbing devices and raw demuxers
and is mapped to the corresponding demuxer options.
.IP "\fB\-an (\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-an (output)"
Disable audio recording.
.IP "\fB\-acodec\fR \fIcodec\fR \fB(\fR\fIinput/output\fR\fB)\fR" 4
.IX Item "-acodec codec (input/output)"
Set the audio codec. This is an alias for \f(CW\*(C`\-codec:a\*(C'\fR.
.IP "\fB\-sample_fmt[:\fR\fIstream_specifier\fR\fB]\fR \fIsample_fmt\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-sample_fmt[:stream_specifier] sample_fmt (output,per-stream)"
Set the audio sample format. Use \f(CW\*(C`\-sample_fmts\*(C'\fR to get a list
of supported sample formats.
.IP "\fB\-af\fR \fIfiltergraph\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-af filtergraph (output)"
Create the filtergraph specified by \fIfiltergraph\fR and use it to
filter the stream.
.Sp
This is an alias for \f(CW\*(C`\-filter:a\*(C'\fR, see the \-filter option.
.SS "Advanced Audio options:"
.IX Subsection "Advanced Audio options:"
.IP "\fB\-atag\fR \fIfourcc/tag\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-atag fourcc/tag (output)"
Force audio tag/fourcc. This is an alias for \f(CW\*(C`\-tag:a\*(C'\fR.
.IP "\fB\-absf\fR \fIbitstream_filter\fR" 4
.IX Item "-absf bitstream_filter"
Deprecated, see \-bsf
.IP "\fB\-guess_layout_max\fR \fIchannels\fR \fB(\fR\fIinput,per\-stream\fR\fB)\fR" 4
.IX Item "-guess_layout_max channels (input,per-stream)"
If some input channel layout is not known, try to guess only if it
corresponds to at most the specified number of channels. For example, 2
tells to \fBffmpeg\fR to recognize 1 channel as mono and 2 channels as
stereo but not 6 channels as 5.1. The default is to always try to guess. Use
0 to disable all guessing.
.SS "Subtitle options:"
.IX Subsection "Subtitle options:"
.IP "\fB\-slang\fR \fIcode\fR" 4
.IX Item "-slang code"
Set the \s-1ISO\s0 639 language code (3 letters) of the current subtitle stream.
.IP "\fB\-scodec\fR \fIcodec\fR \fB(\fR\fIinput/output\fR\fB)\fR" 4
.IX Item "-scodec codec (input/output)"
Set the subtitle codec. This is an alias for \f(CW\*(C`\-codec:s\*(C'\fR.
.IP "\fB\-sn (\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-sn (output)"
Disable subtitle recording.
.IP "\fB\-sbsf\fR \fIbitstream_filter\fR" 4
.IX Item "-sbsf bitstream_filter"
Deprecated, see \-bsf
.SS "Advanced Subtitle options:"
.IX Subsection "Advanced Subtitle options:"
.IP "\fB\-fix_sub_duration\fR" 4
.IX Item "-fix_sub_duration"
Fix subtitles durations. For each subtitle, wait for the next packet in the
same stream and adjust the duration of the first to avoid overlap. This is
necessary with some subtitles codecs, especially \s-1DVB\s0 subtitles, because the
duration in the original packet is only a rough estimate and the end is
actually marked by an empty subtitle frame. Failing to use this option when
necessary can result in exaggerated durations or muxing failures due to
non-monotonic timestamps.
.Sp
Note that this option will delay the output of all data until the next
subtitle packet is decoded: it may increase memory consumption and latency a
lot.
.IP "\fB\-canvas_size\fR \fIsize\fR" 4
.IX Item "-canvas_size size"
Set the size of the canvas used to render subtitles.
.SS "Advanced options"
.IX Subsection "Advanced options"
.IP "\fB\-map [\-]\fR\fIinput_file_id\fR\fB[:\fR\fIstream_specifier\fR\fB][,\fR\fIsync_file_id\fR\fB[:\fR\fIstream_specifier\fR\fB]] |\fR \fI[linklabel]\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-map [-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]] | [linklabel] (output)"
Designate one or more input streams as a source for the output file. Each input
stream is identified by the input file index \fIinput_file_id\fR and
the input stream index \fIinput_stream_id\fR within the input
file. Both indices start at 0. If specified,
\&\fIsync_file_id\fR:\fIstream_specifier\fR sets which input stream
is used as a presentation sync reference.
.Sp
The first \f(CW\*(C`\-map\*(C'\fR option on the command line specifies the
source for output stream 0, the second \f(CW\*(C`\-map\*(C'\fR option specifies
the source for output stream 1, etc.
.Sp
A \f(CW\*(C`\-\*(C'\fR character before the stream identifier creates a \*(L"negative\*(R" mapping.
It disables matching streams from already created mappings.
.Sp
An alternative \fI[linklabel]\fR form will map outputs from complex filter
graphs (see the \fB\-filter_complex\fR option) to the output file.
\&\fIlinklabel\fR must correspond to a defined output link label in the graph.
.Sp
For example, to map \s-1ALL\s0 streams from the first input file to output
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0 output
.Ve
.Sp
For example, if you have two audio streams in the first input file,
these streams are identified by \*(L"0:0\*(R" and \*(L"0:1\*(R". You can use
\&\f(CW\*(C`\-map\*(C'\fR to select which streams to place in an output file. For
example:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0:1 out.wav
.Ve
.Sp
will map the input stream in \fI\s-1INPUT\s0\fR identified by \*(L"0:1\*(R" to
the (single) output stream in \fIout.wav\fR.
.Sp
For example, to select the stream with index 2 from input file
\&\fIa.mov\fR (specified by the identifier \*(L"0:2\*(R"), and stream with
index 6 from input \fIb.mov\fR (specified by the identifier \*(L"1:6\*(R"),
and copy them to the output file \fIout.mov\fR:
.Sp
.Vb 1
\&        ffmpeg \-i a.mov \-i b.mov \-c copy \-map 0:2 \-map 1:6 out.mov
.Ve
.Sp
To select all video and the third audio stream from an input file:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0:v \-map 0:a:2 OUTPUT
.Ve
.Sp
To map all the streams except the second audio, use negative mappings
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map 0 \-map \-0:a:1 OUTPUT
.Ve
.Sp
Note that using this option disables the default mappings for this output file.
.IP "\fB\-map_channel [\fR\fIinput_file_id\fR\fB.\fR\fIstream_specifier\fR\fB.\fR\fIchannel_id\fR\fB|\-1][:\fR\fIoutput_file_id\fR\fB.\fR\fIstream_specifier\fR\fB]\fR" 4
.IX Item "-map_channel [input_file_id.stream_specifier.channel_id|-1][:output_file_id.stream_specifier]"
Map an audio channel from a given input to an output. If
\&\fIoutput_file_id\fR.\fIstream_specifier\fR is not set, the audio channel will
be mapped on all the audio streams.
.Sp
Using \*(L"\-1\*(R" instead of
\&\fIinput_file_id\fR.\fIstream_specifier\fR.\fIchannel_id\fR will map a muted
channel.
.Sp
For example, assuming \fI\s-1INPUT\s0\fR is a stereo audio file, you can switch the
two audio channels with the following command:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map_channel 0.0.1 \-map_channel 0.0.0 OUTPUT
.Ve
.Sp
If you want to mute the first channel and keep the second:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map_channel \-1 \-map_channel 0.0.1 OUTPUT
.Ve
.Sp
The order of the \*(L"\-map_channel\*(R" option specifies the order of the channels in
the output stream. The output channel layout is guessed from the number of
channels mapped (mono if one \*(L"\-map_channel\*(R", stereo if two, etc.). Using \*(L"\-ac\*(R"
in combination of \*(L"\-map_channel\*(R" makes the channel gain levels to be updated if
input and output channel layouts don't match (for instance two \*(L"\-map_channel\*(R"
options and \*(L"\-ac 6\*(R").
.Sp
You can also extract each channel of an input to specific outputs; the following
command extracts two channels of the \fI\s-1INPUT\s0\fR audio stream (file 0, stream 0)
to the respective \fI\s-1OUTPUT_CH0\s0\fR and \fI\s-1OUTPUT_CH1\s0\fR outputs:
.Sp
.Vb 1
\&        ffmpeg \-i INPUT \-map_channel 0.0.0 OUTPUT_CH0 \-map_channel 0.0.1 OUTPUT_CH1
.Ve
.Sp
The following example splits the channels of a stereo input into two separate
streams, which are put into the same output file:
.Sp
.Vb 1
\&        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
.Ve
.Sp
Note that currently each output stream can only contain channels from a single
input stream; you can't for example use \*(L"\-map_channel\*(R" to pick multiple input
audio channels contained in different streams (from the same or different files)
and merge them into a single output stream. It is therefore not currently
possible, for example, to turn two separate mono streams into a single stereo
stream. However splitting a stereo stream into two single channel mono streams
is possible.
.Sp
If you need this feature, a possible workaround is to use the \fIamerge\fR
filter. For example, if you need to merge a media (here \fIinput.mkv\fR) with 2
mono audio streams into one single stereo channel audio stream (and keep the
video stream), you can use the following command:
.Sp
.Vb 1
\&        ffmpeg \-i input.mkv \-filter_complex "[0:1] [0:2] amerge" \-c:a pcm_s16le \-c:v copy output.mkv
.Ve
.IP "\fB\-map_metadata[:\fR\fImetadata_spec_out\fR\fB]\fR \fIinfile\fR\fB[:\fR\fImetadata_spec_in\fR\fB] (\fR\fIoutput,per\-metadata\fR\fB)\fR" 4
.IX Item "-map_metadata[:metadata_spec_out] infile[:metadata_spec_in] (output,per-metadata)"
Set metadata information of the next output file from \fIinfile\fR. Note that
those are file indices (zero-based), not filenames.
Optional \fImetadata_spec_in/out\fR parameters specify, which metadata to copy.
A metadata specifier can have the following forms:
.RS 4
.IP "\fIg\fR" 4
.IX Item "g"
global metadata, i.e. metadata that applies to the whole file
.IP "\fIs\fR\fB[:\fR\fIstream_spec\fR\fB]\fR" 4
.IX Item "s[:stream_spec]"
per-stream metadata. \fIstream_spec\fR is a stream specifier as described
in the Stream specifiers chapter. In an input metadata specifier, the first
matching stream is copied from. In an output metadata specifier, all matching
streams are copied to.
.IP "\fIc\fR\fB:\fR\fIchapter_index\fR" 4
.IX Item "c:chapter_index"
per-chapter metadata. \fIchapter_index\fR is the zero-based chapter index.
.IP "\fIp\fR\fB:\fR\fIprogram_index\fR" 4
.IX Item "p:program_index"
per-program metadata. \fIprogram_index\fR is the zero-based program index.
.RE
.RS 4
.Sp
If metadata specifier is omitted, it defaults to global.
.Sp
By default, global metadata is copied from the first input file,
per-stream and per-chapter metadata is copied along with streams/chapters. These
default mappings are disabled by creating any mapping of the relevant type. A negative
file index can be used to create a dummy mapping that just disables automatic copying.
.Sp
For example to copy metadata from the first stream of the input file to global metadata
of the output file:
.Sp
.Vb 1
\&        ffmpeg \-i in.ogg \-map_metadata 0:s:0 out.mp3
.Ve
.Sp
To do the reverse, i.e. copy global metadata to all audio streams:
.Sp
.Vb 1
\&        ffmpeg \-i in.mkv \-map_metadata:s:a 0:g out.mkv
.Ve
.Sp
Note that simple \f(CW0\fR would work as well in this example, since global
metadata is assumed by default.
.RE
.IP "\fB\-map_chapters\fR \fIinput_file_index\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-map_chapters input_file_index (output)"
Copy chapters from input file with index \fIinput_file_index\fR to the next
output file. If no chapter mapping is specified, then chapters are copied from
the first input file with at least one chapter. Use a negative file index to
disable any chapter copying.
.IP "\fB\-benchmark (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-benchmark (global)"
Show benchmarking information at the end of an encode.
Shows \s-1CPU\s0 time used and maximum memory consumption.
Maximum memory consumption is not supported on all systems,
it will usually display as 0 if not supported.
.IP "\fB\-benchmark_all (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-benchmark_all (global)"
Show benchmarking information during the encode.
Shows \s-1CPU\s0 time used in various steps (audio/video encode/decode).
.IP "\fB\-timelimit\fR \fIduration\fR \fB(\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-timelimit duration (global)"
Exit after ffmpeg has been running for \fIduration\fR seconds.
.IP "\fB\-dump (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-dump (global)"
Dump each input packet to stderr.
.IP "\fB\-hex (\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-hex (global)"
When dumping packets, also dump the payload.
.IP "\fB\-re (\fR\fIinput\fR\fB)\fR" 4
.IX Item "-re (input)"
Read input at native frame rate. Mainly used to simulate a grab device.
By default \fBffmpeg\fR attempts to read the input(s) as fast as possible.
This option will slow down the reading of the input(s) to the native frame rate
of the input(s). It is useful for real-time output (e.g. live streaming). If
your input(s) is coming from some other live streaming source (through \s-1HTTP\s0 or
\&\s-1UDP\s0 for example) the server might already be in real-time, thus the option will
likely not be required. On the other hand, this is meaningful if your input(s)
is a file you are trying to push in real-time.
.IP "\fB\-loop_input\fR" 4
.IX Item "-loop_input"
Loop over the input stream. Currently it works only for image
streams. This option is used for automatic FFserver testing.
This option is deprecated, use \-loop 1.
.IP "\fB\-loop_output\fR \fInumber_of_times\fR" 4
.IX Item "-loop_output number_of_times"
Repeatedly loop output for formats that support looping such as animated \s-1GIF\s0
(0 will loop the output infinitely).
This option is deprecated, use \-loop.
.IP "\fB\-vsync\fR \fIparameter\fR" 4
.IX Item "-vsync parameter"
Video sync method.
For compatibility reasons old values can be specified as numbers.
Newly added values will have to be specified as strings always.
.RS 4
.IP "\fB0, passthrough\fR" 4
.IX Item "0, passthrough"
Each frame is passed with its timestamp from the demuxer to the muxer.
.IP "\fB1, cfr\fR" 4
.IX Item "1, cfr"
Frames will be duplicated and dropped to achieve exactly the requested
constant frame rate.
.IP "\fB2, vfr\fR" 4
.IX Item "2, vfr"
Frames are passed through with their timestamp or dropped so as to
prevent 2 frames from having the same timestamp.
.IP "\fBdrop\fR" 4
.IX Item "drop"
As passthrough but destroys all timestamps, making the muxer generate
fresh timestamps based on frame-rate.
.IP "\fB\-1, auto\fR" 4
.IX Item "-1, auto"
Chooses between 1 and 2 depending on muxer capabilities. This is the
default method.
.RE
.RS 4
.Sp
Note that the timestamps may be further modified by the muxer, after this.
For example, in the case that the format option \fBavoid_negative_ts\fR
is enabled.
.Sp
With \-map you can select from which stream the timestamps should be
taken. You can leave either video or audio unchanged and sync the
remaining stream(s) to the unchanged one.
.RE
.IP "\fB\-async\fR \fIsamples_per_second\fR" 4
.IX Item "-async samples_per_second"
Audio sync method. \*(L"Stretches/squeezes\*(R" the audio stream to match the timestamps,
the parameter is the maximum samples per second by which the audio is changed.
\&\-async 1 is a special case where only the start of the audio stream is corrected
without any later correction.
.Sp
Note that the timestamps may be further modified by the muxer, after this.
For example, in the case that the format option \fBavoid_negative_ts\fR
is enabled.
.Sp
This option has been deprecated. Use the \f(CW\*(C`aresample\*(C'\fR audio filter instead.
.IP "\fB\-copyts\fR" 4
.IX Item "-copyts"
Do not process input timestamps, but keep their values without trying
to sanitize them. In particular, do not remove the initial start time
offset value.
.Sp
Note that, depending on the \fBvsync\fR option or on specific muxer
processing (e.g. in case the format option \fBavoid_negative_ts\fR
is enabled) the output timestamps may mismatch with the input
timestamps even when this option is selected.
.IP "\fB\-copytb\fR \fImode\fR" 4
.IX Item "-copytb mode"
Specify how to set the encoder timebase when stream copying.  \fImode\fR is an
integer numeric value, and can assume one of the following values:
.RS 4
.IP "\fB1\fR" 4
.IX Item "1"
Use the demuxer timebase.
.Sp
The time base is copied to the output encoder from the corresponding input
demuxer. This is sometimes required to avoid non monotonically increasing
timestamps when copying video streams with variable frame rate.
.IP "\fB0\fR" 4
.IX Item "0"
Use the decoder timebase.
.Sp
The time base is copied to the output encoder from the corresponding input
decoder.
.IP "\fB\-1\fR" 4
.IX Item "-1"
Try to make the choice automatically, in order to generate a sane output.
.RE
.RS 4
.Sp
Default value is \-1.
.RE
.IP "\fB\-shortest (\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-shortest (output)"
Finish encoding when the shortest input stream ends.
.IP "\fB\-dts_delta_threshold\fR" 4
.IX Item "-dts_delta_threshold"
Timestamp discontinuity delta threshold.
.IP "\fB\-muxdelay\fR \fIseconds\fR \fB(\fR\fIinput\fR\fB)\fR" 4
.IX Item "-muxdelay seconds (input)"
Set the maximum demux-decode delay.
.IP "\fB\-muxpreload\fR \fIseconds\fR \fB(\fR\fIinput\fR\fB)\fR" 4
.IX Item "-muxpreload seconds (input)"
Set the initial demux-decode delay.
.IP "\fB\-streamid\fR \fIoutput-stream-index\fR\fB:\fR\fInew-value\fR \fB(\fR\fIoutput\fR\fB)\fR" 4
.IX Item "-streamid output-stream-index:new-value (output)"
Assign a new stream-id value to an output stream. This option should be
specified prior to the output filename to which it applies.
For the situation where multiple output files exist, a streamid
may be reassigned to a different value.
.Sp
For example, to set the stream 0 \s-1PID\s0 to 33 and the stream 1 \s-1PID\s0 to 36 for
an output mpegts file:
.Sp
.Vb 1
\&        ffmpeg \-i infile \-streamid 0:33 \-streamid 1:36 out.ts
.Ve
.IP "\fB\-bsf[:\fR\fIstream_specifier\fR\fB]\fR \fIbitstream_filters\fR \fB(\fR\fIoutput,per\-stream\fR\fB)\fR" 4
.IX Item "-bsf[:stream_specifier] bitstream_filters (output,per-stream)"
Set bitstream filters for matching streams. \fIbitstream_filters\fR is
a comma-separated list of bitstream filters. Use the \f(CW\*(C`\-bsfs\*(C'\fR option
to get the list of bitstream filters.
.Sp
.Vb 1
\&        ffmpeg \-i h264.mp4 \-c:v copy \-bsf:v h264_mp4toannexb \-an out.h264
\&
\&        
\&        ffmpeg \-i file.mov \-an \-vn \-bsf:s mov2textsub \-c:s copy \-f rawvideo sub.txt
.Ve
.IP "\fB\-tag[:\fR\fIstream_specifier\fR\fB]\fR \fIcodec_tag\fR \fB(\fR\fIper-stream\fR\fB)\fR" 4
.IX Item "-tag[:stream_specifier] codec_tag (per-stream)"
Force a tag/fourcc for matching streams.
.IP "\fB\-timecode\fR \fIhh\fR\fB:\fR\fImm\fR\fB:\fR\fIss\fR\fB\s-1SEP\s0\fR\fIff\fR" 4
.IX Item "-timecode hh:mm:ssSEPff"
Specify Timecode for writing. \fI\s-1SEP\s0\fR is ':' for non drop timecode and ';'
(or '.') for drop.
.Sp
.Vb 1
\&        ffmpeg \-i input.mpg \-timecode 01:02:03.04 \-r 30000/1001 \-s ntsc output.mpg
.Ve
.IP "\fB\-filter_complex\fR \fIfiltergraph\fR \fB(\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-filter_complex filtergraph (global)"
Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
outputs. For simple graphs \*(-- those with one input and one output of the same
type \*(-- see the \fB\-filter\fR options. \fIfiltergraph\fR is a description of
the filtergraph, as described in the ``Filtergraph syntax'' section of the
ffmpeg-filters manual.
.Sp
Input link labels must refer to input streams using the
\&\f(CW\*(C`[file_index:stream_specifier]\*(C'\fR syntax (i.e. the same as \fB\-map\fR
uses). If \fIstream_specifier\fR matches multiple streams, the first one will be
used. An unlabeled input will be connected to the first unused input stream of
the matching type.
.Sp
Output link labels are referred to with \fB\-map\fR. Unlabeled outputs are
added to the first output file.
.Sp
Note that with this option it is possible to use only lavfi sources without
normal input files.
.Sp
For example, to overlay an image over video
.Sp
.Vb 2
\&        ffmpeg \-i video.mkv \-i image.png \-filter_complex \*(Aq[0:v][1:v]overlay[out]\*(Aq \-map
\&        \*(Aq[out]\*(Aq out.mkv
.Ve
.Sp
Here \f(CW\*(C`[0:v]\*(C'\fR refers to the first video stream in the first input file,
which is linked to the first (main) input of the overlay filter. Similarly the
first video stream in the second input is linked to the second (overlay) input
of overlay.
.Sp
Assuming there is only one video stream in each input file, we can omit input
labels, so the above is equivalent to
.Sp
.Vb 2
\&        ffmpeg \-i video.mkv \-i image.png \-filter_complex \*(Aqoverlay[out]\*(Aq \-map
\&        \*(Aq[out]\*(Aq out.mkv
.Ve
.Sp
Furthermore we can omit the output label and the single output from the filter
graph will be added to the output file automatically, so we can simply write
.Sp
.Vb 1
\&        ffmpeg \-i video.mkv \-i image.png \-filter_complex \*(Aqoverlay\*(Aq out.mkv
.Ve
.Sp
To generate 5 seconds of pure red video using lavfi \f(CW\*(C`color\*(C'\fR source:
.Sp
.Vb 1
\&        ffmpeg \-filter_complex \*(Aqcolor=c=red\*(Aq \-t 5 out.mkv
.Ve
.IP "\fB\-lavfi\fR \fIfiltergraph\fR \fB(\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-lavfi filtergraph (global)"
Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
outputs. Equivalent to \fB\-filter_complex\fR.
.IP "\fB\-filter_complex_script\fR \fIfilename\fR \fB(\fR\fIglobal\fR\fB)\fR" 4
.IX Item "-filter_complex_script filename (global)"
This option is similar to \fB\-filter_complex\fR, the only difference is that
its argument is the name of the file from which a complex filtergraph
description is to be read.
.PP
As a special exception, you can use a bitmap subtitle stream as input: it
will be converted into a video with the same size as the largest video in
the file, or 720x576 if no video is present. Note that this is an
experimental and temporary solution. It will be removed once libavfilter has
proper support for subtitles.
.PP
For example, to hardcode subtitles on top of a DVB-T recording stored in
MPEG-TS format, delaying the subtitles by 1 second:
.PP
.Vb 3
\&        ffmpeg \-i input.ts \-filter_complex \e
\&          \*(Aq[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay\*(Aq \e
\&          \-sn \-map \*(Aq#0x2dc\*(Aq output.mkv
.Ve
.PP
(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
.SS "Preset files"
.IX Subsection "Preset files"
A preset file contains a sequence of \fIoption\fR=\fIvalue\fR pairs,
one for each line, specifying a sequence of options which would be
awkward to specify on the command line. Lines starting with the hash
('#') character are ignored and are used to provide comments. Check
the \fIpresets\fR directory in the FFmpeg source tree for examples.
.PP
Preset files are specified with the \f(CW\*(C`vpre\*(C'\fR, \f(CW\*(C`apre\*(C'\fR,
\&\f(CW\*(C`spre\*(C'\fR, and \f(CW\*(C`fpre\*(C'\fR options. The \f(CW\*(C`fpre\*(C'\fR option takes the
filename of the preset instead of a preset name as input and can be
used for any kind of codec. For the \f(CW\*(C`vpre\*(C'\fR, \f(CW\*(C`apre\*(C'\fR, and
\&\f(CW\*(C`spre\*(C'\fR options, the options specified in a preset file are
applied to the currently selected codec of the same type as the preset
option.
.PP
The argument passed to the \f(CW\*(C`vpre\*(C'\fR, \f(CW\*(C`apre\*(C'\fR, and \f(CW\*(C`spre\*(C'\fR
preset options identifies the preset file to use according to the
following rules:
.PP
First ffmpeg searches for a file named \fIarg\fR.ffpreset in the
directories \fI\f(CI$FFMPEG_DATADIR\fI\fR (if set), and \fI\f(CI$HOME\fI/.ffmpeg\fR, and in
the datadir defined at configuration time (usually \fIPREFIX/share/ffmpeg\fR)
or in a \fIffpresets\fR folder along the executable on win32,
in that order. For example, if the argument is \f(CW\*(C`libvpx\-1080p\*(C'\fR, it will
search for the file \fIlibvpx\-1080p.ffpreset\fR.
.PP
If no such file is found, then ffmpeg will search for a file named
\&\fIcodec_name\fR\-\fIarg\fR.ffpreset in the above-mentioned
directories, where \fIcodec_name\fR is the name of the codec to which
the preset file options will be applied. For example, if you select
the video codec with \f(CW\*(C`\-vcodec libvpx\*(C'\fR and use \f(CW\*(C`\-vpre 1080p\*(C'\fR,
then it will search for the file \fIlibvpx\-1080p.ffpreset\fR.
.SH "TIPS"
.IX Header "TIPS"
.IP "\(bu" 4
For streaming at very low bitrate application, use a low frame rate
and a small \s-1GOP\s0 size. This is especially true for RealVideo where
the Linux player does not seem to be very fast, so it can miss
frames. An example is:
.Sp
.Vb 1
\&        ffmpeg \-g 3 \-r 3 \-t 10 \-b:v 50k \-s qcif \-f rv10 /tmp/b.rm
.Ve
.IP "\(bu" 4
The parameter 'q' which is displayed while encoding is the current
quantizer. The value 1 indicates that a very good quality could
be achieved. The value 31 indicates the worst quality. If q=31 appears
too often, it means that the encoder cannot compress enough to meet
your bitrate. You must either increase the bitrate, decrease the
frame rate or decrease the frame size.
.IP "\(bu" 4
If your computer is not fast enough, you can speed up the
compression at the expense of the compression ratio. You can use
\&'\-me zero' to speed up motion estimation, and '\-g 0' to disable
motion estimation completely (you have only I\-frames, which means it
is about as good as \s-1JPEG\s0 compression).
.IP "\(bu" 4
To have very low audio bitrates, reduce the sampling frequency
(down to 22050 Hz for \s-1MPEG\s0 audio, 22050 or 11025 for \s-1AC\-3\s0).
.IP "\(bu" 4
To have a constant quality (but a variable bitrate), use the option
\&'\-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
quality).
.SH "EXAMPLES"
.IX Header "EXAMPLES"
.SS "Preset files"
.IX Subsection "Preset files"
A preset file contains a sequence of \fIoption=value\fR pairs, one for
each line, specifying a sequence of options which can be specified also on
the command line. Lines starting with the hash ('#') character are ignored and
are used to provide comments. Empty lines are also ignored. Check the
\&\fIpresets\fR directory in the FFmpeg source tree for examples.
.PP
Preset files are specified with the \f(CW\*(C`pre\*(C'\fR option, this option takes a
preset name as input.  FFmpeg searches for a file named \fIpreset_name\fR.avpreset in
the directories \fI\f(CI$AVCONV_DATADIR\fI\fR (if set), and \fI\f(CI$HOME\fI/.ffmpeg\fR, and in
the data directory defined at configuration time (usually \fI\f(CI$PREFIX\fI/share/ffmpeg\fR)
in that order.  For example, if the argument is \f(CW\*(C`libx264\-max\*(C'\fR, it will
search for the file \fIlibx264\-max.avpreset\fR.
.SS "Video and Audio grabbing"
.IX Subsection "Video and Audio grabbing"
If you specify the input format and device then ffmpeg can grab video
and audio directly.
.PP
.Vb 1
\&        ffmpeg \-f oss \-i /dev/dsp \-f video4linux2 \-i /dev/video0 /tmp/out.mpg
.Ve
.PP
Or with an \s-1ALSA\s0 audio source (mono input, card id 1) instead of \s-1OSS:\s0
.PP
.Vb 1
\&        ffmpeg \-f alsa \-ac 1 \-i hw:1 \-f video4linux2 \-i /dev/video0 /tmp/out.mpg
.Ve
.PP
Note that you must activate the right video source and channel before
launching ffmpeg with any \s-1TV\s0 viewer such as
<\fBhttp://linux.bytesex.org/xawtv/\fR> by Gerd Knorr. You also
have to set the audio recording levels correctly with a
standard mixer.
.SS "X11 grabbing"
.IX Subsection "X11 grabbing"
Grab the X11 display with ffmpeg via
.PP
.Vb 1
\&        ffmpeg \-f x11grab \-s cif \-r 25 \-i :0.0 /tmp/out.mpg
.Ve
.PP
0.0 is display.screen number of your X11 server, same as
the \s-1DISPLAY\s0 environment variable.
.PP
.Vb 1
\&        ffmpeg \-f x11grab \-s cif \-r 25 \-i :0.0+10,20 /tmp/out.mpg
.Ve
.PP
0.0 is display.screen number of your X11 server, same as the \s-1DISPLAY\s0 environment
variable. 10 is the x\-offset and 20 the y\-offset for the grabbing.
.SS "Video and Audio file format conversion"
.IX Subsection "Video and Audio file format conversion"
Any supported file format and protocol can serve as input to ffmpeg:
.PP
Examples:
.IP "\(bu" 4
You can use \s-1YUV\s0 files as input:
.Sp
.Vb 1
\&        ffmpeg \-i /tmp/test%d.Y /tmp/out.mpg
.Ve
.Sp
It will use the files:
.Sp
.Vb 2
\&        /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
\&        /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
.Ve
.Sp
The Y files use twice the resolution of the U and V files. They are
raw files, without header. They can be generated by all decent video
decoders. You must specify the size of the image with the \fB\-s\fR option
if ffmpeg cannot guess it.
.IP "\(bu" 4
You can input from a raw \s-1YUV420P\s0 file:
.Sp
.Vb 1
\&        ffmpeg \-i /tmp/test.yuv /tmp/out.avi
.Ve
.Sp
test.yuv is a file containing raw \s-1YUV\s0 planar data. Each frame is composed
of the Y plane followed by the U and V planes at half vertical and
horizontal resolution.
.IP "\(bu" 4
You can output to a raw \s-1YUV420P\s0 file:
.Sp
.Vb 1
\&        ffmpeg \-i mydivx.avi hugefile.yuv
.Ve
.IP "\(bu" 4
You can set several input files and output files:
.Sp
.Vb 1
\&        ffmpeg \-i /tmp/a.wav \-s 640x480 \-i /tmp/a.yuv /tmp/a.mpg
.Ve
.Sp
Converts the audio file a.wav and the raw \s-1YUV\s0 video file a.yuv
to \s-1MPEG\s0 file a.mpg.
.IP "\(bu" 4
You can also do audio and video conversions at the same time:
.Sp
.Vb 1
\&        ffmpeg \-i /tmp/a.wav \-ar 22050 /tmp/a.mp2
.Ve
.Sp
Converts a.wav to \s-1MPEG\s0 audio at 22050 Hz sample rate.
.IP "\(bu" 4
You can encode to several formats at the same time and define a
mapping from input stream to output streams:
.Sp
.Vb 1
\&        ffmpeg \-i /tmp/a.wav \-map 0:a \-b:a 64k /tmp/a.mp2 \-map 0:a \-b:a 128k /tmp/b.mp2
.Ve
.Sp
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '\-map
file:index' specifies which input stream is used for each output
stream, in the order of the definition of output streams.
.IP "\(bu" 4
You can transcode decrypted VOBs:
.Sp
.Vb 1
\&        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
.Ve
.Sp
This is a typical \s-1DVD\s0 ripping example; the input is a \s-1VOB\s0 file, the
output an \s-1AVI\s0 file with \s-1MPEG\-4\s0 video and \s-1MP3\s0 audio. Note that in this
command we use B\-frames so the \s-1MPEG\-4\s0 stream is DivX5 compatible, and
\&\s-1GOP\s0 size is 300 which means one intra frame every 10 seconds for 29.97fps
input video. Furthermore, the audio stream is MP3\-encoded so you need
to enable \s-1LAME\s0 support by passing \f(CW\*(C`\-\-enable\-libmp3lame\*(C'\fR to configure.
The mapping is particularly useful for \s-1DVD\s0 transcoding
to get the desired audio language.
.Sp
\&\s-1NOTE:\s0 To see the supported input formats, use \f(CW\*(C`ffmpeg \-formats\*(C'\fR.
.IP "\(bu" 4
You can extract images from a video, or create a video from many images:
.Sp
For extracting images from a video:
.Sp
.Vb 1
\&        ffmpeg \-i foo.avi \-r 1 \-s WxH \-f image2 foo\-%03d.jpeg
.Ve
.Sp
This will extract one video frame per second from the video and will
output them in files named \fIfoo\-001.jpeg\fR, \fIfoo\-002.jpeg\fR,
etc. Images will be rescaled to fit the new WxH values.
.Sp
If you want to extract just a limited number of frames, you can use the
above command in combination with the \-vframes or \-t option, or in
combination with \-ss to start extracting from a certain point in time.
.Sp
For creating a video from many images:
.Sp
.Vb 1
\&        ffmpeg \-f image2 \-i foo\-%03d.jpeg \-r 12 \-s WxH foo.avi
.Ve
.Sp
The syntax \f(CW\*(C`foo\-%03d.jpeg\*(C'\fR specifies to use a decimal number
composed of three digits padded with zeroes to express the sequence
number. It is the same syntax supported by the C printf function, but
only formats accepting a normal integer are suitable.
.Sp
When importing an image sequence, \-i also supports expanding
shell-like wildcard patterns (globbing) internally, by selecting the
image2\-specific \f(CW\*(C`\-pattern_type glob\*(C'\fR option.
.Sp
For example, for creating a video from filenames matching the glob pattern
\&\f(CW\*(C`foo\-*.jpeg\*(C'\fR:
.Sp
.Vb 1
\&        ffmpeg \-f image2 \-pattern_type glob \-i \*(Aqfoo\-*.jpeg\*(Aq \-r 12 \-s WxH foo.avi
.Ve
.IP "\(bu" 4
You can put many streams of the same type in the output:
.Sp
.Vb 1
\&        ffmpeg \-i test1.avi \-i test2.avi \-map 0:3 \-map 0:2 \-map 0:1 \-map 0:0 \-c copy test12.nut
.Ve
.Sp
The resulting output file \fItest12.avi\fR will contain first four streams from
the input file in reverse order.
.IP "\(bu" 4
To force \s-1CBR\s0 video output:
.Sp
.Vb 1
\&        ffmpeg \-i myfile.avi \-b 4000k \-minrate 4000k \-maxrate 4000k \-bufsize 1835k out.m2v
.Ve
.IP "\(bu" 4
The four options lmin, lmax, mblmin and mblmax use 'lambda' units,
but you may use the \s-1QP2LAMBDA\s0 constant to easily convert from 'q' units:
.Sp
.Vb 1
\&        ffmpeg \-i src.ext \-lmax 21*QP2LAMBDA dst.ext
.Ve
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIffmpeg\-all\fR\|(1),
\&\fIffplay\fR\|(1), \fIffprobe\fR\|(1), \fIffserver\fR\|(1),
\&\fIffmpeg\-utils\fR\|(1), \fIffmpeg\-scaler\fR\|(1), \fIffmpeg\-resampler\fR\|(1),
\&\fIffmpeg\-codecs\fR\|(1), \fIffmpeg\-bitstream\-filters\fR\|(1), \fIffmpeg\-formats\fR\|(1),
\&\fIffmpeg\-devices\fR\|(1), \fIffmpeg\-protocols\fR\|(1), \fIffmpeg\-filters\fR\|(1)
.SH "AUTHORS"
.IX Header "AUTHORS"
The FFmpeg developers.
.PP
For details about the authorship, see the Git history of the project
(git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
\&\fBgit log\fR in the FFmpeg source directory, or browsing the
online repository at <\fBhttp://source.ffmpeg.org\fR>.
.PP
Maintainers for the specific components are listed in the file
\&\fI\s-1MAINTAINERS\s0\fR in the source code tree.