Man page for ffmpeg
-
Upload
shamir-rivera -
Category
Documents
-
view
127 -
download
5
description
Transcript of Man page for ffmpeg
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
FFMPEG(1) FFMPEG(1)
NAME
ffmpeg - ffmpeg video converter
SYNOPSIS
ffmpeg [global options] [[infile options][-i infile]]... {[outfile
options] outfile}...
DESCRIPTION
ffmpeg is a very fast video and audio conver ter that can also grab from
a live audio/video source. It can also conve rt between arbitrary sample
rates and resize video on the fly with a hig h quality polyphase filter.
ffmpeg reads from an arbitrary number of inp ut "files" (which can be
regular files, pipes, network streams, grabb ing devices, etc.),
specified by the "-i" option, and writes to an arbitrary number of
output "files", which are specified by a pla in output filename.
Anything found on the command line which can not be interpreted as an
option is considered to be an output filenam e.
Each input or output file can in principle c ontain any number of
streams of different types (video/audio/subt itle/attachment/data).
Allowed number and/or types of streams can b e limited by the container
format. Selecting, which streams from which inputs go into output, is
done either automatically or with the "-map" option (see the Stream
selection chapter).
To refer to input files in options, you must use their indices
(0-based). E.g. the first input file is 0, th e second is 1 etc.
Similarly, streams within a file are referre d to by their indices. E.g.
"2:3" refers to the fourth stream in the thi rd input file. See also the
Stream specifiers chapter.
As a general rule, options are applied to th e next specified file.
Therefore, order is important, and you can h ave the same option on the
command line multiple times. Each occurrence is then applied to the
next input or output file. Exceptions from this rule are the global
options (e.g. verbosity level), which should be specified first.
Do not mix input and output files -- first s pecify all input files,
then all output files. Also do not mix optio ns which belong to
different files. All options apply ONLY to t he next input or output
file and are reset between files.
To set the video bitrate of the output f ile to 64kbit/s:
ffmpeg -i input.avi -b:v 64k output.avi
To force the frame rate of the output fi le to 24 fps:
-1-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
ffmpeg -i input.avi -r 24 output.avi
To force the frame rate of the input fil e (valid for raw formats
only) to 1 fps and the frame rate of the output file to 24 fps:
ffmpeg -r 1 -i input.m2v -r 24 output.avi
The format option may be needed for raw inpu t files.
STREAM SELECTION
By default ffmpeg includes only one stream o f each type (video, audio,
subtitle) present in the input files and add s them to each output file.
It picks the "best" of each based upon the f ollowing criteria; for
video it is the stream with the highest reso lution, for audio the
stream with the most channels, for subtitle its the first subtitle
stream. In the case where several streams of the same type rate
equally, the lowest numbered stream is chose n.
You can disable some of those defaults by us ing "-vn/-an/-sn" options.
For full manual control, use the "-map" opti on, which disables the
defaults just described.
OPTIONS
All the numerical options, if not specified otherwise, accept in input
a string representing a number, which may co ntain one of the
International System number postfixes, for e xample K, M, G. If
i is appended after the postfix, powers of 2 are used instead of
powers of 10. The B postfix multiplies the value for 8, and can be
appended after another postfix or used alone . This allows using for
example KB, MiB, G and B as postfix.
Options which do not take arguments are bool ean options, and set the
corresponding value to true. They can be set to false by prefixing with
"no" the option name, for example using "-no foo" in the command line
will set to false the boolean option with na me "foo".
Stream specifiers
Some options are applied per-stream, e.g. bi trate or codec. Stream
specifiers are used to precisely specify whi ch stream(s) does a given
option belong to.
A stream specifier is a string generally app ended to the option name
and separated from it by a colon. E.g. "-cod ec:a:1 ac3" option contains
"a:1" stream specifer, which matches the sec ond audio stream. Therefore
it would select the ac3 codec for the second audio stream.
A stream specifier can match several stream, the option is then applied
to all of them. E.g. the stream specifier in "-b:a 128k" matches all
audio streams.
An empty stream specifier matches all stream s, for example "-codec
copy" or "-codec: copy" would copy all the s treams without reencoding.
-2-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Possible forms of stream specifiers are:
stream_index
Matches the stream with this index. E.g. "-threa ds:1 4" would set
the thread count for the second stream to 4.
stream_type[:stream_index]
stream_type is one of: v for video, a for au dio, s for
subtitle, d for data and t for attachments. If stream_index is
given, then matches stream number stream_index o f this type.
Otherwise matches all streams of this type.
p:program_id[:stream_index]
If stream_index is given, then matches stream nu mber stream_index
in program with id program_id. Otherwise matches all streams in
this program.
Generic options
These options are shared amongst the av* too ls.
-L Show license.
-h, -?, -help, --help
Show help.
-version
Show version.
-formats
Show available formats.
The fields preceding the format names have the f ollowing meanings:
D Decoding available
E Encoding available
-codecs
Show available codecs.
The fields preceding the codec names have the fo llowing meanings:
D Decoding available
E Encoding available
V/A/S
Video/audio/subtitle codec
S Codec supports slices
D Codec supports direct rendering
-3-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
T Codec can handle input truncated at random l ocations instead of
only at frame boundaries
-bsfs
Show available bitstream filters.
-protocols
Show available protocols.
-filters
Show available libavfilter filters.
-pix_fmts
Show available pixel formats.
-sample_fmts
Show available sample formats.
-loglevel loglevel | -v loglevel
Set the logging level used by the library. logl evel is a number or
a string containing one of the following values:
quiet
panic
fatal
error
warning
info
verbose
debug
By default the program logs to stderr, if colori ng is supported by
the terminal, colors are used to mark errors and warnings. Log
coloring can be disabled setting the environment variable
AV_LOG_FORCE_NOCOLOR or NO_COLOR, or can be forc ed setting the
environment variable AV_LOG_FORCE_COLOR. The us e of the
environment variable NO_COLOR is deprecated and will be dropped in
a following FFmpeg version.
-report
Dump full command line and console output to a f ile named
"program-YYYYMMDD-HHMMSS.log" in the current dir ectory. This file
can be useful for bug reports. It also implies "-loglevel
verbose".
Note: setting the environment variable "FFREPORT " to any value has
the same effect.
AVOptions
These options are provided directly by the l ibavformat, libavdevice and
libavcodec libraries. To see the list of ava ilable AVOptions, use the
-help option. They are separated into two ca tegories:
-4-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
generic
These options can be set for any container, code c or device.
Generic options are listed under AVFormatContext options for
containers/devices and under AVCodecContext opti ons for codecs.
private
These options are specific to the given containe r, device or codec.
Private options are listed under their correspon ding
containers/devices/codecs.
For example to write an ID3v2.3 header inste ad of a default ID3v2.4 to
an MP3 file, use the id3v2_version private o ption of the MP3 muxer:
ffmpeg -i input.flac -id3v2_version 3 out.mp 3
All codec AVOptions are obviously per-stream , so the chapter on stream
specifiers applies to them
Note -nooption syntax cannot be used for boo lean AVOptions, use -option
0/-option 1.
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.
Main options
-f fmt (input/output)
Force input or output file format. The format is normally auto
detected for input files and guessed from file e xtension for output
files, so this option is not needed in most case s.
-i filename (input)
input file name
-y (global)
Overwrite output files without asking.
-n (global)
Do not overwrite output files but exit if file e xists.
-c[:stream_specifier] codec (input/output,pe r-stream)
-codec[:stream_specifier] codec (input/outpu t,per-stream)
Select an encoder (when used before an output fi le) or a decoder
(when used before an input file) for one or more streams. codec is
the name of a decoder/encoder or a special value "copy" (output
only) to indicate that the stream is not to be r e-encoded.
For example
ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OU TPUT
encodes all video streams with libx264 and copie s all audio
streams.
-5-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
For each stream, the last matching "c" option is applied, so
ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c :a:137 libvorbis OUTPUT
will copy all the streams except the second vide o, which will be
encoded with libx264, and the 138th audio, which will be encoded
with libvorbis.
-t duration (output)
Stop writing the output after its duration reach es duration.
duration may be a number in seconds, or in "hh:m m:ss[.xxx]" form.
-fs limit_size (output)
Set the file size limit.
-ss position (input/output)
When used as an input option (before "-i"), seek s in this input
file to position. When used as an output option (before an output
filename), decodes but discards input until the timestamps reach
position. This is slower, but more accurate.
position may be either in seconds or in "hh:mm:s s[.xxx]" form.
-itsoffset offset (input)
Set the input time offset in seconds. "[-]hh:mm :ss[.xxx]" syntax
is also supported. The offset is added to the t imestamps of the
input files. Specifying a positive offset means that the
corresponding streams are delayed by offset seco nds.
-timestamp time (output)
Set the recording timestamp in the container. T he syntax for time
is:
now|([(YYYY-MM-DD|YYYYMMDD)[T|t| ]]((HH[:MM[:SS[ .m...]]])|(HH[MM[SS[.m...]]]))[Z|z])
If the value is "now" it takes the current time. Time is local
time unless Z or z is appended, in which cas e it is interpreted
as UTC. If the year-month-day part is not speci fied it takes the
current year-month-day.
-metadata[:metadata_specifier] key=value (ou tput,per-metadata)
Set a metadata key/value pair.
An optional metadata_specifier may be given to s et metadata on
streams or chapters. See "-map_metadata" documen tation for details.
This option overrides metadata set with "-map_me tadata". It is also
possible to delete metadata by using an empty va lue.
For example, for setting the title in the output file:
ffmpeg -i in.avi -metadata title="my title" out. flv
-6-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
To set the language of the first audio stream:
ffmpeg -i INPUT -metadata:s:a:1 language=eng OUT PUT
-target type (output)
Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50"). type
may be prefixed with "pal-", "ntsc-" or "film-" to use the
corresponding standard. All the format options ( bitrate, codecs,
buffer sizes) are then set automatically. You ca n just type:
ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
Nevertheless you can specify additional options as long as you know
they do not conflict with the standard, as in:
ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd. mpg
-dframes number (output)
Set the number of data frames to record. This is an alias for
"-frames:d".
-frames[:stream_specifier] framecount (outpu t,per-stream)
Stop writing to the stream after framecount fram es.
-q[:stream_specifier] q (output,per-stream)
-qscale[:stream_specifier] q (output,per-str eam)
Use fixed quality scale (VBR). The meaning of q is codec-dependent.
-filter[:stream_specifier] filter_graph (out put,per-stream)
filter_graph is a description of the filter grap h to apply to the
stream. Use "-filters" to show all the available filters (including
also sources and sinks).
-pre[:stream_specifier] preset_name (output, per-stream)
Specify the preset for matching stream(s).
-stats (global)
Print encoding progress/statistics. On by defaul t.
-attach filename (output)
Add an attachment to the output file. This is su pported by a few
formats like Matroska for e.g. fonts used in ren dering subtitles.
Attachments are implemented as a specific type o f 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 usu al way. Attachment
streams created with this option will be created after all the
other streams (i.e. those created with "-map" or automatic
mappings).
Note that for Matroska you also have to set the mimetype metadata
tag:
-7-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata :s:2
mimetype=application/x-truetype-font out.mkv
(assuming that the attachment stream will be thi rd in the output
file).
-dump_attachment[:stream_specifier] filename (input,per-stream)
Extract the matching attachment stream into a fi le named filename.
If filename is empty, then the value of the "fil ename" metadata tag
will be used.
E.g. to extract the first attachment to a file n amed out.ttf:
ffmpeg -dump_attachment:t:0 out.ttf INPUT
To extract all attachments to files determined b y the "filename"
tag:
ffmpeg -dump_attachment:t "" INPUT
Technical note -- attachments are implemented as codec extradata,
so this option can actually be used to extract e xtradata from any
stream, not just attachments.
Video Options
-vframes number (output)
Set the number of video frames to record. This i s an alias for
"-frames:v".
-r[:stream_specifier] fps (input/output,per- stream)
Set frame rate (Hz value, fraction or abbreviati on), (default =
25).
-s[:stream_specifier] size (input/output,per -stream)
Set frame size. The format is wxh (default - sam e as source). The
following abbreviations are recognized:
sqcif
128x96
qcif
176x144
cif 352x288
4cif
704x576
16cif
1408x1152
qqvga
160x120
-8-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
qvga
320x240
vga 640x480
svga
800x600
xga 1024x768
uxga
1600x1200
qxga
2048x1536
sxga
1280x1024
qsxga
2560x2048
hsxga
5120x4096
wvga
852x480
wxga
1366x768
wsxga
1600x1024
wuxga
1920x1200
woxga
2560x1600
wqsxga
3200x2048
wquxga
3840x2400
whsxga
6400x4096
whuxga
7680x4800
-9-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
cga 320x200
ega 640x350
hd480
852x480
hd720
1280x720
hd1080
1920x1080
-aspect[:stream_specifier] aspect (output,pe r-stream)
Set the video display aspect ratio specified by aspect.
aspect can be a floating point number string, or a string of the
form num:den, where num and den are the numerato r and denominator
of the aspect ratio. For example "4:3", "16:9", "1.3333", and
"1.7777" are valid argument values.
-croptop size
-cropbottom size
-cropleft size
-cropright size
All the crop options have been removed. Use -vf
crop=width:height:x:y instead.
-padtop size
-padbottom size
-padleft size
-padright size
-padcolor hex_color
All the pad options have been removed. Use -vf
pad=width:height:x:y:color instead.
-vn (output)
Disable video recording.
-bt tolerance
Set video bitrate tolerance (in bits, default 40 00k). Has a
minimum value of: (target_bitrate/target_framera te). In 1-pass
mode, bitrate tolerance specifies how far rateco ntrol is willing to
deviate from the target average bitrate value. T his is not related
to min/max bitrate. Lowering tolerance too much has an adverse
effect on quality.
-maxrate bitrate
Set max video bitrate (in bit/s). Requires -buf size to be set.
-minrate bitrate
Set min video bitrate (in bit/s). Most useful i n setting up a CBR
encode:
-10-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
ffmpeg -i myfile.avi -b:v 4000k -minrate 4000k - maxrate 4000k -bufsize 1835k out.m2v
It is of little use elsewise.
-bufsize size
Set video buffer verifier buffer size (in bits).
-vcodec codec (output)
Set the video codec. This is an alias for "-code c:v".
-same_quant
Use same quantizer as source (implies VBR).
Note that this is NOT SAME QUALITY. Do not use t his option unless
you know you need it.
-pass n
Select the pass number (1 or 2). It is used to d o two-pass video
encoding. The statistics of the video are record ed in the first
pass into a log file (see also the option -passl ogfile), and in the
second pass that log file is used to generate th e video at the
exact requested bitrate. On pass 1, you may jus t deactivate audio
and set output to null, examples for Windows and Unix:
ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f ra wvideo -y NUL
ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f ra wvideo -y /dev/null
-passlogfile prefix (global)
Set two-pass log file name prefix to prefix, the default file name
prefix is ffmpeg2pass. The complete file nam e will be
PREFIX-N.log, where N is a number specific to th e output stream
Note that this option is overwritten by a local option of the same
name when using "-vcodec libx264". That option m aps to the x264
option stats which has a different syntax.
-vlang code
Set the ISO 639 language code (3 letters) of the current video
stream.
-vf filter_graph (output)
filter_graph is a description of the filter grap h to apply to the
input video. Use the option "-filters" to show a ll the available
filters (including also sources and sinks). This is an alias for
"-filter:v".
Advanced Video Options
-pix_fmt[:stream_specifier] format (input/ou tput,per-stream)
Set pixel format. Use "-pix_fmts" to show all th e supported pixel
formats.
-sws_flags flags (input/output)
-11-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Set SwScaler flags.
-g gop_size
Set the group of pictures size.
-intra
deprecated, use -g 1
-vdt n
Discard threshold.
-qmin q
minimum video quantizer scale (VBR)
-qmax q
maximum video quantizer scale (VBR)
-qdiff q
maximum difference between the quantizer scales (VBR)
-qblur blur
video quantizer scale blur (VBR) (range 0.0 - 1. 0)
-qcomp compression
video quantizer scale compression (VBR) (default 0.5). Constant of
ratecontrol equation. Recommended range for defa ult rc_eq: 0.0-1.0
-lmin lambda
minimum video lagrange factor (VBR)
-lmax lambda
max video lagrange factor (VBR)
-mblmin lambda
minimum macroblock quantizer scale (VBR)
-mblmax lambda
maximum macroblock quantizer scale (VBR)
These four options (lmin, lmax, mblmin, mblmax) use lambda units,
but you may use the QP2LAMBDA constant to easily convert from q
units:
ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
-rc_init_cplx complexity
initial complexity for single pass encoding
-b_qfactor factor
qp factor between P- and B-frames
-i_qfactor factor
qp factor between P- and I-frames
-12-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-b_qoffset offset
qp offset between P- and B-frames
-i_qoffset offset
qp offset between P- and I-frames
-rc_eq equation
Set rate control equation (see section "Expressi on Evaluation")
(default = "tex^qComp").
When computing the rate control equation express ion, besides the
standard functions defined in the section "Expre ssion Evaluation",
the following functions are available:
bits2qp(bits)
qp2bits(qp)
and the following constants are available:
iTex
pTex
tex
mv
fCode
iCount
mcVar
var
isI
isP
isB
avgQP
qComp
avgIITex
avgPITex
avgPPTex
avgBPTex
avgTex
-rc_override[:stream_specifier] override (ou tput,per-stream)
Rate control override for specific intervals, fo rmatted as
"int,int,int" list separated with slashes. Two f irst values are the
beginning and end frame numbers, last one is qua ntizer to use if
positive, or quality factor if negative.
-me_method method
Set motion estimation method to method. Availab le methods are
(from lowest to best quality):
zero
Try just the (0, 0) vector.
phods
log
-13-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
x1
hex
umh
epzs
(default method)
full
exhaustive search (slow and marginally bette r than epzs)
-dct_algo algo
Set DCT algorithm to algo. Available values are:
0 FF_DCT_AUTO (default)
1 FF_DCT_FASTINT
2 FF_DCT_INT
3 FF_DCT_MMX
4 FF_DCT_MLIB
5 FF_DCT_ALTIVEC
-idct_algo algo
Set IDCT algorithm to algo. Available values are :
0 FF_IDCT_AUTO (default)
1 FF_IDCT_INT
2 FF_IDCT_SIMPLE
3 FF_IDCT_SIMPLEMMX
4 FF_IDCT_LIBMPEG2MMX
5 FF_IDCT_PS2
6 FF_IDCT_MLIB
7 FF_IDCT_ARM
8 FF_IDCT_ALTIVEC
9 FF_IDCT_SH4
10 FF_IDCT_SIMPLEARM
-er n
Set error resilience to n.
1 FF_ER_CAREFUL (default)
-14-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
2 FF_ER_COMPLIANT
3 FF_ER_AGGRESSIVE
4 FF_ER_VERY_AGGRESSIVE
-ec bit_mask
Set error concealment to bit_mask. bit_mask is a bit mask of the
following values:
1 FF_EC_GUESS_MVS (default = enabled)
2 FF_EC_DEBLOCK (default = enabled)
-bf frames
Use frames B-frames (supported for MPEG-1, MPE G-2 and MPEG-4).
-mbd mode
macroblock decision
0 FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot ch ange it yet in
ffmpeg).
1 FF_MB_DECISION_BITS: Choose the one which ne eds the fewest
bits.
2 FF_MB_DECISION_RD: rate distortion
-4mv
Use four motion vector by macroblock (MPEG-4 onl y).
-part
Use data partitioning (MPEG-4 only).
-bug param
Work around encoder bugs that are not auto-detec ted.
-strict strictness
How strictly to follow the standards.
-aic
Enable Advanced intra coding (h263+).
-umv
Enable Unlimited Motion Vector (h263+)
-deinterlace
Deinterlace pictures.
-ilme
Force interlacing support in encoder (MPEG-2 and MPEG-4 only). Use
this option if your input file is interlaced and you want to keep
-15-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
the interlaced format for minimum losses. The a lternative is to
deinterlace the input stream with -deinterlace, but deinterlacing
introduces losses.
-psnr
Calculate PSNR of compressed frames.
-vstats
Dump video coding statistics to vstats_HHMMSS.lo g.
-vstats_file file
Dump video coding statistics to file.
-top[:stream_specifier] n (output,per-stream )
top=1/bottom=0/auto=-1 field first
-dc precision
Intra_dc_precision.
-vtag fourcc/tag (output)
Force video tag/fourcc. This is an alias for "-t ag:v".
-qphist (global)
Show QP histogram
-vbsf bitstream_filter
Deprecated see -bsf
-force_key_frames[:stream_specifier] time[,t ime...] (output,per-stream)
Force key frames at the specified timestamps, mo re precisely at the
first frames after each specified time. This op tion can be useful
to ensure that a seek point is present at a chap ter mark or any
other designated place in the output file. The timestamps must be
specified in ascending order.
-copyinkf[:stream_specifier] (output,per-str eam)
When doing stream copy, copy also non-key frames found at the
beginning.
Audio Options
-aframes number (output)
Set the number of audio frames to record. This i s an alias for
"-frames:a".
-ar[:stream_specifier] freq (input/output,pe r-stream)
Set the audio sampling frequency. For output str eams it is set by
default to the frequency of the corresponding in put stream. For
input streams this option only makes sense for a udio grabbing
devices and raw demuxers and is mapped to the co rresponding demuxer
options.
-aq q (output)
Set the audio quality (codec-specific, VBR). Thi s is an alias for
-16-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-q:a.
-ac[:stream_specifier] channels (input/outpu t,per-stream)
Set the number of audio channels. For output str eams it is set by
default to the number of input audio channels. F or input streams
this option only makes sense for audio grabbing devices and raw
demuxers and is mapped to the corresponding demu xer options.
-an (output)
Disable audio recording.
-acodec codec (input/output)
Set the audio codec. This is an alias for "-code c:a".
-sample_fmt[:stream_specifier] sample_fmt (o utput,per-stream)
Set the audio sample format. Use "-sample_fmts" to get a list of
supported sample formats.
Advanced Audio options:
-atag fourcc/tag (output)
Force audio tag/fourcc. This is an alias for "-t ag:a".
-audio_service_type type
Set the type of service that the audio stream co ntains.
ma Main Audio Service (default)
ef Effects
vi Visually Impaired
hi Hearing Impaired
di Dialogue
co Commentary
em Emergency
vo Voice Over
ka Karaoke
-absf bitstream_filter
Deprecated, see -bsf
Subtitle options:
-slang code
Set the ISO 639 language code (3 letters) of the current subtitle
stream.
-scodec codec (input/output)
Set the subtitle codec. This is an alias for "-c odec:s".
-17-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-sn (output)
Disable subtitle recording.
-sbsf bitstream_filter
Deprecated, see -bsf
Audio/Video grab options
-isync (global)
Synchronize read on input.
Advanced options
-map
[-]input_file_id[:stream_specifier][,sync_fi le_id[:stream_specifier]]
(output)
Designate one or more input streams as a source for the output
file. Each input stream is identified by the inp ut file index
input_file_id and the input stream index input_s tream_id within the
input file. Both indices start at 0. If specifie d,
sync_file_id:stream_specifier sets which input s tream is used as a
presentation sync reference.
The first "-map" option on the command line spec ifies the source
for output stream 0, the second "-map" option sp ecifies the source
for output stream 1, etc.
A "-" character before the stream identifier cre ates a "negative"
mapping. It disables matching streams from alre ady created
mappings.
For example, to map ALL streams from the first i nput file to output
ffmpeg -i INPUT -map 0 output
For example, if you have two audio streams in th e first input file,
these streams are identified by "0:0" and "0:1". You can use "-map"
to select which streams to place in an output fi le. For example:
ffmpeg -i INPUT -map 0:1 out.wav
will map the input stream in INPUT identified by "0:1" to the
(single) output stream in out.wav.
For example, to select the stream with index 2 f rom input file
a.mov (specified by the identifier "0:2"), and s tream with index 6
from input b.mov (specified by the identifier "1 :6"), and copy them
to the output file out.mov:
ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1 :6 out.mov
To select all video and the third audio stream f rom an input file:
ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
-18-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
To map all the streams except the second audio, use negative
mappings
ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
Note that using this option disables the default mappings for this
output file.
-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 ou tput. If
output_file_id.stream_specifier are not set, the audio channel will
be mapped on all the audio streams.
Using "-1" instead of input_file_id.stream_speci fier.channel_id
will map a muted channel.
For example, assuming INPUT is a stereo audio fi le, you can switch
the two audio channels with the following comman d:
ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
If you want to mute the first channel and keep t he second:
ffmpeg -i INPUT -map_channel -1 -map_channel 0.0 .1 OUTPUT
The order of the "-map_channel" option specifies the order of the
channels in the output stream. The output channe l layout is guessed
from the number of channels mapped (mono if one "-map_channel",
stereo if two, etc.). Using "-ac" in combination of "-map_channel"
makes the channel gain levels to be updated if c hannel layouts
dont match (for instance two "-map_channel" opt ions and "-ac 6").
You can also extract each channel of an INPUT to specific outputs;
the following command extract each channel of th e audio stream
(file 0, stream 0) to the respective OUTPUT_CH0 and OUTPUT_CH1:
ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -m ap_channel 0.0.1 OUTPUT_CH1
The following example split the channels of a st ereo input into
streams:
ffmpeg -i stereo.wav -map 0:0 -map 0:0 -map_chan nel 0.0.0:0.0 -map_channel 0.0.1:0.1
-y out.ogg
Note that currently each output stream can only contain channels
from a single input stream; you cant for exampl e use
"-map_channel" to pick multiple input audio chan nels contained in
different streams (from the same or different fi les) 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 spliting a stereo stream into two
-19-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
single channel mono streams is possible.
-map_metadata[:metadata_spec_out] infile[:me tadata_spec_in]
(output,per-metadata)
Set metadata information of the next output file from infile. Note
that those are file indices (zero-based), not fi lenames. Optional
metadata_spec_in/out parameters specify, which m etadata to copy. A
metadata specifier can have the following forms:
g global metadata, i.e. metadata that applies to the whole file
s[:stream_spec]
per-stream metadata. stream_spec is a stream specifier as
described in the Stream specifiers chapter. In an input
metadata specifier, the first matching strea m is copied from.
In an output metadata specifier, all matchin g streams are
copied to.
c:chapter_index
per-chapter metadata. chapter_index is the z ero-based chapter
index.
p:program_index
per-program metadata. program_index is the z ero-based program
index.
If metadata specifier is omitted, it defaults to global.
By default, global metadata is copied from the f irst input file,
per-stream and per-chapter metadata is copied al ong with
streams/chapters. These default mappings are dis abled by creating
any mapping of the relevant type. A negative fil e index can be used
to create a dummy mapping that just disables aut omatic copying.
For example to copy metadata from the first stre am of the input
file to global metadata of the output file:
ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
To do the reverse, i.e. copy global metadata to all audio streams:
ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
Note that simple 0 would work as well in this ex ample, since global
metadata is assumed by default.
-map_chapters input_file_index (output)
Copy chapters from input file with index input_f ile_index to the
next output file. If no chapter mapping is speci fied, then chapters
are copied from the first input file with at lea st one chapter. Use
a negative file index to disable any chapter cop ying.
-debug category
-20-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Print specific debug info. category is a number or a string
containing one of the following values:
bitstream
buffers
picture buffer allocations
bugs
dct_coeff
er error recognition
mb_type
macroblock (MB) type
mmco
memory management control operations (H.264)
mv motion vector
pict
picture info
pts
qp per-block quantization parameter (QP)
rc rate control
skip
startcode
thread_ops
threading operations
vis_mb_type
visualize block types
vis_qp
visualize quantization parameter (QP), lower QP are tinted
greener
-benchmark (global)
Show benchmarking information at the end of an e ncode. Shows CPU
time used and maximum memory consumption. Maxim um memory
consumption is not supported on all systems, it will usually
display as 0 if not supported.
-timelimit duration (global)
Exit after ffmpeg has been running for duration seconds.
-dump (global)
Dump each input packet to stderr.
-hex (global)
When dumping packets, also dump the payload.
-21-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-ps size
Set RTP payload size in bytes.
-re (input)
Read input at native frame rate. Mainly used to simulate a grab
device.
-loop_input
Loop over the input stream. Currently it works o nly for image
streams. This option is used for automatic FFser ver testing. This
option is deprecated, use -loop 1.
-loop_output number_of_times
Repeatedly loop output for formats that support looping such as
animated GIF (0 will loop the output infinitely) . This option is
deprecated, use -loop.
-threads count
Thread count.
-vsync parameter
Video sync method.
0, passthrough
Each frame is passed with its timestamp from the demuxer to the
muxer.
1, cfr
Frames will be duplicated and dropped to ach ieve exactly the
requested constant framerate.
2, vfr
Frames are passed through with their timesta mp or dropped so as
to prevent 2 frames from having the same tim estamp.
-1, auto
Chooses between 1 and 2 depending on muxer c apabilities. This
is the default method.
With -map you can select from which stream the t imestamps should be
taken. You can leave either video or audio uncha nged and sync the
remaining stream(s) to the unchanged one.
-async samples_per_second
Audio sync method. "Stretches/squeezes" the audi o stream to match
the timestamps, the parameter is the maximum sam ples per second by
which the audio is changed. -async 1 is a special case where only
the start of the audio stream is corrected witho ut any later
correction.
-copyts
Copy timestamps from input to output.
-22-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-copytb
Copy input stream time base from input to output when stream
copying.
-shortest
Finish encoding when the shortest input stream e nds.
-dts_delta_threshold
Timestamp discontinuity delta threshold.
-muxdelay seconds (input)
Set the maximum demux-decode delay.
-muxpreload seconds (input)
Set the initial demux-decode delay.
-streamid output-stream-index:new-value (out put)
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 outpu t files exist, a
streamid may be reassigned to a different value.
For example, to set the stream 0 PID to 33 and t he stream 1 PID to
36 for an output mpegts file:
ffmpeg -i infile -streamid 0:33 -streamid 1:36 o ut.ts
-bsf[:stream_specifier] bitstream_filters (o utput,per-stream)
Set bitstream filters for matching streams. bist ream_filters is a
comma-separated list of bitstream filters. Use t he "-bsfs" option
to get the list of bitstream filters.
ffmpeg -i h264.mp4 -c:v copy -vbsf h264_mp4toann exb -an out.h264
ffmpeg -i file.mov -an -vn -sbsf mov2textsub -c: s copy -f rawvideo sub.txt
-tag[:stream_specifier] codec_tag (per-strea m)
Force a tag/fourcc for matching streams.
-timecode hh:mm:ssSEPff
Specify Timecode for writing. SEP is : for non drop timecode and
; (or .) for drop.
ffmpeg -i input.mpg -timecode 01:02:03.04 -r 300 00/1001 -s ntsc output.mpg
Preset files
A preset file contains a sequence of option= value pairs, one for each
line, specifying a sequence of options which would be awkward to
specify on the command line. Lines starting with the hash (#)
character are ignored and are used to provid e comments. Check the
presets directory in the FFmpeg source tree for examples.
-23-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Preset files are specified with the "vpre", "apre", "spre", and "fpre"
options. The "fpre" option takes the filenam e of the preset instead of
a preset name as input and can be used for a ny kind of codec. For the
"vpre", "apre", and "spre" options, the opti ons specified in a preset
file are applied to the currently selected c odec of the same type as
the preset option.
The argument passed to the "vpre", "apre", a nd "spre" preset options
identifies the preset file to use according to the following rules:
First ffmpeg searches for a file named arg.f fpreset in the directories
$FFMPEG_DATADIR (if set), and $HOME/.ffmpeg, and in the datadir defined
at configuration time (usually PREFIX/share/ ffmpeg) or in a ffpresets
folder along the executable on win32, in tha t order. For example, if
the argument is "libx264-max", it will searc h for the file
libx264-max.ffpreset.
If no such file is found, then ffmpeg will s earch for a file named
codec_name-arg.ffpreset in the above-mention ed directories, where
codec_name is the name of the codec to which the preset file options
will be applied. For example, if you select the video codec with
"-vcodec libx264" and use "-vpre max", then it will search for the file
libx264-max.ffpreset.
TIPS
For streaming at very low bitrate applic ation, use a low frame rate
and a small GOP size. This is especially true fo r RealVideo where
the Linux player does not seem to be very fast, so it can miss
frames. An example is:
ffmpeg -g 3 -r 3 -t 10 -b:v 50k -s qcif -f rv10 /tmp/b.rm
The parameter q which is displayed whi le encoding is the current
quantizer. The value 1 indicates that a very goo d quality could be
achieved. The value 31 indicates the worst quali ty. If q=31 appears
too often, it means that the encoder cannot comp ress enough to meet
your bitrate. You must either increase the bitra te, decrease the
frame rate or decrease the frame size.
If your computer is not fast enough, you can speed up the
compression at the expense of the compression ra tio. You can use
-me zero to speed up motion estimation, and - intra to disable
motion estimation completely (you have only I-fr ames, which means
it is about as good as JPEG compression).
To have very low audio bitrates, reduce the sampling frequency
(down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
To have a constant quality (but a variab le bitrate), use the option
-qscale n when n is between 1 (excellent qua lity) and 31 (worst
quality).
-24-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
EXAMPLES
Preset files
A preset file contains a sequence of option= value pairs, one for each
line, specifying a sequence of options which can be specified also on
the command line. Lines starting with the ha sh (#) character are
ignored and are used to provide comments. Em pty lines are also ignored.
Check the presets directory in the FFmpeg so urce tree for examples.
Preset files are specified with the "pre" op tion, this option takes a
preset name as input. FFmpeg searches for a file named
preset_name.avpreset in the directories $AVC ONV_DATADIR (if set), and
$HOME/.ffmpeg, and in the data directory def ined at configuration time
(usually $PREFIX/share/ffmpeg) in that order . For example, if the
argument is "libx264-max", it will search fo r the file
libx264-max.avpreset.
Video and Audio grabbing
If you specify the input format and device t hen ffmpeg can grab video
and audio directly.
ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
Or with an ALSA audio source (mono input, ca rd id 1) instead of OSS:
ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
Note that you must activate the right video source and channel before
launching ffmpeg with any TV viewer such as
xawtv ("http://linux.bytesex.org/xawtv/") by Gerd K norr. You also have
to set the audio recording levels correctly with a standard mixer.
X11 grabbing
Grab the X11 display with ffmpeg via
ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/ out.mpg
0.0 is display.screen number of your X11 ser ver, same as the DISPLAY
environment variable.
ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg
0.0 is display.screen number of your X11 ser ver, same as the DISPLAY
environment variable. 10 is the x-offset and 20 the y-offset for the
grabbing.
Video and Audio file format conversion
Any supported file format and protocol can s erve as input to ffmpeg:
Examples:
You can use YUV files as input:
ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
-25-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
It will use the files:
/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
The Y files use twice the resolution of the U an d V files. They are
raw files, without header. They can be generated by all decent
video decoders. You must specify the size of the image with the -s
option if ffmpeg cannot guess it.
You can input from a raw YUV420P file:
ffmpeg -i /tmp/test.yuv /tmp/out.avi
test.yuv is a file containing raw YUV planar dat a. Each frame is
composed of the Y plane followed by the U and V planes at half
vertical and horizontal resolution.
You can output to a raw YUV420P file:
ffmpeg -i mydivx.avi hugefile.yuv
You can set several input files and outp ut files:
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /t mp/a.mpg
Converts the audio file a.wav and the raw YUV vi deo file a.yuv to
MPEG file a.mpg.
You can also do audio and video conversi ons at the same time:
ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
Converts a.wav to MPEG audio at 22050 Hz sample rate.
You can encode to several formats at the same time and define a
mapping from input stream to output streams:
ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp 2 -map 0:a -b:a 128k /tmp/b.mp2
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits.
-map file:index specifies which input stream i s used for each
output stream, in the order of the definition of output streams.
You can transcode decrypted VOBs:
ffmpeg -i snatch_1.vob -f avi -c:v mpeg4 -b:v 80 0k -g 300 -bf 2 -c:a libmp3lame -b:a
128k snatch.avi
This is a typical DVD ripping example; the input is a VOB file, the
output an AVI file with MPEG-4 video and MP3 aud io. Note that in
this command we use B-frames so the MPEG-4 strea m is DivX5
-26-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
compatible, and GOP size is 300 which means one intra frame every
10 seconds for 29.97fps input video. Furthermore , the audio stream
is MP3-encoded so you need to enable LAME suppor t by passing
"--enable-libmp3lame" to configure. The mapping i s particularly
useful for DVD transcoding to get the desired au dio language.
NOTE: To see the supported input formats, use "f fmpeg -formats".
You can extract images from a video, or create a video from many
images:
For extracting images from a video:
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d .jpeg
This will extract one video frame per second fro m the video and
will output them in files named foo-001.jpeg, fo o-002.jpeg, etc.
Images will be rescaled to fit the new WxH value s.
If you want to extract just a limited number of frames, you can use
the above command in combination with the -vfram es or -t option, or
in combination with -ss to start extracting from a certain point in
time.
For creating a video from many images:
ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH f oo.avi
The syntax "foo-%03d.jpeg" specifies to use a de cimal number
composed of three digits padded with zeroes to e xpress the sequence
number. It is the same syntax supported by the C printf function,
but only formats accepting a normal integer are suitable.
You can put many streams of the same typ e in the output:
ffmpeg -i test1.avi -i test2.avi -map 0.3 -map 0 .2 -map 0.1 -map 0.0 -c copy
test12.nut
The resulting output file test12.avi will contai n first four
streams from the input file in reverse order.
EXPRESSION EVALUATION
When evaluating an arithmetic expression, FF mpeg uses an internal
formula evaluator, implemented through the l ibavutil/eval.h interface.
An expression may contain unary, binary oper ators, constants, and
functions.
Two expressions expr1 and expr2 can be combi ned to form another
expression "expr1;expr2". expr1 and expr2 a re evaluated in turn, and
the new expression evaluates to the value of expr2.
The following binary operators are available : "+", "-", "*", "/", "^".
-27-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
The following unary operators are available: "+", "-".
The following functions are available:
sinh(x)
cosh(x)
tanh(x)
sin(x)
cos(x)
tan(x)
atan(x)
asin(x)
acos(x)
exp(x)
log(x)
abs(x)
squish(x)
gauss(x)
isnan(x)
Return 1.0 if x is NAN, 0.0 otherwise.
mod(x, y)
max(x, y)
min(x, y)
eq(x, y)
gte(x, y)
gt(x, y)
lte(x, y)
lt(x, y)
st(var, expr)
Allow to store the value of the expression expr in an internal
variable. var specifies the number of the variab le where to store
the value, and it is a value ranging from 0 to 9 . The function
returns the value stored in the internal variabl e. Note, Variables
are currently not shared between expressions.
ld(var)
Allow to load the value of the internal variable with number var,
which was previously stored with st(var, expr). The function
returns the loaded value.
while(cond, expr)
Evaluate expression expr while the expression co nd is non-zero, and
returns the value of the last expr evaluation, o r NAN if cond was
always false.
ceil(expr)
Round the value of expression expr upwards to th e nearest integer.
For example, "ceil(1.5)" is "2.0".
floor(expr)
Round the value of expression expr downwards to the nearest
-28-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
integer. For example, "floor(-1.5)" is "-2.0".
trunc(expr)
Round the value of expression expr towards zero to the nearest
integer. For example, "trunc(-1.5)" is "-1.0".
sqrt(expr)
Compute the square root of expr. This is equival ent to "(expr)^.5".
not(expr)
Return 1.0 if expr is zero, 0.0 otherwise.
pow(x, y)
Compute the power of x elevated y, it is equival ent to "(x)^(y)".
random(x)
Return a pseudo random value between 0.0 and 1.0 . x is the index of
the internal variable which will be used to save the seed/state.
hypot(x, y)
This function is similar to the C function with the same name; it
returns "sqrt(x*x + y*y)", the length of the hyp otenuse of a right
triangle with sides of length x and y, or the di stance of the point
(x, y) from the origin.
gcd(x, y)
Return the greatest common divisor of x and y. I f both x and y are
0 or either or both are less than zero then beha vior is undefined.
if(x, y)
Evaluate x, and if the result is non-zero return the result of the
evaluation of y, return 0 otherwise.
ifnot(x, y)
Evaluate x, and if the result is zero return the result of the
evaluation of y, return 0 otherwise.
The following constants are available:
PI area of the unit disc, approximately 3.1 4
E exp(1) (Eulers number), approximately 2 .718
PHI golden ratio (1+sqrt(5))/2, approximatel y 1.618
Assuming that an expression is considered "t rue" if it has a non-zero
value, note that:
"*" works like AND
"+" works like OR
and the construct:
-29-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
if A then B else C
is equivalent to
if(A,B) + ifnot(A,C)
In your C code, you can extend the list of u nary and binary functions,
and define recognized constants, so that the y are available for your
expressions.
The evaluator also recognizes the Internatio nal System number
postfixes. If i is appended after the post fix, powers of 2 are used
instead of powers of 10. The B postfix mul tiplies the value for 8,
and can be appended after another postfix or used alone. This allows
using for example KB, MiB, G and B a s postfix.
Follows the list of available International System postfixes, with
indication of the corresponding powers of 10 and of 2.
y -24 / -80
z -21 / -70
a -18 / -60
f -15 / -50
p -12 / -40
n -9 / -30
u -6 / -20
m -3 / -10
c -2
d -1
h 2
k 3 / 10
K 3 / 10
M 6 / 20
G 9 / 30
T 12 / 40
P 15 / 40
-30-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
E 18 / 50
Z 21 / 60
Y 24 / 70
DECODERS
Decoders are configured elements in FFmpeg w hich allow the decoding of
multimedia streams.
When you configure your FFmpeg build, all th e supported native decoders
are enabled by default. Decoders requiring a n external library must be
enabled manually via the corresponding "--en able-lib" option. You can
list all available decoders using the config ure option
"--list-decoders".
You can disable all the decoders with the co nfigure option
"--disable-decoders" and selectively enable / disable single decoders
with the options "--enable-decoder=DECODER" /
"--disable-decoder=DECODER".
The option "-codecs" of the ff* tools will d isplay the list of enabled
decoders.
VIDEO DECODERS
A description of some of the currently avail able video decoders
follows.
rawvideo
Raw video decoder.
This decoder decodes rawvideo streams.
Options
top top_field_first
Specify the assumed field type of the input vide o.
-1 the video is assumed to be progressive (defa ult)
0 bottom-field-first is assumed
1 top-field-first is assumed
AUDIO DECODERS
ffwavesynth
Internal wave synthetizer.
This decoder generates wave patterns accordi ng to predefined sequences.
Its use is purely internal and the format of the data it accepts is not
publicly documented.
-31-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
ENCODERS
Encoders are configured elements in FFmpeg w hich allow the encoding of
multimedia streams.
When you configure your FFmpeg build, all th e supported native encoders
are enabled by default. Encoders requiring a n external library must be
enabled manually via the corresponding "--en able-lib" option. You can
list all available encoders using the config ure option
"--list-encoders".
You can disable all the encoders with the co nfigure option
"--disable-encoders" and selectively enable / disable single encoders
with the options "--enable-encoder=ENCODER" /
"--disable-encoder=ENCODER".
The option "-codecs" of the ff* tools will d isplay the list of enabled
encoders.
AUDIO ENCODERS
A description of some of the currently avail able audio encoders
follows.
ac3 and ac3_fixed
AC-3 audio encoders.
These encoders implement part of ATSC A/52:2 010 and ETSI TS 102 366, as
well as the undocumented RealAudio 3 (a.k.a. dnet).
The ac3 encoder uses floating-point math, wh ile the ac3_fixed encoder
only uses fixed-point integer math. This doe s not mean that one is
always faster, just that one or the other ma y be better suited to a
particular system. The floating-point encode r will generally produce
better quality audio for a given bitrate. Th e ac3_fixed encoder is not
the default codec for any of the output form ats, so it must be
specified explicitly using the option "-acod ec ac3_fixed" in order to
use it.
AC-3 Metadata
The AC-3 metadata options are used to set pa rameters that describe the
audio, but in most cases do not affect the a udio encoding itself. Some
of the options do directly affect or influen ce the decoding and
playback of the resulting bitstream, while o thers are just for
informational purposes. A few of the options will add bits to the
output stream that could otherwise be used f or audio data, and will
thus affect the quality of the output. Those will be indicated
accordingly with a note in the option list b elow.
These parameters are described in detail in several publicly-available
documents.
*
-32-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
*
*
*
Metadata Control Options
-per_frame_metadata boolean
Allow Per-Frame Metadata. Specifies if the encod er should check for
changing metadata for each frame.
0 The metadata values set at initialization wi ll be used for
every frame in the stream. (default)
1 Metadata values can be changed before encodi ng each frame.
Downmix Levels
-center_mixlev level
Center Mix Level. The amount of gain the decoder should apply to
the center channel when downmixing to stereo. Th is field will only
be written to the bitstream if a center channel is present. The
value is specified as a scale factor. There are 3 valid values:
0.707
Apply -3dB gain
0.595
Apply -4.5dB gain (default)
0.500
Apply -6dB gain
-surround_mixlev level
Surround Mix Level. The amount of gain the decod er should apply to
the surround channel(s) when downmixing to stere o. This field will
only be written to the bitstream if one or more surround channels
are present. The value is specified as a scale f actor. There are 3
valid values:
0.707
Apply -3dB gain
0.500
Apply -6dB gain (default)
0.000
-33-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Silence Surround Channel(s)
Audio Production Information
Audio Production Information is optional inf ormation describing the
mixing environment. Either none or both of the fields are written to
the bitstream.
-mixing_level number
Mixing Level. Specifies peak sound pressure leve l (SPL) in the
production environment when the mix was mastered . Valid values are
80 to 111, or -1 for unknown or not indicated. T he default value is
-1, but that value cannot be used if the Audio P roduction
Information is written to the bitstream. Therefo re, if the
"room_type" option is not the default value, the "mixing_level"
option must not be -1.
-room_type type
Room Type. Describes the equalization used durin g the final mixing
session at the studio or on the dubbing stage. A large room is a
dubbing stage with the industry standard X-curve equalization; a
small room has flat equalization. This field wi ll not be written
to the bitstream if both the "mixing_level" opti on and the
"room_type" option have the default values.
0
notindicated
Not Indicated (default)
1
large
Large Room
2
small
Small Room
Other Metadata Options
-copyright boolean
Copyright Indicator. Specifies whether a copyrig ht exists for this
audio.
0
off No Copyright Exists (default)
1
on Copyright Exists
-dialnorm value
Dialogue Normalization. Indicates how far the av erage dialogue
level of the program is below digital 100% full scale (0 dBFS).
This parameter determines a level shift during a udio reproduction
-34-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
that sets the average volume of the dialogue to a preset level. The
goal is to match volume level between program so urces. A value of
-31dB will result in no volume level change, rel ative to the source
volume, during audio reproduction. Valid values are whole numbers
in the range -31 to -1, with -31 being the defau lt.
-dsur_mode mode
Dolby Surround Mode. Specifies whether the stere o signal uses Dolby
Surround (Pro Logic). This field will only be wr itten to the
bitstream if the audio stream is stereo. Using t his option does NOT
mean the encoder will actually apply Dolby Surro und processing.
0
notindicated
Not Indicated (default)
1
off Not Dolby Surround Encoded
2
on Dolby Surround Encoded
-original boolean
Original Bit Stream Indicator. Specifies whether this audio is from
the original source and not a copy.
0
off Not Original Source
1
on Original Source (default)
Extended Bitstream Information
The extended bitstream options are part of t he Alternate Bit Stream
Syntax as specified in Annex D of the A/52:2 010 standard. It is grouped
into 2 parts. If any one parameter in a gro up is specified, all values
in that group will be written to the bitstre am. Default values are
used for those that are written but have not been specified. If the
mixing levels are written, the decoder will use these values instead of
the ones specified in the "center_mixlev" an d "surround_mixlev" options
if it supports the Alternate Bit Stream Synt ax.
Extended Bitstream Information - Part 1
-dmix_mode mode
Preferred Stereo Downmix Mode. Allows the user t o select either
Lt/Rt (Dolby Surround) or Lo/Ro (normal stereo) as the preferred
stereo downmix mode.
0
notindicated
Not Indicated (default)
-35-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
1
ltrt
Lt/Rt Downmix Preferred
2
loro
Lo/Ro Downmix Preferred
-ltrt_cmixlev level
Lt/Rt Center Mix Level. The amount of gain the d ecoder should apply
to the center channel when downmixing to stereo in Lt/Rt mode.
1.414
Apply +3dB gain
1.189
Apply +1.5dB gain
1.000
Apply 0dB gain
0.841
Apply -1.5dB gain
0.707
Apply -3.0dB gain
0.595
Apply -4.5dB gain (default)
0.500
Apply -6.0dB gain
0.000
Silence Center Channel
-ltrt_surmixlev level
Lt/Rt Surround Mix Level. The amount of gain the decoder should
apply to the surround channel(s) when downmixing to stereo in Lt/Rt
mode.
0.841
Apply -1.5dB gain
0.707
Apply -3.0dB gain
0.595
Apply -4.5dB gain
0.500
Apply -6.0dB gain (default)
-36-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
0.000
Silence Surround Channel(s)
-loro_cmixlev level
Lo/Ro Center Mix Level. The amount of gain the d ecoder should apply
to the center channel when downmixing to stereo in Lo/Ro mode.
1.414
Apply +3dB gain
1.189
Apply +1.5dB gain
1.000
Apply 0dB gain
0.841
Apply -1.5dB gain
0.707
Apply -3.0dB gain
0.595
Apply -4.5dB gain (default)
0.500
Apply -6.0dB gain
0.000
Silence Center Channel
-loro_surmixlev level
Lo/Ro Surround Mix Level. The amount of gain the decoder should
apply to the surround channel(s) when downmixing to stereo in Lo/Ro
mode.
0.841
Apply -1.5dB gain
0.707
Apply -3.0dB gain
0.595
Apply -4.5dB gain
0.500
Apply -6.0dB gain (default)
0.000
Silence Surround Channel(s)
Extended Bitstream Information - Part 2
-37-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-dsurex_mode mode
Dolby Surround EX Mode. Indicates whether the st ream uses Dolby
Surround EX (7.1 matrixed to 5.1). Using this op tion does NOT mean
the encoder will actually apply Dolby Surround E X processing.
0
notindicated
Not Indicated (default)
1
on Dolby Surround EX Off
2
off Dolby Surround EX On
-dheadphone_mode mode
Dolby Headphone Mode. Indicates whether the stre am uses Dolby
Headphone encoding (multi-channel matrixed to 2. 0 for use with
headphones). Using this option does NOT mean the encoder will
actually apply Dolby Headphone processing.
0
notindicated
Not Indicated (default)
1
on Dolby Headphone Off
2
off Dolby Headphone On
-ad_conv_type type
A/D Converter Type. Indicates whether the audio has passed through
HDCD A/D conversion.
0
standard
Standard A/D Converter (default)
1
hdcd
HDCD A/D Converter
Other AC-3 Encoding Options
-stereo_rematrixing boolean
Stereo Rematrixing. Enables/Disables use of rema trixing for stereo
input. This is an optional AC-3 feature that inc reases quality by
selectively encoding the left/right channels as mid/side. This
option is enabled by default, and it is highly r ecommended that it
be left as enabled except for testing purposes.
-38-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
Floating-Point-Only AC-3 Encoding Options
These options are only valid for the floatin g-point encoder and do not
exist for the fixed-point encoder due to the corresponding features not
being implemented in fixed-point.
-channel_coupling boolean
Enables/Disables use of channel coupling, which is an optional AC-3
feature that increases quality by combining high frequency
information from multiple channels into a single channel. The per-
channel high frequency information is sent with less accuracy in
both the frequency and time domains. This allows more bits to be
used for lower frequencies while preserving enou gh information to
reconstruct the high frequencies. This option is enabled by default
for the floating-point encoder and should genera lly be left as
enabled except for testing purposes or to increa se encoding speed.
-1
auto
Selected by Encoder (default)
0
off Disable Channel Coupling
1
on Enable Channel Coupling
-cpl_start_band number
Coupling Start Band. Sets the channel coupling s tart band, from 1
to 15. If a value higher than the bandwidth is u sed, it will be
reduced to 1 less than the coupling end band. If auto is used, the
start band will be determined by the encoder bas ed on the bit rate,
sample rate, and channel layout. This option has no effect if
channel coupling is disabled.
-1
auto
Selected by Encoder (default)
VIDEO ENCODERS
A description of some of the currently avail able video encoders
follows.
libvpx
VP8 format supported through libvpx.
Requires the presence of the libvpx headers and library during
configuration. You need to explicitly confi gure the build with
"--enable-libvpx".
Options
Mapping from FFmpeg to libvpx options with c onversion notes in
-39-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
parentheses.
threads
g_threads
profile
g_profile
vb rc_target_bitrate
g kf_max_dist
keyint_min
kf_min_dist
qmin
rc_min_quantizer
qmax
rc_max_quantizer
bufsize, vb
rc_buf_sz "(bufsize * 1000 / vb)"
rc_buf_optimal_sz "(bufsize * 1000 / vb * 5 / 6) "
rc_init_occupancy, vb
rc_buf_initial_sz "(rc_init_occupancy * 1000 / v b)"
rc_buffer_aggressivity
rc_undershoot_pct
skip_threshold
rc_dropframe_thresh
qcomp
rc_2pass_vbr_bias_pct
maxrate, vb
rc_2pass_vbr_maxsection_pct "(maxrate * 100 / vb )"
minrate, vb
rc_2pass_vbr_minsection_pct "(minrate * 100 / vb )"
minrate, maxrate, vb
"VPX_CBR" "(minrate == maxrate == vb)"
crf "VPX_CQ", "VP8E_SET_CQ_LEVEL"
quality
best
"VPX_DL_BEST_QUALITY"
-40-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
good
"VPX_DL_GOOD_QUALITY"
realtime
"VPX_DL_REALTIME"
speed
"VP8E_SET_CPUUSED"
nr "VP8E_SET_NOISE_SENSITIVITY"
mb_threshold
"VP8E_SET_STATIC_THRESHOLD"
slices
"VP8E_SET_TOKEN_PARTITIONS"
Alternate reference frame related
vp8flags altref
"VP8E_SET_ENABLEAUTOALTREF"
arnr_max_frames
"VP8E_SET_ARNR_MAXFRAMES"
arnr_type
"VP8E_SET_ARNR_TYPE"
arnr_strength
"VP8E_SET_ARNR_STRENGTH"
rc_lookahead
g_lag_in_frames
vp8flags error_resilient
g_error_resilient
For more information about libvpx see:
libx264
H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 fo rmat supported through
libx264.
Requires the presence of the libx264 headers and library during
configuration. You need to explicitly config ure the build with
"--enable-libx264".
Options
preset preset_name
Set the encoding preset.
tune tune_name
Tune the encoding params.
-41-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
fastfirstpass bool
Use fast settings when encoding first pass, defa ult value is 1.
profile profile_name
Set profile restrictions.
level level
Specify level (as defined by Annex A). Deprecat ed in favor of
x264opts.
passlogfile filename
Specify filename for 2 pass stats. Deprecated i n favor of x264opts
(see stats libx264 option).
wpredp wpred_type
Specify Weighted prediction for P-frames. Depre cated in favor of
x264opts (see weightp libx264 option).
x264opts options
Allow to set any x264 option, see x264 --fullhel p for a list.
options is a list of key=value couples separated by ":".
For example to specify libx264 encoding opti ons with ffmpeg:
ffmpeg -i foo.mpg -vcodec libx264 -x264opts keyint=123:min-keyint=20 -an out.mkv
For more information about libx264 and the s upported options see:
DEMUXERS
Demuxers are configured elements in FFmpeg w hich allow to read the
multimedia streams from a particular type of file.
When you configure your FFmpeg build, all th e supported demuxers are
enabled by default. You can list all availab le ones using the configure
option "--list-demuxers".
You can disable all the demuxers using the c onfigure option
"--disable-demuxers", and selectively enable a single demuxer with the
option "--enable-demuxer=DEMUXER", or disabl e it with the option
"--disable-demuxer=DEMUXER".
The option "-formats" of the ff* tools will display the list of enabled
demuxers.
The description of some of the currently ava ilable demuxers follows.
image2
Image file demuxer.
This demuxer reads from a list of image file s specified by a pattern.
-42-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
The pattern may contain the string "%d" or " %0Nd", which specifies the
position of the characters representing a se quential number in each
filename matched by the pattern. If the form "%d0Nd" is used, the
string representing the number in each filen ame is 0-padded and N is
the total number of 0-padded digits represen ting the number. The
literal character % can be specified in th e pattern with the string
"%%".
If the pattern contains "%d" or "%0Nd", the first filename of the file
list specified by the pattern must contain a number inclusively
contained between 0 and 4, all the following numbers must be
sequential. This limitation may be hopefully fixed.
The pattern may contain a suffix which is us ed to automatically
determine the format of the images contained in the files.
For example the pattern "img-%03d.bmp" will match a sequence of
filenames of the form img-001.bmp, img-002.b mp, ..., img-010.bmp, etc.;
the pattern "i%%m%%g-%d.jpg" will match a se quence of filenames of the
form i%m%g-1.jpg, i%m%g-2.jpg, ..., i%m%g-10 .jpg, etc.
The size, the pixel format, and the format o f each image must be the
same for all the files in the sequence.
The following example shows how to use ffmpe g for creating a video from
the images in the file sequence img-001.jpeg , img-002.jpeg, ...,
assuming an input frame rate of 10 frames pe r second:
ffmpeg -i 'img-%03d.jpeg' -r 10 out.mkv
Note that the pattern must not necessarily c ontain "%d" or "%0Nd", for
example to convert a single image file img.j peg you can employ the
command:
ffmpeg -i img.jpeg img.png
applehttp
Apple HTTP Live Streaming demuxer.
This demuxer presents all AVStreams from all variant streams. The id
field is set to the bitrate variant index nu mber. By setting the
discard flags on AVStreams (by pressing a or v in ffplay), the
caller can decide which variant streams to a ctually receive. The total
bitrate of the variant that the stream belon gs to is available in a
metadata key named "variant_bitrate".
sbg
SBaGen script demuxer.
This demuxer reads the script language used by SBaGen
to generate binaur al beats sessions. A SBG
script looks like that:
-43-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
-SE
a: 300-2.5/3 440+4.5/0
b: 300-2.5/0 440+4.5/3
off: -
NOW == a
+0:07:00 == b
+0:14:00 == a
+0:21:00 == b
+0:30:00 off
A SBG script can mix absolute and relative t imestamps. If the script
uses either only absolute timestamps (includ ing the script start time)
or only relative ones, then its layout is fi xed, and the conversion is
straightforward. On the other hand, if the s cript mixes both kind of
timestamps, then the NOW reference for relat ive timestamps will be
taken from the current time of day at the ti me the script is read, and
the script layout will be frozen according t o that reference. That
means that if the script is directly played, the actual times will
match the absolute timestamps up to the soun d controllers clock
accuracy, but if the user somehow pauses the playback or seeks, all
times will be shifted accordingly.
MUXERS
Muxers are configured elements in FFmpeg whi ch allow writing multimedia
streams to a particular type of file.
When you configure your FFmpeg build, all th e supported muxers are
enabled by default. You can list all availab le muxers using the
configure option "--list-muxers".
You can disable all the muxers with the conf igure option
"--disable-muxers" and selectively enable / disable single muxers with
the options "--enable-muxer=MUXER" / "--disa ble-muxer=MUXER".
The option "-formats" of the ff* tools will display the list of enabled
muxers.
A description of some of the currently avail able muxers follows.
crc
CRC (Cyclic Redundancy Check) testing format .
This muxer computes and prints the Adler-32 CRC of all the input audio
and video frames. By default audio frames ar e converted to signed
16-bit raw audio and video frames to raw vid eo before computing the
CRC.
The output of the muxer consists of a single line of the form:
CRC=0xCRC, where CRC is a hexadecimal number 0-padded to 8 digits
containing the CRC for all the decoded input frames.
For example to compute the CRC of the input, and store it in the file
-44-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
out.crc:
ffmpeg -i INPUT -f crc out.crc
You can print the CRC to stdout with the com mand:
ffmpeg -i INPUT -f crc -
You can select the output format of each fra me with ffmpeg by
specifying the audio and video codec and for mat. For example to compute
the CRC of the input audio converted to PCM unsigned 8-bit and the
input video converted to MPEG-2 video, use t he command:
ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
See also the framecrc muxer.
framecrc
Per-frame CRC (Cyclic Redundancy Check) test ing format.
This muxer computes and prints the Adler-32 CRC for each decoded audio
and video frame. By default audio frames are converted to signed 16-bit
raw audio and video frames to raw video befo re computing the CRC.
The output of the muxer consists of a line f or each audio and video
frame of the form: stream_index, frame_dts, frame_size, 0xCRC, where
CRC is a hexadecimal number 0-padded to 8 di gits containing the CRC of
the decoded frame.
For example to compute the CRC of each decod ed frame in the input, and
store it in the file out.crc:
ffmpeg -i INPUT -f framecrc out.crc
You can print the CRC of each decoded frame to stdout with the command:
ffmpeg -i INPUT -f framecrc -
You can select the output format of each fra me with ffmpeg by
specifying the audio and video codec and for mat. For example, to
compute the CRC of each decoded input audio frame converted to PCM
unsigned 8-bit and of each decoded input vid eo frame converted to
MPEG-2 video, use the command:
ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
See also the crc muxer.
image2
Image file muxer.
The image file muxer writes video frames to image files.
-45-
-
X:\Z_ELEMENTAL_TESTING\ffmpeg_man.txt Wednesday, October 29, 2014 2:11 PM
The output filenames are specified by a patt ern, which can be used to
produce sequentially numbered series of file s. The pattern may contain
the string "%d" or "%0Nd", this string speci fies the position of the
characters representing a numbering in the f ilenames. If the form
"%0Nd" is used, the string representing the number in each filename is
0-padded to N digits. The literal character % can be specified in the
pattern with the string "%%".
If the pattern contains "%d" or "%0Nd", the first filename of the file
list specified will cont