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.

538 lines
17KB

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