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.

525 lines
16KB

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