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 [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
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
161 show available formats, codecs, protocols, ...
170 overwrite output files
173 set the recording time in seconds. @code{hh:mm:ss[.xxx]} syntax is also
177 seek to given time position. @code{hh:mm:ss[.xxx]} syntax is also
186 @item -copyright string
189 @item -comment string
193 specify target file type ("vcd", "svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd", ... ). All the format
194 options (bitrate, codecs, buffer sizes) are automatically set by this
195 option. You can just type:
198 ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
201 Nevertheless you can specify additional options as long as you know they do not compromise the
205 ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
209 activate high quality settings
211 @item -itsoffset offset
212 set the input time offset in seconds. @code{[-]hh:mm:ss[.xxx]} syntax
213 is also supported. This option affects all the input files that
214 follow it. The offset is added to the input files' timestamps;
215 specifying a positive offset means that the corresponding streams are
216 delayed by 'offset' seconds.
220 @section Video Options
224 set the video bitrate in kbit/s (default = 200 kb/s)
226 set frame rate (default = 25)
228 set frame size. The format is @samp{WxH} (default 160x128). The
229 following abbreviations are recognized:
242 set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
244 set top crop band size (in pixels)
245 @item -cropbottom size
246 set bottom crop band size (in pixels)
248 set left crop band size (in pixels)
249 @item -cropright size
250 set right crop band size (in pixels)
252 set top pad band size (in pixels)
253 @item -padbottom size
254 set bottom pad band size (in pixels)
256 set left pad band size (in pixels)
258 set right pad band size (in pixels)
259 @item -padcolor (hex color)
260 set color of padded bands. The value for pad color is expressed
261 as a six digit hexidecimal number where the first two digits represent red,
262 middle two digits green and last two digits blue. Defaults to 000000 (black)
264 disable video recording
266 set video bitrate tolerance (in kbit/s)
267 @item -maxrate bitrate
268 set max video bitrate tolerance (in kbit/s)
269 @item -minrate bitrate
270 set min video bitrate tolerance (in kbit/s)
272 set ratecontrol buffere size (in kbit)
274 force video codec to @var{codec}. Use the @code{copy} special value to
275 tell that the raw codec data must be copied as is.
277 use same video quality as source (implies VBR)
280 select the pass number (1 or 2). It is useful to do two pass
281 encoding. The statistics of the video are recorded in the first pass and
282 the video at the exact requested bit rate is generated in the second
285 @item -passlogfile file
286 select two pass log file name to @var{file}.
290 @section Advanced Video Options
294 set the group of picture size
296 use only intra frames
298 use fixed video quantiser scale (VBR)
300 min video quantiser scale (VBR)
302 max video quantiser scale (VBR)
304 max difference between the quantiser scale (VBR)
306 video quantiser scale blur (VBR)
307 @item -qcomp compression
308 video quantiser scale compression (VBR)
310 @item -rc_init_cplx complexity
311 initial complexity for 1-pass encoding
312 @item -b_qfactor factor
313 qp factor between p and b frames
314 @item -i_qfactor factor
315 qp factor between p and i frames
316 @item -b_qoffset offset
317 qp offset between p and b frames
318 @item -i_qoffset offset
319 qp offset between p and i frames
320 @item -rc_eq equation
321 set rate control equation (@pxref{FFmpeg formula
322 evaluator}). Default is @code{tex^qComp}.
323 @item -rc_override override
324 rate control override for specific intervals
326 set motion estimation method to @var{method}. Available methods are
327 (from lower to best quality):
330 Try just the (0, 0) vector.
337 exhaustive search (slow and marginally better than epzs)
341 set dct algorithm to @var{algo}. Available values are:
344 FF_DCT_AUTO (default)
357 @item -idct_algo algo
358 set idct algorithm to @var{algo}. Available values are:
361 FF_IDCT_AUTO (default)
385 set error resilience to @var{n}.
388 FF_ER_CAREFULL (default)
394 FF_ER_VERY_AGGRESSIVE
398 set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
399 the following values:
402 FF_EC_GUESS_MVS (default=enabled)
404 FF_EC_DEBLOCK (default=enabled)
408 use 'frames' B frames (supported for MPEG-1, MPEG-2 and MPEG-4)
413 FF_MB_DECISION_SIMPLE: use mb_cmp (cannot change it yet in ffmpeg)
415 FF_MB_DECISION_BITS: chooses the one which needs the fewest bits
417 FF_MB_DECISION_RD: rate distoration
421 use four motion vector by macroblock (only MPEG-4)
423 use data partitioning (only MPEG-4)
425 workaround not auto detected encoder bugs
426 @item -strict strictness
427 how strictly to follow the standarts
429 enable Advanced intra coding (h263+)
431 enable Unlimited Motion Vector (h263+)
436 force interlacing support in encoder (only MPEG-2 and MPEG-4). Use this option
437 if your input file is interlaced and if you want to keep the interlaced
438 format for minimum losses. The alternative is to deinterlace the input
439 stream with @option{-deinterlace}, but deinterlacing introduces more
442 calculate PSNR of compressed frames
444 dump video coding statistics to @file{vstats_HHMMSS.log}.
446 insert video processing @var{module}. @var{module} contains the module
447 name and its parameters separated by spaces.
450 @section Audio Options
454 set the audio sampling freq (default = 44100 Hz)
456 set the audio bitrate in kbit/s (default = 64)
458 set the number of audio channels (default = 1)
460 disable audio recording
462 force audio codec to @var{codec}. Use the @code{copy} special value to
463 tell that the raw codec data must be copied as is.
466 @section Audio/Video grab options
470 set video grab device (e.g. @file{/dev/video0})
472 set video grab channel (DV1394 only)
473 @item -tvstd standard
474 set television standard (NTSC, PAL (SECAM))
478 set audio device (e.g. @file{/dev/dsp})
481 @section Advanced options
484 @item -map file:stream
485 set input stream mapping
487 print specific debug info
489 add timings for benchmarking
491 dump each input packet
493 only use bit exact algorithms (for codec testing)
495 set packet size in bits
497 read input at native frame rate. Mainly used to simulate a grab device.
499 loop over the input stream. Currently it works only for image
500 streams. This option is used for ffserver automatic testing.
501 @item -loop_output number_of_times
502 Repeatedly loop output for formats that support looping such as animated gif
503 (Zero will loop the output infinitely)
506 @node FFmpeg formula evaluator
507 @section FFmpeg formula evaluator
509 When evaluating a rate control string, FFmpeg uses an internal formula
512 The following binary operators are available: @code{+}, @code{-},
513 @code{*}, @code{/}, @code{^}.
515 The following unary operators are available: @code{+}, @code{-},
518 The following functions are available:
540 The following constants are available:
569 @settitle FFmpeg video converter
572 ffserver(1), ffplay(1) and the html documentation of @file{ffmpeg}.
583 The filename can be @file{-} to read from the standard input or to write
584 to the standard output.
586 ffmpeg handles also many protocols specified with the URL syntax.
588 Use 'ffmpeg -formats' to have a list of the supported protocols.
590 The protocol @code{http:} is currently used only to communicate with
591 ffserver (see the ffserver documentation). When ffmpeg will be a
592 video player it will also be used for streaming :-)
597 @item For streaming at very low bit rate application, use a low frame rate
598 and a small gop size. This is especially true for real video where
599 the Linux player does not seem to be very fast, so it can miss
600 frames. An example is:
603 ffmpeg -g 3 -r 3 -t 10 -b 50 -s qcif -f rv10 /tmp/b.rm
606 @item The parameter 'q' which is displayed while encoding is the current
607 quantizer. The value of 1 indicates that a very good quality could
608 be achieved. The value of 31 indicates the worst quality. If q=31
609 too often, it means that the encoder cannot compress enough to meet
610 your bit rate. You must either increase the bit rate, decrease the
611 frame rate or decrease the frame size.
613 @item If your computer is not fast enough, you can speed up the
614 compression at the expense of the compression ratio. You can use
615 '-me zero' to speed up motion estimation, and '-intra' to disable
616 completely motion estimation (you have only I frames, which means it
617 is about as good as JPEG compression).
619 @item To have very low bitrates in audio, reduce the sampling frequency
620 (down to 22050 kHz for mpeg audio, 22050 or 11025 for ac3).
622 @item To have a constant quality (but a variable bitrate), use the option
623 '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
626 @item When converting video files, you can use the '-sameq' option which
627 uses in the encoder the same quality factor than in the decoder. It
628 allows to be almost lossless in encoding.
632 @chapter Supported File Formats and Codecs
634 You can use the @code{-formats} option to have an exhaustive list.
636 @section File Formats
638 FFmpeg supports the following file formats through the @code{libavformat}
641 @multitable @columnfractions .4 .1 .1
642 @item Supported File Format @tab Encoding @tab Decoding @tab Comments
643 @item MPEG audio @tab X @tab X
644 @item MPEG1 systems @tab X @tab X
645 @tab muxed audio and video
646 @item MPEG2 PS @tab X @tab X
647 @tab also known as @code{VOB} file
648 @item MPEG2 TS @tab @tab X
649 @tab also known as DVB Transport Stream
650 @item ASF@tab X @tab X
651 @item AVI@tab X @tab X
652 @item WAV@tab X @tab X
653 @item Macromedia Flash@tab X @tab X
654 @tab Only embedded audio is decoded
655 @item FLV @tab X @tab X
656 @tab Macromedia Flash video files
657 @item Real Audio and Video @tab X @tab X
658 @item Raw AC3 @tab X @tab X
659 @item Raw MJPEG @tab X @tab X
660 @item Raw MPEG video @tab X @tab X
661 @item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
662 @item Raw CRI ADX audio @tab X @tab X
663 @item Raw Shorten audio @tab @tab X
664 @item SUN AU format @tab X @tab X
665 @item NUT @tab X @tab X @tab NUT Open Container Format
666 @item Quicktime @tab X @tab X
667 @item MPEG4 @tab X @tab X
668 @tab MPEG4 is a variant of Quicktime
669 @item Raw MPEG4 video @tab X @tab X
670 @item DV @tab X @tab X
671 @item 4xm @tab @tab X
672 @tab 4X Technologies format, used in some games
673 @item Playstation STR @tab @tab X
674 @item Id RoQ @tab @tab X
675 @tab used in Quake III, Jedi Knight 2, other computer games
676 @item Interplay MVE @tab @tab X
677 @tab format used in various Interplay computer games
678 @item WC3 Movie @tab @tab X
679 @tab multimedia format used in Origin's Wing Commander III computer game
680 @item Sega FILM/CPK @tab @tab X
681 @tab used in many Sega Saturn console games
682 @item Westwood Studios VQA/AUD @tab @tab X
683 @tab Multimedia formats used in Westwood Studios games
684 @item Id Cinematic (.cin) @tab @tab X
685 @tab Used in Quake II
686 @item FLIC format @tab @tab X
688 @item Sierra VMD @tab @tab X
689 @tab used in Sierra CD-ROM games
690 @item Sierra Online @tab @tab X
691 @tab .sol files used in Sierra Online games
692 @item Matroska @tab @tab X
693 @item Electronic Arts Multimedia @tab @tab X
694 @tab used in various EA games; files have extensions like WVE and UV2
695 @item Nullsoft Video (NSV) format @tab @tab X
698 @code{X} means that the encoding (resp. decoding) is supported.
700 @section Image Formats
702 FFmpeg can read and write images for each frame of a video sequence. The
703 following image formats are supported:
705 @multitable @columnfractions .4 .1 .1
706 @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
707 @item PGM, PPM @tab X @tab X
708 @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support
709 @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
710 @item JPEG @tab X @tab X @tab Progressive JPEG is not supported
711 @item .Y.U.V @tab X @tab X @tab One raw file per component
712 @item Animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated
713 @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet
714 @item SGI @tab X @tab X @tab SGI RGB image format
717 @code{X} means that the encoding (resp. decoding) is supported.
719 @section Video Codecs
721 @multitable @columnfractions .4 .1 .1 .7
722 @item Supported Codec @tab Encoding @tab Decoding @tab Comments
723 @item MPEG1 video @tab X @tab X
724 @item MPEG2 video @tab X @tab X
725 @item MPEG4 @tab X @tab X @tab Also known as DIVX4/5
726 @item MSMPEG4 V1 @tab X @tab X
727 @item MSMPEG4 V2 @tab X @tab X
728 @item MSMPEG4 V3 @tab X @tab X @tab Also known as DIVX3
729 @item WMV7 @tab X @tab X
730 @item WMV8 @tab X @tab X @tab Not completely working
731 @item H.261 @tab X @tab X
732 @item H.263(+) @tab X @tab X @tab Also known as Real Video 1.0
733 @item H.264 @tab @tab X
734 @item MJPEG @tab X @tab X
735 @item Lossless MJPEG @tab X @tab X
736 @item Apple MJPEG-B @tab @tab X
737 @item Sunplus MJPEG @tab @tab X @tab fourcc: SP5X
738 @item DV @tab X @tab X
739 @item Huff YUV @tab X @tab X
740 @item FFmpeg Video 1 @tab X @tab X @tab Experimental lossless codec (fourcc: FFV1)
741 @item FFmpeg Snow @tab X @tab X @tab Experimental wavelet codec (fourcc: SNOW)
742 @item Asus v1 @tab X @tab X @tab fourcc: ASV1
743 @item Asus v2 @tab X @tab X @tab fourcc: ASV2
744 @item Creative YUV @tab @tab X @tab fourcc: CYUV
745 @item Sorenson Video 1 @tab X @tab X @tab fourcc: SVQ1
746 @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
747 @item On2 VP3 @tab @tab X @tab still experimental
748 @item Theora @tab @tab X @tab still experimental
749 @item Intel Indeo 3 @tab @tab X
750 @item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
751 @item ATI VCR1 @tab @tab X @tab fourcc: VCR1
752 @item ATI VCR2 @tab @tab X @tab fourcc: VCR2
753 @item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
754 @item 4X Video @tab @tab X @tab used in certain computer games
755 @item Sony Playstation MDEC @tab @tab X
756 @item Id RoQ @tab @tab X @tab used in Quake III, Jedi Knight 2, other computer games
757 @item Xan/WC3 @tab @tab X @tab used in Wing Commander III .MVE files
758 @item Interplay Video @tab @tab X @tab used in Interplay .MVE files
759 @item Apple Animation @tab @tab X @tab fourcc: 'rle '
760 @item Apple Graphics @tab @tab X @tab fourcc: 'smc '
761 @item Apple Video @tab @tab X @tab fourcc: rpza
762 @item Apple QuickDraw @tab @tab X @tab fourcc: qdrw
763 @item Cinepak @tab @tab X
764 @item Microsoft RLE @tab @tab X
765 @item Microsoft Video-1 @tab @tab X
766 @item Westwood VQA @tab @tab X
767 @item Id Cinematic Video @tab @tab X @tab used in Quake II
768 @item Planar RGB @tab @tab X @tab fourcc: 8BPS
769 @item FLIC video @tab @tab X
770 @item Duck TrueMotion v1 @tab @tab X @tab fourcc: DUCK
771 @item VMD Video @tab @tab X @tab used in Sierra VMD files
772 @item MSZH @tab @tab X @tab Part of LCL
773 @item ZLIB @tab X @tab X @tab Part of LCL, encoder experimental
774 @item TechSmith Camtasia @tab @tab X @tab fourcc: TSCC
775 @item IBM Ultimotion @tab @tab X @tab fourcc: ULTI
776 @item Miro VideoXL @tab @tab X @tab fourcc: VIXL
777 @item QPEG @tab @tab X @tab fourccs: QPEG, Q1.0, Q1.1
778 @item LOCO @tab @tab X @tab
779 @item Winnov WNV1 @tab @tab X @tab
780 @item Autodesk Animator Studio Codec @tab @tab X @tab fourcc: AASC
781 @item Fraps FPS1 @tab @tab X @tab
784 @code{X} means that the encoding (resp. decoding) is supported.
786 Check at @url{http://www.mplayerhq.hu/~michael/codec-features.html} to
787 get a precise comparison of FFmpeg MPEG4 codec compared to the other
790 @section Audio Codecs
792 @multitable @columnfractions .4 .1 .1 .1 .7
793 @item Supported Codec @tab Encoding @tab Decoding @tab Comments
794 @item MPEG audio layer 2 @tab IX @tab IX
795 @item MPEG audio layer 1/3 @tab IX @tab IX
796 @tab MP3 encoding is supported through the external library LAME
797 @item AC3 @tab IX @tab IX
798 @tab liba52 is used internally for decoding
799 @item Vorbis @tab X @tab X
800 @tab supported through the external library libvorbis
801 @item WMA V1/V2 @tab @tab X
802 @item AAC @tab X @tab X
803 @tab supported through the external library libfaac/libfaad
804 @item Microsoft ADPCM @tab X @tab X
805 @item MS IMA ADPCM @tab X @tab X
806 @item QT IMA ADPCM @tab @tab X
807 @item 4X IMA ADPCM @tab @tab X
808 @item G.726 ADPCM @tab X @tab X
809 @item Duck DK3 IMA ADPCM @tab @tab X
810 @tab used in some Sega Saturn console games
811 @item Duck DK4 IMA ADPCM @tab @tab X
812 @tab used in some Sega Saturn console games
813 @item Westwood Studios IMA ADPCM @tab @tab X
814 @tab used in Westwood Studios games like Command and Conquer
815 @item SMJPEG IMA ADPCM @tab @tab X
816 @tab used in certain Loki game ports
817 @item CD-ROM XA ADPCM @tab @tab X
818 @item CRI ADX ADPCM @tab X @tab X
819 @tab used in Sega Dreamcast games
820 @item Electronic Arts ADPCM @tab @tab X
821 @tab used in various EA titles
822 @item Creative ADPCM @tab @tab X
823 @item RA144 @tab @tab X
824 @tab Real 14400 bit/s codec
825 @item RA288 @tab @tab X
826 @tab Real 28800 bit/s codec
827 @item RADnet @tab X @tab IX
828 @tab Real lowbitrate AC3 codec, liba52 is used for decoding
829 @item AMR-NB @tab X @tab X
830 @tab supported through an external library
831 @item AMR-WB @tab X @tab X
832 @tab supported through an external library
833 @item DV audio @tab @tab X
834 @item Id RoQ DPCM @tab @tab X
835 @tab used in Quake III, Jedi Knight 2, other computer games
836 @item Interplay MVE DPCM @tab @tab X
837 @tab used in various Interplay computer games
838 @item Xan DPCM @tab @tab X
839 @tab used in Origin's Wing Commander IV AVI files
840 @item Sierra Online DPCM @tab @tab X
841 @tab used in Sierra Online game audio files
842 @item Apple MACE 3 @tab @tab X
843 @item Apple MACE 6 @tab @tab X
844 @item FLAC lossless audio @tab @tab X
845 @item Shorten lossless audio @tab @tab X
846 @item Apple lossless audio @tab @tab X
847 @tab QuickTime fourcc 'alac'
848 @item FFmpeg Sonic @tab X @tab X
849 @tab Experimental lossy/lossless codec
852 @code{X} means that the encoding (resp. decoding) is supported.
854 @code{I} means that an integer only version is available too (ensures highest
855 performances on systems without hardware floating point support).
857 @chapter Platform Specific information
861 ffmpeg should be compiled with at least GCC 2.95.3. GCC 3.2 is the
862 preferred compiler now for ffmpeg. All future optimizations will depend on
863 features only found in GCC 3.2.
869 @subsection Native Windows compilation
872 @item Install the current versions of MSYS and MinGW from
873 @url{http://www.mingw.org/}. You can find detailed installation
874 instructions in the download section and the FAQ.
876 @item If you want to test the FFmpeg Simple Media Player, also download
877 the MinGW development library of SDL 1.2.x
878 (@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
879 @url{http://www.libsdl.org}. Unpack it in a temporary place, and
880 unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
881 directory. Edit the @file{sdl-config} script so that it gives the
882 correct SDL directory when invoked.
884 @item Extract the current version of FFmpeg (the latest release version or the current CVS snapshot whichever is recommended).
886 @item Start the MSYS shell (file @file{msys.bat}).
888 @item Change to the FFMPEG directory and follow
889 the instructions of how to compile ffmpeg (file
890 @file{INSTALL}). Usually, launching @file{./configure} and @file{make}
891 suffices. If you have problems using SDL, verify that
892 @file{sdl-config} can be launched from the MSYS command line.
894 @item You can install FFmpeg in @file{Program Files/FFmpeg} by typing @file{make install}. Don't forget to copy @file{SDL.dll} at the place you launch
902 @item The target @file{make wininstaller} can be used to create a
903 Nullsoft based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
904 must be copied in the ffmpeg directory in order to build the
907 @item By using @code{./configure --enable-shared} when configuring ffmpeg,
908 you can build @file{avcodec.dll} and @file{avformat.dll}. With
909 @code{make install} you install the FFmpeg DLLs and the associated
910 headers in @file{Program Files/FFmpeg}.
912 @item Visual C++ compatibility: if you used @code{./configure --enable-shared}
913 when configuring FFmpeg, then FFmpeg tries to use the Microsoft Visual
914 C++ @code{lib} tool to build @code{avcodec.lib} and
915 @code{avformat.lib}. With these libraries, you can link your Visual C++
916 code directly with the FFmpeg DLLs.
920 @subsection Cross compilation for Windows with Linux
922 You must use the MinGW cross compilation tools available at
923 @url{http://www.mingw.org/}.
925 Then configure ffmpeg with the following options:
927 ./configure --enable-mingw32 --cross-prefix=i386-mingw32msvc-
929 (you can change the cross-prefix according to the prefix choosen for the
932 Then you can easily test ffmpeg with wine
933 (@url{http://www.winehq.com/}).
939 The configure script should guess the configuration itself.
940 Networking support is currently not finished.
941 errno issues fixed by Andrew Bachmann.
945 François Revol - revol at free dot fr - April 2002
947 The configure script should guess the configuration itself,
948 however I still didn't tested building on net_server version of BeOS.
950 ffserver is broken (needs poll() implementation).
952 There is still issues with errno codes, which are negative in BeOs, and
953 that ffmpeg negates when returning. This ends up turning errors into
954 valid results, then crashes.
957 @chapter Developers Guide
961 @item libavcodec is the library containing the codecs (both encoding and
962 decoding). See @file{libavcodec/apiexample.c} to see how to use it.
964 @item libavformat is the library containing the file formats handling (mux and
965 demux code for several formats). See @file{ffplay.c} to use it in a
966 player. See @file{output_example.c} to use it to generate audio or video
971 @section Integrating libavcodec or libavformat in your program
973 You can integrate all the source code of the libraries to link them
974 statically to avoid any version problem. All you need is to provide a
975 'config.mak' and a 'config.h' in the parent directory. See the defines
976 generated by ./configure to understand what is needed.
978 You can use libavcodec or libavformat in your commercial program, but
979 @emph{any patch you make must be published}. The best way to proceed is
980 to send your patches to the ffmpeg mailing list.
983 @section Coding Rules
985 ffmpeg is programmed in the ISO C90 language with a few additional
986 features from ISO C99, namely:
989 the @samp{inline} keyword;
993 designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
995 compound literals (@samp{x = (struct s) @{ 17, 23 @};})
998 These features are supported by all compilers we care about, so we won't
999 accept patches to remove their use unless they absolutely don't impair
1000 clarity and performance.
1002 All code must compile with gcc 2.95 and gcc 3.3. Currently, ffmpeg also
1003 compiles with several other compilers, such as the Compaq ccc compiler
1004 or Sun Studio 9, and we would like to keep it that way unless it would
1005 be exceedingly involved. To ensure compatibility, please don't use any
1006 additional C99 features or gcc extensions. Watch out especially for:
1009 mixing statements and declarations;
1011 @samp{long long} (use @samp{int64_t} instead);
1013 @samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
1015 gcc statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
1018 Indent size is 4. The TAB character should not be used.
1019 The presentation is the one specified by 'indent -i4 -kr'.
1021 Main priority in ffmpeg is simplicity and small code size (=less
1024 Comments: use the JavaDoc/Doxygen
1025 format (see examples below) so that a documentation
1026 can be generated automatically. All non trivial functions should have a comment
1027 above it explaining what the function does, even if its just one sentance.
1028 All Structures and their member variables should be documented too.
1041 typedef struct Foobar@{
1042 int var1; /**< var1 description */
1043 int var2; ///< var2 description
1044 /** var3 description */
1052 * @@param my_parameter description of my_parameter
1053 * @@return return value description
1055 int myfunc(int my_parameter)
1059 fprintf and printf are forbidden in libavformat and libavcodec,
1060 please use av_log() instead.
1067 You must not commit code which breaks FFmpeg! (Meaning unfinished but
1068 enabled code which breaks compilation or compiles but does not work. Or
1069 breaks the regression tests)
1070 You can commit unfinished stuff (for testing etc), but it must be disabled
1071 (#ifdef etc) by default so it does not interfere with other developers'
1074 You don't have to over-test things. If it works for you, and you think it
1075 should work for others, too, then commit. If your code has problems
1076 (portability, exploits compiler bugs, unusual environment etc) they will be
1077 reported and eventually fixed.
1079 Do not commit unrelated changes together, split them into self-contained
1082 Do not change behavior of the program (renaming options etc) without
1083 first discussing it on the ffmpeg-dev mailing list. Do not remove
1084 functionality from the code. Just improve!
1086 Note: Redundant code can be removed
1088 Do not commit changes to the build system (Makefiles, configure script)
1089 which change behaviour, defaults etc, without asking first. The same
1090 applies to compiler warning fixes, trivial looking fixes and to code
1091 maintained by other developers. We usually have a reason for doing things
1092 the way we do. Send your changes as patches to the ffmpeg-dev mailing
1093 list, and if the code maintainers say OK, you may commit. This does not
1094 apply to files you wrote and/or maintain.
1096 We refuse source indentation and other cosmetic changes if they are mixed
1097 with functional changes, such commits will be rejected and removed. Every
1098 developer has his own indentation style, you should not change it. Of course
1099 if you (re)write something, you can use your own style, even though we would
1100 prefer if the indention throughout ffmpeg would be consistant (Many projects
1101 force a given indentation style - we don't.) If you really need to make
1102 indentation changes (try to avoid this), separate them strictly from real
1105 NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
1106 then either do NOT change the indentation of the inner part within (don't
1107 move it to the right)! or do so in a seperate commit
1109 Always fill out the commit log message. Describe in a few lines what you
1110 changed and why. You can refer to mailing list postings if you fix a
1111 particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
1113 If you apply a patch by someone else, include the name and email address in
1114 the CVS log message. Since the ffmpeg-cvslog mailing list is publicly
1115 archived you should add some spam protection to the email address. Send an
1116 answer to ffmpeg-dev (or wherever you got the patch from) saying that
1117 you applied the patch.
1119 Do NOT commit to code actively maintained by others without permission. Send
1120 a patch to ffmpeg-dev instead.
1122 Subscribe to the ffmpeg-cvslog mailing list. The diffs of all CVS commits
1123 are sent there and reviewed by all the other developers. Bugs and possible
1124 improvements or general questions regarding commits are discussed there. We
1125 expect you to react if problems with your code are uncovered.
1127 Update the documentation if you change behavior or add features. If you are
1128 unsure how best to do this, send a patch to ffmpeg-dev, the documentation
1129 maintainer(s) will review and commit your stuff.
1131 Revert a commit ONLY in case of a big blunder like committing something not
1132 intended to be committed or committing a wrong file, the wrong version of a
1133 patch, cvs policy violation or broken code and you are going to recommit the
1134 right thing immediately.
1136 Never revert changes made a long time ago or buggy code. Fix it in the
1139 Never write to not allocated memory, never write over the end of arrays,
1140 always check values read from some untrusted source before using them as index
1141 into an array or otherwise risky things.
1144 We think our rules are not too hard. If you have comments, contact us.
1146 Note, these rules are mostly borrowed from the MPlayer project.
1148 @subsection Renaming/moving files or content of files
1149 You CANNOT do that. Post a request for such a change to the mailinglist
1150 Do NOT remove & readd a file - it will kill the changelog!!!!
1152 @section Submitting patches
1154 First, (@pxref{Coding Rules}) above if you didn't yet.
1156 When you submit your patch, try to send a unified diff (diff '-up'
1157 option). I cannot read other diffs :-)
1159 Also please do not submit patches which contain several unrelated changes,
1160 split them into individual self-contained patches, this makes reviewing
1163 Run the regression tests before submitting a patch so that you can
1164 verify that there are no big problems.
1166 Patches should be posted as base64 encoded attachments (or any other
1167 encoding which ensures that the patch wont be trashed during
1168 transmission) to the ffmpeg-devel mailinglist, see
1169 @url{http://www1.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
1171 It also helps quite a bit if you tell us what the patch does (for example
1172 'replaces lrint by lrintf') , and why (for example '*bsd isnt c99 compliant
1173 and has no lrint()')
1175 We reply to all patches submitted and either apply or reject with some
1176 explanation why, but sometimes we are quite busy so it can take a week or 2
1178 @section Regression tests
1180 Before submitting a patch (or committing with CVS), you should at least
1181 test that you did not break anything.
1183 The regression test build a synthetic video stream and a synthetic
1184 audio stream. Then these are encoded then decoded with all codecs or
1185 formats. The CRC (or MD5) of each generated file is recorded in a
1186 result file. Then a 'diff' is launched with the reference results and
1189 The regression test then goes on to test the ffserver code with a
1190 limited set of streams. It is important that this step runs correctly
1193 Run 'make test' to test all the codecs and formats.
1195 Run 'make fulltest' to test all the codecs, formats and ffserver.
1197 [Of course, some patches may change the regression tests results. In
1198 this case, the regression tests reference results shall be modified