You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

571 lines
18KB

  1. \input texinfo @c -*- texinfo -*-
  2. @settitle FFmpeg Documentation
  3. @titlepage
  4. @sp 7
  5. @center @titlefont{FFmpeg Documentation}
  6. @sp 3
  7. @end titlepage
  8. @chapter Introduction
  9. FFmpeg is a very fast video and audio converter. It can also grab from
  10. a live audio/video source.
  11. The command line interface is designed to be intuitive, in the sense
  12. that ffmpeg tries to figure out all the parameters, when
  13. possible. You have usually to give only the target bitrate you want.
  14. FFmpeg can also convert from any sample rate to any other, and resize
  15. video on the fly with a high quality polyphase filter.
  16. @chapter Quick Start
  17. @c man begin EXAMPLES
  18. @section Video and Audio grabbing
  19. FFmpeg can use a video4linux compatible video source and any Open Sound
  20. System audio source:
  21. @example
  22. ffmpeg /tmp/out.mpg
  23. @end example
  24. Note that you must activate the right video source and channel before
  25. launching ffmpeg. You can use any TV viewer such as xawtv
  26. (@url{http://bytesex.org/xawtv/}) by Gerd Knorr which I find very
  27. good. You must also set correctly the audio recording levels with a
  28. standard mixer.
  29. @section Video and Audio file format conversion
  30. * ffmpeg can use any supported file format and protocol as input:
  31. Examples:
  32. * You can input from YUV files:
  33. @example
  34. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  35. @end example
  36. It will use the files:
  37. @example
  38. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  39. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  40. @end example
  41. The Y files use twice the resolution of the U and V files. They are
  42. raw files, without header. They can be generated by all decent video
  43. decoders. You must specify the size of the image with the @option{-s} option
  44. if ffmpeg cannot guess it.
  45. * You can input from a RAW YUV420P file:
  46. @example
  47. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  48. @end example
  49. The RAW YUV420P is a file containing RAW YUV planar, for each frame first
  50. come the Y plane followed by U and V planes, which are half vertical and
  51. horizontal resolution.
  52. * You can output to a RAW YUV420P file:
  53. @example
  54. ffmpeg -i mydivx.avi -o hugefile.yuv
  55. @end example
  56. * You can set several input files and output files:
  57. @example
  58. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  59. @end example
  60. Convert the audio file a.wav and the raw yuv video file a.yuv
  61. to mpeg file a.mpg
  62. * You can also do audio and video conversions at the same time:
  63. @example
  64. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  65. @end example
  66. Convert the sample rate of a.wav to 22050 Hz and encode it to MPEG audio.
  67. * You can encode to several formats at the same time and define a
  68. mapping from input stream to output streams:
  69. @example
  70. ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
  71. @end example
  72. Convert a.wav to a.mp2 at 64 kbits and b.mp2 at 128 kbits. '-map
  73. file:index' specify which input stream is used for each output
  74. stream, in the order of the definition of output streams.
  75. * You can transcode decrypted VOBs
  76. @example
  77. ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800 -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
  78. @end example
  79. This is a typical DVD ripper example, input from a VOB file, output
  80. to an AVI file with MPEG-4 video and MP3 audio, note that in this
  81. command we use B frames so the MPEG-4 stream is DivX5 compatible, GOP
  82. size is 300 that means an INTRA frame every 10 seconds for 29.97 fps
  83. input video. Also the audio stream is MP3 encoded so you need LAME
  84. support which is enabled using @code{--enable-mp3lame} when
  85. configuring. The mapping is particularly useful for DVD transcoding
  86. to get the desired audio language.
  87. NOTE: to see the supported input formats, use @code{ffmpeg -formats}.
  88. @c man end
  89. @chapter Invocation
  90. @section Syntax
  91. The generic syntax is:
  92. @example
  93. @c man begin SYNOPSIS
  94. ffmpeg [[options][@option{-i} @var{input_file}]]... @{[options] @var{output_file}@}...
  95. @c man end
  96. @end example
  97. @c man begin DESCRIPTION
  98. If no input file is given, audio/video grabbing is done.
  99. As a general rule, options are applied to the next specified
  100. file. For example, if you give the @option{-b 64} option, it sets the video
  101. bitrate of the next file. Format option may be needed for raw input
  102. files.
  103. By default, ffmpeg tries to convert as losslessly as possible: it
  104. uses the same audio and video parameter for the outputs as the one
  105. specified for the inputs.
  106. @c man end
  107. @c man begin OPTIONS
  108. @section Main options
  109. @table @option
  110. @item -L
  111. show license
  112. @item -h
  113. show help
  114. @item -formats
  115. show available formats, codecs, protocols, ...
  116. @item -f fmt
  117. force format
  118. @item -i filename
  119. input file name
  120. @item -y
  121. overwrite output files
  122. @item -t duration
  123. set the recording time in seconds. @code{hh:mm:ss[.xxx]} syntax is also
  124. supported.
  125. @item -title string
  126. set the title
  127. @item -author string
  128. set the author
  129. @item -copyright string
  130. set the copyright
  131. @item -comment string
  132. set the comment
  133. @end table
  134. @section Video Options
  135. @table @option
  136. @item -s size
  137. set frame size [160x128]
  138. @item -r fps
  139. set frame rate [25]
  140. @item -b bitrate
  141. set the video bitrate in kbit/s [200]
  142. @item -vn
  143. disable video recording [no]
  144. @item -bt tolerance
  145. set video bitrate tolerance (in kbit/s)
  146. @item -sameq
  147. use same video quality as source (implies VBR)
  148. @item -pass n
  149. 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.
  150. @item -passlogfile file
  151. select two pass log file name
  152. @end table
  153. @section Audio Options
  154. @table @option
  155. @item -ab bitrate
  156. set audio bitrate (in kbit/s)
  157. @item -ar freq
  158. set the audio sampling freq [44100]
  159. @item -ab bitrate
  160. set the audio bitrate in kbit/s [64]
  161. @item -ac channels
  162. set the number of audio channels [1]
  163. @item -an
  164. disable audio recording [no]
  165. @end table
  166. @section Advanced options
  167. @table @option
  168. @item -map file:stream
  169. set input stream mapping
  170. @item -g gop_size
  171. set the group of picture size
  172. @item -intra
  173. use only intra frames
  174. @item -qscale q
  175. use fixed video quantiser scale (VBR)
  176. @item -qmin q
  177. min video quantiser scale (VBR)
  178. @item -qmax q
  179. max video quantiser scale (VBR)
  180. @item -qdiff q
  181. max difference between the quantiser scale (VBR)
  182. @item -qblur blur
  183. video quantiser scale blur (VBR)
  184. @item -qcomp compression
  185. video quantiser scale compression (VBR)
  186. @item -vd device
  187. set video device
  188. @item -vcodec codec
  189. force video codec
  190. @item -me method
  191. set motion estimation method
  192. @item -bf frames
  193. use 'frames' B frames (only MPEG-4)
  194. @item -hq
  195. activate high quality settings
  196. @item -4mv
  197. use four motion vector by macroblock (only MPEG-4)
  198. @item -ad device
  199. set audio device
  200. @item -acodec codec
  201. force audio codec
  202. @item -deinterlace
  203. deinterlace pictures
  204. @item -benchmark
  205. add timings for benchmarking
  206. @item -hex
  207. dump each input packet
  208. @item -psnr
  209. calculate PSNR of compressed frames
  210. @item -vstats
  211. dump video coding statistics to file
  212. @end table
  213. @c man end
  214. @ignore
  215. @setfilename ffmpeg
  216. @settitle FFmpeg video converter
  217. @c man begin SEEALSO
  218. ffserver(1), ffplay(1) and the html documentation of @file{ffmpeg}.
  219. @c man end
  220. @c man begin AUTHOR
  221. Fabrice Bellard
  222. @c man end
  223. @end ignore
  224. @section Protocols
  225. The filename can be @file{-} to read from the standard input or to write
  226. to the standard output.
  227. ffmpeg handles also many protocols specified with the URL syntax.
  228. Use 'ffmpeg -formats' to have a list of the supported protocols.
  229. The protocol @code{http:} is currently used only to communicate with
  230. ffserver (see the ffserver documentation). When ffmpeg will be a
  231. video player it will also be used for streaming :-)
  232. @chapter Tips
  233. @itemize
  234. @item For streaming at very low bit rate application, use a low frame rate
  235. and a small gop size. This is especially true for real video where
  236. the Linux player does not seem to be very fast, so it can miss
  237. frames. An example is:
  238. @example
  239. ffmpeg -g 3 -r 3 -t 10 -b 50 -s qcif -f rv10 /tmp/b.rm
  240. @end example
  241. @item The parameter 'q' which is displayed while encoding is the current
  242. quantizer. The value of 1 indicates that a very good quality could
  243. be achieved. The value of 31 indicates the worst quality. If q=31
  244. too often, it means that the encoder cannot compress enough to meet
  245. your bit rate. You must either increase the bit rate, decrease the
  246. frame rate or decrease the frame size.
  247. @item If your computer is not fast enough, you can speed up the
  248. compression at the expense of the compression ratio. You can use
  249. '-me zero' to speed up motion estimation, and '-intra' to disable
  250. completely motion estimation (you have only I frames, which means it
  251. is about as good as JPEG compression).
  252. @item To have very low bitrates in audio, reduce the sampling frequency
  253. (down to 22050 kHz for mpeg audio, 22050 or 11025 for ac3).
  254. @item To have a constant quality (but a variable bitrate), use the option
  255. '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
  256. quality).
  257. @item When converting video files, you can use the '-sameq' option which
  258. uses in the encoder the same quality factor than in the decoder. It
  259. allows to be almost lossless in encoding.
  260. @end itemize
  261. @chapter Supported File Formats and Codecs
  262. You can use the @code{-formats} option to have an exhaustive list.
  263. @section File Formats
  264. FFmpeg supports the following file formats through the @code{libavformat}
  265. library:
  266. @multitable @columnfractions .4 .1 .1
  267. @item Supported File Format @tab Encoding @tab Decoding @tab Comments
  268. @item MPEG audio @tab X @tab X
  269. @item MPEG1 systems @tab X @tab X
  270. @tab muxed audio and video
  271. @item MPEG2 PS @tab X @tab X
  272. @tab also known as @code{VOB} file
  273. @item MPEG2 TS @tab @tab X
  274. @tab also known as DVB Transport Stream
  275. @item ASF@tab X @tab X
  276. @item AVI@tab X @tab X
  277. @item WAV@tab X @tab X
  278. @item Macromedia Flash@tab X @tab X
  279. @tab Only embedded audio is decoded
  280. @item FLV @tab X @tab X
  281. @tab Macromedia Flash video files
  282. @item Real Audio and Video @tab X @tab X
  283. @item Raw AC3 @tab X @tab X
  284. @item Raw MJPEG @tab X @tab X
  285. @item Raw MPEG video @tab X @tab X
  286. @item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
  287. @item SUN AU format @tab X @tab X
  288. @item Quicktime @tab @tab X
  289. @item MPEG4 @tab @tab X
  290. @tab MPEG4 is a variant of Quicktime
  291. @item Raw MPEG4 video @tab X @tab X
  292. @item DV @tab @tab X
  293. @item 4xm @tab @tab X
  294. @tab 4X Technologies format, used in some games
  295. @end multitable
  296. @code{X} means that the encoding (resp. decoding) is supported.
  297. @section Image Formats
  298. FFmpeg can read and write images for each frame of a video sequence. The
  299. following image formats are supported:
  300. @multitable @columnfractions .4 .1 .1
  301. @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
  302. @item PGM, PPM @tab X @tab X
  303. @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support
  304. @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
  305. @item JPEG @tab X @tab X @tab Progressive JPEG is not supported
  306. @item .Y.U.V @tab X @tab X @tab One raw file per component
  307. @item Animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated
  308. @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet
  309. @end multitable
  310. @code{X} means that the encoding (resp. decoding) is supported.
  311. @section Video Codecs
  312. @multitable @columnfractions .4 .1 .1 .7
  313. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  314. @item MPEG1 video @tab X @tab X
  315. @item MPEG2 video @tab @tab X
  316. @item MPEG4 @tab X @tab X @tab Also known as DIVX4/5
  317. @item MSMPEG4 V1 @tab X @tab X
  318. @item MSMPEG4 V2 @tab X @tab X
  319. @item MSMPEG4 V3 @tab X @tab X @tab Also known as DIVX3
  320. @item WMV7 @tab X @tab X
  321. @item WMV8 @tab X @tab X @tab Not completely working
  322. @item H263(+) @tab X @tab X @tab Also known as Real Video 1.0
  323. @item MJPEG @tab X @tab X
  324. @item DV @tab @tab X
  325. @item Huff YUV @tab X @tab X
  326. @item Asus v1 @tab X @tab X @tab fourcc: ASV1
  327. @item Creative YUV @tab @tab X @tab fourcc: CYUV
  328. @item H.264 @tab @tab X
  329. @item Sorenson Video 1 @tab @tab X @tab fourcc: SVQ1
  330. @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
  331. @item On2 VP3 @tab @tab X @tab still experimental
  332. @item Intel Indeo 3 @tab @tab X @tab only works on i386 right now
  333. @item FLV @tab X @tab X @tab Flash H263 variant
  334. @end multitable
  335. @code{X} means that the encoding (resp. decoding) is supported.
  336. Check at @url{http://www.mplayerhq.hu/~michael/codec-features.html} to
  337. get a precise comparison of FFmpeg MPEG4 codec compared to the other
  338. solutions.
  339. @section Audio Codecs
  340. @multitable @columnfractions .4 .1 .1 .1 .7
  341. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  342. @item MPEG audio layer 2 @tab IX @tab IX
  343. @item MPEG audio layer 1/3 @tab IX @tab IX
  344. @tab MP3 encoding is supported through the external library LAME
  345. @item AC3 @tab IX @tab X
  346. @tab liba52 is used internally for decoding
  347. @item Vorbis @tab X @tab X
  348. @tab supported through the external library libvorbis
  349. @item WMA V1/V2 @tab @tab X
  350. @item Microsoft ADPCM @tab X @tab X
  351. @item IMA ADPCM @tab X @tab X
  352. @item RA144 @tab @tab X
  353. @tab Real 14400 bit/s codec
  354. @item RA288 @tab @tab X
  355. @tab Real 28800 bit/s codec
  356. @item AMR-NB @tab X @tab X
  357. @tab supported through an external library
  358. @item DV audio @tab @tab X
  359. @end multitable
  360. @code{X} means that the encoding (resp. decoding) is supported.
  361. @code{I} means that an integer only version is available too (ensures highest
  362. performances on systems without hardware floating point support).
  363. @chapter Platform Specific information
  364. @section Linux
  365. ffmpeg should be compiled with at least GCC 2.95.3. GCC 3.2 is the
  366. preferred compiler now for ffmpeg. All future optimizations will depend on
  367. features only found in GCC 3.2.
  368. @section BSD
  369. @section Windows
  370. @section MacOS X
  371. @section BeOS
  372. The configure script should guess the configuration itself.
  373. Networking support is currently not finished.
  374. errno issues fixed by Andrew Bachmann.
  375. Old stuff:
  376. François Revol - revol at free dot fr - April 2002
  377. The configure script should guess the configuration itself,
  378. however I still didn't tested building on net_server version of BeOS.
  379. ffserver is broken (needs poll() implementation).
  380. There is still issues with errno codes, which are negative in BeOs, and
  381. that ffmpeg negates when returning. This ends up turning errors into
  382. valid results, then crashes.
  383. (To be fixed)
  384. @chapter Developers Guide
  385. @section API
  386. @itemize
  387. @item libavcodec is the library containing the codecs (both encoding and
  388. decoding). See @file{libavcodec/apiexample.c} to see how to use it.
  389. @item libavformat is the library containing the file formats handling (mux and
  390. demux code for several formats). See @file{ffplay.c} to use it in a
  391. player. See @file{output_example.c} to use it to generate audio or video
  392. streams.
  393. @end itemize
  394. @section Integrating libavcodec or libavformat in your program
  395. You can integrate all the source code of the libraries to link them
  396. statically to avoid any version problem. All you need is to provide a
  397. 'config.mak' and a 'config.h' in the parent directory. See the defines
  398. generated by ./configure to understand what is needed.
  399. You can use libavcodec or libavformat in your commercial program, but
  400. @emph{any patch you make must be published}. The best way to proceed is
  401. to send your patches to the ffmpeg mailing list.
  402. @section Coding Rules
  403. ffmpeg is programmed in ANSI C language. GCC extensions are
  404. tolerated. Indent size is 4. The TAB character should not be used.
  405. The presentation is the one specified by 'indent -i4 -kr'.
  406. Main priority in ffmpeg is simplicity and small code size (=less
  407. bugs).
  408. Comments: for functions visible from other modules, use the JavaDoc
  409. format (see examples in @file{libav/utils.c}) so that a documentation
  410. can be generated automatically.
  411. @section Submitting patches
  412. When you submit your patch, try to send a unified diff (diff '-u'
  413. option). I cannot read other diffs :-)
  414. Run the regression tests before submitting a patch so that you can
  415. verify that there are no big problems.
  416. Patches should be posted as base64 encoded attachments (or any other
  417. encoding which ensures that the patch wont be trashed during
  418. transmission) to the ffmpeg-devel mailinglist, see
  419. @url{http://lists.sourceforge.net/lists/listinfo/ffmpeg-devel}
  420. @section Regression tests
  421. Before submitting a patch (or committing with CVS), you should at least
  422. test that you did not break anything.
  423. The regression test build a synthetic video stream and a synthetic
  424. audio stream. Then these are encoded then decoded with all codecs or
  425. formats. The CRC (or MD5) of each generated file is recorded in a
  426. result file. Then a 'diff' is launched with the reference results and
  427. the result file.
  428. The regression test then goes on to test the ffserver code with a
  429. limited set of streams. It is important that this step runs correctly
  430. as well.
  431. Run 'make test' to test all the codecs.
  432. Run 'make libavtest' to test all the codecs.
  433. [Of course, some patches may change the regression tests results. In
  434. this case, the regression tests reference results shall be modified
  435. accordingly].
  436. @bye