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