ffmpeg-doc.texi 26.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
\input texinfo @c -*- texinfo -*-

@settitle FFmpeg Documentation
@titlepage
@sp 7
@center @titlefont{FFmpeg Documentation}
@sp 3
@end titlepage


@chapter Introduction

FFmpeg is a very fast video and audio converter. It can also grab from
a live audio/video source.
15

16
The command line interface is designed to be intuitive, in the sense
diego's avatar
diego committed
17 18 19
that FFmpeg tries to figure out all parameters that can possibly be
derived automatically. You usually only have to specify the target
bitrate you want.
20 21 22 23 24 25

FFmpeg can also convert from any sample rate to any other, and resize
video on the fly with a high quality polyphase filter.

@chapter Quick Start

26
@c man begin EXAMPLES
27 28
@section Video and Audio grabbing

29 30
FFmpeg can grab video and audio from devices given that you specify the input
format and device.
31

32
@example
33
ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
34 35
@end example

36
Note that you must activate the right video source and channel before
diego's avatar
diego committed
37
launching FFmpeg with any TV viewer such as xawtv
38
(@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also
diego's avatar
diego committed
39
have to set the audio recording levels correctly with a
40
standard mixer.
41

bcoudurier's avatar
bcoudurier committed
42 43
@section X11 grabbing

diego's avatar
diego committed
44
FFmpeg can grab the X11 display.
bcoudurier's avatar
bcoudurier committed
45 46

@example
benoit's avatar
 
benoit committed
47
ffmpeg -f x11grab -s cif -i :0.0 /tmp/out.mpg
bcoudurier's avatar
bcoudurier committed
48 49
@end example

diego's avatar
diego committed
50 51
0.0 is display.screen number of your X11 server, same as
the DISPLAY environment variable.
bcoudurier's avatar
bcoudurier committed
52

53
@example
benoit's avatar
 
benoit committed
54
ffmpeg -f x11grab -s cif -i :0.0+10,20 /tmp/out.mpg
55 56 57 58 59
@end example

0.0 is display.screen number of your X11 server, same as the DISPLAY environment
variable. 10 is the x-offset and 20 the y-offset for the grabbing.

60
@section Video and Audio file format conversion
61

diego's avatar
diego committed
62
* FFmpeg can use any supported file format and protocol as input:
63 64 65

Examples:

diego's avatar
diego committed
66
* You can use YUV files as input:
67 68

@example
69
ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
70 71
@end example

72
It will use the files:
73
@example
74 75
/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
76 77
@end example

78 79 80
The Y files use twice the resolution of the U and V files. They are
raw files, without header. They can be generated by all decent video
decoders. You must specify the size of the image with the @option{-s} option
diego's avatar
diego committed
81
if FFmpeg cannot guess it.
82

diego's avatar
diego committed
83
* You can input from a raw YUV420P file:
84 85

@example
86
ffmpeg -i /tmp/test.yuv /tmp/out.avi
87 88
@end example

diego's avatar
diego committed
89 90
test.yuv is a file containing raw YUV planar data. Each frame is composed
of the Y plane followed by the U and V planes at half vertical and
91
horizontal resolution.
92

diego's avatar
diego committed
93
* You can output to a raw YUV420P file:
94 95

@example
96
ffmpeg -i mydivx.avi hugefile.yuv
97 98 99 100 101
@end example

* You can set several input files and output files:

@example
102
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
103 104
@end example

diego's avatar
diego committed
105 106
Converts the audio file a.wav and the raw YUV video file a.yuv
to MPEG file a.mpg.
107

108
* You can also do audio and video conversions at the same time:
109 110

@example
111
ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
112 113
@end example

114
Converts a.wav to MPEG audio at 22050 Hz sample rate.
115 116

* You can encode to several formats at the same time and define a
117
mapping from input stream to output streams:
118 119

@example
120
ffmpeg -i /tmp/a.wav -ab 64k /tmp/a.mp2 -ab 128k /tmp/b.mp2 -map 0:0 -map 0:0
121 122
@end example

diego's avatar
diego committed
123 124
Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
file:index' specifies which input stream is used for each output
125
stream, in the order of the definition of output streams.
126

127
* You can transcode decrypted VOBs:
128 129

@example
130
ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k snatch.avi
131 132
@end example

diego's avatar
diego committed
133 134 135 136 137
This is a typical DVD ripping example; the input is a VOB file, the
output an AVI file with MPEG-4 video and MP3 audio. Note that in this
command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
input video. Furthermore, the audio stream is MP3-encoded so you need
138
to enable LAME support by passing @code{--enable-libmp3lame} to configure.
diego's avatar
diego committed
139
The mapping is particularly useful for DVD transcoding
140
to get the desired audio language.
141

diego's avatar
diego committed
142
NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
143

144
* You can extract images from a video, or create a video from many images:
145

146
For extracting images from a video:
147 148 149 150 151 152 153 154
@example
ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
@end example

This will extract one video frame per second from the video and will
output them in files named @file{foo-001.jpeg}, @file{foo-002.jpeg},
etc. Images will be rescaled to fit the new WxH values.

155 156 157 158 159 160 161 162 163
If you want to extract just a limited number of frames, you can use the
above command in combination with the -vframes or -t option, or in
combination with -ss to start extracting from a certain point in time.

For creating a video from many images:
@example
ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
@end example

164 165 166 167 168
The syntax @code{foo-%03d.jpeg} specifies to use a decimal number
composed of three digits padded with zeroes to express the sequence
number. It is the same syntax supported by the C printf function, but
only formats accepting a normal integer are suitable.

169 170 171 172 173 174 175 176 177 178 179 180 181
* You can put many streams of the same type in the output:

@example
ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy -vcodec copy -acodec copy test12.avi -newvideo -newaudio
@end example

In addition to the first video and audio streams, the resulting
output file @file{test12.avi} will contain the second video
and the second audio stream found in the input streams list.

The @code{-newvideo}, @code{-newaudio} and @code{-newsubtitle}
options have to be specified immediately after the name of the output
file to which you want to add them.
182
@c man end
183 184 185 186 187

@chapter Invocation

@section Syntax

188
The generic syntax is:
189

190
@example
191
@c man begin SYNOPSIS
michael's avatar
michael committed
192
ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
193
@c man end
194
@end example
195 196
@c man begin DESCRIPTION
As a general rule, options are applied to the next specified
197
file. Therefore, order is important, and you can have the same
diego's avatar
typo  
diego committed
198
option on the command line multiple times. Each occurrence is
199 200
then applied to the next input or output file.

diego's avatar
diego committed
201
* To set the video bitrate of the output file to 64kbit/s:
202 203 204 205 206 207 208 209 210
@example
ffmpeg -i input.avi -b 64k output.avi
@end example

* To force the frame rate of the output file to 24 fps:
@example
ffmpeg -i input.avi -r 24 output.avi
@end example

211 212
* To force the frame rate of the input file (valid for raw formats only)
to 1 fps and the frame rate of the output file to 24 fps:
213
@example
214
ffmpeg -r 1 -i input.m2v -r 24 output.avi
215 216 217
@end example

The format option may be needed for raw input files.
218

diego's avatar
diego committed
219 220
By default, FFmpeg tries to convert as losslessly as possible: It
uses the same audio and video parameters for the outputs as the one
221 222
specified for the inputs.
@c man end
223

224
@c man begin OPTIONS
225 226
@section Main options

227
@table @option
228
@item -L
diego's avatar
diego committed
229
Show license.
bellard's avatar
bellard committed
230

231
@item -h
diego's avatar
diego committed
232
Show help.
bellard's avatar
bellard committed
233

234 235 236
@item -version
Show version.

237
@item -formats
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254
Show available formats, codecs, bitstream filters, protocols, and frame size and frame rate abbreviations.

The fields preceding the format and codec names have the following meanings:
@table @samp
@item D
Decoding available
@item E
Encoding available
@item V/A/S
Video/audio/subtitle codec
@item S
Codec supports slices
@item D
Codec supports direct rendering
@item T
Codec can handle input truncated at random locations instead of only at frame boundaries
@end table
bellard's avatar
bellard committed
255

256
@item -f @var{fmt}
diego's avatar
diego committed
257
Force format.
bellard's avatar
bellard committed
258

259
@item -i @var{filename}
260
input file name
261

262
@item -y
diego's avatar
diego committed
263
Overwrite output files.
264

265
@item -t @var{duration}
benoit's avatar
benoit committed
266 267
Restrict the transcoded/captured video sequence
to the duration specified in seconds.
diego's avatar
diego committed
268
@code{hh:mm:ss[.xxx]} syntax is also supported.
269

270
@item -fs @var{limit_size}
271 272
Set the file size limit.

273
@item -ss @var{position}
diego's avatar
diego committed
274 275
Seek to given time position in seconds.
@code{hh:mm:ss[.xxx]} syntax is also supported.
276

277
@item -itsoffset @var{offset}
278 279 280 281 282 283 284
Set the input time offset in seconds.
@code{[-]hh:mm:ss[.xxx]} syntax is also supported.
This option affects all the input files that follow it.
The offset is added to the timestamps of the input files.
Specifying a positive offset means that the corresponding
streams are delayed by 'offset' seconds.

285
@item -timestamp @var{time}
286 287
Set the timestamp.

288
@item -metadata @var{key}=@var{value}
stefano's avatar
stefano committed
289
Set a metadata key/value pair.
290

291
For example, for setting the title in the output file:
292
@example
293
ffmpeg -i in.avi -metadata title="my title" out.flv
294
@end example
295

296
@item -v @var{number}
297
Set the logging verbosity level.
298

299 300 301 302 303 304 305 306 307 308 309 310 311 312
@item -loglevel @var{loglevel}
Set the logging level used by the library.
@var{loglevel} is a number or a string containing one of the following values:
@table @samp
@item quiet
@item panic
@item fatal
@item error
@item warning
@item info
@item verbose
@item debug
@end table

313
@item -target @var{type}
314
Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd",
diego's avatar
diego committed
315 316
"ntsc-svcd", ... ). All the format options (bitrate, codecs,
buffer sizes) are then set automatically. You can just type:
bellard's avatar
bellard committed
317 318 319 320 321

@example
ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
@end example

diego's avatar
diego committed
322 323
Nevertheless you can specify additional options as long as you know
they do not conflict with the standard, as in:
324 325 326 327 328

@example
ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
@end example

329
@item -dframes @var{number}
330 331
Set the number of data frames to record.

332
@item -scodec @var{codec}
333 334 335 336 337
Force subtitle codec ('copy' to copy stream).

@item -newsubtitle
Add a new subtitle stream to the current output stream.

338
@item -slang @var{code}
339
Set the ISO 639 language code (3 letters) of the current subtitle stream.
340

341 342 343 344
@end table

@section Video Options

345
@table @option
346
@item -b @var{bitrate}
347
Set the video bitrate in bit/s (default = 200 kb/s).
348
@item -vframes @var{number}
349
Set the number of video frames to record.
350
@item -r @var{fps}
351
Set frame rate (Hz value, fraction or abbreviation), (default = 25).
352
@item -s @var{size}
353
Set frame size. The format is @samp{wxh} (ffserver default = 160x128, ffmpeg default = same as source).
diego's avatar
diego committed
354
The following abbreviations are recognized:
bellard's avatar
bellard committed
355
@table @samp
bellard's avatar
bellard committed
356 357 358 359 360 361 362 363
@item sqcif
128x96
@item qcif
176x144
@item cif
352x288
@item 4cif
704x576
364 365
@item 16cif
1408x1152
benoit's avatar
 
benoit committed
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
@item qqvga
160x120
@item qvga
320x240
@item vga
640x480
@item svga
800x600
@item xga
1024x768
@item uxga
1600x1200
@item qxga
2048x1536
@item sxga
1280x1024
@item qsxga
2560x2048
@item hsxga
5120x4096
@item wvga
852x480
@item wxga
1366x768
@item wsxga
1600x1024
@item wuxga
1920x1200
@item woxga
2560x1600
@item wqsxga
3200x2048
@item wquxga
3840x2400
@item whsxga
6400x4096
@item whuxga
7680x4800
@item cga
320x200
@item ega
640x350
@item hd480
852x480
@item hd720
1280x720
@item hd1080
1920x1080
bellard's avatar
bellard committed
414 415
@end table

416
@item -aspect @var{aspect}
diego's avatar
diego committed
417
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
418
@item -croptop @var{size}
diego's avatar
diego committed
419
Set top crop band size (in pixels).
420
@item -cropbottom @var{size}
diego's avatar
diego committed
421
Set bottom crop band size (in pixels).
422
@item -cropleft @var{size}
diego's avatar
diego committed
423
Set left crop band size (in pixels).
424
@item -cropright @var{size}
diego's avatar
diego committed
425
Set right crop band size (in pixels).
426
@item -padtop @var{size}
diego's avatar
diego committed
427
Set top pad band size (in pixels).
428
@item -padbottom @var{size}
diego's avatar
diego committed
429
Set bottom pad band size (in pixels).
430
@item -padleft @var{size}
diego's avatar
diego committed
431
Set left pad band size (in pixels).
432
@item -padright @var{size}
diego's avatar
diego committed
433
Set right pad band size (in pixels).
434
@item -padcolor @var{hex_color}
diego's avatar
diego committed
435 436 437 438
Set color of padded bands. The value for padcolor is expressed
as a six digit hexadecimal number where the first two digits
represent red, the middle two digits green and last two digits
blue (default = 000000 (black)).
439
@item -vn
diego's avatar
diego committed
440
Disable video recording.
441
@item -bt @var{tolerance}
442 443 444 445 446 447
Set video bitrate tolerance (in bits, default 4000k).
Has a minimum value of: (target_bitrate/target_framerate).
In 1-pass mode, bitrate tolerance specifies how far ratecontrol is
willing to deviate from the target average bitrate value. This is
not related to min/max bitrate. Lowering tolerance too much has
an adverse effect on quality.
448
@item -maxrate @var{bitrate}
449
Set max video bitrate (in bit/s).
450
Requires -bufsize to be set.
451
@item -minrate @var{bitrate}
452
Set min video bitrate (in bit/s).
453 454 455 456 457
Most useful in setting up a CBR encode:
@example
ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
@end example
It is of little use elsewise.
458
@item -bufsize @var{size}
diego's avatar
diego committed
459
Set video buffer verifier buffer size (in bits).
460
@item -vcodec @var{codec}
diego's avatar
diego committed
461
Force video codec to @var{codec}. Use the @code{copy} special value to
bellard's avatar
bellard committed
462
tell that the raw codec data must be copied as is.
bellard's avatar
bellard committed
463
@item -sameq
diego's avatar
diego committed
464
Use same video quality as source (implies VBR).
465

466
@item -pass @var{n}
467 468 469 470 471
Select the pass number (1 or 2). It is used to do two-pass
video encoding. The statistics of the video are recorded in the first
pass into a log file (see also the option -passlogfile),
and in the second pass that log file is used to generate the video
at the exact requested bitrate.
472 473 474 475 476 477
On pass 1, you may just deactivate audio and set output to null,
examples for Windows and Unix:
@example
ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y NUL
ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y /dev/null
@end example
478

479 480 481 482
@item -passlogfile @var{prefix}
Set two-pass log file name prefix to @var{prefix}, the default file name
prefix is ``ffmpeg2pass''. The complete file name will be
@file{PREFIX-N.log}, where N is a number specific to the output
483
stream.
484

485 486 487
@item -newvideo
Add a new video stream to the current output stream.

488 489
@end table

bellard's avatar
bellard committed
490
@section Advanced Video Options
491

492
@table @option
493
@item -pix_fmt @var{format}
benoit's avatar
 
benoit committed
494 495
Set pixel format. Use 'list' as parameter to show all the supported
pixel formats.
496
@item -sws_flags @var{flags}
497
Set SwScaler flags (only available when compiled with swscale support).
498
@item -g @var{gop_size}
diego's avatar
diego committed
499
Set the group of pictures size.
500
@item -intra
diego's avatar
diego committed
501
Use only intra frames.
502
@item -vdt @var{n}
503
Discard threshold.
504
@item -qscale @var{q}
diego's avatar
diego committed
505
Use fixed video quantizer scale (VBR).
506
@item -qmin @var{q}
diego's avatar
diego committed
507
minimum video quantizer scale (VBR)
508
@item -qmax @var{q}
diego's avatar
diego committed
509
maximum video quantizer scale (VBR)
510
@item -qdiff @var{q}
diego's avatar
diego committed
511
maximum difference between the quantizer scales (VBR)
512
@item -qblur @var{blur}
513
video quantizer scale blur (VBR) (range 0.0 - 1.0)
514
@item -qcomp @var{compression}
515 516
video quantizer scale compression (VBR) (default 0.5).
Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0
bellard's avatar
bellard committed
517

518
@item -lmin @var{lambda}
519
minimum video lagrange factor (VBR)
520
@item -lmax @var{lambda}
521
max video lagrange factor (VBR)
522
@item -mblmin @var{lambda}
523
minimum macroblock quantizer scale (VBR)
524
@item -mblmax @var{lambda}
525 526 527 528 529 530 531 532
maximum macroblock quantizer scale (VBR)

These four options (lmin, lmax, mblmin, mblmax) use 'lambda' units,
but you may use the QP2LAMBDA constant to easily convert from 'q' units:
@example
ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
@end example

533
@item -rc_init_cplx @var{complexity}
diego's avatar
diego committed
534
initial complexity for single pass encoding
535
@item -b_qfactor @var{factor}
diego's avatar
diego committed
536
qp factor between P- and B-frames
537
@item -i_qfactor @var{factor}
diego's avatar
diego committed
538
qp factor between P- and I-frames
539
@item -b_qoffset @var{offset}
diego's avatar
diego committed
540
qp offset between P- and B-frames
541
@item -i_qoffset @var{offset}
diego's avatar
diego committed
542
qp offset between P- and I-frames
543
@item -rc_eq @var{equation}
diego's avatar
diego committed
544 545
Set rate control equation (@pxref{FFmpeg formula
evaluator}) (default = @code{tex^qComp}).
546
@item -rc_override @var{override}
bellard's avatar
bellard committed
547
rate control override for specific intervals
548
@item -me_method @var{method}
diego's avatar
diego committed
549 550
Set motion estimation method to @var{method}.
Available methods are (from lowest to best quality):
bellard's avatar
bellard committed
551 552
@table @samp
@item zero
bellard's avatar
bellard committed
553
Try just the (0, 0) vector.
bellard's avatar
bellard committed
554 555 556
@item phods
@item log
@item x1
557 558
@item hex
@item umh
bellard's avatar
bellard committed
559 560 561 562 563 564
@item epzs
(default method)
@item full
exhaustive search (slow and marginally better than epzs)
@end table

565
@item -dct_algo @var{algo}
diego's avatar
diego committed
566
Set DCT algorithm to @var{algo}. Available values are:
bellard's avatar
bellard committed
567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
@table @samp
@item 0
FF_DCT_AUTO (default)
@item 1
FF_DCT_FASTINT
@item 2
FF_DCT_INT
@item 3
FF_DCT_MMX
@item 4
FF_DCT_MLIB
@item 5
FF_DCT_ALTIVEC
@end table

582
@item -idct_algo @var{algo}
diego's avatar
diego committed
583
Set IDCT algorithm to @var{algo}. Available values are:
bellard's avatar
bellard committed
584 585 586 587
@table @samp
@item 0
FF_IDCT_AUTO (default)
@item 1
588
FF_IDCT_INT
bellard's avatar
bellard committed
589
@item 2
590
FF_IDCT_SIMPLE
bellard's avatar
bellard committed
591
@item 3
592
FF_IDCT_SIMPLEMMX
bellard's avatar
bellard committed
593
@item 4
594
FF_IDCT_LIBMPEG2MMX
bellard's avatar
bellard committed
595
@item 5
596
FF_IDCT_PS2
bellard's avatar
bellard committed
597
@item 6
598
FF_IDCT_MLIB
bellard's avatar
bellard committed
599
@item 7
600
FF_IDCT_ARM
bellard's avatar
bellard committed
601
@item 8
602
FF_IDCT_ALTIVEC
bellard's avatar
bellard committed
603
@item 9
604
FF_IDCT_SH4
bellard's avatar
bellard committed
605
@item 10
606
FF_IDCT_SIMPLEARM
bellard's avatar
bellard committed
607 608
@end table

609
@item -er @var{n}
diego's avatar
diego committed
610
Set error resilience to @var{n}.
bellard's avatar
bellard committed
611
@table @samp
612
@item 1
diego's avatar
diego committed
613
FF_ER_CAREFUL (default)
bellard's avatar
bellard committed
614
@item 2
bellard's avatar
bellard committed
615
FF_ER_COMPLIANT
bellard's avatar
bellard committed
616 617 618 619 620 621
@item 3
FF_ER_AGGRESSIVE
@item 4
FF_ER_VERY_AGGRESSIVE
@end table

622
@item -ec @var{bit_mask}
diego's avatar
diego committed
623
Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
bellard's avatar
bellard committed
624
the following values:
bellard's avatar
bellard committed
625 626
@table @samp
@item 1
diego's avatar
diego committed
627
FF_EC_GUESS_MVS (default = enabled)
bellard's avatar
bellard committed
628
@item 2
diego's avatar
diego committed
629
FF_EC_DEBLOCK (default = enabled)
bellard's avatar
bellard committed
630 631
@end table

632
@item -bf @var{frames}
diego's avatar
diego committed
633
Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
634
@item -mbd @var{mode}
bellard's avatar
bellard committed
635 636 637
macroblock decision
@table @samp
@item 0
diego's avatar
diego committed
638
FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg).
bellard's avatar
bellard committed
639
@item 1
diego's avatar
diego committed
640
FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
bellard's avatar
bellard committed
641
@item 2
diego's avatar
diego committed
642
FF_MB_DECISION_RD: rate distortion
bellard's avatar
bellard committed
643 644 645
@end table

@item -4mv
diego's avatar
diego committed
646
Use four motion vector by macroblock (MPEG-4 only).
bellard's avatar
bellard committed
647
@item -part
diego's avatar
diego committed
648
Use data partitioning (MPEG-4 only).
649
@item -bug @var{param}
diego's avatar
diego committed
650
Work around encoder bugs that are not auto-detected.
651
@item -strict @var{strictness}
diego's avatar
diego committed
652
How strictly to follow the standards.
bellard's avatar
bellard committed
653
@item -aic
diego's avatar
diego committed
654
Enable Advanced intra coding (h263+).
bellard's avatar
bellard committed
655
@item -umv
diego's avatar
diego committed
656
Enable Unlimited Motion Vector (h263+)
bellard's avatar
bellard committed
657 658

@item -deinterlace
diego's avatar
diego committed
659
Deinterlace pictures.
660
@item -ilme
diego's avatar
diego committed
661 662 663 664 665
Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
Use this option if your input file is interlaced and you want
to keep the interlaced format for minimum losses.
The alternative is to deinterlace the input stream with
@option{-deinterlace}, but deinterlacing introduces losses.
bellard's avatar
bellard committed
666
@item -psnr
diego's avatar
diego committed
667
Calculate PSNR of compressed frames.
bellard's avatar
bellard committed
668
@item -vstats
diego's avatar
diego committed
669
Dump video coding statistics to @file{vstats_HHMMSS.log}.
670
@item -vstats_file @var{file}
benoit's avatar
 
benoit committed
671
Dump video coding statistics to @var{file}.
672
@item -top @var{n}
673
top=1/bottom=0/auto=-1 field first
674
@item -dc @var{precision}
675
Intra_dc_precision.
676
@item -vtag @var{fourcc/tag}
677 678 679
Force video tag/fourcc.
@item -qphist
Show QP histogram.
680
@item -vbsf @var{bitstream_filter}
681 682 683 684
Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump".
@example
ffmpeg -i h264.mp4 -vcodec copy -vbsf h264_mp4toannexb -an out.h264
@end example
bellard's avatar
bellard committed
685 686 687 688 689
@end table

@section Audio Options

@table @option
690
@item -aframes @var{number}
691
Set the number of audio frames to record.
692
@item -ar @var{freq}
diego's avatar
diego committed
693
Set the audio sampling frequency (default = 44100 Hz).
694
@item -ab @var{bitrate}
695
Set the audio bitrate in bit/s (default = 64k).
696
@item -ac @var{channels}
diego's avatar
diego committed
697
Set the number of audio channels (default = 1).
bellard's avatar
bellard committed
698
@item -an
diego's avatar
diego committed
699
Disable audio recording.
700
@item -acodec @var{codec}
diego's avatar
diego committed
701 702
Force audio codec to @var{codec}. Use the @code{copy} special value to
specify that the raw codec data must be copied as is.
703
@item -newaudio
diego's avatar
diego committed
704 705
Add a new audio track to the output file. If you want to specify parameters,
do so before @code{-newaudio} (@code{-acodec}, @code{-ab}, etc..).
706

diego's avatar
diego committed
707 708
Mapping will be done automatically, if the number of output streams is equal to
the number of input streams, else it will pick the first one that matches. You
709 710 711 712
can override the mapping using @code{-map} as usual.

Example:
@example
713
ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384k test.mpg -acodec mp2 -ab 192k -newaudio
714
@end example
715
@item -alang @var{code}
716 717 718 719 720 721
Set the ISO 639 language code (3 letters) of the current audio stream.
@end table

@section Advanced Audio options:

@table @option
722
@item -atag @var{fourcc/tag}
723
Force audio tag/fourcc.
724
@item -absf @var{bitstream_filter}
725 726 727 728 729 730
Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
@end table

@section Subtitle options:

@table @option
731
@item -scodec @var{codec}
732 733 734
Force subtitle codec ('copy' to copy stream).
@item -newsubtitle
Add a new subtitle stream to the current output stream.
735
@item -slang @var{code}
736
Set the ISO 639 language code (3 letters) of the current subtitle stream.
737 738 739 740 741
@item -sbsf @var{bitstream_filter}
Bitstream filters available are "mov2textsub", "text2movsub".
@example
ffmpeg -i file.mov -an -vn -sbsf mov2textsub -scodec copy -f rawvideo sub.txt
@end example
bellard's avatar
bellard committed
742 743 744 745 746
@end table

@section Audio/Video grab options

@table @option
747
@item -vc @var{channel}
diego's avatar
diego committed
748
Set video grab channel (DV1394 only).
749
@item -tvstd @var{standard}
diego's avatar
diego committed
750
Set television standard (NTSC, PAL (SECAM)).
751 752
@item -isync
Synchronize read on input.
bellard's avatar
bellard committed
753 754 755 756 757
@end table

@section Advanced options

@table @option
758
@item -map @var{input_stream_id}[:@var{sync_stream_id}]
banan's avatar
banan committed
759 760
Set stream mapping from input streams to output streams.
Just enumerate the input streams in the order you want them in the output.
761 762
@var{sync_stream_id} if specified sets the input stream to sync
against.
763 764
@item -map_meta_data @var{outfile}:@var{infile}
Set meta data information of @var{outfile} from @var{infile}.
bellard's avatar
bellard committed
765
@item -debug
diego's avatar
diego committed
766
Print specific debug info.
767
@item -benchmark
diego's avatar
diego committed
768
Add timings for benchmarking.
769
@item -dump
diego's avatar
diego committed
770
Dump each input packet.
771 772
@item -hex
When dumping packets, also dump the payload.
bellard's avatar
bellard committed
773
@item -bitexact
diego's avatar
diego committed
774
Only use bit exact algorithms (for codec testing).
775
@item -ps @var{size}
776
Set RTP payload size in bytes.
bellard's avatar
bellard committed
777
@item -re
diego's avatar
diego committed
778
Read input at native frame rate. Mainly used to simulate a grab device.
779
@item -loop_input
diego's avatar
diego committed
780 781
Loop over the input stream. Currently it works only for image
streams. This option is used for automatic FFserver testing.
782
@item -loop_output @var{number_of_times}
diego's avatar
diego committed
783
Repeatedly loop output for formats that support looping such as animated GIF
diego's avatar
diego committed
784
(0 will loop the output infinitely).
785
@item -threads @var{count}
786
Thread count.
787
@item -vsync @var{parameter}
diego's avatar
diego committed
788 789 790
Video sync method. Video will be stretched/squeezed to match the timestamps,
it is done by duplicating and dropping frames. With -map you can select from
which stream the timestamps should be taken. You can leave either video or
791
audio unchanged and sync the remaining stream(s) to the unchanged one.
792
@item -async @var{samples_per_second}
diego's avatar
diego committed
793
Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
794 795 796
the parameter is the maximum samples per second by which the audio is changed.
-async 1 is a special case where only the start of the audio stream is corrected
without any later correction.
victor's avatar
victor committed
797 798 799 800 801 802
@item -copyts
Copy timestamps from input to output.
@item -shortest
Finish encoding when the shortest input stream ends.
@item -dts_delta_threshold
Timestamp discontinuity delta threshold.
803
@item -muxdelay @var{seconds}
victor's avatar
victor committed
804
Set the maximum demux-decode delay.
805
@item -muxpreload @var{seconds}
victor's avatar
victor committed
806
Set the initial demux-decode delay.
807
@end table
bellard's avatar
bellard committed
808

stefano's avatar
stefano committed
809 810 811 812 813 814 815 816 817 818
@section Preset files

A preset file contains a sequence of @var{option}=@var{value} pairs,
one for each line, specifying a sequence of options which would be
awkward to specify on the command line. Lines starting with the hash
('#') character are ignored and are used to provide comments. Check
the @file{ffpresets} directory in the FFmpeg source tree for examples.

Preset files are specified with the @code{vpre}, @code{apre} and
@code{spre} options. The options specified in a preset file are
819 820
applied to the currently selected codec of the same type as the preset
option.
stefano's avatar
stefano committed
821 822 823 824 825

The argument passed to the preset options identifies the preset file
to use according to the following rules.

First ffmpeg searches for a file named @var{arg}.ffpreset in the
826 827 828 829
directories @file{$HOME/.ffmpeg}, and in the datadir defined at
configuration time (usually @file{PREFIX/share/ffmpeg}) in that
order. For example, if the argument is @code{libx264-max}, it will
search for the file @file{libx264-max.ffpreset}.
stefano's avatar
stefano committed
830 831 832 833 834 835 836 837 838 839 840 841 842

If no such file is found, then ffmpeg will search for a file named
@var{codec_name}-@var{arg}.ffpreset in the above-mentioned
directories, where @var{codec_name} is the name of the codec to which
the preset file options will be applied. For example, if you select
the video codec with @code{-vcodec libx264} and use @code{-vpre max},
then it will search for the file @file{libx264-max.ffpreset}.

Finally, if the above rules failed and the argument specifies an
absolute pathname, ffmpeg will search for that filename. This way you
can specify the absolute and complete filename of the preset file, for
example @file{./ffpresets/libx264-max.ffpreset}.

843
@anchor{FFmpeg formula evaluator}
bellard's avatar
bellard committed
844 845 846
@section FFmpeg formula evaluator

When evaluating a rate control string, FFmpeg uses an internal formula
847
evaluator.
bellard's avatar
bellard committed
848 849 850 851 852 853 854

The following binary operators are available: @code{+}, @code{-},
@code{*}, @code{/}, @code{^}.

The following unary operators are available: @code{+}, @code{-},
@code{(...)}.

855 856 857
The following statements are available: @code{ld}, @code{st},
@code{while}.

bellard's avatar
bellard committed
858 859 860 861 862 863 864 865
The following functions are available:
@table @var
@item sinh(x)
@item cosh(x)
@item tanh(x)
@item sin(x)
@item cos(x)
@item tan(x)
866 867 868
@item atan(x)
@item asin(x)
@item acos(x)
bellard's avatar
bellard committed
869 870
@item exp(x)
@item log(x)
871
@item abs(x)
bellard's avatar
bellard committed
872 873
@item squish(x)
@item gauss(x)
874
@item mod(x, y)
bellard's avatar
bellard committed
875 876
@item max(x, y)
@item min(x, y)
877 878
@item eq(x, y)
@item gte(x, y)
bellard's avatar
bellard committed
879
@item gt(x, y)
880
@item lte(x, y)
bellard's avatar
bellard committed
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909
@item lt(x, y)
@item bits2qp(bits)
@item qp2bits(qp)
@end table

The following constants are available:
@table @var
@item PI
@item E
@item iTex
@item pTex
@item tex
@item mv
@item fCode
@item iCount
@item mcVar
@item var
@item isI
@item isP
@item isB
@item avgQP
@item qComp
@item avgIITex
@item avgPITex
@item avgPPTex
@item avgBPTex
@item avgTex
@end table

910 911 912 913 914 915 916 917
@c man end

@ignore

@setfilename ffmpeg
@settitle FFmpeg video converter

@c man begin SEEALSO
diego's avatar
diego committed
918
ffserver(1), ffplay(1) and the HTML documentation of @file{ffmpeg}.
919 920 921 922 923 924 925
@c man end

@c man begin AUTHOR
Fabrice Bellard
@c man end

@end ignore
926 927 928

@section Protocols

929
The file name can be @file{-} to read from standard input or to write
diego's avatar
diego committed
930
to standard output.
931

diego's avatar
diego committed
932
FFmpeg also handles many protocols specified with an URL syntax.
933

diego's avatar
diego committed
934
Use 'ffmpeg -formats' to see a list of the supported protocols.
935

936
The protocol @code{http:} is currently used only to communicate with
diego's avatar
diego committed
937
FFserver (see the FFserver documentation). When FFmpeg will be a
938
video player it will also be used for streaming :-)
939 940 941 942

@chapter Tips

@itemize
diego's avatar
diego committed
943 944
@item For streaming at very low bitrate application, use a low frame rate
and a small GOP size. This is especially true for RealVideo where
945 946
the Linux player does not seem to be very fast, so it can miss
frames. An example is:
947 948

@example
949
ffmpeg -g 3 -r 3 -t 10 -b 50k -s qcif -f rv10 /tmp/b.rm
950 951 952
@end example

@item  The parameter 'q' which is displayed while encoding is the current
diego's avatar
diego committed
953 954
quantizer. The value 1 indicates that a very good quality could
be achieved. The value 31 indicates the worst quality. If q=31 appears
955
too often, it means that the encoder cannot compress enough to meet
diego's avatar
diego committed
956
your bitrate. You must either increase the bitrate, decrease the
957
frame rate or decrease the frame size.
958 959

@item If your computer is not fast enough, you can speed up the
960 961
compression at the expense of the compression ratio. You can use
'-me zero' to speed up motion estimation, and '-intra' to disable
diego's avatar
diego committed
962
motion estimation completely (you have only I-frames, which means it
963
is about as good as JPEG compression).
964

diego's avatar
diego committed
965
@item To have very low audio bitrates, reduce the sampling frequency
966
(down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
967 968

@item To have a constant quality (but a variable bitrate), use the option
969 970
'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
quality).
971 972

@item When converting video files, you can use the '-sameq' option which
diego's avatar
diego committed
973 974
uses the same quality factor in the encoder as in the decoder.
It allows almost lossless encoding.
975 976 977 978

@end itemize

@bye