1 \input texinfo @c -*- texinfo -*-
3 @settitle FFmpeg Documentation
6 @center @titlefont{FFmpeg Documentation}
13 FFmpeg is a very fast video and audio converter. It can also grab from
14 a live audio/video source.
16 The command line interface is designed to be intuitive, in the sense
17 that ffmpeg tries to figure out all the parameters, when
18 possible. You have usually to give only the target bitrate you want.
20 FFmpeg can also convert from any sample rate to any other, and resize
21 video on the fly with a high quality polyphase filter.
26 @section Video and Audio grabbing
28 FFmpeg can use a video4linux compatible video source and any Open Sound
35 Note that you must activate the right video source and channel before
36 launching ffmpeg. You can use any TV viewer such as xawtv
37 (@url{http://bytesex.org/xawtv/}) by Gerd Knorr which I find very
38 good. You must also set correctly the audio recording levels with a
41 @section Video and Audio file format conversion
43 * ffmpeg can use any supported file format and protocol as input:
47 * You can input from YUV files:
50 ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
53 It will use the files:
55 /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
56 /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
59 The Y files use twice the resolution of the U and V files. They are
60 raw files, without header. They can be generated by all decent video
61 decoders. You must specify the size of the image with the @option{-s} option
62 if ffmpeg cannot guess it.
64 * You can input from a RAW YUV420P file:
67 ffmpeg -i /tmp/test.yuv /tmp/out.avi
70 The RAW YUV420P is a file containing RAW YUV planar, for each frame first
71 come the Y plane followed by U and V planes, which are half vertical and
72 horizontal resolution.
74 * You can output to a RAW YUV420P file:
77 ffmpeg -i mydivx.avi -o hugefile.yuv
80 * You can set several input files and output files:
83 ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
86 Convert the audio file a.wav and the raw yuv video file a.yuv
89 * You can also do audio and video conversions at the same time:
92 ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
95 Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.
97 * You can encode to several formats at the same time and define a
98 mapping from input stream to output streams:
101 ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
104 Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. '-map
105 file:index' specify which input stream is used for each output
106 stream, in the order of the definition of output streams.
108 * You can transcode decrypted VOBs
111 ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
114 This is a typical DVD ripper example, input from a VOB file, output
115 to an AVI file with MPEG-4 video and MP3 audio, note that in this
116 command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP
117 size is 300 that means an INTRA frame every 10 seconds for 29.97 fps
118 input video. Also the audio stream is MP3 encoded so you need LAME
119 support which is enabled using @code{--enable-mp3lame} when
120 configuring. The mapping is particularly useful for DVD transcoding
121 to get the desired audio language.
123 NOTE: to see the supported input formats, use @code{ffmpeg -formats}.
130 The generic syntax is:
133 @c man begin SYNOPSIS
134 ffmpeg [[options][@option{-i} @var{input_file}]]... @{[options] @var{output_file}@}...
137 @c man begin DESCRIPTION
138 If no input file is given, audio/video grabbing is done.
140 As a general rule, options are applied to the next specified
141 file. For example, if you give the @option{-b 64} option, it sets the video
142 bitrate of the next file. Format option may be needed for raw input
145 By default, ffmpeg tries to convert as losslessly as possible: it
146 uses the same audio and video parameter for the outputs as the one
147 specified for the inputs.
151 @section Main options
159 show available formats, codecs, protocols, ...
166 overwrite output files
169 set the recording time in seconds. @code{hh:mm:ss[.xxx]} syntax is also
178 @item -copyright string
181 @item -comment string
186 @section Video Options
190 set frame size [160x128]
194 set the video bitrate in kbit/s [200]
196 disable video recording [no]
198 set video bitrate tolerance (in kbit/s)
200 use same video quality as source (implies VBR)
203 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 at the exact requested bit rate is generated in the second pass.
205 @item -passlogfile file
206 select two pass log file name
210 @section Audio Options
214 set audio bitrate (in kbit/s)
216 set the audio sampling freq [44100]
218 set the audio bitrate in kbit/s [64]
220 set the number of audio channels [1]
222 disable audio recording [no]
225 @section Advanced options
228 @item -map file:stream
229 set input stream mapping
231 set the group of picture size
233 use only intra frames
235 use fixed video quantiser scale (VBR)
237 min video quantiser scale (VBR)
239 max video quantiser scale (VBR)
241 max difference between the quantiser scale (VBR)
243 video quantiser scale blur (VBR)
244 @item -qcomp compression
245 video quantiser scale compression (VBR)
251 set motion estimation method
253 use 'frames' B frames (only MPEG-4)
255 activate high quality settings
257 use four motion vector by macroblock (only MPEG-4)
265 add timings for benchmarking
267 dump each input packet
269 calculate PSNR of compressed frames
271 dump video coding statistics to file
278 @settitle FFmpeg video converter
281 ffserver(1), ffplay(1) and the html documentation of @file{ffmpeg}.
292 The filename can be @file{-} to read from the standard input or to write
293 to the standard output.
295 ffmpeg handles also many protocols specified with the URL syntax.
297 Use 'ffmpeg -formats' to have a list of the supported protocols.
299 The protocol @code{http:} is currently used only to communicate with
300 ffserver (see the ffserver documentation). When ffmpeg will be a
301 video player it will also be used for streaming :-)
306 @item For streaming at very low bit rate application, use a low frame rate
307 and a small gop size. This is especially true for real video where
308 the Linux player does not seem to be very fast, so it can miss
309 frames. An example is:
312 ffmpeg -g 3 -r 3 -t 10 -b 50 -s qcif -f rv10 /tmp/b.rm
315 @item The parameter 'q' which is displayed while encoding is the current
316 quantizer. The value of 1 indicates that a very good quality could
317 be achieved. The value of 31 indicates the worst quality. If q=31
318 too often, it means that the encoder cannot compress enough to meet
319 your bit rate. You must either increase the bit rate, decrease the
320 frame rate or decrease the frame size.
322 @item If your computer is not fast enough, you can speed up the
323 compression at the expense of the compression ratio. You can use
324 '-me zero' to speed up motion estimation, and '-intra' to disable
325 completely motion estimation (you have only I frames, which means it
326 is about as good as JPEG compression).
328 @item To have very low bitrates in audio, reduce the sampling frequency
329 (down to 22050 kHz for mpeg audio, 22050 or 11025 for ac3).
331 @item To have a constant quality (but a variable bitrate), use the option
332 '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
335 @item When converting video files, you can use the '-sameq' option which
336 uses in the encoder the same quality factor than in the decoder. It
337 allows to be almost lossless in encoding.
341 @chapter Supported File Formats and Codecs
343 You can use the @code{-formats} option to have an exhaustive list.
345 @section File Formats
347 FFmpeg supports the following file formats through the @code{libavformat}
350 @multitable @columnfractions .4 .1 .1
351 @item Supported File Format @tab Encoding @tab Decoding @tab Comments
352 @item MPEG audio @tab X @tab X
353 @item MPEG1 systems @tab X @tab X
354 @tab muxed audio and video
355 @item MPEG2 PS @tab X @tab X
356 @tab also known as @code{VOB} file
357 @item MPEG2 TS @tab @tab X
358 @tab also known as DVB Transport Stream
359 @item ASF@tab X @tab X
360 @item AVI@tab X @tab X
361 @item WAV@tab X @tab X
362 @item Macromedia Flash@tab X @tab X
363 @tab Only embedded audio is decoded
364 @item FLV @tab X @tab X
365 @tab Macromedia Flash video files
366 @item Real Audio and Video @tab X @tab X
367 @item Raw AC3 @tab X @tab X
368 @item Raw MJPEG @tab X @tab X
369 @item Raw MPEG video @tab X @tab X
370 @item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
371 @item SUN AU format @tab X @tab X
372 @item Quicktime @tab @tab X
373 @item MPEG4 @tab @tab X
374 @tab MPEG4 is a variant of Quicktime
375 @item Raw MPEG4 video @tab X @tab X
377 @item 4xm @tab @tab X
378 @tab 4X Technologies format, used in some games
381 @code{X} means that the encoding (resp. decoding) is supported.
383 @section Image Formats
385 FFmpeg can read and write images for each frame of a video sequence. The
386 following image formats are supported:
388 @multitable @columnfractions .4 .1 .1
389 @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
390 @item PGM, PPM @tab X @tab X
391 @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support
392 @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
393 @item JPEG @tab X @tab X @tab Progressive JPEG is not supported
394 @item .Y.U.V @tab X @tab X @tab One raw file per component
395 @item Animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated
396 @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet
399 @code{X} means that the encoding (resp. decoding) is supported.
401 @section Video Codecs
403 @multitable @columnfractions .4 .1 .1 .7
404 @item Supported Codec @tab Encoding @tab Decoding @tab Comments
405 @item MPEG1 video @tab X @tab X
406 @item MPEG2 video @tab @tab X
407 @item MPEG4 @tab X @tab X @tab Also known as DIVX4/5
408 @item MSMPEG4 V1 @tab X @tab X
409 @item MSMPEG4 V2 @tab X @tab X
410 @item MSMPEG4 V3 @tab X @tab X @tab Also known as DIVX3
411 @item WMV7 @tab X @tab X
412 @item WMV8 @tab X @tab X @tab Not completely working
413 @item H263(+) @tab X @tab X @tab Also known as Real Video 1.0
414 @item MJPEG @tab X @tab X
416 @item Huff YUV @tab X @tab X
417 @item Asus v1 @tab X @tab X @tab fourcc: ASV1
418 @item Creative YUV @tab @tab X @tab fourcc: CYUV
419 @item H.264 @tab @tab X
420 @item Sorenson Video 1 @tab @tab X @tab fourcc: SVQ1
421 @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
422 @item On2 VP3 @tab @tab X @tab still experimental
423 @item Intel Indeo 3 @tab @tab X @tab only works on i386 right now
424 @item FLV @tab X @tab X @tab Flash H263 variant
427 @code{X} means that the encoding (resp. decoding) is supported.
429 Check at @url{http://www.mplayerhq.hu/~michael/codec-features.html} to
430 get a precise comparison of FFmpeg MPEG4 codec compared to the other
433 @section Audio Codecs
435 @multitable @columnfractions .4 .1 .1 .1 .7
436 @item Supported Codec @tab Encoding @tab Decoding @tab Comments
437 @item MPEG audio layer 2 @tab IX @tab IX
438 @item MPEG audio layer 1/3 @tab IX @tab IX
439 @tab MP3 encoding is supported through the external library LAME
440 @item AC3 @tab IX @tab X
441 @tab liba52 is used internally for decoding
442 @item Vorbis @tab X @tab X
443 @tab supported through the external library libvorbis
444 @item WMA V1/V2 @tab @tab X
445 @item Microsoft ADPCM @tab X @tab X
446 @item IMA ADPCM @tab X @tab X
447 @item RA144 @tab @tab X
448 @tab Real 14400 bit/s codec
449 @item RA288 @tab @tab X
450 @tab Real 28800 bit/s codec
451 @item AMR-NB @tab X @tab X
452 @tab supported through an external library
453 @item DV audio @tab @tab X
456 @code{X} means that the encoding (resp. decoding) is supported.
458 @code{I} means that an integer only version is available too (ensures highest
459 performances on systems without hardware floating point support).
461 @chapter Platform Specific information
465 ffmpeg should be compiled with at least GCC 2.95.3. GCC 3.2 is the
466 preferred compiler now for ffmpeg. All future optimizations will depend on
467 features only found in GCC 3.2.
477 The configure script should guess the configuration itself.
478 Networking support is currently not finished.
479 errno issues fixed by Andrew Bachmann.
483 François Revol - revol at free dot fr - April 2002
485 The configure script should guess the configuration itself,
486 however I still didn't tested building on net_server version of BeOS.
488 ffserver is broken (needs poll() implementation).
490 There is still issues with errno codes, which are negative in BeOs, and
491 that ffmpeg negates when returning. This ends up turning errors into
492 valid results, then crashes.
495 @chapter Developers Guide
499 @item libavcodec is the library containing the codecs (both encoding and
500 decoding). See @file{libavcodec/apiexample.c} to see how to use it.
502 @item libavformat is the library containing the file formats handling (mux and
503 demux code for several formats). See @file{ffplay.c} to use it in a
504 player. See @file{output_example.c} to use it to generate audio or video
509 @section Integrating libavcodec or libavformat in your program
511 You can integrate all the source code of the libraries to link them
512 statically to avoid any version problem. All you need is to provide a
513 'config.mak' and a 'config.h' in the parent directory. See the defines
514 generated by ./configure to understand what is needed.
516 You can use libavcodec or libavformat in your commercial program, but
517 @emph{any patch you make must be published}. The best way to proceed is
518 to send your patches to the ffmpeg mailing list.
520 @section Coding Rules
522 ffmpeg is programmed in ANSI C language. GCC extensions are
523 tolerated. Indent size is 4. The TAB character should not be used.
525 The presentation is the one specified by 'indent -i4 -kr'.
527 Main priority in ffmpeg is simplicity and small code size (=less
530 Comments: for functions visible from other modules, use the JavaDoc
531 format (see examples in @file{libav/utils.c}) so that a documentation
532 can be generated automatically.
534 @section Submitting patches
536 When you submit your patch, try to send a unified diff (diff '-u'
537 option). I cannot read other diffs :-)
539 Run the regression tests before submitting a patch so that you can
540 verify that there are no big problems.
542 Patches should be posted as base64 encoded attachments (or any other
543 encoding which ensures that the patch wont be trashed during
544 transmission) to the ffmpeg-devel mailinglist, see
545 @url{http://lists.sourceforge.net/lists/listinfo/ffmpeg-devel}
547 @section Regression tests
549 Before submitting a patch (or committing with CVS), you should at least
550 test that you did not break anything.
552 The regression test build a synthetic video stream and a synthetic
553 audio stream. Then these are encoded then decoded with all codecs or
554 formats. The CRC (or MD5) of each generated file is recorded in a
555 result file. Then a 'diff' is launched with the reference results and
558 The regression test then goes on to test the ffserver code with a
559 limited set of streams. It is important that this step runs correctly
562 Run 'make test' to test all the codecs.
564 Run 'make libavtest' to test all the codecs.
566 [Of course, some patches may change the regression tests results. In
567 this case, the regression tests reference results shall be modified