3 <!-- Created by texi2html
1.56k from ffmpeg-doc.texi on
27 October
2002 --
>
5 <TITLE>FFmpeg Documentation
</TITLE>
8 <H1>FFmpeg Documentation
</H1>
11 <H1>Table of Contents
</H1>
13 <LI><A NAME=
"TOC1" HREF=
"ffmpeg-doc.html#SEC1">1. Introduction
</A>
14 <LI><A NAME=
"TOC2" HREF=
"ffmpeg-doc.html#SEC2">2. Quick Start
</A>
16 <LI><A NAME=
"TOC3" HREF=
"ffmpeg-doc.html#SEC3">2.1 Video and Audio grabbing
</A>
17 <LI><A NAME=
"TOC4" HREF=
"ffmpeg-doc.html#SEC4">2.2 Video and Audio file format convertion
</A>
19 <LI><A NAME=
"TOC5" HREF=
"ffmpeg-doc.html#SEC5">3. Invocation
</A>
21 <LI><A NAME=
"TOC6" HREF=
"ffmpeg-doc.html#SEC6">3.1 Syntax
</A>
22 <LI><A NAME=
"TOC7" HREF=
"ffmpeg-doc.html#SEC7">3.2 Main options
</A>
23 <LI><A NAME=
"TOC8" HREF=
"ffmpeg-doc.html#SEC8">3.3 Video Options
</A>
24 <LI><A NAME=
"TOC9" HREF=
"ffmpeg-doc.html#SEC9">3.4 Audio Options
</A>
25 <LI><A NAME=
"TOC10" HREF=
"ffmpeg-doc.html#SEC10">3.5 Advanced options
</A>
26 <LI><A NAME=
"TOC11" HREF=
"ffmpeg-doc.html#SEC11">3.6 Protocols
</A>
28 <LI><A NAME=
"TOC12" HREF=
"ffmpeg-doc.html#SEC12">4. Tips
</A>
29 <LI><A NAME=
"TOC13" HREF=
"ffmpeg-doc.html#SEC13">5. Supported File Formats and Codecs
</A>
31 <LI><A NAME=
"TOC14" HREF=
"ffmpeg-doc.html#SEC14">5.1 File Formats
</A>
32 <LI><A NAME=
"TOC15" HREF=
"ffmpeg-doc.html#SEC15">5.2 Video Codecs
</A>
33 <LI><A NAME=
"TOC16" HREF=
"ffmpeg-doc.html#SEC16">5.3 Audio Codecs
</A>
35 <LI><A NAME=
"TOC17" HREF=
"ffmpeg-doc.html#SEC17">6. Developpers Guide
</A>
37 <LI><A NAME=
"TOC18" HREF=
"ffmpeg-doc.html#SEC18">6.1 API
</A>
38 <LI><A NAME=
"TOC19" HREF=
"ffmpeg-doc.html#SEC19">6.2 Integrating libavcodec or libavformat in your program
</A>
39 <LI><A NAME=
"TOC20" HREF=
"ffmpeg-doc.html#SEC20">6.3 Coding Rules
</A>
40 <LI><A NAME=
"TOC21" HREF=
"ffmpeg-doc.html#SEC21">6.4 Submitting patches
</A>
41 <LI><A NAME=
"TOC22" HREF=
"ffmpeg-doc.html#SEC22">6.5 Regression tests
</A>
52 <H1><A NAME=
"SEC1" HREF=
"ffmpeg-doc.html#TOC1">1. Introduction
</A></H1>
55 FFmpeg is a very fast video and audio converter. It can also grab from
56 a live audio/video source.
58 The command line interface is designed to be intuitive, in the sense
59 that ffmpeg tries to figure out all the parameters, when
60 possible. You have usually to give only the target bitrate you want.
64 FFmpeg can also convert from any sample rate to any other, and resize
65 video on the fly with a high quality polyphase filter.
70 <H1><A NAME=
"SEC2" HREF=
"ffmpeg-doc.html#TOC2">2. Quick Start
</A></H1>
74 <H2><A NAME=
"SEC3" HREF=
"ffmpeg-doc.html#TOC3">2.1 Video and Audio grabbing
</A></H2>
77 FFmpeg can use a video4linux compatible video source and any Open Sound
85 Note that you must activate the right video source and channel
86 before launching ffmpeg. You can use any TV viewer such as xawtv by
87 Gerd Knorr which I find very good. You must also set correctly the
88 audio recording levels with a standard mixer.
93 <H2><A NAME=
"SEC4" HREF=
"ffmpeg-doc.html#TOC4">2.2 Video and Audio file format convertion
</A></H2>
96 * ffmpeg can use any supported file format and protocol as input:
104 * You can input from YUV files:
109 ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
113 It will use the files:
116 /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
117 /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
121 The Y files use twice the resolution of the U and V files. They are
122 raw files, without header. They can be generated by all decent video
123 decoders. You must specify the size of the image with the '-s' option
124 if ffmpeg cannot guess it.
128 * You can input from a RAW YUV420P file:
133 ffmpeg -i /tmp/test.yuv /tmp/out.avi
137 The RAW YUV420P is a file containing RAW YUV planar, for each frame first
138 come the Y plane followed by U and V planes, which are half vertical and
139 horizontal resolution.
143 * You can output to a RAW YUV420P file:
148 ffmpeg -i mydivx.avi -o hugefile.yuv
152 * You can set several input files and output files:
157 ffmpeg -i /tmp/a.wav -s
640x480 -i /tmp/a.yuv /tmp/a.mpg
161 Convert the audio file a.wav and the raw yuv video file a.yuv
166 * You can also do audio and video convertions at the same time:
171 ffmpeg -i /tmp/a.wav -ar
22050 /tmp/a.mp2
175 Convert the sample rate of a.wav to
22050 Hz and encode it to MPEG audio.
179 * You can encode to several formats at the same time and define a
180 mapping from input stream to output streams:
185 ffmpeg -i /tmp/a.wav -ab
64 /tmp/a.mp2 -ab
128 /tmp/b.mp2 -map
0:
0 -map
0:
0
189 Convert a.wav to a.mp2 at
64 kbits and b.mp2 at
128 kbits. '-map
190 file:index' specify which input stream is used for each output
191 stream, in the order of the definition of output streams.
195 * You can transcode decrypted VOBs
200 ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b
800 -g
300 -bf
2 -acodec mp3 -ab
128 snatch.avi
204 This is a typicall DVD ripper example, input from a VOB file, output
205 to an AVI file with MPEG-
4 video and MP3 audio, note that in this
206 command we use B frames so the MPEG-
4 stream is DivX5 compatible, GOP
207 size is
300 that means an INTRA frame every
10 seconds for
29.97 fps
208 input video. Also the audio stream is MP3 encoded so you need LAME
209 support which is enabled using
<CODE>--enable-mp3lame
</CODE> when
210 configuring. The mapping is particullary usefull for DVD transcoding
211 to get the desired audio language.
215 NOTE: to see the supported input formats, use
<CODE>ffmpeg -formats
</CODE>.
220 <H1><A NAME=
"SEC5" HREF=
"ffmpeg-doc.html#TOC5">3. Invocation
</A></H1>
224 <H2><A NAME=
"SEC6" HREF=
"ffmpeg-doc.html#TOC6">3.1 Syntax
</A></H2>
227 The generic syntax is:
232 ffmpeg [[options][-i input_file]]... {[options] output_file}...
236 If no input file is given, audio/video grabbing is done.
240 As a general rule, options are applied to the next specified
241 file. For example, if you give the '-b
64' option, it sets the video
242 bitrate of the next file. Format option may be needed for raw input
247 By default, ffmpeg tries to convert as losslessly as possible: it
248 uses the same audio and video parameter fors the outputs as the one
249 specified for the inputs.
254 <H2><A NAME=
"SEC7" HREF=
"ffmpeg-doc.html#TOC7">3.2 Main options
</A></H2>
258 <DT><SAMP>`-L'
</SAMP>
261 <DT><SAMP>`-h'
</SAMP>
264 <DT><SAMP>`-formats'
</SAMP>
266 show available formats, codecs, protocols, ...
267 <DT><SAMP>`-f fmt'
</SAMP>
270 <DT><SAMP>`-i filename'
</SAMP>
274 <DT><SAMP>`-y'
</SAMP>
276 overwrite output files
278 <DT><SAMP>`-t duration'
</SAMP>
280 set the recording time in seconds.
<CODE>hh:mm:ss[.xxx]
</CODE> syntax is also
283 <DT><SAMP>`-title string'
</SAMP>
287 <DT><SAMP>`-author string'
</SAMP>
291 <DT><SAMP>`-copyright string'
</SAMP>
295 <DT><SAMP>`-comment string'
</SAMP>
299 <DT><SAMP>`-b bitrate'
</SAMP>
301 set video bitrate (in kbit/s)
306 <H2><A NAME=
"SEC8" HREF=
"ffmpeg-doc.html#TOC8">3.3 Video Options
</A></H2>
310 <DT><SAMP>`-s size'
</SAMP>
312 set frame size [
160x128]
313 <DT><SAMP>`-r fps'
</SAMP>
316 <DT><SAMP>`-b bitrate'
</SAMP>
318 set the video bitrate in kbit/s [
200]
319 <DT><SAMP>`-vn'
</SAMP>
321 disable video recording [no]
322 <DT><SAMP>`-bt tolerance'
</SAMP>
324 set video bitrate tolerance (in kbit/s)
325 <DT><SAMP>`-sameq'
</SAMP>
327 use same video quality as source (implies VBR)
329 <DT><SAMP>`-pass n'
</SAMP>
331 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.
333 <DT><SAMP>`-passlogfile file'
</SAMP>
335 select two pass log file name
341 <H2><A NAME=
"SEC9" HREF=
"ffmpeg-doc.html#TOC9">3.4 Audio Options
</A></H2>
345 <DT><SAMP>`-ab bitrate'
</SAMP>
347 set audio bitrate (in kbit/s)
348 <DT><SAMP>`-ar freq'
</SAMP>
350 set the audio sampling freq [
44100]
351 <DT><SAMP>`-ab bitrate'
</SAMP>
353 set the audio bitrate in kbit/s [
64]
354 <DT><SAMP>`-ac channels'
</SAMP>
356 set the number of audio channels [
1]
357 <DT><SAMP>`-an'
</SAMP>
359 disable audio recording [no]
364 <H2><A NAME=
"SEC10" HREF=
"ffmpeg-doc.html#TOC10">3.5 Advanced options
</A></H2>
368 <DT><SAMP>`-map file:stream'
</SAMP>
370 set input stream mapping
371 <DT><SAMP>`-g gop_size'
</SAMP>
373 set the group of picture size
374 <DT><SAMP>`-intra'
</SAMP>
376 use only intra frames
377 <DT><SAMP>`-qscale q'
</SAMP>
379 use fixed video quantiser scale (VBR)
380 <DT><SAMP>`-qmin q'
</SAMP>
382 min video quantiser scale (VBR)
383 <DT><SAMP>`-qmax q'
</SAMP>
385 max video quantiser scale (VBR)
386 <DT><SAMP>`-qdiff q'
</SAMP>
388 max difference between the quantiser scale (VBR)
389 <DT><SAMP>`-qblur blur'
</SAMP>
391 video quantiser scale blur (VBR)
392 <DT><SAMP>`-qcomp compression'
</SAMP>
394 video quantiser scale compression (VBR)
395 <DT><SAMP>`-vd device'
</SAMP>
398 <DT><SAMP>`-vcodec codec'
</SAMP>
401 <DT><SAMP>`-me method'
</SAMP>
403 set motion estimation method
404 <DT><SAMP>`-bf frames'
</SAMP>
406 use 'frames' B frames (only MPEG-
4)
407 <DT><SAMP>`-hq'
</SAMP>
409 activate high quality settings
410 <DT><SAMP>`-
4mv'
</SAMP>
412 use four motion vector by macroblock (only MPEG-
4)
413 <DT><SAMP>`-ad device'
</SAMP>
416 <DT><SAMP>`-acodec codec'
</SAMP>
419 <DT><SAMP>`-deinterlace'
</SAMP>
422 <DT><SAMP>`-benchmark'
</SAMP>
424 add timings for benchmarking
425 <DT><SAMP>`-hex'
</SAMP>
427 dump each input packet
428 <DT><SAMP>`-psnr'
</SAMP>
430 calculate PSNR of compressed frames
431 <DT><SAMP>`-vstats'
</SAMP>
433 dump video coding statistics to file
438 <H2><A NAME=
"SEC11" HREF=
"ffmpeg-doc.html#TOC11">3.6 Protocols
</A></H2>
441 The output file can be
"-" to output to a pipe. This is only possible
442 with mpeg1 and h263 formats.
446 ffmpeg handles also many protocols specified with the URL syntax.
450 Use 'ffmpeg -formats' to have a list of the supported protocols.
454 The protocol
<CODE>http:
</CODE> is currently used only to communicate with
455 ffserver (see the ffserver documentation). When ffmpeg will be a
456 video player it will also be used for streaming :-)
461 <H1><A NAME=
"SEC12" HREF=
"ffmpeg-doc.html#TOC12">4. Tips
</A></H1>
465 <LI>For streaming at very low bit rate application, use a low frame rate
467 and a small gop size. This is especially true for real video where
468 the Linux player does not seem to be very fast, so it can miss
469 frames. An example is:
473 ffmpeg -g
3 -r
3 -t
10 -b
50 -s qcif -f rv10 /tmp/b.rm
476 <LI>The parameter 'q' which is displayed while encoding is the current
478 quantizer. The value of
1 indicates that a very good quality could
479 be achieved. The value of
31 indicates the worst quality. If q=
31
480 too often, it means that the encoder cannot compress enough to meet
481 your bit rate. You must either increase the bit rate, decrease the
482 frame rate or decrease the frame size.
484 <LI>If your computer is not fast enough, you can speed up the
486 compression at the expense of the compression ratio. You can use
487 '-me zero' to speed up motion estimation, and '-intra' to disable
488 completly motion estimation (you have only I frames, which means it
489 is about as good as JPEG compression).
491 <LI>To have very low bitrates in audio, reduce the sampling frequency
493 (down to
22050 kHz for mpeg audio,
22050 or
11025 for ac3).
495 <LI>To have a constant quality (but a variable bitrate), use the option
497 '-qscale n' when 'n' is between
1 (excellent quality) and
31 (worst
500 <LI>When converting video files, you can use the '-sameq' option which
502 uses in the encoder the same quality factor than in the decoder. It
503 allows to be almost lossless in encoding.
509 <H1><A NAME=
"SEC13" HREF=
"ffmpeg-doc.html#TOC13">5. Supported File Formats and Codecs
</A></H1>
512 You can use the
<CODE>-formats
</CODE> option to have an exhaustive list.
517 <H2><A NAME=
"SEC14" HREF=
"ffmpeg-doc.html#TOC14">5.1 File Formats
</A></H2>
520 FFmpeg supports the following file formats thru the
<CODE>libavformat
</CODE>
526 <TR><TD>Supported File Format
</TD><TD> Encoding
</TD><TD> Decoding
</TD><TD> Comments
</TD>
529 <TR><TD>MPEG audio
</TD><TD> X
</TD><TD> X
</TD>
532 <TR><TD>MPEG1 systems
</TD><TD> X
</TD><TD> X
</TD>
534 </TD><TD> muxed audio and video
536 <TR><TD>MPEG2 PS
</TD><TD> X
</TD><TD> X
</TD>
538 </TD><TD> also known as
<CODE>VOB
</CODE> file
540 <TR><TD>MPEG2 TS
</TD><TD> </TD><TD> X
</TD>
542 </TD><TD> also known as DVB Transport Stream
544 <TR><TD>ASF
</TD><TD> X
</TD><TD> X
</TD>
547 <TR><TD>AVI
</TD><TD> X
</TD><TD> X
</TD>
550 <TR><TD>WAV
</TD><TD> X
</TD><TD> X
</TD>
553 <TR><TD>Macromedia Flash
</TD><TD> X
</TD><TD> X
</TD>
555 </TD><TD> Only embedded audio is decoded
557 <TR><TD>Real Audio and Video
</TD><TD> X
</TD><TD> X
</TD>
560 <TR><TD>PGM, YUV, PPM, JPEG images
</TD><TD> X
</TD><TD> X
</TD>
563 <TR><TD>Animated GIF
</TD><TD> X
</TD><TD></TD>
565 </TD><TD> Only uncompressed GIFs are generated
567 <TR><TD>Raw AC3
</TD><TD> X
</TD><TD> X
</TD>
570 <TR><TD>Raw MJPEG
</TD><TD> X
</TD><TD> X
</TD>
573 <TR><TD>Raw MPEG video
</TD><TD> X
</TD><TD> X
</TD>
576 <TR><TD>Raw PCM8/
16 bits, mulaw/Alaw
</TD><TD> X
</TD><TD> X
</TD>
579 <TR><TD>SUN AU format
</TD><TD> X
</TD><TD> X
</TD>
582 <TR><TD>Quicktime
</TD><TD> </TD><TD> X
</TD>
585 <TR><TD>MPEG4
</TD><TD> </TD><TD> X
</TD>
587 </TD><TD> MPEG4 is a variant of Quicktime
589 <TR><TD>Raw MPEG4 video
</TD><TD> </TD><TD> X
</TD>
591 </TD><TD> Only small files are supported.
593 <TR><TD>DV
</TD><TD> </TD><TD> X
</TD>
595 </TD><TD> Only the video track is decoded.
599 <CODE>X
</CODE> means that the encoding (resp. decoding) is supported.
604 <H2><A NAME=
"SEC15" HREF=
"ffmpeg-doc.html#TOC15">5.2 Video Codecs
</A></H2>
608 <TR><TD>Supported Codec
</TD><TD> Encoding
</TD><TD> Decoding
</TD><TD> Comments
</TD>
611 <TR><TD>MPEG1 video
</TD><TD> X
</TD><TD> X
</TD>
614 <TR><TD>MPEG2 video
</TD><TD> </TD><TD> X
</TD>
617 <TR><TD>MPEG4
</TD><TD> X
</TD><TD> X
</TD><TD> Also known as DIVX4/
5</TD>
620 <TR><TD>MSMPEG4 V1
</TD><TD> X
</TD><TD> X
</TD>
623 <TR><TD>MSMPEG4 V2
</TD><TD> X
</TD><TD> X
</TD>
626 <TR><TD>MSMPEG4 V3
</TD><TD> X
</TD><TD> X
</TD><TD> Also known as DIVX3
</TD>
629 <TR><TD>WMV7
</TD><TD> X
</TD><TD> X
</TD>
632 <TR><TD>H263(+)
</TD><TD> X
</TD><TD> X
</TD><TD> Also known as Real Video
1.0</TD>
635 <TR><TD>MJPEG
</TD><TD> X
</TD><TD> X
</TD>
638 <TR><TD>DV
</TD><TD> </TD><TD> X
</TD>
643 <CODE>X
</CODE> means that the encoding (resp. decoding) is supported.
648 <H2><A NAME=
"SEC16" HREF=
"ffmpeg-doc.html#TOC16">5.3 Audio Codecs
</A></H2>
652 <TR><TD>Supported Codec
</TD><TD> Encoding
</TD><TD> Decoding
</TD><TD> Comments
</TD>
655 <TR><TD>MPEG audio layer
2 </TD><TD> IX
</TD><TD> IX
</TD>
658 <TR><TD>MPEG audio layer
1/
3 </TD><TD> IX
</TD><TD> IX
</TD>
660 </TD><TD> MP3 encoding is supported thru the external library LAME
662 <TR><TD>AC3
</TD><TD> IX
</TD><TD> X
</TD>
664 </TD><TD> liba52 is used internally for decoding.
666 <TR><TD>Vorbis
</TD><TD> X
</TD><TD></TD>
668 </TD><TD> encoding is supported thru the external library libvorbis.
672 <CODE>X
</CODE> means that the encoding (resp. decoding) is supported.
676 <CODE>I
</CODE> means that an integer only version is available too (ensures highest
677 performances on systems without hardware floating point support).
682 <H1><A NAME=
"SEC17" HREF=
"ffmpeg-doc.html#TOC17">6. Developpers Guide
</A></H1>
686 <H2><A NAME=
"SEC18" HREF=
"ffmpeg-doc.html#TOC18">6.1 API
</A></H2>
689 <LI>libavcodec is the library containing the codecs (both encoding and
691 decoding). See
<TT>`libavcodec/apiexample.c'
</TT> to see how to use it.
693 <LI>libavformat is the library containing the file formats handling (mux and
695 demux code for several formats). (no example yet, the API is likely to
701 <H2><A NAME=
"SEC19" HREF=
"ffmpeg-doc.html#TOC19">6.2 Integrating libavcodec or libavformat in your program
</A></H2>
704 You can integrate all the source code of the libraries to link them
705 statically to avoid any version problem. All you need is to provide a
706 'config.mak' and a 'config.h' in the parent directory. See the defines
707 generated by ./configure to understand what is needed.
711 You can use libavcodec or libavformat in your commercial program, but
712 <EM>any patch you make must be published
</EM>. The best way to proceed is
713 to send your patches to the ffmpeg mailing list.
718 <H2><A NAME=
"SEC20" HREF=
"ffmpeg-doc.html#TOC20">6.3 Coding Rules
</A></H2>
721 ffmpeg is programmed in ANSI C language. GCC extensions are
722 tolerated. Indent size is
4. The TAB character should not be used.
726 The presentation is the one specified by 'indent -i4 -kr'.
730 Main priority in ffmpeg is simplicity and small code size (=less
735 Comments: for functions visible from other modules, use the JavaDoc
736 format (see examples in
<TT>`libav/utils.c'
</TT>) so that a documentation
737 can be generated automatically.
742 <H2><A NAME=
"SEC21" HREF=
"ffmpeg-doc.html#TOC21">6.4 Submitting patches
</A></H2>
745 When you submit your patch, try to send a unified diff (diff '-u'
746 option). I cannot read other diffs :-)
750 Run the regression tests before submitting a patch so that you can
751 verify that there is no big problems.
755 Except if your patch is really big and adds an important feature, by
756 submitting it to me, you accept implicitely to put it under my
757 copyright. I prefer to do this to avoid potential problems if
758 licensing of ffmpeg changes.
762 Patches should be posted as base64 encoded attachments (or any other
763 encoding which ensures that the patch wont be trashed during
764 transmission) to the ffmpeg-devel mailinglist, see
765 <A HREF=
"http://lists.sourceforge.net/lists/listinfo/ffmpeg-devel">http://lists.sourceforge.net/lists/listinfo/ffmpeg-devel
</A>
770 <H2><A NAME=
"SEC22" HREF=
"ffmpeg-doc.html#TOC22">6.5 Regression tests
</A></H2>
773 Before submitting a patch (or commiting with CVS), you should at least
774 test that you did not break anything.
778 The regression test build a synthetic video stream and a synthetic
779 audio stream. Then there are encoded then decoded with all codecs or
780 formats. The CRC (or MD5) of each generated file is recorded in a
781 result file. Then a 'diff' is launched with the reference results and
786 Run 'make test' to test all the codecs.
790 Run 'make libavtest' to test all the codecs.
794 [Of course, some patches may change the regression tests results. In
795 this case, the regression tests reference results shall be modified
800 This document was generated on
27 October
2002 using
801 <A HREF=
"http://wwwinfo.cern.ch/dis/texi2html/">texi2html
</A> 1.56k.