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.

986 lines
41KB

  1. \input texinfo @c -*- texinfo -*-
  2. @settitle General Documentation
  3. @titlepage
  4. @sp 7
  5. @center @titlefont{General Documentation}
  6. @sp 3
  7. @end titlepage
  8. @chapter external libraries
  9. FFmpeg can be hooked up with a number of external libraries to add support
  10. for more formats. None of them are used by default, their use has to be
  11. explicitly requested by passing the appropriate flags to @file{./configure}.
  12. @section AMR
  13. AMR comes in two different flavors, wideband and narrowband. FFmpeg can make
  14. use of the AMR wideband (floating-point mode) and the AMR narrowband
  15. (floating-point mode) reference decoders and encoders.
  16. Go to @url{http://www.penguin.cz/~utx/amr} and follow the instructions for
  17. installing the libraries. Then pass @code{--enable-libamr-nb} and/or
  18. @code{--enable-libamr-wb} to configure to enable the libraries.
  19. Note that libamr is copyrighted without any sort of license grant. This means
  20. that you can use it if you legally obtained it but you are not allowed to
  21. redistribute it in any way. @strong{Any FFmpeg binaries with libamr support
  22. you create are non-free and unredistributable!}
  23. @chapter Supported File Formats and Codecs
  24. You can use the @code{-formats} option to have an exhaustive list.
  25. @section File Formats
  26. FFmpeg supports the following file formats through the @code{libavformat}
  27. library:
  28. @multitable @columnfractions .4 .1 .1 .4
  29. @item Supported File Format @tab Encoding @tab Decoding @tab Comments
  30. @item MPEG audio @tab X @tab X
  31. @item MPEG-1 systems @tab X @tab X
  32. @tab muxed audio and video
  33. @item MPEG-2 PS @tab X @tab X
  34. @tab also known as @code{VOB} file
  35. @item MPEG-2 TS @tab @tab X
  36. @tab also known as DVB Transport Stream
  37. @item ASF@tab X @tab X
  38. @item AVI@tab X @tab X
  39. @item WAV@tab X @tab X
  40. @item Macromedia Flash@tab X @tab X
  41. @item AVM2 (Flash 9) @tab X @tab X
  42. @tab Only embedded audio is decoded.
  43. @item FLV @tab X @tab X
  44. @tab Macromedia Flash video files
  45. @item Real Audio and Video @tab X @tab X
  46. @item Raw AC3 @tab X @tab X
  47. @item Raw MJPEG @tab X @tab X
  48. @item Raw MPEG video @tab X @tab X
  49. @item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
  50. @item Raw CRI ADX audio @tab X @tab X
  51. @item Raw Shorten audio @tab @tab X
  52. @item SUN AU format @tab X @tab X
  53. @item NUT @tab X @tab X @tab NUT Open Container Format
  54. @item QuickTime @tab X @tab X
  55. @item MPEG-4 @tab X @tab X
  56. @tab MPEG-4 is a variant of QuickTime.
  57. @item Raw MPEG4 video @tab X @tab X
  58. @item DV @tab X @tab X
  59. @item 4xm @tab @tab X
  60. @tab 4X Technologies format, used in some games.
  61. @item Playstation STR @tab @tab X
  62. @item Id RoQ @tab X @tab X
  63. @tab Used in Quake III, Jedi Knight 2, other computer games.
  64. @item Interplay MVE @tab @tab X
  65. @tab Format used in various Interplay computer games.
  66. @item WC3 Movie @tab @tab X
  67. @tab Multimedia format used in Origin's Wing Commander III computer game.
  68. @item Sega FILM/CPK @tab @tab X
  69. @tab Used in many Sega Saturn console games.
  70. @item Westwood Studios VQA/AUD @tab @tab X
  71. @tab Multimedia formats used in Westwood Studios games.
  72. @item Id Cinematic (.cin) @tab @tab X
  73. @tab Used in Quake II.
  74. @item FLIC format @tab @tab X
  75. @tab .fli/.flc files
  76. @item Sierra VMD @tab @tab X
  77. @tab Used in Sierra CD-ROM games.
  78. @item Sierra Online @tab @tab X
  79. @tab .sol files used in Sierra Online games.
  80. @item Matroska @tab X @tab X
  81. @item Electronic Arts Multimedia @tab @tab X
  82. @tab Used in various EA games; files have extensions like WVE and UV2.
  83. @item Nullsoft Video (NSV) format @tab @tab X
  84. @item ADTS AAC audio @tab X @tab X
  85. @item Creative VOC @tab X @tab X @tab Created for the Sound Blaster Pro.
  86. @item American Laser Games MM @tab @tab X
  87. @tab Multimedia format used in games like Mad Dog McCree
  88. @item AVS @tab @tab X
  89. @tab Multimedia format used by the Creature Shock game.
  90. @item Smacker @tab @tab X
  91. @tab Multimedia format used by many games.
  92. @item GXF @tab X @tab X
  93. @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley playout servers.
  94. @item CIN @tab @tab X
  95. @tab Multimedia format used by Delphine Software games.
  96. @item MXF @tab @tab X
  97. @tab Material eXchange Format SMPTE 377M, used by D-Cinema, broadcast industry.
  98. @item SEQ @tab @tab X
  99. @tab Tiertex .seq files used in the DOS CDROM version of the game Flashback.
  100. @item DXA @tab @tab X
  101. @tab This format is used in non-Windows version of Feeble Files game and
  102. different game cutscenes repacked for use with ScummVM.
  103. @item THP @tab @tab X
  104. @tab Used on the Nintendo GameCube.
  105. @item C93 @tab @tab X
  106. @tab Used in the game Cyberia from Interplay.
  107. @item Bethsoft VID @tab @tab X
  108. @tab Used in some games from Bethesda Softworks.
  109. @item CRYO APC @tab @tab X
  110. @tab Audio format used in some games by CRYO Interactive Entertainment.
  111. @item Monkey's Audio @tab @tab X
  112. @item SIFF @tab @tab X
  113. @tab Audio and video format used in some games by Beam Software
  114. @end multitable
  115. @code{X} means that encoding (resp. decoding) is supported.
  116. @section Image Formats
  117. FFmpeg can read and write images for each frame of a video sequence. The
  118. following image formats are supported:
  119. @multitable @columnfractions .4 .1 .1 .4
  120. @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
  121. @item PGM, PPM @tab X @tab X
  122. @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support.
  123. @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
  124. @item JPEG @tab X @tab X @tab Progressive JPEG is not supported.
  125. @item .Y.U.V @tab X @tab X @tab one raw file per component
  126. @item animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated.
  127. @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet.
  128. @item Targa @tab @tab X @tab Targa (.TGA) image format.
  129. @item TIFF @tab X @tab X @tab YUV, JPEG and some extension is not supported yet.
  130. @item SGI @tab X @tab X @tab SGI RGB image format
  131. @item PTX @tab @tab X @tab V.Flash PTX format
  132. @end multitable
  133. @code{X} means that encoding (resp. decoding) is supported.
  134. @section Video Codecs
  135. @multitable @columnfractions .4 .1 .1 .4
  136. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  137. @item MPEG-1 video @tab X @tab X
  138. @item MPEG-2 video @tab X @tab X
  139. @item MPEG-4 @tab X @tab X
  140. @item MSMPEG4 V1 @tab X @tab X
  141. @item MSMPEG4 V2 @tab X @tab X
  142. @item MSMPEG4 V3 @tab X @tab X
  143. @item WMV7 @tab X @tab X
  144. @item WMV8 @tab X @tab X @tab not completely working
  145. @item WMV9 @tab @tab X @tab not completely working
  146. @item VC1 @tab @tab X
  147. @item H.261 @tab X @tab X
  148. @item H.263(+) @tab X @tab X @tab also known as RealVideo 1.0
  149. @item H.264 @tab @tab X
  150. @item RealVideo 1.0 @tab X @tab X
  151. @item RealVideo 2.0 @tab X @tab X
  152. @item MJPEG @tab X @tab X
  153. @item lossless MJPEG @tab X @tab X
  154. @item JPEG-LS @tab X @tab X @tab fourcc: MJLS, lossless and near-lossless is supported
  155. @item Apple MJPEG-B @tab @tab X
  156. @item Sunplus MJPEG @tab @tab X @tab fourcc: SP5X
  157. @item DV @tab X @tab X
  158. @item HuffYUV @tab X @tab X
  159. @item FFmpeg Video 1 @tab X @tab X @tab experimental lossless codec (fourcc: FFV1)
  160. @item FFmpeg Snow @tab X @tab X @tab experimental wavelet codec (fourcc: SNOW)
  161. @item Asus v1 @tab X @tab X @tab fourcc: ASV1
  162. @item Asus v2 @tab X @tab X @tab fourcc: ASV2
  163. @item Creative YUV @tab @tab X @tab fourcc: CYUV
  164. @item Sorenson Video 1 @tab X @tab X @tab fourcc: SVQ1
  165. @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
  166. @item On2 VP3 @tab @tab X @tab still experimental
  167. @item On2 VP5 @tab @tab X @tab fourcc: VP50
  168. @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62
  169. @item Theora @tab X @tab X @tab still experimental
  170. @item Intel Indeo 3 @tab @tab X
  171. @item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
  172. @item Flash Screen Video @tab X @tab X @tab fourcc: FSV1
  173. @item ATI VCR1 @tab @tab X @tab fourcc: VCR1
  174. @item ATI VCR2 @tab @tab X @tab fourcc: VCR2
  175. @item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
  176. @item 4X Video @tab @tab X @tab Used in certain computer games.
  177. @item Sony Playstation MDEC @tab @tab X
  178. @item Id RoQ @tab X @tab X @tab Used in Quake III, Jedi Knight 2, other computer games.
  179. @item Xan/WC3 @tab @tab X @tab Used in Wing Commander III .MVE files.
  180. @item Interplay Video @tab @tab X @tab Used in Interplay .MVE files.
  181. @item Apple Animation @tab X @tab X @tab fourcc: 'rle '
  182. @item Apple Graphics @tab @tab X @tab fourcc: 'smc '
  183. @item Apple Video @tab @tab X @tab fourcc: rpza
  184. @item Apple QuickDraw @tab @tab X @tab fourcc: qdrw
  185. @item Cinepak @tab @tab X
  186. @item Microsoft RLE @tab @tab X
  187. @item Microsoft Video-1 @tab @tab X
  188. @item Westwood VQA @tab @tab X
  189. @item Id Cinematic Video @tab @tab X @tab Used in Quake II.
  190. @item Planar RGB @tab @tab X @tab fourcc: 8BPS
  191. @item FLIC video @tab @tab X
  192. @item Duck TrueMotion v1 @tab @tab X @tab fourcc: DUCK
  193. @item Duck TrueMotion v2 @tab @tab X @tab fourcc: TM20
  194. @item VMD Video @tab @tab X @tab Used in Sierra VMD files.
  195. @item MSZH @tab @tab X @tab Part of LCL
  196. @item ZLIB @tab X @tab X @tab Part of LCL, encoder experimental
  197. @item TechSmith Camtasia @tab @tab X @tab fourcc: TSCC
  198. @item IBM Ultimotion @tab @tab X @tab fourcc: ULTI
  199. @item Miro VideoXL @tab @tab X @tab fourcc: VIXL
  200. @item QPEG @tab @tab X @tab fourccs: QPEG, Q1.0, Q1.1
  201. @item LOCO @tab @tab X @tab
  202. @item Winnov WNV1 @tab @tab X @tab
  203. @item Autodesk Animator Studio Codec @tab @tab X @tab fourcc: AASC
  204. @item Fraps FPS1 @tab @tab X @tab
  205. @item CamStudio @tab @tab X @tab fourcc: CSCD
  206. @item American Laser Games Video @tab @tab X @tab Used in games like Mad Dog McCree
  207. @item ZMBV @tab X @tab X @tab Encoder works only on PAL8
  208. @item AVS Video @tab @tab X @tab Video encoding used by the Creature Shock game.
  209. @item Smacker Video @tab @tab X @tab Video encoding used in Smacker.
  210. @item RTjpeg @tab @tab X @tab Video encoding used in NuppelVideo files.
  211. @item KMVC @tab @tab X @tab Codec used in Worms games.
  212. @item VMware Video @tab @tab X @tab Codec used in videos captured by VMware.
  213. @item Cin Video @tab @tab X @tab Codec used in Delphine Software games.
  214. @item Tiertex Seq Video @tab @tab X @tab Codec used in DOS CDROM FlashBack game.
  215. @item DXA Video @tab @tab X @tab Codec originally used in Feeble Files game.
  216. @item AVID DNxHD @tab X @tab X @tab aka SMPTE VC3
  217. @item C93 Video @tab @tab X @tab Codec used in Cyberia game.
  218. @item THP @tab @tab X @tab Used on the Nintendo GameCube.
  219. @item Bethsoft VID @tab @tab X @tab Used in some games from Bethesda Softworks.
  220. @item Renderware TXD @tab @tab X @tab Texture dictionaries used by the Renderware Engine.
  221. @item AMV @tab @tab X @tab Used in Chinese MP3 players.
  222. @end multitable
  223. @code{X} means that encoding (resp. decoding) is supported.
  224. @section Audio Codecs
  225. @multitable @columnfractions .4 .1 .1 .1 .7
  226. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  227. @item MPEG audio layer 2 @tab IX @tab IX
  228. @item MPEG audio layer 1/3 @tab X @tab IX
  229. @tab MP3 encoding is supported through the external library LAME.
  230. @item AC3 @tab IX @tab IX
  231. @tab liba52 is used internally for decoding.
  232. @item Vorbis @tab X @tab X
  233. @item WMA V1/V2 @tab X @tab X
  234. @item AAC @tab X @tab X
  235. @tab Supported through the external library libfaac/libfaad.
  236. @item Microsoft ADPCM @tab X @tab X
  237. @item AMV IMA ADPCM @tab @tab X
  238. @tab Used in AMV files
  239. @item MS IMA ADPCM @tab X @tab X
  240. @item QT IMA ADPCM @tab X @tab X
  241. @item 4X IMA ADPCM @tab @tab X
  242. @item G.726 ADPCM @tab X @tab X
  243. @item Duck DK3 IMA ADPCM @tab @tab X
  244. @tab Used in some Sega Saturn console games.
  245. @item Duck DK4 IMA ADPCM @tab @tab X
  246. @tab Used in some Sega Saturn console games.
  247. @item Westwood Studios IMA ADPCM @tab @tab X
  248. @tab Used in Westwood Studios games like Command and Conquer.
  249. @item SMJPEG IMA ADPCM @tab @tab X
  250. @tab Used in certain Loki game ports.
  251. @item CD-ROM XA ADPCM @tab @tab X
  252. @item CRI ADX ADPCM @tab X @tab X
  253. @tab Used in Sega Dreamcast games.
  254. @item Electronic Arts ADPCM @tab @tab X
  255. @tab Used in various EA titles.
  256. @item Creative ADPCM @tab @tab X
  257. @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2
  258. @item THP ADPCM @tab @tab X
  259. @tab Used on the Nintendo GameCube.
  260. @item RA144 @tab @tab X
  261. @tab Real 14400 bit/s codec
  262. @item RA288 @tab @tab X
  263. @tab Real 28800 bit/s codec
  264. @item RADnet @tab X @tab IX
  265. @tab Real low bitrate AC3 codec, liba52 is used for decoding.
  266. @item AMR-NB @tab X @tab X
  267. @tab Supported through an external library.
  268. @item AMR-WB @tab X @tab X
  269. @tab Supported through an external library.
  270. @item DV audio @tab @tab X
  271. @item Id RoQ DPCM @tab X @tab X
  272. @tab Used in Quake III, Jedi Knight 2, other computer games.
  273. @item Interplay MVE DPCM @tab @tab X
  274. @tab Used in various Interplay computer games.
  275. @item Xan DPCM @tab @tab X
  276. @tab Used in Origin's Wing Commander IV AVI files.
  277. @item Sierra Online DPCM @tab @tab X
  278. @tab Used in Sierra Online game audio files.
  279. @item Apple MACE 3 @tab @tab X
  280. @item Apple MACE 6 @tab @tab X
  281. @item FLAC lossless audio @tab X @tab X
  282. @item Shorten lossless audio @tab @tab X
  283. @item Apple lossless audio @tab @tab X
  284. @tab QuickTime fourcc 'alac'
  285. @item FFmpeg Sonic @tab X @tab X
  286. @tab experimental lossy/lossless codec
  287. @item Qdesign QDM2 @tab @tab X
  288. @tab there are still some distortions
  289. @item Real COOK @tab @tab X
  290. @tab All versions except 5.1 are supported
  291. @item DSP Group TrueSpeech @tab @tab X
  292. @item True Audio (TTA) @tab @tab X
  293. @item Smacker Audio @tab @tab X
  294. @item WavPack Audio @tab @tab X
  295. @item Cin Audio @tab @tab X
  296. @tab Codec used in Delphine Software games.
  297. @item Intel Music Coder @tab @tab X
  298. @item Musepack @tab @tab X
  299. @tab SV7 and SV8 are supported
  300. @item DT$ Coherent Audio @tab @tab X
  301. @item ATRAC 3 @tab @tab X
  302. @item Monkey's Audio @tab @tab X @tab Only versions 3.97-3.99 are supported
  303. @item Nellymoser ASAO @tab @tab X
  304. @end multitable
  305. @code{X} means that encoding (resp. decoding) is supported.
  306. @code{I} means that an integer-only version is available, too (ensures high
  307. performance on systems without hardware floating point support).
  308. @chapter Platform Specific information
  309. @section BSD
  310. BSD make will not build FFmpeg, you need to install and use GNU Make
  311. (@file{gmake}).
  312. @section Windows
  313. To get help and instructions for building FFmpeg under Windows, check out
  314. the FFmpeg Windows Help Forum at
  315. @url{http://arrozcru.no-ip.org/ffmpeg/}.
  316. @subsection Native Windows compilation
  317. FFmpeg can be built to run natively on Windows using the MinGW tools. Install
  318. the current versions of MSYS and MinGW from @url{http://www.mingw.org/}. Also
  319. install the coreutils package. You can find detailed installation
  320. instructions in the download section and the FAQ.
  321. Within the MSYS shell, configure and make with:
  322. @example
  323. ./configure --enable-memalign-hack
  324. make
  325. make install
  326. @end example
  327. This will install @file{ffmpeg.exe} along with many other development files
  328. to @file{/usr/local}. You may specify another install path using the
  329. @code{--prefix} option in @file{configure}.
  330. Notes:
  331. @itemize
  332. @item Use at least bash 3.1. Older versions are known to fail on the
  333. configure script.
  334. @item In order to compile vhooks, you must have a POSIX-compliant libdl in
  335. your MinGW system. Get dlfcn-win32 from
  336. @url{http://code.google.com/p/dlfcn-win32}.
  337. @item In order to compile FFplay, you must have the MinGW development library
  338. of SDL. Get it from @url{http://www.libsdl.org}.
  339. Edit the @file{bin/sdl-config} script so that it points to the correct prefix
  340. where SDL was installed. Verify that @file{sdl-config} can be launched from
  341. the MSYS command line.
  342. @item The target @code{make wininstaller} can be used to create a
  343. Nullsoft-based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
  344. must be copied to the FFmpeg directory in order to build the
  345. installer.
  346. @item By using @code{./configure --enable-shared} when configuring FFmpeg,
  347. you can build libavutil, libavcodec and libavformat as DLLs.
  348. @end itemize
  349. @subsection Microsoft Visual C++ compatibility
  350. As stated in the FAQ, FFmpeg will not compile under MSVC++. However, if you
  351. want to use the libav* libraries in your own applications, you can still
  352. compile those applications using MSVC++. But the libav* libraries you link
  353. to @emph{must} be built with MinGW. However, you will not be able to debug
  354. inside the libav* libraries, since MSVC++ does not recognize the debug
  355. symbols generated by GCC.
  356. We strongly recommend you to move over from MSVC++ to MinGW tools.
  357. This description of how to use the FFmpeg libraries with MSVC++ is based on
  358. Microsoft Visual C++ 2005 Express Edition. If you have a different version,
  359. you might have to modify the procedures slightly.
  360. @subsubsection Using static libraries
  361. Assuming you have just built and installed FFmpeg in @file{/usr/local}.
  362. @enumerate
  363. @item Create a new console application ("File / New / Project") and then
  364. select "Win32 Console Application". On the appropriate page of the
  365. Application Wizard, uncheck the "Precompiled headers" option.
  366. @item Write the source code for your application, or, for testing, just
  367. copy the code from an existing sample application into the source file
  368. that MSVC++ has already created for you. For example, you can copy
  369. @file{output_example.c} from the FFmpeg distribution.
  370. @item Open the "Project / Properties" dialog box. In the "Configuration"
  371. combo box, select "All Configurations" so that the changes you make will
  372. affect both debug and release builds. In the tree view on the left hand
  373. side, select "C/C++ / General", then edit the "Additional Include
  374. Directories" setting to contain the path where the FFmpeg includes were
  375. installed (i.e. @file{c:\msys\1.0\local\include}).
  376. @item Still in the "Project / Properties" dialog box, select
  377. "Linker / General" from the tree view and edit the
  378. "Additional Library Directories" setting to contain the @file{lib}
  379. directory where FFmpeg was installed (i.e. @file{c:\msys\1.0\local\lib}),
  380. the directory where MinGW libs are installed (i.e. @file{c:\mingw\lib}),
  381. and the directory where MinGW's GCC libs are installed
  382. (i.e. @file{C:\mingw\lib\gcc\mingw32\4.2.1-sjlj}). Then select
  383. "Linker / Input" from the tree view, and add the files @file{libavformat.a},
  384. @file{libavcodec.a}, @file{libavutil.a}, @file{libmingwex.a},
  385. @file{libgcc.a}, and any other libraries you used (i.e. @file{libz.a})
  386. to the end of "Additional Dependencies".
  387. @item Now, select "C/C++ / Code Generation" from the tree view. Select
  388. "Debug" in the "Configuration" combo box. Make sure that "Runtime
  389. Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
  390. the "Configuration" combo box and make sure that "Runtime Library" is
  391. set to "Multi-threaded DLL".
  392. @item Click "OK" to close the "Project / Properties" dialog box.
  393. @item MSVC++ lacks some C99 header files that are fundamental for FFmpeg.
  394. Get msinttypes from @url{http://code.google.com/p/msinttypes/downloads/list}
  395. and install it in MSVC++'s include directory
  396. (i.e. @file{C:\Program Files\Microsoft Visual Studio 8\VC\include}).
  397. @item MSVC++ also does not understand the @code{inline} keyword used by
  398. FFmpeg, so you must add this line before @code{#include}ing libav*:
  399. @example
  400. #define inline _inline
  401. @end example
  402. @item If you used @file{output_example.c} as your sample application,
  403. you will have to edit the @code{#include}s to point to the files which
  404. are under the @file{ffmpeg} directory (i.e. @code{<ffmpeg/avformat.h>}).
  405. @item Build your application, everything should work.
  406. @end enumerate
  407. @subsubsection Using shared libraries
  408. This is how to create DLL and LIB files that are compatible with MSVC++:
  409. @enumerate
  410. @item Add a call to @file{vcvars32.bat} (which sets up the environment
  411. variables for the Visual C++ tools) as the first line of @file{msys.bat}.
  412. The standard location for @file{vcvars32.bat} is
  413. @file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
  414. and the standard location for @file{msys.bat} is @file{C:\msys\1.0\msys.bat}.
  415. If this corresponds to your setup, add the following line as the first line
  416. of @file{msys.bat}:
  417. @example
  418. call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"
  419. @end example
  420. Alternatively, you may start the @file{Visual Studio 2005 Command Prompt},
  421. and run @file{c:\msys\1.0\msys.bat} from there.
  422. @item Within the MSYS shell, run @code{lib.exe}. If you get a help message
  423. from @file{Microsoft (R) Library Manager}, this means your environment
  424. variables are set up correctly, the @file{Microsoft (R) Library Manager}
  425. is on the path and will be used by FFmpeg to create
  426. MSVC++-compatible import libraries.
  427. @item Build FFmpeg with
  428. @example
  429. ./configure --enable-shared --enable-memalign-hack
  430. make
  431. make install
  432. @end example
  433. Your install path (@file{/usr/local/} by default) should now have the
  434. necessary DLL and LIB files under the @file{bin} directory.
  435. @end enumerate
  436. To use those files with MSVC++, do the same as you would do with
  437. the static libraries, as described above. But in Step 4,
  438. you should only need to add the directory where the LIB files are installed
  439. (i.e. @file{c:\msys\usr\local\bin}). This is not a typo, the LIB files are
  440. installed in the @file{bin} directory. And instead of adding @file{libxx.a}
  441. files, you should add @file{avcodec.lib}, @file{avformat.lib}, and
  442. @file{avutil.lib}. There should be no need for @file{libmingwex.a},
  443. @file{libgcc.a}, and @file{wsock32.lib}, nor any other external library
  444. statically linked into the DLLs. The @file{bin} directory contains a bunch
  445. of DLL files, but the ones that are actually used to run your application
  446. are the ones with a major version number in their filenames
  447. (i.e. @file{avcodec-51.dll}).
  448. @subsection Cross compilation for Windows with Linux
  449. You must use the MinGW cross compilation tools available at
  450. @url{http://www.mingw.org/}.
  451. Then configure FFmpeg with the following options:
  452. @example
  453. ./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
  454. @end example
  455. (you can change the cross-prefix according to the prefix chosen for the
  456. MinGW tools).
  457. Then you can easily test FFmpeg with Wine
  458. (@url{http://www.winehq.com/}).
  459. @subsection Compilation under Cygwin
  460. The main issue with Cygwin is that newlib, its C library, does not
  461. contain llrint(). However, it is possible to leverage the
  462. implementation in MinGW.
  463. Just install your Cygwin with all the "Base" packages, plus the
  464. following "Devel" ones:
  465. @example
  466. binutils, gcc-core, make, subversion, mingw-runtime
  467. @end example
  468. Do not install binutils-20060709-1 (they are buggy on shared builds);
  469. use binutils-20050610-1 instead.
  470. Then create a small library that just contains llrint():
  471. @example
  472. ar x /usr/lib/mingw/libmingwex.a llrint.o
  473. ar cq /usr/local/lib/libllrint.a llrint.o
  474. @end example
  475. Then run
  476. @example
  477. ./configure --enable-static --disable-shared --extra-ldflags='-L /usr/local/lib' --extra-libs='-l llrint'
  478. @end example
  479. to make a static build or
  480. @example
  481. ./configure --enable-shared --disable-static --extra-ldflags='-L /usr/local/lib' --extra-libs='-l llrint'
  482. @end example
  483. to build shared libraries.
  484. If you want to build FFmpeg with additional libraries, download Cygwin
  485. "Devel" packages for Ogg and Vorbis from any Cygwin packages repository
  486. and/or SDL, xvid, faac, faad2 packages from Cygwin Ports,
  487. (@url{http://cygwinports.dotsrc.org/}).
  488. @subsection Crosscompilation for Windows under Cygwin
  489. With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
  490. Just install your Cygwin as explained before, plus these additional
  491. "Devel" packages:
  492. @example
  493. gcc-mingw-core, mingw-runtime, mingw-zlib
  494. @end example
  495. and add some special flags to your configure invocation.
  496. For a static build run
  497. @example
  498. ./configure --target-os=mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  499. @end example
  500. and for a build with shared libraries
  501. @example
  502. ./configure --target-os=mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  503. @end example
  504. @section BeOS
  505. BeOS support is broken in mysterious ways.
  506. @section OS/2
  507. For information about compiling FFmpeg on OS/2 see
  508. @url{http://www.edm2.com/index.php/FFmpeg}.
  509. @chapter Developers Guide
  510. @section API
  511. @itemize @bullet
  512. @item libavcodec is the library containing the codecs (both encoding and
  513. decoding). Look at @file{libavcodec/apiexample.c} to see how to use it.
  514. @item libavformat is the library containing the file format handling (mux and
  515. demux code for several formats). Look at @file{ffplay.c} to use it in a
  516. player. See @file{output_example.c} to use it to generate audio or video
  517. streams.
  518. @end itemize
  519. @section Integrating libavcodec or libavformat in your program
  520. You can integrate all the source code of the libraries to link them
  521. statically to avoid any version problem. All you need is to provide a
  522. 'config.mak' and a 'config.h' in the parent directory. See the defines
  523. generated by ./configure to understand what is needed.
  524. You can use libavcodec or libavformat in your commercial program, but
  525. @emph{any patch you make must be published}. The best way to proceed is
  526. to send your patches to the FFmpeg mailing list.
  527. @node Coding Rules
  528. @section Coding Rules
  529. FFmpeg is programmed in the ISO C90 language with a few additional
  530. features from ISO C99, namely:
  531. @itemize @bullet
  532. @item
  533. the @samp{inline} keyword;
  534. @item
  535. @samp{//} comments;
  536. @item
  537. designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
  538. @item
  539. compound literals (@samp{x = (struct s) @{ 17, 23 @};})
  540. @end itemize
  541. These features are supported by all compilers we care about, so we will not
  542. accept patches to remove their use unless they absolutely do not impair
  543. clarity and performance.
  544. All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
  545. compiles with several other compilers, such as the Compaq ccc compiler
  546. or Sun Studio 9, and we would like to keep it that way unless it would
  547. be exceedingly involved. To ensure compatibility, please do not use any
  548. additional C99 features or GCC extensions. Especially watch out for:
  549. @itemize @bullet
  550. @item
  551. mixing statements and declarations;
  552. @item
  553. @samp{long long} (use @samp{int64_t} instead);
  554. @item
  555. @samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
  556. @item
  557. GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
  558. @end itemize
  559. Indent size is 4.
  560. The presentation is the one specified by 'indent -i4 -kr -nut'.
  561. The TAB character is forbidden outside of Makefiles as is any
  562. form of trailing whitespace. Commits containing either will be
  563. rejected by the Subversion repository.
  564. The main priority in FFmpeg is simplicity and small code size in order to
  565. minimize the bug count.
  566. Comments: Use the JavaDoc/Doxygen
  567. format (see examples below) so that code documentation
  568. can be generated automatically. All nontrivial functions should have a comment
  569. above them explaining what the function does, even if it is just one sentence.
  570. All structures and their member variables should be documented, too.
  571. @example
  572. /**
  573. * @@file mpeg.c
  574. * MPEG codec.
  575. * @@author ...
  576. */
  577. /**
  578. * Summary sentence.
  579. * more text ...
  580. * ...
  581. */
  582. typedef struct Foobar@{
  583. int var1; /**< var1 description */
  584. int var2; ///< var2 description
  585. /** var3 description */
  586. int var3;
  587. @} Foobar;
  588. /**
  589. * Summary sentence.
  590. * more text ...
  591. * ...
  592. * @@param my_parameter description of my_parameter
  593. * @@return return value description
  594. */
  595. int myfunc(int my_parameter)
  596. ...
  597. @end example
  598. fprintf and printf are forbidden in libavformat and libavcodec,
  599. please use av_log() instead.
  600. Casts should be used only when necessary. Unneeded parentheses
  601. should also be avoided if they don't make the code easier to understand.
  602. @section Development Policy
  603. @enumerate
  604. @item
  605. Contributions should be licensed under the LGPL 2.1, including an
  606. "or any later version" clause, or the MIT license. GPL 2 including
  607. an "or any later version" clause is also acceptable, but LGPL is
  608. preferred.
  609. @item
  610. You must not commit code which breaks FFmpeg! (Meaning unfinished but
  611. enabled code which breaks compilation or compiles but does not work or
  612. breaks the regression tests)
  613. You can commit unfinished stuff (for testing etc), but it must be disabled
  614. (#ifdef etc) by default so it does not interfere with other developers'
  615. work.
  616. @item
  617. You do not have to over-test things. If it works for you, and you think it
  618. should work for others, then commit. If your code has problems
  619. (portability, triggers compiler bugs, unusual environment etc) they will be
  620. reported and eventually fixed.
  621. @item
  622. Do not commit unrelated changes together, split them into self-contained
  623. pieces. Also do not forget that if part B depends on part A, but A does not
  624. depend on B, then A can and should be committed first and separate from B.
  625. Keeping changes well split into self-contained parts makes reviewing and
  626. understanding them on the commit log mailing list easier. This also helps
  627. in case of debugging later on.
  628. Also if you have doubts about splitting or not splitting, do not hesitate to
  629. ask/discuss it on the developer mailing list.
  630. @item
  631. Do not change behavior of the program (renaming options etc) without
  632. first discussing it on the ffmpeg-devel mailing list. Do not remove
  633. functionality from the code. Just improve!
  634. Note: Redundant code can be removed.
  635. @item
  636. Do not commit changes to the build system (Makefiles, configure script)
  637. which change behavior, defaults etc, without asking first. The same
  638. applies to compiler warning fixes, trivial looking fixes and to code
  639. maintained by other developers. We usually have a reason for doing things
  640. the way we do. Send your changes as patches to the ffmpeg-devel mailing
  641. list, and if the code maintainers say OK, you may commit. This does not
  642. apply to files you wrote and/or maintain.
  643. @item
  644. We refuse source indentation and other cosmetic changes if they are mixed
  645. with functional changes, such commits will be rejected and removed. Every
  646. developer has his own indentation style, you should not change it. Of course
  647. if you (re)write something, you can use your own style, even though we would
  648. prefer if the indentation throughout FFmpeg was consistent (Many projects
  649. force a given indentation style - we do not.). If you really need to make
  650. indentation changes (try to avoid this), separate them strictly from real
  651. changes.
  652. NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
  653. then either do NOT change the indentation of the inner part within (do not
  654. move it to the right)! or do so in a separate commit
  655. @item
  656. Always fill out the commit log message. Describe in a few lines what you
  657. changed and why. You can refer to mailing list postings if you fix a
  658. particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
  659. @item
  660. If you apply a patch by someone else, include the name and email address in
  661. the log message. Since the ffmpeg-cvslog mailing list is publicly
  662. archived you should add some SPAM protection to the email address. Send an
  663. answer to ffmpeg-devel (or wherever you got the patch from) saying that
  664. you applied the patch.
  665. @item
  666. When applying patches that have been discussed (at length) on the mailing
  667. list, reference the thread in the log message.
  668. @item
  669. Do NOT commit to code actively maintained by others without permission.
  670. Send a patch to ffmpeg-devel instead. If no one answers within a reasonable
  671. timeframe (12h for build failures and security fixes, 3 days small changes,
  672. 1 week for big patches) then commit your patch if you think it is OK.
  673. Also note, the maintainer can simply ask for more time to review!
  674. @item
  675. Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
  676. are sent there and reviewed by all the other developers. Bugs and possible
  677. improvements or general questions regarding commits are discussed there. We
  678. expect you to react if problems with your code are uncovered.
  679. @item
  680. Update the documentation if you change behavior or add features. If you are
  681. unsure how best to do this, send a patch to ffmpeg-devel, the documentation
  682. maintainer(s) will review and commit your stuff.
  683. @item
  684. Try to keep important discussions and requests (also) on the public
  685. developer mailing list, so that all developers can benefit from them.
  686. @item
  687. Never write to unallocated memory, never write over the end of arrays,
  688. always check values read from some untrusted source before using them
  689. as array index or other risky things.
  690. @item
  691. Remember to check if you need to bump versions for the specific libav
  692. parts (libavutil, libavcodec, libavformat) you are changing. You need
  693. to change the version integer and the version string.
  694. Incrementing the first component means no backward compatibility to
  695. previous versions (e.g. removal of a function from the public API).
  696. Incrementing the second component means backward compatible change
  697. (e.g. addition of a function to the public API).
  698. Incrementing the third component means a noteworthy binary compatible
  699. change (e.g. encoder bug fix that matters for the decoder).
  700. @item
  701. If you add a new codec, remember to update the changelog, add it to
  702. the supported codecs table in the documentation and bump the second
  703. component of the @file{libavcodec} version number appropriately. If
  704. it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
  705. is only a decoder.
  706. @item
  707. Compiler warnings indicate potential bugs or code with bad style. If a type of
  708. warning always points to correct and clean code, that warning should
  709. be disabled, not the code changed.
  710. Thus the remaining warnings can either be bugs or correct code.
  711. If it is a bug, the bug has to be fixed. If it is not, the code should
  712. be changed to not generate a warning unless that causes a slowdown
  713. or obfuscates the code.
  714. @item
  715. If you add a new file, give it a proper license header. Do not copy and
  716. paste it from a random place, use an existing file as template.
  717. @end enumerate
  718. We think our rules are not too hard. If you have comments, contact us.
  719. Note, these rules are mostly borrowed from the MPlayer project.
  720. @section Submitting patches
  721. First, (@pxref{Coding Rules}) above if you did not yet.
  722. When you submit your patch, try to send a unified diff (diff '-up'
  723. option). We cannot read other diffs :-)
  724. Also please do not submit a patch which contains several unrelated changes.
  725. Split it into separate, self-contained pieces. This does not mean splitting
  726. file by file. Instead, make the patch as small as possible while still
  727. keeping it as a logical unit that contains an individual change, even
  728. if it spans multiple files. This makes reviewing your patches much easier
  729. for us and greatly increases your chances of getting your patch applied.
  730. Run the regression tests before submitting a patch so that you can
  731. verify that there are no big problems.
  732. Patches should be posted as base64 encoded attachments (or any other
  733. encoding which ensures that the patch will not be trashed during
  734. transmission) to the ffmpeg-devel mailing list, see
  735. @url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
  736. It also helps quite a bit if you tell us what the patch does (for example
  737. 'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
  738. and has no lrint()')
  739. Also please if you send several patches, send each patch as a separate mail,
  740. do not attach several unrelated patches to the same mail.
  741. @section patch submission checklist
  742. @enumerate
  743. @item
  744. Do the regression tests pass with the patch applied?
  745. @item
  746. Is the patch a unified diff?
  747. @item
  748. Is the patch against latest FFmpeg SVN?
  749. @item
  750. Are you subscribed to ffmpeg-dev?
  751. (the list is subscribers only due to spam)
  752. @item
  753. Have you checked that the changes are minimal, so that the same cannot be
  754. achieved with a smaller patch and/or simpler final code?
  755. @item
  756. If the change is to speed critical code, did you benchmark it?
  757. @item
  758. If you did any benchmarks, did you provide them in the mail?
  759. @item
  760. Have you checked that the patch does not introduce buffer overflows or
  761. other security issues?
  762. @item
  763. Is the patch created from the root of the source tree, so it can be
  764. applied with @code{patch -p0}?
  765. @item
  766. Does the patch not mix functional and cosmetic changes?
  767. @item
  768. Did you add tabs or trailing whitespace to the code? Both are forbidden.
  769. @item
  770. Is the patch attached to the email you send?
  771. @item
  772. Is the mime type of the patch correct? It should be text/x-diff or
  773. text/x-patch or at least text/plain and not application/octet-stream.
  774. @item
  775. If the patch fixes a bug, did you provide a verbose analysis of the bug?
  776. @item
  777. If the patch fixes a bug, did you provide enough information, including
  778. a sample, so the bug can be reproduced and the fix can be verified?
  779. Note please do not attach samples >100k to mails but rather provide a
  780. URL, you can upload to ftp://upload.mplayerhq.hu
  781. @item
  782. Did you provide a verbose summary about what the patch does change?
  783. @item
  784. Did you provide a verbose explanation why it changes things like it does?
  785. @item
  786. Did you provide a verbose summary of the user visible advantages and
  787. disadvantages if the patch is applied?
  788. @item
  789. Did you provide an example so we can verify the new feature added by the
  790. patch easily?
  791. @item
  792. If you added a new file, did you insert a license header? It should be
  793. taken from FFmpeg, not randomly copied and pasted from somewhere else.
  794. @item
  795. You should maintain alphabetical order in alphabetically ordered lists as
  796. long as doing so does not break API/ABI compatibility.
  797. @item
  798. Lines with similar content should be aligned vertically when doing so
  799. improves readability.
  800. @item
  801. Did you provide a suggestion for a clear commit log message?
  802. @item
  803. Did you test your decoder or demuxer against damaged data? If no, see
  804. tools/trasher and the noise bitstream filter. Your decoder or demuxer
  805. should not crash or end in a (near) infinite loop when fed damaged data.
  806. @end enumerate
  807. @section Patch review process
  808. All patches posted to ffmpeg-devel will be reviewed, unless they contain a
  809. clear note that the patch is not for SVN.
  810. Reviews and comments will be posted as replies to the patch on the
  811. mailing list. The patch submitter then has to take care of every comment,
  812. that can be by resubmitting a changed patch or by discussion. Resubmitted
  813. patches will themselves be reviewed like any other patch. If at some point
  814. a patch passes review with no comments then it is approved, that can for
  815. simple and small patches happen immediately while large patches will generally
  816. have to be changed and reviewed many times before they are approved.
  817. After a patch is approved it will be committed to the repository.
  818. We will review all submitted patches, but sometimes we are quite busy so
  819. especially for large patches this can take several weeks.
  820. When resubmitting patches, please do not make any significant changes
  821. not related to the comments received during review. Such patches will
  822. be rejected. Instead, submit significant changes or new features as
  823. separate patches.
  824. @section Regression tests
  825. Before submitting a patch (or committing to the repository), you should at least
  826. test that you did not break anything.
  827. The regression tests build a synthetic video stream and a synthetic
  828. audio stream. These are then encoded and decoded with all codecs or
  829. formats. The CRC (or MD5) of each generated file is recorded in a
  830. result file. A 'diff' is launched to compare the reference results and
  831. the result file.
  832. The regression tests then go on to test the FFserver code with a
  833. limited set of streams. It is important that this step runs correctly
  834. as well.
  835. Run 'make test' to test all the codecs and formats.
  836. Run 'make fulltest' to test all the codecs, formats and FFserver.
  837. [Of course, some patches may change the results of the regression tests. In
  838. this case, the reference results of the regression tests shall be modified
  839. accordingly].
  840. @bye