ffmpeg-doc.texi 45.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
D
Diego Biurrun 已提交
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 31
FFmpeg can use a video4linux compatible video source and any Open Sound
System audio source:

32
@example
33
ffmpeg /tmp/out.mpg
34 35
@end example

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

42
@section Video and Audio file format conversion
43

D
Diego Biurrun 已提交
44
* FFmpeg can use any supported file format and protocol as input:
45 46 47

Examples:

D
Diego Biurrun 已提交
48
* You can use YUV files as input:
49 50

@example
51
ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
52 53
@end example

54
It will use the files:
55
@example
56 57
/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
58 59
@end example

60 61 62
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
D
Diego Biurrun 已提交
63
if FFmpeg cannot guess it.
64

D
Diego Biurrun 已提交
65
* You can input from a raw YUV420P file:
66 67

@example
68
ffmpeg -i /tmp/test.yuv /tmp/out.avi
69 70
@end example

D
Diego Biurrun 已提交
71 72
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
73
horizontal resolution.
74

D
Diego Biurrun 已提交
75
* You can output to a raw YUV420P file:
76 77

@example
78
ffmpeg -i mydivx.avi hugefile.yuv
79 80 81 82 83
@end example

* You can set several input files and output files:

@example
84
ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
85 86
@end example

D
Diego Biurrun 已提交
87 88
Converts the audio file a.wav and the raw YUV video file a.yuv
to MPEG file a.mpg.
89

90
* You can also do audio and video conversions at the same time:
91 92

@example
93
ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
94 95
@end example

D
Diego Biurrun 已提交
96
Converts a.wav to MPEG audio at 22050Hz sample rate.
97 98

* You can encode to several formats at the same time and define a
99
mapping from input stream to output streams:
100 101

@example
102
ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
103 104
@end example

D
Diego Biurrun 已提交
105 106
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
107
stream, in the order of the definition of output streams.
108 109 110 111

* You can transcode decrypted VOBs

@example
112
ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
113 114
@end example

D
Diego Biurrun 已提交
115 116 117 118 119 120 121
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
to enable LAME support by passing @code{--enable-mp3lame} to configure.
The mapping is particularly useful for DVD transcoding
122
to get the desired audio language.
123

D
Diego Biurrun 已提交
124
NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
125
@c man end
126 127 128 129 130

@chapter Invocation

@section Syntax

131
The generic syntax is:
132

133
@example
134
@c man begin SYNOPSIS
M
Michael Niedermayer 已提交
135
ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
136
@c man end
137
@end example
138 139
@c man begin DESCRIPTION
If no input file is given, audio/video grabbing is done.
140

141 142
As a general rule, options are applied to the next specified
file. For example, if you give the @option{-b 64} option, it sets the video
D
Diego Biurrun 已提交
143
bitrate of the next file. The format option may be needed for raw input
144
files.
145

D
Diego Biurrun 已提交
146 147
By default, FFmpeg tries to convert as losslessly as possible: It
uses the same audio and video parameters for the outputs as the one
148 149
specified for the inputs.
@c man end
150

151
@c man begin OPTIONS
152 153
@section Main options

154
@table @option
155
@item -L
D
Diego Biurrun 已提交
156
Show license.
F
Fabrice Bellard 已提交
157

158
@item -h
D
Diego Biurrun 已提交
159
Show help.
F
Fabrice Bellard 已提交
160

161
@item -formats
D
Diego Biurrun 已提交
162
Show available formats, codecs, protocols, ...
F
Fabrice Bellard 已提交
163

164
@item -f fmt
D
Diego Biurrun 已提交
165
Force format.
F
Fabrice Bellard 已提交
166

167
@item -i filename
D
Diego Biurrun 已提交
168
input filename
169

170
@item -y
D
Diego Biurrun 已提交
171
Overwrite output files.
172

173
@item -t duration
D
Diego Biurrun 已提交
174 175
Set the recording time in seconds.
@code{hh:mm:ss[.xxx]} syntax is also supported.
176

177
@item -ss position
D
Diego Biurrun 已提交
178 179
Seek to given time position in seconds.
@code{hh:mm:ss[.xxx]} syntax is also supported.
180

181
@item -title string
D
Diego Biurrun 已提交
182
Set the title.
183

184
@item -author string
D
Diego Biurrun 已提交
185
Set the author.
186

187
@item -copyright string
D
Diego Biurrun 已提交
188
Set the copyright.
189

190
@item -comment string
D
Diego Biurrun 已提交
191
Set the comment.
192

F
update  
Fabrice Bellard 已提交
193
@item -target type
D
Diego Biurrun 已提交
194 195 196
Specify target file type ("vcd", "svcd", "dvd", "dv", "pal-vcd",
"ntsc-svcd", ... ). All the format options (bitrate, codecs,
buffer sizes) are then set automatically. You can just type:
F
update  
Fabrice Bellard 已提交
197 198 199 200 201

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

D
Diego Biurrun 已提交
202 203
Nevertheless you can specify additional options as long as you know
they do not conflict with the standard, as in:
204 205 206 207 208

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

F
update  
Fabrice Bellard 已提交
209
@item -hq
D
Diego Biurrun 已提交
210
Activate high quality settings.
F
Fabrice Bellard 已提交
211

212
@item -itsoffset offset
D
Diego Biurrun 已提交
213 214 215 216 217 218
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.
219

220 221 222 223
@end table

@section Video Options

224
@table @option
225
@item -b bitrate
D
Diego Biurrun 已提交
226
Set the video bitrate in kbit/s (default = 200 kb/s).
227
@item -r fps
D
Diego Biurrun 已提交
228
Set frame rate (default = 25).
229
@item -s size
D
Diego Biurrun 已提交
230 231
Set frame size. The format is @samp{wxh} (default = 160x128).
The following abbreviations are recognized:
F
update  
Fabrice Bellard 已提交
232
@table @samp
F
Fabrice Bellard 已提交
233 234 235 236 237 238 239 240 241 242 243
@item sqcif
128x96
@item qcif
176x144
@item cif
352x288
@item 4cif
704x576
@end table

@item -aspect aspect
D
Diego Biurrun 已提交
244
Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
F
Fabrice Bellard 已提交
245
@item -croptop size
D
Diego Biurrun 已提交
246
Set top crop band size (in pixels).
F
Fabrice Bellard 已提交
247
@item -cropbottom size
D
Diego Biurrun 已提交
248
Set bottom crop band size (in pixels).
F
Fabrice Bellard 已提交
249
@item -cropleft size
D
Diego Biurrun 已提交
250
Set left crop band size (in pixels).
F
Fabrice Bellard 已提交
251
@item -cropright size
D
Diego Biurrun 已提交
252
Set right crop band size (in pixels).
253
@item -padtop size
D
Diego Biurrun 已提交
254
Set top pad band size (in pixels).
255
@item -padbottom size
D
Diego Biurrun 已提交
256
Set bottom pad band size (in pixels).
257
@item -padleft size
D
Diego Biurrun 已提交
258
Set left pad band size (in pixels).
259
@item -padright size
D
Diego Biurrun 已提交
260
Set right pad band size (in pixels).
261
@item -padcolor (hex color)
D
Diego Biurrun 已提交
262 263 264 265
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)).
266
@item -vn
D
Diego Biurrun 已提交
267
Disable video recording.
268
@item -bt tolerance
D
Diego Biurrun 已提交
269
Set video bitrate tolerance (in kbit/s).
F
Fabrice Bellard 已提交
270
@item -maxrate bitrate
D
Diego Biurrun 已提交
271
Set max video bitrate tolerance (in kbit/s).
F
Fabrice Bellard 已提交
272
@item -minrate bitrate
D
Diego Biurrun 已提交
273
Set min video bitrate tolerance (in kbit/s).
F
Fabrice Bellard 已提交
274
@item -bufsize size
D
Diego Biurrun 已提交
275
Set rate control buffer size (in kbit).
276
@item -vcodec codec
D
Diego Biurrun 已提交
277
Force video codec to @var{codec}. Use the @code{copy} special value to
F
update  
Fabrice Bellard 已提交
278
tell that the raw codec data must be copied as is.
F
Fabrice Bellard 已提交
279
@item -sameq
D
Diego Biurrun 已提交
280
Use same video quality as source (implies VBR).
281

282
@item -pass n
D
Diego Biurrun 已提交
283 284 285 286
Select the pass number (1 or 2). It is useful to do two pass
encoding. The statistics of the video are recorded in the first
pass and the video is generated at the exact requested bitrate
in the second pass.
287

288
@item -passlogfile file
D
Diego Biurrun 已提交
289
Set two pass logfile name to @var{file}.
290 291 292

@end table

F
Fabrice Bellard 已提交
293
@section Advanced Video Options
294

295
@table @option
296
@item -g gop_size
D
Diego Biurrun 已提交
297
Set the group of pictures size.
298
@item -intra
D
Diego Biurrun 已提交
299
Use only intra frames.
300
@item -qscale q
D
Diego Biurrun 已提交
301
Use fixed video quantiser scale (VBR).
302
@item -qmin q
D
Diego Biurrun 已提交
303
minimum video quantiser scale (VBR)
304
@item -qmax q
D
Diego Biurrun 已提交
305
maximum video quantiser scale (VBR)
306
@item -qdiff q
D
Diego Biurrun 已提交
307
maximum difference between the quantiser scales (VBR)
308
@item -qblur blur
309
video quantiser scale blur (VBR)
310
@item -qcomp compression
311
video quantiser scale compression (VBR)
F
Fabrice Bellard 已提交
312 313

@item -rc_init_cplx complexity
D
Diego Biurrun 已提交
314
initial complexity for single pass encoding
F
Fabrice Bellard 已提交
315
@item -b_qfactor factor
D
Diego Biurrun 已提交
316
qp factor between P- and B-frames
F
Fabrice Bellard 已提交
317
@item -i_qfactor factor
D
Diego Biurrun 已提交
318
qp factor between P- and I-frames
F
Fabrice Bellard 已提交
319
@item -b_qoffset offset
D
Diego Biurrun 已提交
320
qp offset between P- and B-frames
F
Fabrice Bellard 已提交
321
@item -i_qoffset offset
D
Diego Biurrun 已提交
322
qp offset between P- and I-frames
F
Fabrice Bellard 已提交
323
@item -rc_eq equation
D
Diego Biurrun 已提交
324 325
Set rate control equation (@pxref{FFmpeg formula
evaluator}) (default = @code{tex^qComp}).
F
update  
Fabrice Bellard 已提交
326 327
@item -rc_override override
rate control override for specific intervals
F
Fabrice Bellard 已提交
328
@item -me method
D
Diego Biurrun 已提交
329 330
Set motion estimation method to @var{method}.
Available methods are (from lowest to best quality):
F
Fabrice Bellard 已提交
331 332
@table @samp
@item zero
F
update  
Fabrice Bellard 已提交
333
Try just the (0, 0) vector.
F
Fabrice Bellard 已提交
334 335 336 337 338 339 340 341 342 343
@item phods
@item log
@item x1
@item epzs
(default method)
@item full
exhaustive search (slow and marginally better than epzs)
@end table

@item -dct_algo algo
D
Diego Biurrun 已提交
344
Set DCT algorithm to @var{algo}. Available values are:
F
Fabrice Bellard 已提交
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360
@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

@item -idct_algo algo
D
Diego Biurrun 已提交
361
Set IDCT algorithm to @var{algo}. Available values are:
F
Fabrice Bellard 已提交
362 363 364 365
@table @samp
@item 0
FF_IDCT_AUTO (default)
@item 1
366
FF_IDCT_INT
F
Fabrice Bellard 已提交
367
@item 2
368
FF_IDCT_SIMPLE
F
Fabrice Bellard 已提交
369
@item 3
370
FF_IDCT_SIMPLEMMX
F
Fabrice Bellard 已提交
371
@item 4
372
FF_IDCT_LIBMPEG2MMX
F
Fabrice Bellard 已提交
373
@item 5
374
FF_IDCT_PS2
F
Fabrice Bellard 已提交
375
@item 6
376
FF_IDCT_MLIB
F
Fabrice Bellard 已提交
377
@item 7
378
FF_IDCT_ARM
F
Fabrice Bellard 已提交
379
@item 8
380
FF_IDCT_ALTIVEC
F
Fabrice Bellard 已提交
381
@item 9
382
FF_IDCT_SH4
F
Fabrice Bellard 已提交
383
@item 10
384
FF_IDCT_SIMPLEARM
F
Fabrice Bellard 已提交
385 386 387
@end table

@item -er n
D
Diego Biurrun 已提交
388
Set error resilience to @var{n}.
F
Fabrice Bellard 已提交
389
@table @samp
390
@item 1
D
Diego Biurrun 已提交
391
FF_ER_CAREFUL (default)
F
Fabrice Bellard 已提交
392
@item 2
F
update  
Fabrice Bellard 已提交
393
FF_ER_COMPLIANT
F
Fabrice Bellard 已提交
394 395 396 397 398 399
@item 3
FF_ER_AGGRESSIVE
@item 4
FF_ER_VERY_AGGRESSIVE
@end table

F
update  
Fabrice Bellard 已提交
400
@item -ec bit_mask
D
Diego Biurrun 已提交
401
Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
F
update  
Fabrice Bellard 已提交
402
the following values:
F
Fabrice Bellard 已提交
403 404
@table @samp
@item 1
D
Diego Biurrun 已提交
405
FF_EC_GUESS_MVS (default = enabled)
F
Fabrice Bellard 已提交
406
@item 2
D
Diego Biurrun 已提交
407
FF_EC_DEBLOCK (default = enabled)
F
Fabrice Bellard 已提交
408 409 410
@end table

@item -bf frames
D
Diego Biurrun 已提交
411
Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
F
Fabrice Bellard 已提交
412 413 414 415
@item -mbd mode
macroblock decision
@table @samp
@item 0
D
Diego Biurrun 已提交
416
FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg).
F
Fabrice Bellard 已提交
417
@item 1
D
Diego Biurrun 已提交
418
FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
F
Fabrice Bellard 已提交
419
@item 2
D
Diego Biurrun 已提交
420
FF_MB_DECISION_RD: rate distortion
F
Fabrice Bellard 已提交
421 422 423
@end table

@item -4mv
D
Diego Biurrun 已提交
424
Use four motion vector by macroblock (MPEG-4 only).
F
Fabrice Bellard 已提交
425
@item -part
D
Diego Biurrun 已提交
426
Use data partitioning (MPEG-4 only).
F
Fabrice Bellard 已提交
427
@item -bug param
D
Diego Biurrun 已提交
428
Work around encoder bugs that are not auto-detected.
F
Fabrice Bellard 已提交
429
@item -strict strictness
D
Diego Biurrun 已提交
430
How strictly to follow the standards.
F
update  
Fabrice Bellard 已提交
431
@item -aic
D
Diego Biurrun 已提交
432
Enable Advanced intra coding (h263+).
F
update  
Fabrice Bellard 已提交
433
@item -umv
D
Diego Biurrun 已提交
434
Enable Unlimited Motion Vector (h263+)
F
Fabrice Bellard 已提交
435 436

@item -deinterlace
D
Diego Biurrun 已提交
437
Deinterlace pictures.
F
update  
Fabrice Bellard 已提交
438
@item -interlace
D
Diego Biurrun 已提交
439 440 441 442 443
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.
F
Fabrice Bellard 已提交
444
@item -psnr
D
Diego Biurrun 已提交
445
Calculate PSNR of compressed frames.
F
Fabrice Bellard 已提交
446
@item -vstats
D
Diego Biurrun 已提交
447
Dump video coding statistics to @file{vstats_HHMMSS.log}.
F
Fabrice Bellard 已提交
448
@item -vhook module
D
Diego Biurrun 已提交
449
Insert video processing @var{module}. @var{module} contains the module
F
Fabrice Bellard 已提交
450 451 452 453 454 455
name and its parameters separated by spaces.
@end table

@section Audio Options

@table @option
456
@item -ar freq
D
Diego Biurrun 已提交
457
Set the audio sampling frequency (default = 44100 Hz).
458
@item -ab bitrate
D
Diego Biurrun 已提交
459
Set the audio bitrate in kbit/s (default = 64).
F
Fabrice Bellard 已提交
460
@item -ac channels
D
Diego Biurrun 已提交
461
Set the number of audio channels (default = 1).
F
update  
Fabrice Bellard 已提交
462
@item -an
D
Diego Biurrun 已提交
463
Disable audio recording.
F
update  
Fabrice Bellard 已提交
464
@item -acodec codec
D
Diego Biurrun 已提交
465 466
Force audio codec to @var{codec}. Use the @code{copy} special value to
specify that the raw codec data must be copied as is.
F
Fabrice Bellard 已提交
467 468 469 470 471 472
@end table

@section Audio/Video grab options

@table @option
@item -vd device
D
Diego Biurrun 已提交
473
sEt video grab device (e.g. @file{/dev/video0}).
F
Fabrice Bellard 已提交
474
@item -vc channel
D
Diego Biurrun 已提交
475
Set video grab channel (DV1394 only).
F
Fabrice Bellard 已提交
476
@item -tvstd standard
D
Diego Biurrun 已提交
477
Set television standard (NTSC, PAL (SECAM)).
F
Fabrice Bellard 已提交
478
@item -dv1394
D
Diego Biurrun 已提交
479
Set DV1394 grab.
F
Fabrice Bellard 已提交
480
@item -ad device
D
Diego Biurrun 已提交
481
Set audio device (e.g. @file{/dev/dsp}).
F
Fabrice Bellard 已提交
482 483 484 485 486
@end table

@section Advanced options

@table @option
487
@item -map file:stream
D
Diego Biurrun 已提交
488
Set input stream mapping.
F
Fabrice Bellard 已提交
489
@item -debug
D
Diego Biurrun 已提交
490
Print specific debug info.
491
@item -benchmark
D
Diego Biurrun 已提交
492
Add timings for benchmarking.
493
@item -hex
D
Diego Biurrun 已提交
494
Dump each input packet.
F
Fabrice Bellard 已提交
495
@item -bitexact
D
Diego Biurrun 已提交
496
Only use bit exact algorithms (for codec testing).
F
Fabrice Bellard 已提交
497
@item -ps size
D
Diego Biurrun 已提交
498
Set packet size in bits.
F
update  
Fabrice Bellard 已提交
499
@item -re
D
Diego Biurrun 已提交
500
Read input at native frame rate. Mainly used to simulate a grab device.
F
update  
Fabrice Bellard 已提交
501
@item -loop
D
Diego Biurrun 已提交
502 503
Loop over the input stream. Currently it works only for image
streams. This option is used for automatic FFserver testing.
504
@item -loop_output number_of_times
D
Diego Biurrun 已提交
505
Repeatedly loop output for formats that support looping such as animated GIF
D
Diego Biurrun 已提交
506
(0 will loop the output infinitely).
507
@end table
F
Fabrice Bellard 已提交
508 509 510 511 512

@node FFmpeg formula evaluator
@section FFmpeg formula evaluator

When evaluating a rate control string, FFmpeg uses an internal formula
513
evaluator.
F
Fabrice Bellard 已提交
514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566

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

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

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)
@item exp(x)
@item log(x)
@item squish(x)
@item gauss(x)
@item abs(x)
@item max(x, y)
@item min(x, y)
@item gt(x, y)
@item lt(x, y)
@item eq(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

567 568 569 570 571 572 573 574
@c man end

@ignore

@setfilename ffmpeg
@settitle FFmpeg video converter

@c man begin SEEALSO
D
Diego Biurrun 已提交
575
ffserver(1), ffplay(1) and the HTML documentation of @file{ffmpeg}.
576 577 578 579 580 581 582
@c man end

@c man begin AUTHOR
Fabrice Bellard
@c man end

@end ignore
583 584 585

@section Protocols

D
Diego Biurrun 已提交
586 587
The filename can be @file{-} to read from standard input or to write
to standard output.
588

D
Diego Biurrun 已提交
589
FFmpeg also handles many protocols specified with an URL syntax.
590

D
Diego Biurrun 已提交
591
Use 'ffmpeg -formats' to see a list of the supported protocols.
592

593
The protocol @code{http:} is currently used only to communicate with
D
Diego Biurrun 已提交
594
FFserver (see the FFserver documentation). When FFmpeg will be a
595
video player it will also be used for streaming :-)
596 597 598 599

@chapter Tips

@itemize
D
Diego Biurrun 已提交
600 601
@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
602 603
the Linux player does not seem to be very fast, so it can miss
frames. An example is:
604 605

@example
606
ffmpeg -g 3 -r 3 -t 10 -b 50 -s qcif -f rv10 /tmp/b.rm
607 608 609
@end example

@item  The parameter 'q' which is displayed while encoding is the current
D
Diego Biurrun 已提交
610 611
quantizer. The value 1 indicates that a very good quality could
be achieved. The value 31 indicates the worst quality. If q=31 appears
612
too often, it means that the encoder cannot compress enough to meet
D
Diego Biurrun 已提交
613
your bitrate. You must either increase the bitrate, decrease the
614
frame rate or decrease the frame size.
615 616

@item If your computer is not fast enough, you can speed up the
617 618
compression at the expense of the compression ratio. You can use
'-me zero' to speed up motion estimation, and '-intra' to disable
D
Diego Biurrun 已提交
619
motion estimation completely (you have only I-frames, which means it
620
is about as good as JPEG compression).
621

D
Diego Biurrun 已提交
622
@item To have very low audio bitrates, reduce the sampling frequency
D
Diego Biurrun 已提交
623
(down to 22050 kHz for MPEG audio, 22050 or 11025 for AC3).
624 625

@item To have a constant quality (but a variable bitrate), use the option
626 627
'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
quality).
628 629

@item When converting video files, you can use the '-sameq' option which
D
Diego Biurrun 已提交
630 631
uses the same quality factor in the encoder as in the decoder.
It allows almost lossless encoding.
632 633 634 635 636 637 638 639 640

@end itemize

@chapter Supported File Formats and Codecs

You can use the @code{-formats} option to have an exhaustive list.

@section File Formats

641
FFmpeg supports the following file formats through the @code{libavformat}
F
update  
Fabrice Bellard 已提交
642
library:
643

644
@multitable @columnfractions .4 .1 .1 .4
645 646
@item Supported File Format @tab Encoding @tab Decoding @tab Comments
@item MPEG audio @tab X @tab X
D
Diego Biurrun 已提交
647
@item MPEG-1 systems @tab X  @tab  X
648
@tab muxed audio and video
D
Diego Biurrun 已提交
649
@item MPEG-2 PS @tab X  @tab  X
650
@tab also known as @code{VOB} file
D
Diego Biurrun 已提交
651
@item MPEG-2 TS @tab    @tab  X
652
@tab also known as DVB Transport Stream
653 654 655
@item ASF@tab X @tab X
@item AVI@tab X @tab X
@item WAV@tab X @tab X
656
@item Macromedia Flash@tab X @tab X
D
Diego Biurrun 已提交
657
@tab Only embedded audio is decoded.
F
Fabrice Bellard 已提交
658 659
@item FLV              @tab  X @tab X
@tab Macromedia Flash video files
660 661 662 663 664 665 666 667
@item Real Audio and Video @tab X @tab X
@item Raw AC3 @tab X  @tab  X
@item Raw MJPEG @tab X  @tab  X
@item Raw MPEG video @tab X  @tab  X
@item Raw PCM8/16 bits, mulaw/Alaw@tab X  @tab  X
@item Raw CRI ADX audio @tab X  @tab  X
@item Raw Shorten audio @tab    @tab  X
@item SUN AU format @tab X  @tab  X
A
Alex Beregszaszi 已提交
668
@item NUT @tab X @tab X @tab NUT Open Container Format
669
@item QuickTime        @tab X @tab  X
D
Diego Biurrun 已提交
670 671
@item MPEG-4           @tab X @tab  X
@tab MPEG-4 is a variant of QuickTime.
672
@item Raw MPEG4 video  @tab  X @tab  X
673
@item DV               @tab  X @tab  X
M
Mike Melanson 已提交
674
@item 4xm              @tab    @tab X
D
Diego Biurrun 已提交
675
@tab 4X Technologies format, used in some games.
M
Mike Melanson 已提交
676 677
@item Playstation STR  @tab    @tab X
@item Id RoQ           @tab    @tab X
D
Diego Biurrun 已提交
678
@tab Used in Quake III, Jedi Knight 2, other computer games.
M
Mike Melanson 已提交
679
@item Interplay MVE    @tab    @tab X
D
Diego Biurrun 已提交
680
@tab Format used in various Interplay computer games.
M
Mike Melanson 已提交
681
@item WC3 Movie        @tab    @tab X
D
Diego Biurrun 已提交
682
@tab Multimedia format used in Origin's Wing Commander III computer game.
683
@item Sega FILM/CPK    @tab    @tab X
D
Diego Biurrun 已提交
684
@tab Used in many Sega Saturn console games.
685
@item Westwood Studios VQA/AUD  @tab    @tab X
D
Diego Biurrun 已提交
686
@tab Multimedia formats used in Westwood Studios games.
687
@item Id Cinematic (.cin) @tab    @tab X
D
Diego Biurrun 已提交
688
@tab Used in Quake II.
M
Mike Melanson 已提交
689 690
@item FLIC format      @tab    @tab X
@tab .fli/.flc files
M
Mike Melanson 已提交
691
@item Sierra VMD       @tab    @tab X
D
Diego Biurrun 已提交
692
@tab Used in Sierra CD-ROM games.
693
@item Sierra Online    @tab    @tab X
D
Diego Biurrun 已提交
694
@tab .sol files used in Sierra Online games.
M
Mike Melanson 已提交
695
@item Matroska         @tab    @tab X
696
@item Electronic Arts Multimedia    @tab    @tab X
D
Diego Biurrun 已提交
697
@tab Used in various EA games; files have extensions like WVE and UV2.
M
Mike Melanson 已提交
698
@item Nullsoft Video (NSV) format @tab    @tab X
699
@item ADTS AAC audio @tab X @tab X
A
Aurelien Jacobs 已提交
700
@item Creative VOC @tab X @tab X @tab Created for the Sound Blaster Pro.
701 702
@item American Laser Games MM  @tab    @tab X
@tab Multimedia format used in games like Mad Dog McCree
703 704
@item AVS @tab    @tab X
@tab Multimedia format used by the Creature Shock game.
M
Mike Melanson 已提交
705
@end multitable
706

D
Diego Biurrun 已提交
707
@code{X} means that encoding (resp. decoding) is supported.
708

F
update  
Fabrice Bellard 已提交
709 710 711 712 713
@section Image Formats

FFmpeg can read and write images for each frame of a video sequence. The
following image formats are supported:

714
@multitable @columnfractions .4 .1 .1 .4
F
update  
Fabrice Bellard 已提交
715
@item Supported Image Format @tab Encoding @tab Decoding @tab Comments
716
@item PGM, PPM     @tab X @tab X
D
Diego Biurrun 已提交
717
@item PAM          @tab X @tab X @tab PAM is a PNM extension with alpha support.
F
Fabrice Bellard 已提交
718
@item PGMYUV       @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
D
Diego Biurrun 已提交
719 720 721 722
@item JPEG         @tab X @tab X @tab Progressive JPEG is not supported.
@item .Y.U.V       @tab X @tab X @tab one raw file per component
@item animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated.
@item PNG          @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet.
723
@item SGI          @tab X @tab X @tab SGI RGB image format
F
update  
Fabrice Bellard 已提交
724 725
@end multitable

D
Diego Biurrun 已提交
726
@code{X} means that encoding (resp. decoding) is supported.
F
update  
Fabrice Bellard 已提交
727

728 729
@section Video Codecs

730
@multitable @columnfractions .4 .1 .1 .4
731
@item Supported Codec @tab Encoding @tab Decoding @tab Comments
D
Diego Biurrun 已提交
732 733 734
@item MPEG-1 video           @tab  X  @tab  X
@item MPEG-2 video           @tab  X  @tab  X
@item MPEG-4                 @tab  X  @tab  X @tab also known as DivX4/5
735 736
@item MSMPEG4 V1             @tab  X  @tab  X
@item MSMPEG4 V2             @tab  X  @tab  X
D
Diego Biurrun 已提交
737
@item MSMPEG4 V3             @tab  X  @tab  X @tab also known as DivX3
738
@item WMV7                   @tab  X  @tab  X
D
Diego Biurrun 已提交
739
@item WMV8                   @tab  X  @tab  X @tab not completely working
M
Mike Melanson 已提交
740
@item H.261                  @tab  X  @tab  X
D
Diego Biurrun 已提交
741
@item H.263(+)               @tab  X  @tab  X @tab also known as RealVideo 1.0
M
Mike Melanson 已提交
742
@item H.264                  @tab     @tab  X
743 744
@item RealVideo 1.0          @tab  X  @tab  X
@item RealVideo 2.0          @tab  X  @tab  X
745
@item MJPEG                  @tab  X  @tab  X
D
Diego Biurrun 已提交
746
@item lossless MJPEG         @tab  X  @tab  X
A
Alex Beregszaszi 已提交
747 748
@item Apple MJPEG-B          @tab     @tab  X
@item Sunplus MJPEG          @tab     @tab  X @tab fourcc: SP5X
749
@item DV                     @tab  X  @tab  X
D
Diego Biurrun 已提交
750 751 752
@item HuffYUV                @tab  X  @tab  X
@item FFmpeg Video 1         @tab  X  @tab  X @tab experimental lossless codec (fourcc: FFV1)
@item FFmpeg Snow            @tab  X  @tab  X @tab experimental wavelet codec (fourcc: SNOW)
M
Mike Melanson 已提交
753
@item Asus v1                @tab  X  @tab  X @tab fourcc: ASV1
M
Mike Melanson 已提交
754
@item Asus v2                @tab  X  @tab  X @tab fourcc: ASV2
M
Mike Melanson 已提交
755
@item Creative YUV           @tab     @tab  X @tab fourcc: CYUV
M
Mike Melanson 已提交
756
@item Sorenson Video 1       @tab  X  @tab  X @tab fourcc: SVQ1
M
Mike Melanson 已提交
757 758
@item Sorenson Video 3       @tab     @tab  X @tab fourcc: SVQ3
@item On2 VP3                @tab     @tab  X @tab still experimental
A
Alex Beregszaszi 已提交
759
@item Theora                 @tab     @tab  X @tab still experimental
760
@item Intel Indeo 3          @tab     @tab  X
A
Alex Beregszaszi 已提交
761
@item FLV                    @tab  X  @tab  X @tab Sorenson H.263 used in Flash
M
Mike Melanson 已提交
762
@item ATI VCR1               @tab     @tab  X @tab fourcc: VCR1
A
Alex Beregszaszi 已提交
763
@item ATI VCR2               @tab     @tab  X @tab fourcc: VCR2
M
Mike Melanson 已提交
764
@item Cirrus Logic AccuPak   @tab     @tab  X @tab fourcc: CLJR
D
Diego Biurrun 已提交
765
@item 4X Video               @tab     @tab  X @tab Used in certain computer games.
766
@item Sony Playstation MDEC  @tab     @tab  X
D
Diego Biurrun 已提交
767 768 769
@item Id RoQ                 @tab     @tab  X @tab Used in Quake III, Jedi Knight 2, other computer games.
@item Xan/WC3                @tab     @tab  X @tab Used in Wing Commander III .MVE files.
@item Interplay Video        @tab     @tab  X @tab Used in Interplay .MVE files.
770
@item Apple Animation        @tab     @tab  X @tab fourcc: 'rle '
M
Mike Melanson 已提交
771
@item Apple Graphics         @tab     @tab  X @tab fourcc: 'smc '
772
@item Apple Video            @tab     @tab  X @tab fourcc: rpza
773
@item Apple QuickDraw        @tab     @tab  X @tab fourcc: qdrw
774 775 776
@item Cinepak                @tab     @tab  X
@item Microsoft RLE          @tab     @tab  X
@item Microsoft Video-1      @tab     @tab  X
777
@item Westwood VQA           @tab     @tab  X
D
Diego Biurrun 已提交
778
@item Id Cinematic Video     @tab     @tab  X @tab Used in Quake II.
R
Roberto Togni 已提交
779
@item Planar RGB             @tab     @tab  X @tab fourcc: 8BPS
M
Mike Melanson 已提交
780
@item FLIC video             @tab     @tab  X
781
@item Duck TrueMotion v1     @tab     @tab  X @tab fourcc: DUCK
M
Mike Melanson 已提交
782
@item Duck TrueMotion v2     @tab     @tab  X @tab fourcc: TM20
D
Diego Biurrun 已提交
783
@item VMD Video              @tab     @tab  X @tab Used in Sierra VMD files.
R
Roberto Togni 已提交
784 785
@item MSZH                   @tab     @tab  X @tab Part of LCL
@item ZLIB                   @tab  X  @tab  X @tab Part of LCL, encoder experimental
786
@item TechSmith Camtasia     @tab     @tab  X @tab fourcc: TSCC
787
@item IBM Ultimotion         @tab     @tab  X @tab fourcc: ULTI
788
@item Miro VideoXL           @tab     @tab  X @tab fourcc: VIXL
789
@item QPEG                   @tab     @tab  X @tab fourccs: QPEG, Q1.0, Q1.1
790 791
@item LOCO                   @tab     @tab  X @tab
@item Winnov WNV1            @tab     @tab  X @tab
792
@item Autodesk Animator Studio Codec  @tab     @tab  X @tab fourcc: AASC
793
@item Fraps FPS1             @tab     @tab  X @tab
D
Diego Biurrun 已提交
794
@item CamStudio              @tab     @tab  X @tab fourcc: CSCD
795
@item American Laser Games Video  @tab    @tab X @tab Used in games like Mad Dog McCree
796
@item ZMBV                   @tab     @tab  X @tab
797
@item AVS Video              @tab     @tab  X @tab Video encoding used by the Creature Shock game.
798 799
@end multitable

D
Diego Biurrun 已提交
800
@code{X} means that encoding (resp. decoding) is supported.
801

D
Diego Biurrun 已提交
802 803 804
See @url{http://www.mplayerhq.hu/~michael/codec-features.html} to
get a precise comparison of the FFmpeg MPEG-4 codec compared to
other implementations.
F
Fabrice Bellard 已提交
805

806 807 808 809
@section Audio Codecs

@multitable @columnfractions .4 .1 .1 .1 .7
@item Supported Codec @tab Encoding @tab Decoding @tab Comments
810
@item MPEG audio layer 2     @tab  IX  @tab  IX
811
@item MPEG audio layer 1/3   @tab IX   @tab  IX
D
Diego Biurrun 已提交
812
@tab MP3 encoding is supported through the external library LAME.
813
@item AC3                    @tab  IX  @tab  IX
D
Diego Biurrun 已提交
814
@tab liba52 is used internally for decoding.
P
Philip Gladstone 已提交
815
@item Vorbis                 @tab  X   @tab  X
D
Diego Biurrun 已提交
816
@tab Supported through the external library libvorbis.
F
update  
Fabrice Bellard 已提交
817
@item WMA V1/V2              @tab      @tab X
818
@item AAC                    @tab X    @tab X
D
Diego Biurrun 已提交
819
@tab Supported through the external library libfaac/libfaad.
M
Michael Niedermayer 已提交
820
@item Microsoft ADPCM        @tab X    @tab X
M
Mike Melanson 已提交
821 822 823
@item MS IMA ADPCM           @tab X    @tab X
@item QT IMA ADPCM           @tab      @tab X
@item 4X IMA ADPCM           @tab      @tab X
R
Roman Shaposhnik 已提交
824
@item G.726  ADPCM           @tab X    @tab X
M
Mike Melanson 已提交
825
@item Duck DK3 IMA ADPCM     @tab      @tab X
D
Diego Biurrun 已提交
826
@tab Used in some Sega Saturn console games.
M
Mike Melanson 已提交
827
@item Duck DK4 IMA ADPCM     @tab      @tab X
D
Diego Biurrun 已提交
828
@tab Used in some Sega Saturn console games.
829
@item Westwood Studios IMA ADPCM @tab      @tab X
D
Diego Biurrun 已提交
830
@tab Used in Westwood Studios games like Command and Conquer.
831
@item SMJPEG IMA ADPCM       @tab      @tab X
D
Diego Biurrun 已提交
832
@tab Used in certain Loki game ports.
M
Mike Melanson 已提交
833 834
@item CD-ROM XA ADPCM        @tab      @tab X
@item CRI ADX ADPCM          @tab X    @tab X
D
Diego Biurrun 已提交
835
@tab Used in Sega Dreamcast games.
836
@item Electronic Arts ADPCM  @tab      @tab X
D
Diego Biurrun 已提交
837
@tab Used in various EA titles.
838
@item Creative ADPCM         @tab      @tab X
839
@tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2
F
Fabrice Bellard 已提交
840 841 842 843
@item RA144                  @tab      @tab X
@tab Real 14400 bit/s codec
@item RA288                  @tab      @tab X
@tab Real 28800 bit/s codec
844
@item RADnet                 @tab X    @tab IX
D
Diego Biurrun 已提交
845
@tab Real low bitrate AC3 codec, liba52 is used for decoding.
F
Fabrice Bellard 已提交
846
@item AMR-NB                 @tab X    @tab X
D
Diego Biurrun 已提交
847
@tab Supported through an external library.
848
@item AMR-WB                 @tab X    @tab X
D
Diego Biurrun 已提交
849
@tab Supported through an external library.
F
Fabrice Bellard 已提交
850
@item DV audio               @tab      @tab X
M
Mike Melanson 已提交
851
@item Id RoQ DPCM            @tab      @tab X
D
Diego Biurrun 已提交
852
@tab Used in Quake III, Jedi Knight 2, other computer games.
M
Mike Melanson 已提交
853
@item Interplay MVE DPCM     @tab      @tab X
D
Diego Biurrun 已提交
854
@tab Used in various Interplay computer games.
M
Mike Melanson 已提交
855
@item Xan DPCM               @tab      @tab X
D
Diego Biurrun 已提交
856
@tab Used in Origin's Wing Commander IV AVI files.
857
@item Sierra Online DPCM     @tab      @tab X
D
Diego Biurrun 已提交
858
@tab Used in Sierra Online game audio files.
A
Alex Beregszaszi 已提交
859 860
@item Apple MACE 3           @tab      @tab X
@item Apple MACE 6           @tab      @tab X
M
Mike Melanson 已提交
861 862
@item FLAC lossless audio    @tab      @tab X
@item Shorten lossless audio @tab      @tab X
863 864
@item Apple lossless audio   @tab      @tab X
@tab QuickTime fourcc 'alac'
A
Alex Beregszaszi 已提交
865
@item FFmpeg Sonic           @tab X    @tab X
D
Diego Biurrun 已提交
866
@tab experimental lossy/lossless codec
R
Roberto Togni 已提交
867 868
@item Qdesign QDM2           @tab      @tab X
@tab there are still some distortions
R
Roberto Togni 已提交
869 870
@item Real COOK              @tab      @tab X
@tab All versions except 5.1 are supported
871
@item DSP Group TrueSpeech   @tab      @tab X
A
Alex Beregszaszi 已提交
872
@item True Audio (TTA)       @tab      @tab X
873 874
@end multitable

D
Diego Biurrun 已提交
875
@code{X} means that encoding (resp. decoding) is supported.
876

D
Diego Biurrun 已提交
877 878
@code{I} means that an integer-only version is available, too (ensures high
performance on systems without hardware floating point support).
879

F
Fabrice Bellard 已提交
880 881 882 883
@chapter Platform Specific information

@section Linux

D
Diego Biurrun 已提交
884 885
FFmpeg should be compiled with at least GCC 2.95.3. GCC 3.2 is the
preferred compiler now for FFmpeg. All future optimizations will depend on
F
Fabrice Bellard 已提交
886 887 888 889
features only found in GCC 3.2.

@section BSD

D
Diego Biurrun 已提交
890 891 892
BSD make will not build FFmpeg, you need to install and use GNU Make
(@file{gmake}).

F
Fabrice Bellard 已提交
893 894
@section Windows

895 896 897 898 899 900 901
@subsection Native Windows compilation

@itemize
@item Install the current versions of MSYS and MinGW from
@url{http://www.mingw.org/}. You can find detailed installation
instructions in the download section and the FAQ.

D
Diego Biurrun 已提交
902
@item If you want to test the FFplay, also download
F
Fabrice Bellard 已提交
903 904
the MinGW development library of SDL 1.2.x
(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
D
Diego Biurrun 已提交
905
@url{http://www.libsdl.org}. Unpack it in a temporary directory, and
F
Fabrice Bellard 已提交
906
unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
F
Fabrice Bellard 已提交
907 908
directory. Edit the @file{sdl-config} script so that it gives the
correct SDL directory when invoked.
F
Fabrice Bellard 已提交
909

910
@item Extract the current version of FFmpeg.
911

912 913
@item Start the MSYS shell (file @file{msys.bat}).

D
Diego Biurrun 已提交
914 915
@item Change to the FFmpeg directory and follow
 the instructions of how to compile FFmpeg (file
F
Fabrice Bellard 已提交
916 917 918 919
@file{INSTALL}). Usually, launching @file{./configure} and @file{make}
suffices. If you have problems using SDL, verify that
@file{sdl-config} can be launched from the MSYS command line.

D
Diego Biurrun 已提交
920 921 922
@item You can install FFmpeg in @file{Program Files/FFmpeg} by typing
@file{make install}. Don't forget to copy @file{SDL.dll} to the place
you launch @file{ffplay} from.
F
Fabrice Bellard 已提交
923

924 925
@end itemize

926
Notes:
F
Fabrice Bellard 已提交
927
@itemize
F
Fabrice Bellard 已提交
928

F
Fabrice Bellard 已提交
929 930
@item The target @file{make wininstaller} can be used to create a
Nullsoft based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
D
Diego Biurrun 已提交
931
must be copied to the FFmpeg directory in order to build the
F
Fabrice Bellard 已提交
932 933
installer.

D
Diego Biurrun 已提交
934
@item By using @code{./configure --enable-shared} when configuring FFmpeg,
F
Fabrice Bellard 已提交
935 936
you can build @file{avcodec.dll} and @file{avformat.dll}. With
@code{make install} you install the FFmpeg DLLs and the associated
937
headers in @file{Program Files/FFmpeg}.
F
Fabrice Bellard 已提交
938

D
Diego Biurrun 已提交
939 940
@item Visual C++ compatibility: If you used @code{./configure --enable-shared}
when configuring FFmpeg, FFmpeg tries to use the Microsoft Visual
F
Fabrice Bellard 已提交
941
C++ @code{lib} tool to build @code{avcodec.lib} and
D
Diego Biurrun 已提交
942
@code{avformat.lib}. With these libraries you can link your Visual C++
943
code directly with the FFmpeg DLLs (see below).
F
Fabrice Bellard 已提交
944 945

@end itemize
946

947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986
@subsection Visual C++ compatibility

FFmpeg will not compile under Visual C++ -- and it has too many
dependencies on the GCC compiler to make a port viable. However,
if you want to use the FFmpeg libraries in your own applications,
you can still compile those applications using Visual C++. An
important restriction to this is that you have to use the
dynamically linked versions of the FFmpeg libraries (i.e. the
DLLs), and you have to make sure that Visual-C++-compatible
import libraries are created during the FFmpeg build process.

This description of how to use the FFmpeg libraries with Visual C++ is
based on Visual C++ 2005 Express Edition Beta 2. If you have a different
version, you might have to modify the procedures slightly.

Here are the step-by-step instructions for building the FFmpeg libraries
so they can be used with Visual C++:

@enumerate

@item Install Visual C++ (if you haven't done so already).

@item Install MinGW and MSYS as described above.

@item Add a call to @file{vcvars32.bat} (which sets up the environment
variables for the Visual C++ tools) as the first line of
@file{msys.bat}. The standard location for @file{vcvars32.bat} is
@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
and the standard location for @file{msys.bat} is
@file{C:\msys\1.0\msys.bat}. If this corresponds to your setup, add the
following line as the first line of @file{msys.bat}:

@code{call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"}

@item Start the MSYS shell (file @file{msys.bat}) and type @code{link.exe}.
If you get a help message with the command line options of @code{link.exe},
this means your environment variables are set up correctly, the
Microsoft linker is on the path and will be used by FFmpeg to
create Visual-C++-compatible import libraries.

987
@item Extract the current version of FFmpeg and change to the FFmpeg directory.
988 989

@item Type the command
990 991 992
@code{./configure --enable-shared --disable-static --enable-memalign-hack}
to configure and, if that didn't produce any errors,
type @code{make} to build FFmpeg.
993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036

@item The subdirectories @file{libavformat}, @file{libavcodec}, and
@file{libavutil} should now contain the files @file{avformat.dll},
@file{avformat.lib}, @file{avcodec.dll}, @file{avcodec.lib},
@file{avutil.dll}, and @file{avutil.lib}, respectively. Copy the three
DLLs to your System32 directory (typically @file{C:\Windows\System32}).

@end enumerate

And here is how to use these libraries with Visual C++:

@enumerate

@item Create a new console application ("File / New / Project") and then
select "Win32 Console Application". On the appropriate page of the
Application Wizard, uncheck the "Precompiled headers" option.

@item Write the source code for your application, or, for testing, just
copy the code from an existing sample application into the source file
that Visual C++ has already created for you. (Note that your source
filehas to have a @code{.cpp} extension; otherwise, Visual C++ won't
compile the FFmpeg headers correctly because in C mode, it doesn't
recognize the @code{inline} keyword.)  For example, you can copy
@file{output_example.c} from the FFmpeg distribution (but you will
have to make minor modifications so the code will compile under
C++, see below).

@item Open the "Project / Properties" dialog box. In the "Configuration"
combo box, select "All Configurations" so that the changes you make will
affect both debug and release builds. In the tree view on the left hand
side, select "C/C++ / General", then edit the "Additional Include
Directories" setting to contain the complete paths to the
@file{libavformat}, @file{libavcodec}, and @file{libavutil}
subdirectories of your FFmpeg directory. Note that the directories have
to be separated using semicolons. Now select "Linker / General" from the
tree view and edit the "Additional Library Directories" setting to
contain the same three directories.

@item Still in the "Project / Properties" dialog box, select "Linker / Input"
from the tree view, then add the files @file{avformat.lib},
@file{avcodec.lib}, and @file{avutil.lib} to the end of the "Additional
Dependencies". Note that the names of the libraries have to be separated
using spaces.

1037
@item Now, select "C/C++ / Code Generation" from the tree view. Select
1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062
"Debug" in the "Configuration" combo box. Make sure that "Runtime
Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
the "Configuration" combo box and make sure that "Runtime Library" is
set to "Multi-threaded DLL".

@item Click "OK" to close the "Project / Properties" dialog box and build
the application. Hopefully, it should compile and run cleanly. If you
used @file{output_example.c} as your sample application, you will get a
few compiler errors, but they are easy to fix. The first type of error
occurs because Visual C++ doesn't allow an @code{int} to be converted to
an @code{enum} without a cast. To solve the problem, insert the required
casts (this error occurs once for a @code{CodecID} and once for a
@code{CodecType}).  The second type of error occurs because C++ requires
the return value of @code{malloc} to be cast to the exact type of the
pointer it is being assigned to. Visual C++ will complain that, for
example, @code{(void *)} is being assigned to @code{(uint8_t *)} without
an explicit cast. So insert an explicit cast in these places to silence
the compiler. The third type of error occurs because the @code{snprintf}
library function is called @code{_snprintf} under Visual C++.  So just
add an underscore to fix the problem. With these changes,
@file{output_example.c} should compile under Visual C++, and the
resulting executable should produce valid video files.

@end enumerate

1063 1064 1065 1066 1067
@subsection Cross compilation for Windows with Linux

You must use the MinGW cross compilation tools available at
@url{http://www.mingw.org/}.

D
Diego Biurrun 已提交
1068
Then configure FFmpeg with the following options:
1069 1070 1071
@example
./configure --enable-mingw32 --cross-prefix=i386-mingw32msvc-
@end example
D
Diego Biurrun 已提交
1072
(you can change the cross-prefix according to the prefix chosen for the
1073 1074
MinGW tools).

D
Diego Biurrun 已提交
1075
Then you can easily test FFmpeg with Wine
1076 1077
(@url{http://www.winehq.com/}).

D
Diego Biurrun 已提交
1078
@section Mac OS X
F
Fabrice Bellard 已提交
1079 1080 1081 1082 1083 1084 1085 1086 1087

@section BeOS

The configure script should guess the configuration itself.
Networking support is currently not finished.
errno issues fixed by Andrew Bachmann.

Old stuff:

1088
François Revol - revol at free dot fr - April 2002
F
Fabrice Bellard 已提交
1089

1090
The configure script should guess the configuration itself,
D
Diego Biurrun 已提交
1091
however I still didn't test building on the net_server version of BeOS.
F
Fabrice Bellard 已提交
1092

D
Diego Biurrun 已提交
1093
FFserver is broken (needs poll() implementation).
F
Fabrice Bellard 已提交
1094

D
Diego Biurrun 已提交
1095
There are still issues with errno codes, which are negative in BeOS, and
1096
that FFmpeg negates when returning. This ends up turning errors into
F
Fabrice Bellard 已提交
1097 1098 1099
valid results, then crashes.
(To be fixed)

P
Philip Gladstone 已提交
1100
@chapter Developers Guide
1101 1102 1103 1104

@section API
@itemize
@item libavcodec is the library containing the codecs (both encoding and
D
Diego Biurrun 已提交
1105
decoding). Look at @file{libavcodec/apiexample.c} to see how to use it.
1106

D
Diego Biurrun 已提交
1107 1108
@item libavformat is the library containing the file format handling (mux and
demux code for several formats). Look at @file{ffplay.c} to use it in a
1109 1110 1111
player. See @file{output_example.c} to use it to generate audio or video
streams.

1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122
@end itemize

@section Integrating libavcodec or libavformat in your program

You can integrate all the source code of the libraries to link them
statically to avoid any version problem. All you need is to provide a
'config.mak' and a 'config.h' in the parent directory. See the defines
generated by ./configure to understand what is needed.

You can use libavcodec or libavformat in your commercial program, but
@emph{any patch you make must be published}. The best way to proceed is
D
Diego Biurrun 已提交
1123
to send your patches to the FFmpeg mailing list.
1124

1125
@node Coding Rules
1126 1127
@section Coding Rules

D
Diego Biurrun 已提交
1128
FFmpeg is programmed in the ISO C90 language with a few additional
F
Falk Hüffner 已提交
1129 1130 1131 1132 1133 1134 1135 1136 1137
features from ISO C99, namely:
@itemize @bullet
@item
the @samp{inline} keyword;
@item
@samp{//} comments;
@item
designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
@item
D
Diego Biurrun 已提交
1138
compound literals (@samp{x = (struct s) @{ 17, 23 @};})
F
Falk Hüffner 已提交
1139 1140 1141 1142 1143 1144
@end itemize

These features are supported by all compilers we care about, so we won't
accept patches to remove their use unless they absolutely don't impair
clarity and performance.

D
Diego Biurrun 已提交
1145
All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
F
Falk Hüffner 已提交
1146 1147 1148
compiles with several other compilers, such as the Compaq ccc compiler
or Sun Studio 9, and we would like to keep it that way unless it would
be exceedingly involved. To ensure compatibility, please don't use any
D
Diego Biurrun 已提交
1149
additional C99 features or GCC extensions. Especially watch out for:
F
Falk Hüffner 已提交
1150 1151 1152 1153 1154 1155 1156 1157
@itemize @bullet
@item
mixing statements and declarations;
@item
@samp{long long} (use @samp{int64_t} instead);
@item
@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
@item
D
Diego Biurrun 已提交
1158
GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
F
Falk Hüffner 已提交
1159
@end itemize
1160

1161
Indent size is 4.
1162
The presentation is the one specified by 'indent -i4 -kr -nut'.
1163 1164 1165
The TAB character is forbidden outside of Makefiles as is any
form of trailing whitespace. Commits containing either will be
rejected by the CVS repository.
1166

D
Diego Biurrun 已提交
1167
Main priority in FFmpeg is simplicity and small code size (=less
1168 1169
bugs).

D
Diego Biurrun 已提交
1170 1171 1172 1173 1174
Comments: Use the JavaDoc/Doxygen
format (see examples below) so that code documentation
can be generated automatically. All nontrivial functions should have a comment
above them explaining what the function does, even if it's just one sentence.
All structures and their member variables should be documented, too.
M
Michael Niedermayer 已提交
1175 1176
@example
/**
M
Måns Rullgård 已提交
1177 1178 1179 1180
 * @@file mpeg.c
 * MPEG codec.
 * @@author ...
 */
M
Michael Niedermayer 已提交
1181 1182

/**
M
Måns Rullgård 已提交
1183 1184 1185 1186
 * Summary sentence.
 * more text ...
 * ...
 */
D
Diego Biurrun 已提交
1187
typedef struct Foobar@{
M
Måns Rullgård 已提交
1188 1189 1190 1191
    int var1; /**< var1 description */
    int var2; ///< var2 description
    /** var3 description */
    int var3;
D
Diego Biurrun 已提交
1192
@} Foobar;
M
Michael Niedermayer 已提交
1193 1194

/**
M
Måns Rullgård 已提交
1195 1196 1197 1198 1199 1200
 * Summary sentence.
 * more text ...
 * ...
 * @@param my_parameter description of my_parameter
 * @@return return value description
 */
M
Michael Niedermayer 已提交
1201 1202 1203
int myfunc(int my_parameter)
...
@end example
1204

1205
fprintf and printf are forbidden in libavformat and libavcodec,
1206 1207
please use av_log() instead.

M
Michael Niedermayer 已提交
1208 1209 1210 1211
@node CVS Policy
@section CVS Policy

@enumerate
1212
@item
M
Michael Niedermayer 已提交
1213
   You must not commit code which breaks FFmpeg! (Meaning unfinished but
D
Diego Biurrun 已提交
1214
   enabled code which breaks compilation or compiles but does not work or
M
Michael Niedermayer 已提交
1215 1216 1217 1218
   breaks the regression tests)
   You can commit unfinished stuff (for testing etc), but it must be disabled
   (#ifdef etc) by default so it does not interfere with other developers'
   work.
1219
@item
M
Michael Niedermayer 已提交
1220
   You don't have to over-test things. If it works for you, and you think it
D
Diego Biurrun 已提交
1221 1222
   should work for others, then commit. If your code has problems
   (portability, triggers compiler bugs, unusual environment etc) they will be
M
Michael Niedermayer 已提交
1223
   reported and eventually fixed.
1224
@item
M
Michael Niedermayer 已提交
1225 1226 1227 1228
   Do not commit unrelated changes together, split them into self-contained
   pieces.
@item
   Do not change behavior of the program (renaming options etc) without
D
Diego Biurrun 已提交
1229
   first discussing it on the ffmpeg-devel mailing list. Do not remove
M
Michael Niedermayer 已提交
1230
   functionality from the code. Just improve!
1231

D
Diego Biurrun 已提交
1232
   Note: Redundant code can be removed.
M
Michael Niedermayer 已提交
1233 1234
@item
   Do not commit changes to the build system (Makefiles, configure script)
D
Diego Biurrun 已提交
1235
   which change behavior, defaults etc, without asking first. The same
M
Michael Niedermayer 已提交
1236 1237
   applies to compiler warning fixes, trivial looking fixes and to code
   maintained by other developers. We usually have a reason for doing things
D
Diego Biurrun 已提交
1238
   the way we do. Send your changes as patches to the ffmpeg-devel mailing
M
Michael Niedermayer 已提交
1239 1240 1241 1242 1243 1244 1245
   list, and if the code maintainers say OK, you may commit. This does not
   apply to files you wrote and/or maintain.
@item
   We refuse source indentation and other cosmetic changes if they are mixed
   with functional changes, such commits will be rejected and removed. Every
   developer has his own indentation style, you should not change it. Of course
   if you (re)write something, you can use your own style, even though we would
D
Diego Biurrun 已提交
1246 1247
   prefer if the indentation throughout FFmpeg was consistent (Many projects
   force a given indentation style - we don't.). If you really need to make
M
Michael Niedermayer 已提交
1248 1249 1250
   indentation changes (try to avoid this), separate them strictly from real
   changes.

D
Diego Biurrun 已提交
1251
   NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
1252
   then either do NOT change the indentation of the inner part within (don't
D
Diego Biurrun 已提交
1253
   move it to the right)! or do so in a separate commit
M
Michael Niedermayer 已提交
1254 1255 1256 1257 1258 1259 1260
@item
   Always fill out the commit log message. Describe in a few lines what you
   changed and why. You can refer to mailing list postings if you fix a
   particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
@item
   If you apply a patch by someone else, include the name and email address in
   the CVS log message. Since the ffmpeg-cvslog mailing list is publicly
D
Diego Biurrun 已提交
1261 1262
   archived you should add some SPAM protection to the email address. Send an
   answer to ffmpeg-devel (or wherever you got the patch from) saying that
M
Michael Niedermayer 已提交
1263 1264 1265
   you applied the patch.
@item
   Do NOT commit to code actively maintained by others without permission. Send
D
Diego Biurrun 已提交
1266
   a patch to ffmpeg-devel instead.
M
Michael Niedermayer 已提交
1267 1268 1269 1270 1271 1272 1273
@item
    Subscribe to the ffmpeg-cvslog mailing list. The diffs of all CVS commits
    are sent there and reviewed by all the other developers. Bugs and possible
    improvements or general questions regarding commits are discussed there. We
    expect you to react if problems with your code are uncovered.
@item
    Update the documentation if you change behavior or add features. If you are
D
Diego Biurrun 已提交
1274
    unsure how best to do this, send a patch to ffmpeg-devel, the documentation
M
Michael Niedermayer 已提交
1275 1276 1277 1278
    maintainer(s) will review and commit your stuff.
@item
    Revert a commit ONLY in case of a big blunder like committing something not
    intended to be committed or committing a wrong file, the wrong version of a
D
Diego Biurrun 已提交
1279
    patch, CVS policy violation or broken code and you are going to recommit the
M
Michael Niedermayer 已提交
1280 1281 1282 1283
    right thing immediately.

    Never revert changes made a long time ago or buggy code. Fix it in the
    normal way instead.
1284
@item
D
Diego Biurrun 已提交
1285 1286 1287
    Never write to unallocated memory, never write over the end of arrays,
    always check values read from some untrusted source before using them
    as array index or other risky things.
1288 1289
@item
    Remember to check if you need to bump versions for the specific libav
D
Diego Biurrun 已提交
1290
    parts (libavutil, libavcodec, libavformat) you are changing. You need
1291 1292
    to change the version integer and the version string.
    Incrementing the first component means no backward compatibility to
D
Diego Biurrun 已提交
1293
    previous versions (e.g. removal of a function).
1294 1295 1296 1297
    Incrementing the second component means backward compatible change
    (e.g. addition of a function).
    Incrementing the third component means a noteworthy binary compatible
    change (e.g. encoder bug fix that matters for the decoder).
1298
@item
1299 1300 1301 1302 1303
    If you add a new codec, remember to update the changelog, add it to
    the supported codecs table in the documentation and bump the second
    component of the @file{libavcodec} version number appropriately. If
    it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
    is only a decoder.
D
Diego Biurrun 已提交
1304
@end enumerate
M
Michael Niedermayer 已提交
1305 1306 1307 1308 1309 1310

We think our rules are not too hard. If you have comments, contact us.

Note, these rules are mostly borrowed from the MPlayer project.

@subsection Renaming/moving files or content of files
D
Diego Biurrun 已提交
1311
  You CANNOT do that. Post a request for such a change to the mailing list
M
Michael Niedermayer 已提交
1312 1313
  Do NOT remove & readd a file - it will kill the changelog!!!!

1314 1315
@section Submitting patches

1316 1317
First, (@pxref{Coding Rules}) above if you didn't yet.

1318
When you submit your patch, try to send a unified diff (diff '-up'
1319 1320
option). I cannot read other diffs :-)

1321
Also please do not submit patches which contain several unrelated changes.
1322
Split them into individual self-contained patches; this makes reviewing
1323 1324
them much easier.

1325
Run the regression tests before submitting a patch so that you can
1326
verify that there are no big problems.
1327 1328

Patches should be posted as base64 encoded attachments (or any other
D
Diego Biurrun 已提交
1329
encoding which ensures that the patch won't be trashed during
1330
transmission) to the ffmpeg-devel mailing list, see
1331
@url{http://www1.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
1332

1333
It also helps quite a bit if you tell us what the patch does (for example
D
Diego Biurrun 已提交
1334
'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
1335 1336
and has no lrint()')

D
Diego Biurrun 已提交
1337 1338
We reply to all submitted patches and either apply or reject with some
explanation why, but sometimes we are quite busy so it can take a week or two.
1339

1340 1341
@section Regression tests

D
Diego Biurrun 已提交
1342
Before submitting a patch (or committing to CVS), you should at least
1343 1344
test that you did not break anything.

D
Diego Biurrun 已提交
1345 1346
The regression tests build a synthetic video stream and a synthetic
audio stream. These are then encoded and decoded with all codecs or
1347
formats. The CRC (or MD5) of each generated file is recorded in a
D
Diego Biurrun 已提交
1348
result file. A 'diff' is launched to compare the reference results and
1349 1350
the result file.

D
Diego Biurrun 已提交
1351
The regression tests then go on to test the FFserver code with a
1352 1353 1354
limited set of streams. It is important that this step runs correctly
as well.

1355
Run 'make test' to test all the codecs and formats.
1356

D
Diego Biurrun 已提交
1357
Run 'make fulltest' to test all the codecs, formats and FFserver.
1358

D
Diego Biurrun 已提交
1359 1360
[Of course, some patches may change the results of the regression tests. In
this case, the reference results of the regression tests shall be modified
1361 1362 1363
accordingly].

@bye