Theora encoding via libtheora.
[libav.git] / doc / ffmpeg-doc.texi
CommitLineData
9181577c
FB
1\input texinfo @c -*- texinfo -*-
2
3@settitle FFmpeg Documentation
4@titlepage
5@sp 7
6@center @titlefont{FFmpeg Documentation}
7@sp 3
8@end titlepage
9
10
11@chapter Introduction
12
13FFmpeg is a very fast video and audio converter. It can also grab from
14a live audio/video source.
115329f1 15
9181577c 16The command line interface is designed to be intuitive, in the sense
4c5f7207
DB
17that FFmpeg tries to figure out all parameters that can possibly be
18derived automatically. You usually only have to specify the target
19bitrate you want.
9181577c
FB
20
21FFmpeg can also convert from any sample rate to any other, and resize
22video on the fly with a high quality polyphase filter.
23
24@chapter Quick Start
25
e99c4e10 26@c man begin EXAMPLES
9181577c
FB
27@section Video and Audio grabbing
28
e99c4e10
FB
29FFmpeg can use a video4linux compatible video source and any Open Sound
30System audio source:
31
9181577c 32@example
115329f1 33ffmpeg /tmp/out.mpg
9181577c
FB
34@end example
35
e99c4e10 36Note that you must activate the right video source and channel before
4c5f7207
DB
37launching FFmpeg with any TV viewer such as xawtv
38(@url{http://bytesex.org/xawtv/}) by Gerd Knorr. You also
39have to set the audio recording levels correctly with a
e99c4e10 40standard mixer.
9181577c 41
76d2efda
BC
42@section X11 grabbing
43
913e4081 44FFmpeg can grab the X11 display.
76d2efda
BC
45
46@example
47ffmpeg -f x11grab -vd x11:0.0 /tmp/out.mpg
48@end example
49
913e4081
DB
500.0 is display.screen number of your X11 server, same as
51the DISPLAY environment variable.
76d2efda 52
0cd4faf9
PI
53@example
54ffmpeg -f x11grab -vd x11:0.0+10,20 /tmp/out.mpg
55@end example
56
570.0 is display.screen number of your X11 server, same as the DISPLAY environment
58variable. 10 is the x-offset and 20 the y-offset for the grabbing.
59
6bf40f39 60@section Video and Audio file format conversion
9181577c 61
4c5f7207 62* FFmpeg can use any supported file format and protocol as input:
9181577c
FB
63
64Examples:
65
4c5f7207 66* You can use YUV files as input:
9181577c
FB
67
68@example
115329f1 69ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
9181577c
FB
70@end example
71
115329f1 72It will use the files:
9181577c 73@example
e99c4e10
FB
74/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
75/tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
9181577c
FB
76@end example
77
e99c4e10
FB
78The Y files use twice the resolution of the U and V files. They are
79raw files, without header. They can be generated by all decent video
80decoders. You must specify the size of the image with the @option{-s} option
4c5f7207 81if FFmpeg cannot guess it.
9181577c 82
4c5f7207 83* You can input from a raw YUV420P file:
9181577c
FB
84
85@example
e99c4e10 86ffmpeg -i /tmp/test.yuv /tmp/out.avi
9181577c
FB
87@end example
88
4c5f7207
DB
89test.yuv is a file containing raw YUV planar data. Each frame is composed
90of the Y plane followed by the U and V planes at half vertical and
e99c4e10 91horizontal resolution.
9181577c 92
4c5f7207 93* You can output to a raw YUV420P file:
9181577c
FB
94
95@example
f926cbe7 96ffmpeg -i mydivx.avi hugefile.yuv
9181577c
FB
97@end example
98
99* You can set several input files and output files:
100
101@example
e99c4e10 102ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
9181577c
FB
103@end example
104
4c5f7207
DB
105Converts the audio file a.wav and the raw YUV video file a.yuv
106to MPEG file a.mpg.
9181577c 107
6bf40f39 108* You can also do audio and video conversions at the same time:
9181577c
FB
109
110@example
e99c4e10 111ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
9181577c
FB
112@end example
113
4c5f7207 114Converts a.wav to MPEG audio at 22050Hz sample rate.
9181577c
FB
115
116* You can encode to several formats at the same time and define a
e99c4e10 117mapping from input stream to output streams:
9181577c
FB
118
119@example
e99c4e10 120ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
9181577c
FB
121@end example
122
4c5f7207
DB
123Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
124file:index' specifies which input stream is used for each output
e99c4e10 125stream, in the order of the definition of output streams.
9181577c
FB
126
127* You can transcode decrypted VOBs
128
129@example
3c0ba870 130ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
9181577c
FB
131@end example
132
4c5f7207
DB
133This is a typical DVD ripping example; the input is a VOB file, the
134output an AVI file with MPEG-4 video and MP3 audio. Note that in this
135command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
136GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
137input video. Furthermore, the audio stream is MP3-encoded so you need
138to enable LAME support by passing @code{--enable-mp3lame} to configure.
139The mapping is particularly useful for DVD transcoding
e99c4e10 140to get the desired audio language.
9181577c 141
4c5f7207 142NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
e99c4e10 143@c man end
9181577c
FB
144
145@chapter Invocation
146
147@section Syntax
148
e99c4e10 149The generic syntax is:
9181577c 150
115329f1 151@example
e99c4e10 152@c man begin SYNOPSIS
28f88dc8 153ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
e99c4e10 154@c man end
9181577c 155@end example
e99c4e10
FB
156@c man begin DESCRIPTION
157If no input file is given, audio/video grabbing is done.
9181577c 158
e99c4e10 159As a general rule, options are applied to the next specified
699e77b1 160file. Therefore, order is important, and you can have the same
8cc62264 161option on the command line multiple times. Each occurrence is
699e77b1
VP
162then applied to the next input or output file.
163
eb10acec 164* To set the video bitrate of the output file to 64kbit/s:
699e77b1
VP
165@example
166ffmpeg -i input.avi -b 64k output.avi
167@end example
168
169* To force the frame rate of the input and output file to 24 fps:
170@example
171ffmpeg -r 24 -i input.avi output.avi
172@end example
173
174* To force the frame rate of the output file to 24 fps:
175@example
176ffmpeg -i input.avi -r 24 output.avi
177@end example
178
179* To force the frame rate of input file to 1 fps and the output file to 24 fps:
180@example
181ffmpeg -r 1 -i input.avi -r 24 output.avi
182@end example
183
184The format option may be needed for raw input files.
9181577c 185
4c5f7207
DB
186By default, FFmpeg tries to convert as losslessly as possible: It
187uses the same audio and video parameters for the outputs as the one
e99c4e10
FB
188specified for the inputs.
189@c man end
9181577c 190
e99c4e10 191@c man begin OPTIONS
9181577c
FB
192@section Main options
193
e99c4e10 194@table @option
9181577c 195@item -L
4c5f7207 196Show license.
18bff752 197
9181577c 198@item -h
4c5f7207 199Show help.
18bff752 200
4386f941
DB
201@item -version
202Show version.
203
e99c4e10 204@item -formats
4c5f7207 205Show available formats, codecs, protocols, ...
18bff752 206
115329f1 207@item -f fmt
4c5f7207 208Force format.
18bff752 209
115329f1 210@item -i filename
4c5f7207 211input filename
9181577c 212
115329f1 213@item -y
4c5f7207 214Overwrite output files.
9181577c 215
115329f1 216@item -t duration
4c5f7207
DB
217Set the recording time in seconds.
218@code{hh:mm:ss[.xxx]} syntax is also supported.
9181577c 219
4386f941
DB
220@item -fs limit_size
221Set the file size limit.
222
e83a84ac 223@item -ss position
4c5f7207
DB
224Seek to given time position in seconds.
225@code{hh:mm:ss[.xxx]} syntax is also supported.
e83a84ac 226
4386f941
DB
227@item -itsoffset offset
228Set the input time offset in seconds.
229@code{[-]hh:mm:ss[.xxx]} syntax is also supported.
230This option affects all the input files that follow it.
231The offset is added to the timestamps of the input files.
232Specifying a positive offset means that the corresponding
233streams are delayed by 'offset' seconds.
234
115329f1 235@item -title string
4c5f7207 236Set the title.
9181577c 237
4386f941
DB
238@item -timestamp time
239Set the timestamp.
240
115329f1 241@item -author string
4c5f7207 242Set the author.
9181577c 243
115329f1 244@item -copyright string
4c5f7207 245Set the copyright.
9181577c 246
115329f1 247@item -comment string
4c5f7207 248Set the comment.
9181577c 249
4386f941
DB
250@item -album string
251Set the album.
252
ec1b10f4
PI
253@item -track number
254Set the track.
255
256@item -year number
257Set the year.
258
4386f941
DB
259@item -v verbose
260Control amount of logging.
261
99db6420 262@item -target type
4386f941 263Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd",
4c5f7207
DB
264"ntsc-svcd", ... ). All the format options (bitrate, codecs,
265buffer sizes) are then set automatically. You can just type:
99db6420
FB
266
267@example
268ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
269@end example
270
4c5f7207
DB
271Nevertheless you can specify additional options as long as you know
272they do not conflict with the standard, as in:
791d8d1d
MB
273
274@example
275ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
276@end example
277
4386f941
DB
278@item -dframes number
279Set the number of data frames to record.
280
281@item -scodec codec
282Force subtitle codec ('copy' to copy stream).
283
284@item -newsubtitle
285Add a new subtitle stream to the current output stream.
286
287@item -slang code
288Set the ISO 639 language code (3 letters) of the current subtitle stream.
401fbdde 289
9181577c
FB
290@end table
291
292@section Video Options
293
e99c4e10 294@table @option
9181577c 295@item -b bitrate
3c0ba870 296Set the video bitrate in bit/s (default = 200 kb/s).
4386f941
DB
297@item -vframes number
298Set the number of video frames to record.
115329f1 299@item -r fps
4386f941 300Set frame rate (Hz value, fraction or abbreviation), (default = 25).
115329f1 301@item -s size
4c5f7207
DB
302Set frame size. The format is @samp{wxh} (default = 160x128).
303The following abbreviations are recognized:
5ee03c86 304@table @samp
18bff752
FB
305@item sqcif
306128x96
307@item qcif
308176x144
309@item cif
310352x288
311@item 4cif
312704x576
313@end table
314
315@item -aspect aspect
4c5f7207 316Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
18bff752 317@item -croptop size
4c5f7207 318Set top crop band size (in pixels).
18bff752 319@item -cropbottom size
4c5f7207 320Set bottom crop band size (in pixels).
18bff752 321@item -cropleft size
4c5f7207 322Set left crop band size (in pixels).
18bff752 323@item -cropright size
4c5f7207 324Set right crop band size (in pixels).
1ff93ffc 325@item -padtop size
4c5f7207 326Set top pad band size (in pixels).
1ff93ffc 327@item -padbottom size
4c5f7207 328Set bottom pad band size (in pixels).
1ff93ffc 329@item -padleft size
4c5f7207 330Set left pad band size (in pixels).
1ff93ffc 331@item -padright size
4c5f7207 332Set right pad band size (in pixels).
5b79a73e 333@item -padcolor (hex color)
4c5f7207
DB
334Set color of padded bands. The value for padcolor is expressed
335as a six digit hexadecimal number where the first two digits
336represent red, the middle two digits green and last two digits
337blue (default = 000000 (black)).
9181577c 338@item -vn
4c5f7207 339Disable video recording.
115329f1 340@item -bt tolerance
dc5ee8bc 341Set video bitrate tolerance (in bit/s).
18bff752 342@item -maxrate bitrate
a5515106 343Set max video bitrate tolerance (in bit/s).
18bff752 344@item -minrate bitrate
a5515106 345Set min video bitrate tolerance (in bit/s).
18bff752 346@item -bufsize size
81d0618f 347Set rate control buffer size (in bits).
115329f1 348@item -vcodec codec
4c5f7207 349Force video codec to @var{codec}. Use the @code{copy} special value to
5ee03c86 350tell that the raw codec data must be copied as is.
18bff752 351@item -sameq
4c5f7207 352Use same video quality as source (implies VBR).
9181577c 353
115329f1 354@item -pass n
4c5f7207
DB
355Select the pass number (1 or 2). It is useful to do two pass
356encoding. The statistics of the video are recorded in the first
357pass and the video is generated at the exact requested bitrate
358in the second pass.
9181577c 359
115329f1 360@item -passlogfile file
4c5f7207 361Set two pass logfile name to @var{file}.
9181577c 362
4386f941
DB
363@item -newvideo
364Add a new video stream to the current output stream.
365
9181577c
FB
366@end table
367
18bff752 368@section Advanced Video Options
9181577c 369
e99c4e10 370@table @option
4386f941
DB
371@item -pix_fmt format
372Set pixel format.
115329f1 373@item -g gop_size
4c5f7207 374Set the group of pictures size.
115329f1 375@item -intra
4c5f7207 376Use only intra frames.
4386f941
DB
377@item -vdt n
378Discard threshold.
115329f1 379@item -qscale q
4bef236b 380Use fixed video quantizer scale (VBR).
115329f1 381@item -qmin q
4bef236b 382minimum video quantizer scale (VBR)
115329f1 383@item -qmax q
4bef236b 384maximum video quantizer scale (VBR)
115329f1 385@item -qdiff q
4bef236b 386maximum difference between the quantizer scales (VBR)
115329f1 387@item -qblur blur
4bef236b 388video quantizer scale blur (VBR)
115329f1 389@item -qcomp compression
4bef236b 390video quantizer scale compression (VBR)
18bff752 391
9ae711e1
VP
392@item -lmin lambda
393minimum video lagrange factor (VBR)
394@item -lmax lambda
395max video lagrange factor (VBR)
396@item -mblmin lambda
397minimum macroblock quantizer scale (VBR)
398@item -mblmax lambda
399maximum macroblock quantizer scale (VBR)
400
401These four options (lmin, lmax, mblmin, mblmax) use 'lambda' units,
402but you may use the QP2LAMBDA constant to easily convert from 'q' units:
403@example
404ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
405@end example
406
18bff752 407@item -rc_init_cplx complexity
4c5f7207 408initial complexity for single pass encoding
18bff752 409@item -b_qfactor factor
4c5f7207 410qp factor between P- and B-frames
18bff752 411@item -i_qfactor factor
4c5f7207 412qp factor between P- and I-frames
18bff752 413@item -b_qoffset offset
4c5f7207 414qp offset between P- and B-frames
18bff752 415@item -i_qoffset offset
4c5f7207 416qp offset between P- and I-frames
18bff752 417@item -rc_eq equation
4c5f7207
DB
418Set rate control equation (@pxref{FFmpeg formula
419evaluator}) (default = @code{tex^qComp}).
5ee03c86
FB
420@item -rc_override override
421rate control override for specific intervals
18bff752 422@item -me method
4c5f7207
DB
423Set motion estimation method to @var{method}.
424Available methods are (from lowest to best quality):
18bff752
FB
425@table @samp
426@item zero
5ee03c86 427Try just the (0, 0) vector.
18bff752
FB
428@item phods
429@item log
430@item x1
431@item epzs
432(default method)
433@item full
434exhaustive search (slow and marginally better than epzs)
435@end table
436
437@item -dct_algo algo
4c5f7207 438Set DCT algorithm to @var{algo}. Available values are:
18bff752
FB
439@table @samp
440@item 0
441FF_DCT_AUTO (default)
442@item 1
443FF_DCT_FASTINT
444@item 2
445FF_DCT_INT
446@item 3
447FF_DCT_MMX
448@item 4
449FF_DCT_MLIB
450@item 5
451FF_DCT_ALTIVEC
452@end table
453
454@item -idct_algo algo
4c5f7207 455Set IDCT algorithm to @var{algo}. Available values are:
18bff752
FB
456@table @samp
457@item 0
458FF_IDCT_AUTO (default)
459@item 1
115329f1 460FF_IDCT_INT
18bff752 461@item 2
115329f1 462FF_IDCT_SIMPLE
18bff752 463@item 3
115329f1 464FF_IDCT_SIMPLEMMX
18bff752 465@item 4
115329f1 466FF_IDCT_LIBMPEG2MMX
18bff752 467@item 5
115329f1 468FF_IDCT_PS2
18bff752 469@item 6
115329f1 470FF_IDCT_MLIB
18bff752 471@item 7
115329f1 472FF_IDCT_ARM
18bff752 473@item 8
115329f1 474FF_IDCT_ALTIVEC
18bff752 475@item 9
115329f1 476FF_IDCT_SH4
18bff752 477@item 10
115329f1 478FF_IDCT_SIMPLEARM
18bff752
FB
479@end table
480
481@item -er n
4c5f7207 482Set error resilience to @var{n}.
18bff752 483@table @samp
115329f1 484@item 1
1471c6c2 485FF_ER_CAREFUL (default)
18bff752 486@item 2
5ee03c86 487FF_ER_COMPLIANT
18bff752
FB
488@item 3
489FF_ER_AGGRESSIVE
490@item 4
491FF_ER_VERY_AGGRESSIVE
492@end table
493
5ee03c86 494@item -ec bit_mask
4c5f7207 495Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
5ee03c86 496the following values:
18bff752
FB
497@table @samp
498@item 1
4c5f7207 499FF_EC_GUESS_MVS (default = enabled)
18bff752 500@item 2
4c5f7207 501FF_EC_DEBLOCK (default = enabled)
18bff752
FB
502@end table
503
504@item -bf frames
4c5f7207 505Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
18bff752
FB
506@item -mbd mode
507macroblock decision
508@table @samp
509@item 0
4c5f7207 510FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg).
18bff752 511@item 1
4c5f7207 512FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
18bff752 513@item 2
019c8838 514FF_MB_DECISION_RD: rate distortion
18bff752
FB
515@end table
516
517@item -4mv
4c5f7207 518Use four motion vector by macroblock (MPEG-4 only).
18bff752 519@item -part
4c5f7207 520Use data partitioning (MPEG-4 only).
18bff752 521@item -bug param
4c5f7207 522Work around encoder bugs that are not auto-detected.
18bff752 523@item -strict strictness
4c5f7207 524How strictly to follow the standards.
5ee03c86 525@item -aic
4c5f7207 526Enable Advanced intra coding (h263+).
5ee03c86 527@item -umv
4c5f7207 528Enable Unlimited Motion Vector (h263+)
18bff752
FB
529
530@item -deinterlace
4c5f7207 531Deinterlace pictures.
3841e813 532@item -ilme
4c5f7207
DB
533Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
534Use this option if your input file is interlaced and you want
535to keep the interlaced format for minimum losses.
536The alternative is to deinterlace the input stream with
537@option{-deinterlace}, but deinterlacing introduces losses.
18bff752 538@item -psnr
4c5f7207 539Calculate PSNR of compressed frames.
18bff752 540@item -vstats
4c5f7207 541Dump video coding statistics to @file{vstats_HHMMSS.log}.
18bff752 542@item -vhook module
4c5f7207 543Insert video processing @var{module}. @var{module} contains the module
18bff752 544name and its parameters separated by spaces.
4386f941
DB
545@item -top n
546top=1/bottom=0/auto=-1 field first
547@item -dc precision
548Intra_dc_precision.
549@item -vtag fourcc/tag
550Force video tag/fourcc.
551@item -qphist
552Show QP histogram.
553@item -vbsf bitstream filter
554Bitstream filters available are "dump_extra", "remove_extra", "noise".
18bff752
FB
555@end table
556
557@section Audio Options
558
559@table @option
4386f941
DB
560@item -aframes number
561Set the number of audio frames to record.
115329f1 562@item -ar freq
4c5f7207 563Set the audio sampling frequency (default = 44100 Hz).
115329f1 564@item -ab bitrate
4c5f7207 565Set the audio bitrate in kbit/s (default = 64).
18bff752 566@item -ac channels
4c5f7207 567Set the number of audio channels (default = 1).
5ee03c86 568@item -an
4c5f7207 569Disable audio recording.
5ee03c86 570@item -acodec codec
4c5f7207
DB
571Force audio codec to @var{codec}. Use the @code{copy} special value to
572specify that the raw codec data must be copied as is.
de62a89d 573@item -newaudio
18fd519f
DB
574Add a new audio track to the output file. If you want to specify parameters,
575do so before @code{-newaudio} (@code{-acodec}, @code{-ab}, etc..).
de62a89d 576
18fd519f
DB
577Mapping will be done automatically, if the number of output streams is equal to
578the number of input streams, else it will pick the first one that matches. You
de62a89d
VP
579can override the mapping using @code{-map} as usual.
580
581Example:
582@example
583ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384 test.mpg -acodec mp2 -ab 192 -newaudio
584@end example
4386f941
DB
585@item -alang code
586Set the ISO 639 language code (3 letters) of the current audio stream.
587@end table
588
589@section Advanced Audio options:
590
591@table @option
592@item -atag fourcc/tag
593Force audio tag/fourcc.
594@item -absf bitstream filter
595Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
596@end table
597
598@section Subtitle options:
599
600@table @option
601@item -scodec codec
602Force subtitle codec ('copy' to copy stream).
603@item -newsubtitle
604Add a new subtitle stream to the current output stream.
605@item -slang code
606Set the ISO 639 language code (3 letters) of the current subtitle stream.
18bff752
FB
607@end table
608
609@section Audio/Video grab options
610
611@table @option
612@item -vd device
4c5f7207 613sEt video grab device (e.g. @file{/dev/video0}).
18bff752 614@item -vc channel
4c5f7207 615Set video grab channel (DV1394 only).
18bff752 616@item -tvstd standard
4c5f7207 617Set television standard (NTSC, PAL (SECAM)).
18bff752 618@item -dv1394
4c5f7207 619Set DV1394 grab.
18bff752 620@item -ad device
4c5f7207 621Set audio device (e.g. @file{/dev/dsp}).
4386f941
DB
622@item -grab format
623Request grabbing using.
624@item -gd device
625Set grab device.
18bff752
FB
626@end table
627
628@section Advanced options
629
630@table @option
e645a733
BL
631@item -map input stream id[:input stream id]
632Set stream mapping from input streams to output streams.
633Just enumerate the input streams in the order you want them in the output.
634[input stream id] sets the (input) stream to sync against.
4386f941
DB
635@item -map_meta_data outfile:infile
636Set meta data information of outfile from infile.
18bff752 637@item -debug
4c5f7207 638Print specific debug info.
115329f1 639@item -benchmark
4c5f7207 640Add timings for benchmarking.
4386f941 641@item -dump
4c5f7207 642Dump each input packet.
4386f941
DB
643@item -hex
644When dumping packets, also dump the payload.
18bff752 645@item -bitexact
4c5f7207 646Only use bit exact algorithms (for codec testing).
18bff752 647@item -ps size
4c5f7207 648Set packet size in bits.
5ee03c86 649@item -re
4c5f7207 650Read input at native frame rate. Mainly used to simulate a grab device.
4386f941 651@item -loop_input
4c5f7207
DB
652Loop over the input stream. Currently it works only for image
653streams. This option is used for automatic FFserver testing.
8108551a 654@item -loop_output number_of_times
019c8838 655Repeatedly loop output for formats that support looping such as animated GIF
4c5f7207 656(0 will loop the output infinitely).
4386f941
DB
657@item -threads count
658Thread count.
c52e13f1 659@item -vsync parameter
29c9183c
DB
660Video sync method. Video will be stretched/squeezed to match the timestamps,
661it is done by duplicating and dropping frames. With -map you can select from
662which stream the timestamps should be taken. You can leave either video or
c52e13f1
BL
663audio unchanged and sync the remaining stream(s) to the unchanged one.
664@item -async samples_per_second
29c9183c 665Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
c52e13f1
BL
666the parameter is the maximum samples per second by which the audio is changed.
667-async 1 is a special case where only the start of the audio stream is corrected
668without any later correction.
9181577c 669@end table
18bff752
FB
670
671@node FFmpeg formula evaluator
672@section FFmpeg formula evaluator
673
674When evaluating a rate control string, FFmpeg uses an internal formula
115329f1 675evaluator.
18bff752
FB
676
677The following binary operators are available: @code{+}, @code{-},
678@code{*}, @code{/}, @code{^}.
679
680The following unary operators are available: @code{+}, @code{-},
681@code{(...)}.
682
683The following functions are available:
684@table @var
685@item sinh(x)
686@item cosh(x)
687@item tanh(x)
688@item sin(x)
689@item cos(x)
690@item tan(x)
691@item exp(x)
692@item log(x)
693@item squish(x)
694@item gauss(x)
695@item abs(x)
696@item max(x, y)
697@item min(x, y)
698@item gt(x, y)
699@item lt(x, y)
700@item eq(x, y)
701@item bits2qp(bits)
702@item qp2bits(qp)
703@end table
704
705The following constants are available:
706@table @var
707@item PI
708@item E
709@item iTex
710@item pTex
711@item tex
712@item mv
713@item fCode
714@item iCount
715@item mcVar
716@item var
717@item isI
718@item isP
719@item isB
720@item avgQP
721@item qComp
722@item avgIITex
723@item avgPITex
724@item avgPPTex
725@item avgBPTex
726@item avgTex
727@end table
728
e99c4e10
FB
729@c man end
730
731@ignore
732
733@setfilename ffmpeg
734@settitle FFmpeg video converter
735
736@c man begin SEEALSO
019c8838 737ffserver(1), ffplay(1) and the HTML documentation of @file{ffmpeg}.
e99c4e10
FB
738@c man end
739
740@c man begin AUTHOR
741Fabrice Bellard
742@c man end
743
744@end ignore
9181577c
FB
745
746@section Protocols
747
4c5f7207
DB
748The filename can be @file{-} to read from standard input or to write
749to standard output.
9181577c 750
4c5f7207 751FFmpeg also handles many protocols specified with an URL syntax.
9181577c 752
4c5f7207 753Use 'ffmpeg -formats' to see a list of the supported protocols.
9181577c 754
e99c4e10 755The protocol @code{http:} is currently used only to communicate with
4c5f7207 756FFserver (see the FFserver documentation). When FFmpeg will be a
e99c4e10 757video player it will also be used for streaming :-)
9181577c
FB
758
759@chapter Tips
760
761@itemize
4c5f7207
DB
762@item For streaming at very low bitrate application, use a low frame rate
763and a small GOP size. This is especially true for RealVideo where
e99c4e10
FB
764the Linux player does not seem to be very fast, so it can miss
765frames. An example is:
9181577c
FB
766
767@example
3c0ba870 768ffmpeg -g 3 -r 3 -t 10 -b 50k -s qcif -f rv10 /tmp/b.rm
9181577c
FB
769@end example
770
771@item The parameter 'q' which is displayed while encoding is the current
4c5f7207
DB
772quantizer. The value 1 indicates that a very good quality could
773be achieved. The value 31 indicates the worst quality. If q=31 appears
e99c4e10 774too often, it means that the encoder cannot compress enough to meet
4c5f7207 775your bitrate. You must either increase the bitrate, decrease the
e99c4e10 776frame rate or decrease the frame size.
9181577c
FB
777
778@item If your computer is not fast enough, you can speed up the
e99c4e10
FB
779compression at the expense of the compression ratio. You can use
780'-me zero' to speed up motion estimation, and '-intra' to disable
4c5f7207 781motion estimation completely (you have only I-frames, which means it
e99c4e10 782is about as good as JPEG compression).
9181577c 783
4c5f7207 784@item To have very low audio bitrates, reduce the sampling frequency
019c8838 785(down to 22050 kHz for MPEG audio, 22050 or 11025 for AC3).
9181577c
FB
786
787@item To have a constant quality (but a variable bitrate), use the option
e99c4e10
FB
788'-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
789quality).
9181577c
FB
790
791@item When converting video files, you can use the '-sameq' option which
4c5f7207
DB
792uses the same quality factor in the encoder as in the decoder.
793It allows almost lossless encoding.
9181577c
FB
794
795@end itemize
796
47404f9f
DB
797
798@chapter external libraries
799
800FFmpeg can be hooked up with a number of external libraries to add support
801for more formats.
802
803@section AMR
804
805AMR comes in two different flavors, WB and NB. FFmpeg can make use of the
806AMR WB (floating-point mode) and the AMR NB (both floating-point and
807fixed-point mode) reference decoders and encoders.
808
809@itemize
810
811@item For AMR WB floating-point download TS26.204 V5.1.0 from
812@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip}
813and extract the source to @file{libavcodec/amrwb_float/}.
814
815@item For AMR NB floating-point download TS26.104 REL-5 V5.1.0 from
816@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip}
817and extract the source to @file{libavcodec/amr_float/}.
818If you try this on Alpha, you may need to change @code{Word32} to
819@code{int} in @file{amr/typedef.h}.
820
821@item For AMR NB fixed-point download TS26.073 REL-5 V5.1.0 from
822@url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip}
823and extract the source to @file{libavcodec/amr}.
824You must also add @code{-DMMS_IO} and remove @code{-pedantic-errors}
825to/from @code{CFLAGS} in @file{libavcodec/amr/makefile}, i.e.
826``@code{CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO}''.
827
828@end itemize
829
830
9181577c
FB
831@chapter Supported File Formats and Codecs
832
833You can use the @code{-formats} option to have an exhaustive list.
834
835@section File Formats
836
6bf40f39 837FFmpeg supports the following file formats through the @code{libavformat}
0699d2fe 838library:
9181577c 839
3fc9e78f 840@multitable @columnfractions .4 .1 .1 .4
9181577c
FB
841@item Supported File Format @tab Encoding @tab Decoding @tab Comments
842@item MPEG audio @tab X @tab X
4c5f7207 843@item MPEG-1 systems @tab X @tab X
9181577c 844@tab muxed audio and video
4c5f7207 845@item MPEG-2 PS @tab X @tab X
9181577c 846@tab also known as @code{VOB} file
4c5f7207 847@item MPEG-2 TS @tab @tab X
9181577c 848@tab also known as DVB Transport Stream
115329f1
DB
849@item ASF@tab X @tab X
850@item AVI@tab X @tab X
851@item WAV@tab X @tab X
9181577c 852@item Macromedia Flash@tab X @tab X
4c5f7207 853@tab Only embedded audio is decoded.
2eb5d024
FB
854@item FLV @tab X @tab X
855@tab Macromedia Flash video files
115329f1
DB
856@item Real Audio and Video @tab X @tab X
857@item Raw AC3 @tab X @tab X
858@item Raw MJPEG @tab X @tab X
859@item Raw MPEG video @tab X @tab X
860@item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
861@item Raw CRI ADX audio @tab X @tab X
862@item Raw Shorten audio @tab @tab X
863@item SUN AU format @tab X @tab X
7fe4c823 864@item NUT @tab X @tab X @tab NUT Open Container Format
115329f1 865@item QuickTime @tab X @tab X
4c5f7207
DB
866@item MPEG-4 @tab X @tab X
867@tab MPEG-4 is a variant of QuickTime.
115329f1 868@item Raw MPEG4 video @tab X @tab X
4fa1c4fa 869@item DV @tab X @tab X
701b603d 870@item 4xm @tab @tab X
4c5f7207 871@tab 4X Technologies format, used in some games.
4d3b1f8d
MM
872@item Playstation STR @tab @tab X
873@item Id RoQ @tab @tab X
4c5f7207 874@tab Used in Quake III, Jedi Knight 2, other computer games.
4d3b1f8d 875@item Interplay MVE @tab @tab X
4c5f7207 876@tab Format used in various Interplay computer games.
b17e9c99 877@item WC3 Movie @tab @tab X
4c5f7207 878@tab Multimedia format used in Origin's Wing Commander III computer game.
2fdf638b 879@item Sega FILM/CPK @tab @tab X
4c5f7207 880@tab Used in many Sega Saturn console games.
2fdf638b 881@item Westwood Studios VQA/AUD @tab @tab X
4c5f7207 882@tab Multimedia formats used in Westwood Studios games.
4120a53a 883@item Id Cinematic (.cin) @tab @tab X
4c5f7207 884@tab Used in Quake II.
42cad81a
MM
885@item FLIC format @tab @tab X
886@tab .fli/.flc files
da00f30e 887@item Sierra VMD @tab @tab X
4c5f7207 888@tab Used in Sierra CD-ROM games.
d08d7142 889@item Sierra Online @tab @tab X
4c5f7207 890@tab .sol files used in Sierra Online games.
38088adf 891@item Matroska @tab @tab X
ad81a9fe 892@item Electronic Arts Multimedia @tab @tab X
4c5f7207 893@tab Used in various EA games; files have extensions like WVE and UV2.
353147ed 894@item Nullsoft Video (NSV) format @tab @tab X
4accd1fd 895@item ADTS AAC audio @tab X @tab X
ea395e8c 896@item Creative VOC @tab X @tab X @tab Created for the Sound Blaster Pro.
4e114829
MM
897@item American Laser Games MM @tab @tab X
898@tab Multimedia format used in games like Mad Dog McCree
26376701
MM
899@item AVS @tab @tab X
900@tab Multimedia format used by the Creature Shock game.
348efc18
KS
901@item Smacker @tab @tab X
902@tab Multimedia format used by many games.
d7a3a783
BC
903@item GXF @tab X @tab X
904@tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley playout servers.
dc56e0de
BC
905@item CIN @tab @tab X
906@tab Multimedia format used by Delphine Software games.
f3239539
BC
907@item MXF @tab @tab X
908@tab Material eXchange Format SMPTE 377M, used by D-Cinema, broadcast industry.
29f86228
BC
909@item SEQ @tab @tab X
910@tab Tiertex .seq files used in the DOS CDROM version of the game Flashback.
353147ed 911@end multitable
9181577c 912
4c5f7207 913@code{X} means that encoding (resp. decoding) is supported.
9181577c 914
0699d2fe
FB
915@section Image Formats
916
917FFmpeg can read and write images for each frame of a video sequence. The
918following image formats are supported:
919
3fc9e78f 920@multitable @columnfractions .4 .1 .1 .4
0699d2fe 921@item Supported Image Format @tab Encoding @tab Decoding @tab Comments
115329f1 922@item PGM, PPM @tab X @tab X
4c5f7207 923@item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support.
2eb5d024 924@item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
4c5f7207
DB
925@item JPEG @tab X @tab X @tab Progressive JPEG is not supported.
926@item .Y.U.V @tab X @tab X @tab one raw file per component
927@item animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated.
928@item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet.
3689cf16 929@item Targa @tab @tab X @tab Targa (.TGA) image format.
a991b1fe 930@item TIFF @tab @tab X @tab Only 24 bit/pixel images are supported.
6a91ec51 931@item SGI @tab X @tab X @tab SGI RGB image format
0699d2fe
FB
932@end multitable
933
4c5f7207 934@code{X} means that encoding (resp. decoding) is supported.
0699d2fe 935
9181577c
FB
936@section Video Codecs
937
3fc9e78f 938@multitable @columnfractions .4 .1 .1 .4
9181577c 939@item Supported Codec @tab Encoding @tab Decoding @tab Comments
4c5f7207
DB
940@item MPEG-1 video @tab X @tab X
941@item MPEG-2 video @tab X @tab X
2bc5da7b 942@item MPEG-4 @tab X @tab X
9181577c
FB
943@item MSMPEG4 V1 @tab X @tab X
944@item MSMPEG4 V2 @tab X @tab X
2bc5da7b 945@item MSMPEG4 V3 @tab X @tab X
9181577c 946@item WMV7 @tab X @tab X
4c5f7207 947@item WMV8 @tab X @tab X @tab not completely working
17a21f3c
DB
948@item WMV9 @tab @tab X @tab not completely working
949@item VC1 @tab @tab X
b06b45c4 950@item H.261 @tab X @tab X
4c5f7207 951@item H.263(+) @tab X @tab X @tab also known as RealVideo 1.0
b06b45c4 952@item H.264 @tab @tab X
e839a994
DB
953@item RealVideo 1.0 @tab X @tab X
954@item RealVideo 2.0 @tab X @tab X
115329f1 955@item MJPEG @tab X @tab X
4c5f7207 956@item lossless MJPEG @tab X @tab X
26d6d032 957@item JPEG-LS @tab X @tab X @tab fourcc: MJLS, lossless and near-lossless is supported
d6896c49
AB
958@item Apple MJPEG-B @tab @tab X
959@item Sunplus MJPEG @tab @tab X @tab fourcc: SP5X
115329f1 960@item DV @tab X @tab X
4c5f7207
DB
961@item HuffYUV @tab X @tab X
962@item FFmpeg Video 1 @tab X @tab X @tab experimental lossless codec (fourcc: FFV1)
963@item FFmpeg Snow @tab X @tab X @tab experimental wavelet codec (fourcc: SNOW)
701b603d 964@item Asus v1 @tab X @tab X @tab fourcc: ASV1
4d3b1f8d 965@item Asus v2 @tab X @tab X @tab fourcc: ASV2
701b603d 966@item Creative YUV @tab @tab X @tab fourcc: CYUV
d2bfadc0 967@item Sorenson Video 1 @tab X @tab X @tab fourcc: SVQ1
701b603d
MM
968@item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
969@item On2 VP3 @tab @tab X @tab still experimental
5ce117c3 970@item On2 VP5 @tab @tab X @tab fourcc: VP50
9110a0e3 971@item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62
150d2772 972@item Theora @tab X @tab X @tab still experimental
cdb2c1ca 973@item Intel Indeo 3 @tab @tab X
9303d49c 974@item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
0919e788 975@item Flash Screen Video @tab @tab X @tab fourcc: FSV1
4d3b1f8d 976@item ATI VCR1 @tab @tab X @tab fourcc: VCR1
7fe4c823 977@item ATI VCR2 @tab @tab X @tab fourcc: VCR2
4d3b1f8d 978@item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
4c5f7207 979@item 4X Video @tab @tab X @tab Used in certain computer games.
115329f1 980@item Sony Playstation MDEC @tab @tab X
4c5f7207
DB
981@item Id RoQ @tab @tab X @tab Used in Quake III, Jedi Knight 2, other computer games.
982@item Xan/WC3 @tab @tab X @tab Used in Wing Commander III .MVE files.
983@item Interplay Video @tab @tab X @tab Used in Interplay .MVE files.
070ed1bc 984@item Apple Animation @tab @tab X @tab fourcc: 'rle '
42cad81a 985@item Apple Graphics @tab @tab X @tab fourcc: 'smc '
2fdf638b 986@item Apple Video @tab @tab X @tab fourcc: rpza
d08d7142 987@item Apple QuickDraw @tab @tab X @tab fourcc: qdrw
2fdf638b
MM
988@item Cinepak @tab @tab X
989@item Microsoft RLE @tab @tab X
990@item Microsoft Video-1 @tab @tab X
4120a53a 991@item Westwood VQA @tab @tab X
4c5f7207 992@item Id Cinematic Video @tab @tab X @tab Used in Quake II.
1dc1ed99 993@item Planar RGB @tab @tab X @tab fourcc: 8BPS
42cad81a 994@item FLIC video @tab @tab X
9a4117d5 995@item Duck TrueMotion v1 @tab @tab X @tab fourcc: DUCK
dce76c20 996@item Duck TrueMotion v2 @tab @tab X @tab fourcc: TM20
4c5f7207 997@item VMD Video @tab @tab X @tab Used in Sierra VMD files.
a273bbfb
RT
998@item MSZH @tab @tab X @tab Part of LCL
999@item ZLIB @tab X @tab X @tab Part of LCL, encoder experimental
9d53d58e 1000@item TechSmith Camtasia @tab @tab X @tab fourcc: TSCC
d0a0bbd2 1001@item IBM Ultimotion @tab @tab X @tab fourcc: ULTI
ab711b3c 1002@item Miro VideoXL @tab @tab X @tab fourcc: VIXL
acfd8f0f 1003@item QPEG @tab @tab X @tab fourccs: QPEG, Q1.0, Q1.1
115329f1
DB
1004@item LOCO @tab @tab X @tab
1005@item Winnov WNV1 @tab @tab X @tab
589f8220 1006@item Autodesk Animator Studio Codec @tab @tab X @tab fourcc: AASC
115329f1 1007@item Fraps FPS1 @tab @tab X @tab
2b6c1d80 1008@item CamStudio @tab @tab X @tab fourcc: CSCD
4e114829 1009@item American Laser Games Video @tab @tab X @tab Used in games like Mad Dog McCree
f48d6e1b 1010@item ZMBV @tab X @tab X @tab Encoder works only on PAL8
26376701 1011@item AVS Video @tab @tab X @tab Video encoding used by the Creature Shock game.
348efc18 1012@item Smacker Video @tab @tab X @tab Video encoding used in Smacker.
dfca23e3 1013@item RTjpeg @tab @tab X @tab Video encoding used in NuppelVideo files.
fd7b1991 1014@item KMVC @tab @tab X @tab Codec used in Worms games.
eb57c889 1015@item VMware Video @tab @tab X @tab Codec used in videos captured by VMware.
dc56e0de 1016@item Cin Video @tab @tab X @tab Codec used in Delphine Software games.
29f86228 1017@item Tiertex Seq Video @tab @tab X @tab Codec used in DOS CDROM FlashBack game.
9181577c
FB
1018@end multitable
1019
4c5f7207 1020@code{X} means that encoding (resp. decoding) is supported.
9181577c
FB
1021
1022@section Audio Codecs
1023
1024@multitable @columnfractions .4 .1 .1 .1 .7
1025@item Supported Codec @tab Encoding @tab Decoding @tab Comments
115329f1 1026@item MPEG audio layer 2 @tab IX @tab IX
9181577c 1027@item MPEG audio layer 1/3 @tab IX @tab IX
4c5f7207 1028@tab MP3 encoding is supported through the external library LAME.
37776c3b 1029@item AC3 @tab IX @tab IX
4c5f7207 1030@tab liba52 is used internally for decoding.
34d7008d 1031@item Vorbis @tab X @tab X
4745b5bf 1032@item WMA V1/V2 @tab @tab X
f6fa7a6c 1033@item AAC @tab X @tab X
4c5f7207 1034@tab Supported through the external library libfaac/libfaad.
d4c3c5a6 1035@item Microsoft ADPCM @tab X @tab X
4d3b1f8d
MM
1036@item MS IMA ADPCM @tab X @tab X
1037@item QT IMA ADPCM @tab @tab X
1038@item 4X IMA ADPCM @tab @tab X
d4e437df 1039@item G.726 ADPCM @tab X @tab X
b17e9c99 1040@item Duck DK3 IMA ADPCM @tab @tab X
4c5f7207 1041@tab Used in some Sega Saturn console games.
b17e9c99 1042@item Duck DK4 IMA ADPCM @tab @tab X
4c5f7207 1043@tab Used in some Sega Saturn console games.
2fdf638b 1044@item Westwood Studios IMA ADPCM @tab @tab X
4c5f7207 1045@tab Used in Westwood Studios games like Command and Conquer.
7d8379f2 1046@item SMJPEG IMA ADPCM @tab @tab X
4c5f7207 1047@tab Used in certain Loki game ports.
42cad81a
MM
1048@item CD-ROM XA ADPCM @tab @tab X
1049@item CRI ADX ADPCM @tab X @tab X
4c5f7207 1050@tab Used in Sega Dreamcast games.
7d8379f2 1051@item Electronic Arts ADPCM @tab @tab X
4c5f7207 1052@tab Used in various EA titles.
b3bfb299 1053@item Creative ADPCM @tab @tab X
2433f24f 1054@tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2
2eb5d024
FB
1055@item RA144 @tab @tab X
1056@tab Real 14400 bit/s codec
1057@item RA288 @tab @tab X
1058@tab Real 28800 bit/s codec
37776c3b 1059@item RADnet @tab X @tab IX
4c5f7207 1060@tab Real low bitrate AC3 codec, liba52 is used for decoding.
2eb5d024 1061@item AMR-NB @tab X @tab X
4c5f7207 1062@tab Supported through an external library.
d663a1fd 1063@item AMR-WB @tab X @tab X
4c5f7207 1064@tab Supported through an external library.
2eb5d024 1065@item DV audio @tab @tab X
4d3b1f8d 1066@item Id RoQ DPCM @tab @tab X
4c5f7207 1067@tab Used in Quake III, Jedi Knight 2, other computer games.
4d3b1f8d 1068@item Interplay MVE DPCM @tab @tab X
4c5f7207 1069@tab Used in various Interplay computer games.
b17e9c99 1070@item Xan DPCM @tab @tab X
4c5f7207 1071@tab Used in Origin's Wing Commander IV AVI files.
d08d7142 1072@item Sierra Online DPCM @tab @tab X
4c5f7207 1073@tab Used in Sierra Online game audio files.
d6896c49
AB
1074@item Apple MACE 3 @tab @tab X
1075@item Apple MACE 6 @tab @tab X
13dfd2b9
MM
1076@item FLAC lossless audio @tab @tab X
1077@item Shorten lossless audio @tab @tab X
f770ee03
MM
1078@item Apple lossless audio @tab @tab X
1079@tab QuickTime fourcc 'alac'
33a4d8b1 1080@item FFmpeg Sonic @tab X @tab X
4c5f7207 1081@tab experimental lossy/lossless codec
d9b1c197
RT
1082@item Qdesign QDM2 @tab @tab X
1083@tab there are still some distortions
440e7988
RT
1084@item Real COOK @tab @tab X
1085@tab All versions except 5.1 are supported
e839a994 1086@item DSP Group TrueSpeech @tab @tab X
3dc411c0 1087@item True Audio (TTA) @tab @tab X
348efc18 1088@item Smacker Audio @tab @tab X
730581f3 1089@item WavPack Audio @tab @tab X
dc56e0de
BC
1090@item Cin Audio @tab @tab X
1091@tab Codec used in Delphine Software games.
84ed36da 1092@item Intel Music Coder @tab @tab X
185c7b6b
KS
1093@item Musepack @tab @tab X
1094@tab Only SV7 is supported
9181577c
FB
1095@end multitable
1096
4c5f7207 1097@code{X} means that encoding (resp. decoding) is supported.
9181577c 1098
4c5f7207
DB
1099@code{I} means that an integer-only version is available, too (ensures high
1100performance on systems without hardware floating point support).
9181577c 1101
47d944d2
FB
1102@chapter Platform Specific information
1103
47d944d2
FB
1104@section BSD
1105
21d1cb12
DB
1106BSD make will not build FFmpeg, you need to install and use GNU Make
1107(@file{gmake}).
1108
47d944d2
FB
1109@section Windows
1110
b030b284
FB
1111@subsection Native Windows compilation
1112
1113@itemize
1114@item Install the current versions of MSYS and MinGW from
1115@url{http://www.mingw.org/}. You can find detailed installation
1116instructions in the download section and the FAQ.
1117
4c5f7207 1118@item If you want to test the FFplay, also download
50f52fcd
FB
1119the MinGW development library of SDL 1.2.x
1120(@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
4c5f7207 1121@url{http://www.libsdl.org}. Unpack it in a temporary directory, and
50f52fcd 1122unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
988a9f9e
FB
1123directory. Edit the @file{sdl-config} script so that it gives the
1124correct SDL directory when invoked.
50f52fcd 1125
e926e391 1126@item Extract the current version of FFmpeg.
115329f1 1127
b030b284
FB
1128@item Start the MSYS shell (file @file{msys.bat}).
1129
4c5f7207
DB
1130@item Change to the FFmpeg directory and follow
1131 the instructions of how to compile FFmpeg (file
50f52fcd
FB
1132@file{INSTALL}). Usually, launching @file{./configure} and @file{make}
1133suffices. If you have problems using SDL, verify that
1134@file{sdl-config} can be launched from the MSYS command line.
1135
4c5f7207
DB
1136@item You can install FFmpeg in @file{Program Files/FFmpeg} by typing
1137@file{make install}. Don't forget to copy @file{SDL.dll} to the place
1138you launch @file{ffplay} from.
50f52fcd 1139
b030b284
FB
1140@end itemize
1141
115329f1 1142Notes:
988a9f9e 1143@itemize
50f52fcd 1144
988a9f9e
FB
1145@item The target @file{make wininstaller} can be used to create a
1146Nullsoft based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
4c5f7207 1147must be copied to the FFmpeg directory in order to build the
988a9f9e
FB
1148installer.
1149
4c5f7207 1150@item By using @code{./configure --enable-shared} when configuring FFmpeg,
988a9f9e
FB
1151you can build @file{avcodec.dll} and @file{avformat.dll}. With
1152@code{make install} you install the FFmpeg DLLs and the associated
115329f1 1153headers in @file{Program Files/FFmpeg}.
988a9f9e 1154
4c5f7207
DB
1155@item Visual C++ compatibility: If you used @code{./configure --enable-shared}
1156when configuring FFmpeg, FFmpeg tries to use the Microsoft Visual
988a9f9e 1157C++ @code{lib} tool to build @code{avcodec.lib} and
4c5f7207 1158@code{avformat.lib}. With these libraries you can link your Visual C++
be0efc0c 1159code directly with the FFmpeg DLLs (see below).
988a9f9e
FB
1160
1161@end itemize
b030b284 1162
be0efc0c
MB
1163@subsection Visual C++ compatibility
1164
1165FFmpeg will not compile under Visual C++ -- and it has too many
1166dependencies on the GCC compiler to make a port viable. However,
1167if you want to use the FFmpeg libraries in your own applications,
1168you can still compile those applications using Visual C++. An
1169important restriction to this is that you have to use the
1170dynamically linked versions of the FFmpeg libraries (i.e. the
1171DLLs), and you have to make sure that Visual-C++-compatible
1172import libraries are created during the FFmpeg build process.
1173
1174This description of how to use the FFmpeg libraries with Visual C++ is
1175based on Visual C++ 2005 Express Edition Beta 2. If you have a different
1176version, you might have to modify the procedures slightly.
1177
1178Here are the step-by-step instructions for building the FFmpeg libraries
1179so they can be used with Visual C++:
1180
1181@enumerate
1182
1183@item Install Visual C++ (if you haven't done so already).
1184
1185@item Install MinGW and MSYS as described above.
1186
1187@item Add a call to @file{vcvars32.bat} (which sets up the environment
1188variables for the Visual C++ tools) as the first line of
1189@file{msys.bat}. The standard location for @file{vcvars32.bat} is
1190@file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
1191and the standard location for @file{msys.bat} is
1192@file{C:\msys\1.0\msys.bat}. If this corresponds to your setup, add the
1193following line as the first line of @file{msys.bat}:
1194
1195@code{call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"}
1196
1197@item Start the MSYS shell (file @file{msys.bat}) and type @code{link.exe}.
1198If you get a help message with the command line options of @code{link.exe},
1199this means your environment variables are set up correctly, the
1200Microsoft linker is on the path and will be used by FFmpeg to
1201create Visual-C++-compatible import libraries.
1202
e926e391 1203@item Extract the current version of FFmpeg and change to the FFmpeg directory.
be0efc0c
MB
1204
1205@item Type the command
51d8321d
DB
1206@code{./configure --enable-shared --disable-static --enable-memalign-hack}
1207to configure and, if that didn't produce any errors,
1208type @code{make} to build FFmpeg.
be0efc0c
MB
1209
1210@item The subdirectories @file{libavformat}, @file{libavcodec}, and
1211@file{libavutil} should now contain the files @file{avformat.dll},
1212@file{avformat.lib}, @file{avcodec.dll}, @file{avcodec.lib},
1213@file{avutil.dll}, and @file{avutil.lib}, respectively. Copy the three
1214DLLs to your System32 directory (typically @file{C:\Windows\System32}).
1215
1216@end enumerate
1217
1218And here is how to use these libraries with Visual C++:
1219
1220@enumerate
1221
1222@item Create a new console application ("File / New / Project") and then
1223select "Win32 Console Application". On the appropriate page of the
1224Application Wizard, uncheck the "Precompiled headers" option.
1225
1226@item Write the source code for your application, or, for testing, just
1227copy the code from an existing sample application into the source file
1228that Visual C++ has already created for you. (Note that your source
1229filehas to have a @code{.cpp} extension; otherwise, Visual C++ won't
1230compile the FFmpeg headers correctly because in C mode, it doesn't
1231recognize the @code{inline} keyword.) For example, you can copy
1232@file{output_example.c} from the FFmpeg distribution (but you will
1233have to make minor modifications so the code will compile under
1234C++, see below).
1235
1236@item Open the "Project / Properties" dialog box. In the "Configuration"
1237combo box, select "All Configurations" so that the changes you make will
1238affect both debug and release builds. In the tree view on the left hand
1239side, select "C/C++ / General", then edit the "Additional Include
1240Directories" setting to contain the complete paths to the
1241@file{libavformat}, @file{libavcodec}, and @file{libavutil}
1242subdirectories of your FFmpeg directory. Note that the directories have
1243to be separated using semicolons. Now select "Linker / General" from the
1244tree view and edit the "Additional Library Directories" setting to
1245contain the same three directories.
1246
1247@item Still in the "Project / Properties" dialog box, select "Linker / Input"
1248from the tree view, then add the files @file{avformat.lib},
1249@file{avcodec.lib}, and @file{avutil.lib} to the end of the "Additional
1250Dependencies". Note that the names of the libraries have to be separated
1251using spaces.
1252
765c3440 1253@item Now, select "C/C++ / Code Generation" from the tree view. Select
be0efc0c
MB
1254"Debug" in the "Configuration" combo box. Make sure that "Runtime
1255Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
1256the "Configuration" combo box and make sure that "Runtime Library" is
1257set to "Multi-threaded DLL".
1258
1259@item Click "OK" to close the "Project / Properties" dialog box and build
1260the application. Hopefully, it should compile and run cleanly. If you
1261used @file{output_example.c} as your sample application, you will get a
1262few compiler errors, but they are easy to fix. The first type of error
1263occurs because Visual C++ doesn't allow an @code{int} to be converted to
1264an @code{enum} without a cast. To solve the problem, insert the required
1265casts (this error occurs once for a @code{CodecID} and once for a
1266@code{CodecType}). The second type of error occurs because C++ requires
1267the return value of @code{malloc} to be cast to the exact type of the
1268pointer it is being assigned to. Visual C++ will complain that, for
1269example, @code{(void *)} is being assigned to @code{(uint8_t *)} without
1270an explicit cast. So insert an explicit cast in these places to silence
1271the compiler. The third type of error occurs because the @code{snprintf}
1272library function is called @code{_snprintf} under Visual C++. So just
1273add an underscore to fix the problem. With these changes,
1274@file{output_example.c} should compile under Visual C++, and the
1275resulting executable should produce valid video files.
1276
1277@end enumerate
1278
b030b284
FB
1279@subsection Cross compilation for Windows with Linux
1280
1281You must use the MinGW cross compilation tools available at
1282@url{http://www.mingw.org/}.
1283
4c5f7207 1284Then configure FFmpeg with the following options:
b030b284
FB
1285@example
1286./configure --enable-mingw32 --cross-prefix=i386-mingw32msvc-
1287@end example
019c8838 1288(you can change the cross-prefix according to the prefix chosen for the
b030b284
FB
1289MinGW tools).
1290
4c5f7207 1291Then you can easily test FFmpeg with Wine
b030b284
FB
1292(@url{http://www.winehq.com/}).
1293
30aee296
DB
1294@subsection Compilation under Cygwin
1295
1296Cygwin works very much like Unix.
1297
1298Just install your Cygwin with all the "Base" packages, plus the
1299following "Devel" ones:
1300@example
1301binutils, gcc-core, make, subversion
1302@end example
1303
1304Do not install binutils-20060709-1 (they are buggy on shared builds);
1305use binutils-20050610-1 instead.
1306
1307Then run
1308
1309@example
1310./configure --enable-static --disable-shared
1311@end example
1312
1313to make a static build or
1314
1315@example
1316./configure --enable-shared --disable-static
1317@end example
1318
1319to build shared libraries.
1320
1321If you want to build FFmpeg with additional libraries, download Cygwin
1322"Devel" packages for Ogg and Vorbis from any Cygwin packages repository
1323and/or SDL, xvid, faac, faad2 packages from Cygwin Ports,
1324(@url{http://cygwinports.dotsrc.org/}).
1325
1326@subsection Crosscompilation for Windows under Cygwin
1327
1328With Cygwin you can create Windows binaries that don't need the cygwin1.dll.
1329
1330Just install your Cygwin as explained before, plus these additional
1331"Devel" packages:
1332@example
1333gcc-mingw-core, mingw-runtime, mingw-zlib
1334@end example
1335
1336and add some special flags to your configure invocation.
1337
1338For a static build run
1339@example
1340./configure --enable-mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
1341@end example
1342
1343and for a build with shared libraries
1344@example
1345./configure --enable-mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
1346@end example
1347
47d944d2
FB
1348@section BeOS
1349
1350The configure script should guess the configuration itself.
1351Networking support is currently not finished.
1352errno issues fixed by Andrew Bachmann.
1353
1354Old stuff:
1355
7dd611c9 1356François Revol - revol at free dot fr - April 2002
47d944d2 1357
115329f1 1358The configure script should guess the configuration itself,
4c5f7207 1359however I still didn't test building on the net_server version of BeOS.
47d944d2 1360
4c5f7207 1361FFserver is broken (needs poll() implementation).
47d944d2 1362
4c5f7207 1363There are still issues with errno codes, which are negative in BeOS, and
115329f1 1364that FFmpeg negates when returning. This ends up turning errors into
47d944d2
FB
1365valid results, then crashes.
1366(To be fixed)
1367
34d7008d 1368@chapter Developers Guide
9181577c
FB
1369
1370@section API
a0b72f90 1371@itemize @bullet
9181577c 1372@item libavcodec is the library containing the codecs (both encoding and
4c5f7207 1373decoding). Look at @file{libavcodec/apiexample.c} to see how to use it.
9181577c 1374
4c5f7207
DB
1375@item libavformat is the library containing the file format handling (mux and
1376demux code for several formats). Look at @file{ffplay.c} to use it in a
a93b9dba
FB
1377player. See @file{output_example.c} to use it to generate audio or video
1378streams.
1379
9181577c
FB
1380@end itemize
1381
1382@section Integrating libavcodec or libavformat in your program
1383
1384You can integrate all the source code of the libraries to link them
1385statically to avoid any version problem. All you need is to provide a
1386'config.mak' and a 'config.h' in the parent directory. See the defines
1387generated by ./configure to understand what is needed.
1388
1389You can use libavcodec or libavformat in your commercial program, but
1390@emph{any patch you make must be published}. The best way to proceed is
4c5f7207 1391to send your patches to the FFmpeg mailing list.
9181577c 1392
80d1c272 1393@node Coding Rules
9181577c
FB
1394@section Coding Rules
1395
4c5f7207 1396FFmpeg is programmed in the ISO C90 language with a few additional
cb6e87c1
FH
1397features from ISO C99, namely:
1398@itemize @bullet
1399@item
1400the @samp{inline} keyword;
1401@item
1402@samp{//} comments;
1403@item
1404designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
1405@item
114afa9c 1406compound literals (@samp{x = (struct s) @{ 17, 23 @};})
cb6e87c1
FH
1407@end itemize
1408
1409These features are supported by all compilers we care about, so we won't
1410accept patches to remove their use unless they absolutely don't impair
1411clarity and performance.
1412
4c5f7207 1413All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
cb6e87c1
FH
1414compiles with several other compilers, such as the Compaq ccc compiler
1415or Sun Studio 9, and we would like to keep it that way unless it would
1416be exceedingly involved. To ensure compatibility, please don't use any
4c5f7207 1417additional C99 features or GCC extensions. Especially watch out for:
cb6e87c1
FH
1418@itemize @bullet
1419@item
1420mixing statements and declarations;
1421@item
1422@samp{long long} (use @samp{int64_t} instead);
1423@item
1424@samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
1425@item
019c8838 1426GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
cb6e87c1 1427@end itemize
9181577c 1428
53862e0f 1429Indent size is 4.
b86e38a0 1430The presentation is the one specified by 'indent -i4 -kr -nut'.
53862e0f
DB
1431The TAB character is forbidden outside of Makefiles as is any
1432form of trailing whitespace. Commits containing either will be
1c1b5a40 1433rejected by the Subversion repository.
9181577c 1434
4c5f7207 1435Main priority in FFmpeg is simplicity and small code size (=less
9181577c
FB
1436bugs).
1437
4c5f7207
DB
1438Comments: Use the JavaDoc/Doxygen
1439format (see examples below) so that code documentation
1440can be generated automatically. All nontrivial functions should have a comment
1441above them explaining what the function does, even if it's just one sentence.
1442All structures and their member variables should be documented, too.
f4888b83
MN
1443@example
1444/**
2185824b
MR
1445 * @@file mpeg.c
1446 * MPEG codec.
1447 * @@author ...
1448 */
f4888b83
MN
1449
1450/**
2185824b
MR
1451 * Summary sentence.
1452 * more text ...
1453 * ...
1454 */
114afa9c 1455typedef struct Foobar@{
2185824b
MR
1456 int var1; /**< var1 description */
1457 int var2; ///< var2 description
1458 /** var3 description */
1459 int var3;
114afa9c 1460@} Foobar;
f4888b83
MN
1461
1462/**
2185824b
MR
1463 * Summary sentence.
1464 * more text ...
1465 * ...
1466 * @@param my_parameter description of my_parameter
1467 * @@return return value description
1468 */
f4888b83
MN
1469int myfunc(int my_parameter)
1470...
1471@end example
9181577c 1472
115329f1 1473fprintf and printf are forbidden in libavformat and libavcodec,
36d9b4e8
MN
1474please use av_log() instead.
1475
1c1b5a40 1476@section Development Policy
7a57b90c
MN
1477
1478@enumerate
115329f1 1479@item
7a57b90c 1480 You must not commit code which breaks FFmpeg! (Meaning unfinished but
4c5f7207 1481 enabled code which breaks compilation or compiles but does not work or
7a57b90c
MN
1482 breaks the regression tests)
1483 You can commit unfinished stuff (for testing etc), but it must be disabled
1484 (#ifdef etc) by default so it does not interfere with other developers'
1485 work.
115329f1 1486@item
7a57b90c 1487 You don't have to over-test things. If it works for you, and you think it
4c5f7207
DB
1488 should work for others, then commit. If your code has problems
1489 (portability, triggers compiler bugs, unusual environment etc) they will be
7a57b90c 1490 reported and eventually fixed.
115329f1 1491@item
7a57b90c
MN
1492 Do not commit unrelated changes together, split them into self-contained
1493 pieces.
1494@item
1495 Do not change behavior of the program (renaming options etc) without
019c8838 1496 first discussing it on the ffmpeg-devel mailing list. Do not remove
7a57b90c 1497 functionality from the code. Just improve!
115329f1 1498
4c5f7207 1499 Note: Redundant code can be removed.
7a57b90c
MN
1500@item
1501 Do not commit changes to the build system (Makefiles, configure script)
019c8838 1502 which change behavior, defaults etc, without asking first. The same
7a57b90c
MN
1503 applies to compiler warning fixes, trivial looking fixes and to code
1504 maintained by other developers. We usually have a reason for doing things
019c8838 1505 the way we do. Send your changes as patches to the ffmpeg-devel mailing
7a57b90c
MN
1506 list, and if the code maintainers say OK, you may commit. This does not
1507 apply to files you wrote and/or maintain.
1508@item
1509 We refuse source indentation and other cosmetic changes if they are mixed
1510 with functional changes, such commits will be rejected and removed. Every
1511 developer has his own indentation style, you should not change it. Of course
1512 if you (re)write something, you can use your own style, even though we would
4c5f7207
DB
1513 prefer if the indentation throughout FFmpeg was consistent (Many projects
1514 force a given indentation style - we don't.). If you really need to make
7a57b90c
MN
1515 indentation changes (try to avoid this), separate them strictly from real
1516 changes.
1517
114afa9c 1518 NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
115329f1 1519 then either do NOT change the indentation of the inner part within (don't
019c8838 1520 move it to the right)! or do so in a separate commit
7a57b90c
MN
1521@item
1522 Always fill out the commit log message. Describe in a few lines what you
1523 changed and why. You can refer to mailing list postings if you fix a
1524 particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
1525@item
1526 If you apply a patch by someone else, include the name and email address in
1c1b5a40 1527 the log message. Since the ffmpeg-cvslog mailing list is publicly
019c8838
DB
1528 archived you should add some SPAM protection to the email address. Send an
1529 answer to ffmpeg-devel (or wherever you got the patch from) saying that
7a57b90c
MN
1530 you applied the patch.
1531@item
5ab0f204
DB
1532 Do NOT commit to code actively maintained by others without permission.
1533 Send a patch to ffmpeg-devel instead. If noone answers within a reasonable
1534 timeframe (12h for build failures and security fixes, 3 days small changes,
1535 1 week for big patches) then commit your patch if you think it's OK.
1536 Also note, the maintainer can simply ask for more time to review!
7a57b90c 1537@item
1c1b5a40 1538 Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
7a57b90c
MN
1539 are sent there and reviewed by all the other developers. Bugs and possible
1540 improvements or general questions regarding commits are discussed there. We
1541 expect you to react if problems with your code are uncovered.
1542@item
1543 Update the documentation if you change behavior or add features. If you are
019c8838 1544 unsure how best to do this, send a patch to ffmpeg-devel, the documentation
7a57b90c
MN
1545 maintainer(s) will review and commit your stuff.
1546@item
4c5f7207
DB
1547 Never write to unallocated memory, never write over the end of arrays,
1548 always check values read from some untrusted source before using them
1549 as array index or other risky things.
76bec1d8
AS
1550@item
1551 Remember to check if you need to bump versions for the specific libav
f0efbde7 1552 parts (libavutil, libavcodec, libavformat) you are changing. You need
76bec1d8
AS
1553 to change the version integer and the version string.
1554 Incrementing the first component means no backward compatibility to
a940b428 1555 previous versions (e.g. removal of a function from the public API).
76bec1d8 1556 Incrementing the second component means backward compatible change
a940b428 1557 (e.g. addition of a function to the public API).
76bec1d8
AS
1558 Incrementing the third component means a noteworthy binary compatible
1559 change (e.g. encoder bug fix that matters for the decoder).
ebd32fd7 1560@item
3f1965c4
DB
1561 If you add a new codec, remember to update the changelog, add it to
1562 the supported codecs table in the documentation and bump the second
1563 component of the @file{libavcodec} version number appropriately. If
1564 it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
1565 is only a decoder.
114afa9c 1566@end enumerate
7a57b90c
MN
1567
1568We think our rules are not too hard. If you have comments, contact us.
1569
1570Note, these rules are mostly borrowed from the MPlayer project.
1571
9181577c
FB
1572@section Submitting patches
1573
80d1c272
MN
1574First, (@pxref{Coding Rules}) above if you didn't yet.
1575
6a6810b1 1576When you submit your patch, try to send a unified diff (diff '-up'
9181577c
FB
1577option). I cannot read other diffs :-)
1578
6e5c1877 1579Also please do not submit patches which contain several unrelated changes.
115329f1 1580Split them into individual self-contained patches; this makes reviewing
7885603a
MN
1581them much easier.
1582
9181577c 1583Run the regression tests before submitting a patch so that you can
6bf40f39 1584verify that there are no big problems.
9181577c 1585
9181577c 1586Patches should be posted as base64 encoded attachments (or any other
4c5f7207 1587encoding which ensures that the patch won't be trashed during
115329f1 1588transmission) to the ffmpeg-devel mailing list, see
2b165e29 1589@url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
9181577c 1590
54fcf429 1591It also helps quite a bit if you tell us what the patch does (for example
4c5f7207 1592'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
54fcf429
MN
1593and has no lrint()')
1594
4c5f7207
DB
1595We reply to all submitted patches and either apply or reject with some
1596explanation why, but sometimes we are quite busy so it can take a week or two.
cf7f2b16 1597
9181577c
FB
1598@section Regression tests
1599
1c1b5a40 1600Before submitting a patch (or committing to the repository), you should at least
9181577c
FB
1601test that you did not break anything.
1602
4c5f7207
DB
1603The regression tests build a synthetic video stream and a synthetic
1604audio stream. These are then encoded and decoded with all codecs or
9181577c 1605formats. The CRC (or MD5) of each generated file is recorded in a
4c5f7207 1606result file. A 'diff' is launched to compare the reference results and
9181577c
FB
1607the result file.
1608
4c5f7207 1609The regression tests then go on to test the FFserver code with a
6bf40f39
PG
1610limited set of streams. It is important that this step runs correctly
1611as well.
1612
36d9b4e8 1613Run 'make test' to test all the codecs and formats.
9181577c 1614
4c5f7207 1615Run 'make fulltest' to test all the codecs, formats and FFserver.
9181577c 1616
4c5f7207
DB
1617[Of course, some patches may change the results of the regression tests. In
1618this case, the reference results of the regression tests shall be modified
9181577c
FB
1619accordingly].
1620
1621@bye