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.

1616 lines
54KB

  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 parameters that can possibly be
  13. derived automatically. You usually only have to specify the target
  14. bitrate you want.
  15. FFmpeg can also convert from any sample rate to any other, and resize
  16. video on the fly with a high quality polyphase filter.
  17. @chapter Quick Start
  18. @c man begin EXAMPLES
  19. @section Video and Audio grabbing
  20. FFmpeg can grab video and audio from devices given that you specify the input
  21. format and device.
  22. @example
  23. ffmpeg -f audio_device -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  24. @end example
  25. Note that you must activate the right video source and channel before
  26. launching FFmpeg with any TV viewer such as xawtv
  27. (@url{http://bytesex.org/xawtv/}) by Gerd Knorr. You also
  28. have to set the audio recording levels correctly with a
  29. standard mixer.
  30. @section X11 grabbing
  31. FFmpeg can grab the X11 display.
  32. @example
  33. ffmpeg -f x11grab -i :0.0 /tmp/out.mpg
  34. @end example
  35. 0.0 is display.screen number of your X11 server, same as
  36. the DISPLAY environment variable.
  37. @example
  38. ffmpeg -f x11grab -i :0.0+10,20 /tmp/out.mpg
  39. @end example
  40. 0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  41. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  42. @section Video and Audio file format conversion
  43. * FFmpeg can use any supported file format and protocol as input:
  44. Examples:
  45. * You can use YUV files as input:
  46. @example
  47. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  48. @end example
  49. It will use the files:
  50. @example
  51. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  52. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  53. @end example
  54. The Y files use twice the resolution of the U and V files. They are
  55. raw files, without header. They can be generated by all decent video
  56. decoders. You must specify the size of the image with the @option{-s} option
  57. if FFmpeg cannot guess it.
  58. * You can input from a raw YUV420P file:
  59. @example
  60. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  61. @end example
  62. test.yuv is a file containing raw YUV planar data. Each frame is composed
  63. of the Y plane followed by the U and V planes at half vertical and
  64. horizontal resolution.
  65. * You can output to a raw YUV420P file:
  66. @example
  67. ffmpeg -i mydivx.avi hugefile.yuv
  68. @end example
  69. * You can set several input files and output files:
  70. @example
  71. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  72. @end example
  73. Converts the audio file a.wav and the raw YUV video file a.yuv
  74. to MPEG file a.mpg.
  75. * You can also do audio and video conversions at the same time:
  76. @example
  77. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  78. @end example
  79. Converts a.wav to MPEG audio at 22050Hz sample rate.
  80. * You can encode to several formats at the same time and define a
  81. mapping from input stream to output streams:
  82. @example
  83. ffmpeg -i /tmp/a.wav -ab 64 /tmp/a.mp2 -ab 128 /tmp/b.mp2 -map 0:0 -map 0:0
  84. @end example
  85. Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
  86. file:index' specifies which input stream is used for each output
  87. stream, in the order of the definition of output streams.
  88. * You can transcode decrypted VOBs
  89. @example
  90. ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec mp3 -ab 128 snatch.avi
  91. @end example
  92. This is a typical DVD ripping example; the input is a VOB file, the
  93. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  94. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  95. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  96. input video. Furthermore, the audio stream is MP3-encoded so you need
  97. to enable LAME support by passing @code{--enable-mp3lame} to configure.
  98. The mapping is particularly useful for DVD transcoding
  99. to get the desired audio language.
  100. NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
  101. @c man end
  102. @chapter Invocation
  103. @section Syntax
  104. The generic syntax is:
  105. @example
  106. @c man begin SYNOPSIS
  107. ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
  108. @c man end
  109. @end example
  110. @c man begin DESCRIPTION
  111. As a general rule, options are applied to the next specified
  112. file. Therefore, order is important, and you can have the same
  113. option on the command line multiple times. Each occurrence is
  114. then applied to the next input or output file.
  115. * To set the video bitrate of the output file to 64kbit/s:
  116. @example
  117. ffmpeg -i input.avi -b 64k output.avi
  118. @end example
  119. * To force the frame rate of the input and output file to 24 fps:
  120. @example
  121. ffmpeg -r 24 -i input.avi output.avi
  122. @end example
  123. * To force the frame rate of the output file to 24 fps:
  124. @example
  125. ffmpeg -i input.avi -r 24 output.avi
  126. @end example
  127. * To force the frame rate of input file to 1 fps and the output file to 24 fps:
  128. @example
  129. ffmpeg -r 1 -i input.avi -r 24 output.avi
  130. @end example
  131. The format option may be needed for raw input files.
  132. By default, FFmpeg tries to convert as losslessly as possible: It
  133. uses the same audio and video parameters for the outputs as the one
  134. specified for the inputs.
  135. @c man end
  136. @c man begin OPTIONS
  137. @section Main options
  138. @table @option
  139. @item -L
  140. Show license.
  141. @item -h
  142. Show help.
  143. @item -version
  144. Show version.
  145. @item -formats
  146. Show available formats, codecs, protocols, ...
  147. @item -f fmt
  148. Force format.
  149. @item -i filename
  150. input filename
  151. @item -y
  152. Overwrite output files.
  153. @item -t duration
  154. Set the recording time in seconds.
  155. @code{hh:mm:ss[.xxx]} syntax is also supported.
  156. @item -fs limit_size
  157. Set the file size limit.
  158. @item -ss position
  159. Seek to given time position in seconds.
  160. @code{hh:mm:ss[.xxx]} syntax is also supported.
  161. @item -itsoffset offset
  162. Set the input time offset in seconds.
  163. @code{[-]hh:mm:ss[.xxx]} syntax is also supported.
  164. This option affects all the input files that follow it.
  165. The offset is added to the timestamps of the input files.
  166. Specifying a positive offset means that the corresponding
  167. streams are delayed by 'offset' seconds.
  168. @item -title string
  169. Set the title.
  170. @item -timestamp time
  171. Set the timestamp.
  172. @item -author string
  173. Set the author.
  174. @item -copyright string
  175. Set the copyright.
  176. @item -comment string
  177. Set the comment.
  178. @item -album string
  179. Set the album.
  180. @item -track number
  181. Set the track.
  182. @item -year number
  183. Set the year.
  184. @item -v verbose
  185. Control amount of logging.
  186. @item -target type
  187. Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd",
  188. "ntsc-svcd", ... ). All the format options (bitrate, codecs,
  189. buffer sizes) are then set automatically. You can just type:
  190. @example
  191. ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  192. @end example
  193. Nevertheless you can specify additional options as long as you know
  194. they do not conflict with the standard, as in:
  195. @example
  196. ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  197. @end example
  198. @item -dframes number
  199. Set the number of data frames to record.
  200. @item -scodec codec
  201. Force subtitle codec ('copy' to copy stream).
  202. @item -newsubtitle
  203. Add a new subtitle stream to the current output stream.
  204. @item -slang code
  205. Set the ISO 639 language code (3 letters) of the current subtitle stream.
  206. @end table
  207. @section Video Options
  208. @table @option
  209. @item -b bitrate
  210. Set the video bitrate in bit/s (default = 200 kb/s).
  211. @item -vframes number
  212. Set the number of video frames to record.
  213. @item -r fps
  214. Set frame rate (Hz value, fraction or abbreviation), (default = 25).
  215. @item -s size
  216. Set frame size. The format is @samp{wxh} (ffserver default = 160x128, ffmpeg default = same as source).
  217. The following abbreviations are recognized:
  218. @table @samp
  219. @item sqcif
  220. 128x96
  221. @item qcif
  222. 176x144
  223. @item cif
  224. 352x288
  225. @item 4cif
  226. 704x576
  227. @end table
  228. @item -aspect aspect
  229. Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
  230. @item -croptop size
  231. Set top crop band size (in pixels).
  232. @item -cropbottom size
  233. Set bottom crop band size (in pixels).
  234. @item -cropleft size
  235. Set left crop band size (in pixels).
  236. @item -cropright size
  237. Set right crop band size (in pixels).
  238. @item -padtop size
  239. Set top pad band size (in pixels).
  240. @item -padbottom size
  241. Set bottom pad band size (in pixels).
  242. @item -padleft size
  243. Set left pad band size (in pixels).
  244. @item -padright size
  245. Set right pad band size (in pixels).
  246. @item -padcolor (hex color)
  247. Set color of padded bands. The value for padcolor is expressed
  248. as a six digit hexadecimal number where the first two digits
  249. represent red, the middle two digits green and last two digits
  250. blue (default = 000000 (black)).
  251. @item -vn
  252. Disable video recording.
  253. @item -bt tolerance
  254. Set video bitrate tolerance (in bit/s).
  255. @item -maxrate bitrate
  256. Set max video bitrate tolerance (in bit/s).
  257. @item -minrate bitrate
  258. Set min video bitrate tolerance (in bit/s).
  259. @item -bufsize size
  260. Set rate control buffer size (in bits).
  261. @item -vcodec codec
  262. Force video codec to @var{codec}. Use the @code{copy} special value to
  263. tell that the raw codec data must be copied as is.
  264. @item -sameq
  265. Use same video quality as source (implies VBR).
  266. @item -pass n
  267. Select the pass number (1 or 2). It is useful to do two pass
  268. encoding. The statistics of the video are recorded in the first
  269. pass and the video is generated at the exact requested bitrate
  270. in the second pass.
  271. @item -passlogfile file
  272. Set two pass logfile name to @var{file}.
  273. @item -newvideo
  274. Add a new video stream to the current output stream.
  275. @end table
  276. @section Advanced Video Options
  277. @table @option
  278. @item -pix_fmt format
  279. Set pixel format.
  280. @item -g gop_size
  281. Set the group of pictures size.
  282. @item -intra
  283. Use only intra frames.
  284. @item -vdt n
  285. Discard threshold.
  286. @item -qscale q
  287. Use fixed video quantizer scale (VBR).
  288. @item -qmin q
  289. minimum video quantizer scale (VBR)
  290. @item -qmax q
  291. maximum video quantizer scale (VBR)
  292. @item -qdiff q
  293. maximum difference between the quantizer scales (VBR)
  294. @item -qblur blur
  295. video quantizer scale blur (VBR)
  296. @item -qcomp compression
  297. video quantizer scale compression (VBR)
  298. @item -lmin lambda
  299. minimum video lagrange factor (VBR)
  300. @item -lmax lambda
  301. max video lagrange factor (VBR)
  302. @item -mblmin lambda
  303. minimum macroblock quantizer scale (VBR)
  304. @item -mblmax lambda
  305. maximum macroblock quantizer scale (VBR)
  306. These four options (lmin, lmax, mblmin, mblmax) use 'lambda' units,
  307. but you may use the QP2LAMBDA constant to easily convert from 'q' units:
  308. @example
  309. ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  310. @end example
  311. @item -rc_init_cplx complexity
  312. initial complexity for single pass encoding
  313. @item -b_qfactor factor
  314. qp factor between P- and B-frames
  315. @item -i_qfactor factor
  316. qp factor between P- and I-frames
  317. @item -b_qoffset offset
  318. qp offset between P- and B-frames
  319. @item -i_qoffset offset
  320. qp offset between P- and I-frames
  321. @item -rc_eq equation
  322. Set rate control equation (@pxref{FFmpeg formula
  323. evaluator}) (default = @code{tex^qComp}).
  324. @item -rc_override override
  325. rate control override for specific intervals
  326. @item -me method
  327. Set motion estimation method to @var{method}.
  328. Available methods are (from lowest to best quality):
  329. @table @samp
  330. @item zero
  331. Try just the (0, 0) vector.
  332. @item phods
  333. @item log
  334. @item x1
  335. @item epzs
  336. (default method)
  337. @item full
  338. exhaustive search (slow and marginally better than epzs)
  339. @end table
  340. @item -dct_algo algo
  341. Set DCT algorithm to @var{algo}. Available values are:
  342. @table @samp
  343. @item 0
  344. FF_DCT_AUTO (default)
  345. @item 1
  346. FF_DCT_FASTINT
  347. @item 2
  348. FF_DCT_INT
  349. @item 3
  350. FF_DCT_MMX
  351. @item 4
  352. FF_DCT_MLIB
  353. @item 5
  354. FF_DCT_ALTIVEC
  355. @end table
  356. @item -idct_algo algo
  357. Set IDCT algorithm to @var{algo}. Available values are:
  358. @table @samp
  359. @item 0
  360. FF_IDCT_AUTO (default)
  361. @item 1
  362. FF_IDCT_INT
  363. @item 2
  364. FF_IDCT_SIMPLE
  365. @item 3
  366. FF_IDCT_SIMPLEMMX
  367. @item 4
  368. FF_IDCT_LIBMPEG2MMX
  369. @item 5
  370. FF_IDCT_PS2
  371. @item 6
  372. FF_IDCT_MLIB
  373. @item 7
  374. FF_IDCT_ARM
  375. @item 8
  376. FF_IDCT_ALTIVEC
  377. @item 9
  378. FF_IDCT_SH4
  379. @item 10
  380. FF_IDCT_SIMPLEARM
  381. @end table
  382. @item -er n
  383. Set error resilience to @var{n}.
  384. @table @samp
  385. @item 1
  386. FF_ER_CAREFUL (default)
  387. @item 2
  388. FF_ER_COMPLIANT
  389. @item 3
  390. FF_ER_AGGRESSIVE
  391. @item 4
  392. FF_ER_VERY_AGGRESSIVE
  393. @end table
  394. @item -ec bit_mask
  395. Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
  396. the following values:
  397. @table @samp
  398. @item 1
  399. FF_EC_GUESS_MVS (default = enabled)
  400. @item 2
  401. FF_EC_DEBLOCK (default = enabled)
  402. @end table
  403. @item -bf frames
  404. Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
  405. @item -mbd mode
  406. macroblock decision
  407. @table @samp
  408. @item 0
  409. FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg).
  410. @item 1
  411. FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
  412. @item 2
  413. FF_MB_DECISION_RD: rate distortion
  414. @end table
  415. @item -4mv
  416. Use four motion vector by macroblock (MPEG-4 only).
  417. @item -part
  418. Use data partitioning (MPEG-4 only).
  419. @item -bug param
  420. Work around encoder bugs that are not auto-detected.
  421. @item -strict strictness
  422. How strictly to follow the standards.
  423. @item -aic
  424. Enable Advanced intra coding (h263+).
  425. @item -umv
  426. Enable Unlimited Motion Vector (h263+)
  427. @item -deinterlace
  428. Deinterlace pictures.
  429. @item -ilme
  430. Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
  431. Use this option if your input file is interlaced and you want
  432. to keep the interlaced format for minimum losses.
  433. The alternative is to deinterlace the input stream with
  434. @option{-deinterlace}, but deinterlacing introduces losses.
  435. @item -psnr
  436. Calculate PSNR of compressed frames.
  437. @item -vstats
  438. Dump video coding statistics to @file{vstats_HHMMSS.log}.
  439. @item -vhook module
  440. Insert video processing @var{module}. @var{module} contains the module
  441. name and its parameters separated by spaces.
  442. @item -top n
  443. top=1/bottom=0/auto=-1 field first
  444. @item -dc precision
  445. Intra_dc_precision.
  446. @item -vtag fourcc/tag
  447. Force video tag/fourcc.
  448. @item -qphist
  449. Show QP histogram.
  450. @item -vbsf bitstream filter
  451. Bitstream filters available are "dump_extra", "remove_extra", "noise".
  452. @end table
  453. @section Audio Options
  454. @table @option
  455. @item -aframes number
  456. Set the number of audio frames to record.
  457. @item -ar freq
  458. Set the audio sampling frequency (default = 44100 Hz).
  459. @item -ab bitrate
  460. Set the audio bitrate in kbit/s (default = 64).
  461. @item -ac channels
  462. Set the number of audio channels (default = 1).
  463. @item -an
  464. Disable audio recording.
  465. @item -acodec codec
  466. Force audio codec to @var{codec}. Use the @code{copy} special value to
  467. specify that the raw codec data must be copied as is.
  468. @item -newaudio
  469. Add a new audio track to the output file. If you want to specify parameters,
  470. do so before @code{-newaudio} (@code{-acodec}, @code{-ab}, etc..).
  471. Mapping will be done automatically, if the number of output streams is equal to
  472. the number of input streams, else it will pick the first one that matches. You
  473. can override the mapping using @code{-map} as usual.
  474. Example:
  475. @example
  476. ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384 test.mpg -acodec mp2 -ab 192 -newaudio
  477. @end example
  478. @item -alang code
  479. Set the ISO 639 language code (3 letters) of the current audio stream.
  480. @end table
  481. @section Advanced Audio options:
  482. @table @option
  483. @item -atag fourcc/tag
  484. Force audio tag/fourcc.
  485. @item -absf bitstream filter
  486. Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
  487. @end table
  488. @section Subtitle options:
  489. @table @option
  490. @item -scodec codec
  491. Force subtitle codec ('copy' to copy stream).
  492. @item -newsubtitle
  493. Add a new subtitle stream to the current output stream.
  494. @item -slang code
  495. Set the ISO 639 language code (3 letters) of the current subtitle stream.
  496. @end table
  497. @section Audio/Video grab options
  498. @table @option
  499. @item -vc channel
  500. Set video grab channel (DV1394 only).
  501. @item -tvstd standard
  502. Set television standard (NTSC, PAL (SECAM)).
  503. @item -isync
  504. Synchronize read on input.
  505. @end table
  506. @section Advanced options
  507. @table @option
  508. @item -map input stream id[:input stream id]
  509. Set stream mapping from input streams to output streams.
  510. Just enumerate the input streams in the order you want them in the output.
  511. [input stream id] sets the (input) stream to sync against.
  512. @item -map_meta_data outfile:infile
  513. Set meta data information of outfile from infile.
  514. @item -debug
  515. Print specific debug info.
  516. @item -benchmark
  517. Add timings for benchmarking.
  518. @item -dump
  519. Dump each input packet.
  520. @item -hex
  521. When dumping packets, also dump the payload.
  522. @item -bitexact
  523. Only use bit exact algorithms (for codec testing).
  524. @item -ps size
  525. Set packet size in bits.
  526. @item -re
  527. Read input at native frame rate. Mainly used to simulate a grab device.
  528. @item -loop_input
  529. Loop over the input stream. Currently it works only for image
  530. streams. This option is used for automatic FFserver testing.
  531. @item -loop_output number_of_times
  532. Repeatedly loop output for formats that support looping such as animated GIF
  533. (0 will loop the output infinitely).
  534. @item -threads count
  535. Thread count.
  536. @item -vsync parameter
  537. Video sync method. Video will be stretched/squeezed to match the timestamps,
  538. it is done by duplicating and dropping frames. With -map you can select from
  539. which stream the timestamps should be taken. You can leave either video or
  540. audio unchanged and sync the remaining stream(s) to the unchanged one.
  541. @item -async samples_per_second
  542. Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
  543. the parameter is the maximum samples per second by which the audio is changed.
  544. -async 1 is a special case where only the start of the audio stream is corrected
  545. without any later correction.
  546. @end table
  547. @node FFmpeg formula evaluator
  548. @section FFmpeg formula evaluator
  549. When evaluating a rate control string, FFmpeg uses an internal formula
  550. evaluator.
  551. The following binary operators are available: @code{+}, @code{-},
  552. @code{*}, @code{/}, @code{^}.
  553. The following unary operators are available: @code{+}, @code{-},
  554. @code{(...)}.
  555. The following functions are available:
  556. @table @var
  557. @item sinh(x)
  558. @item cosh(x)
  559. @item tanh(x)
  560. @item sin(x)
  561. @item cos(x)
  562. @item tan(x)
  563. @item exp(x)
  564. @item log(x)
  565. @item squish(x)
  566. @item gauss(x)
  567. @item abs(x)
  568. @item max(x, y)
  569. @item min(x, y)
  570. @item gt(x, y)
  571. @item lt(x, y)
  572. @item eq(x, y)
  573. @item bits2qp(bits)
  574. @item qp2bits(qp)
  575. @end table
  576. The following constants are available:
  577. @table @var
  578. @item PI
  579. @item E
  580. @item iTex
  581. @item pTex
  582. @item tex
  583. @item mv
  584. @item fCode
  585. @item iCount
  586. @item mcVar
  587. @item var
  588. @item isI
  589. @item isP
  590. @item isB
  591. @item avgQP
  592. @item qComp
  593. @item avgIITex
  594. @item avgPITex
  595. @item avgPPTex
  596. @item avgBPTex
  597. @item avgTex
  598. @end table
  599. @c man end
  600. @ignore
  601. @setfilename ffmpeg
  602. @settitle FFmpeg video converter
  603. @c man begin SEEALSO
  604. ffserver(1), ffplay(1) and the HTML documentation of @file{ffmpeg}.
  605. @c man end
  606. @c man begin AUTHOR
  607. Fabrice Bellard
  608. @c man end
  609. @end ignore
  610. @section Protocols
  611. The filename can be @file{-} to read from standard input or to write
  612. to standard output.
  613. FFmpeg also handles many protocols specified with an URL syntax.
  614. Use 'ffmpeg -formats' to see a list of the supported protocols.
  615. The protocol @code{http:} is currently used only to communicate with
  616. FFserver (see the FFserver documentation). When FFmpeg will be a
  617. video player it will also be used for streaming :-)
  618. @chapter Tips
  619. @itemize
  620. @item For streaming at very low bitrate application, use a low frame rate
  621. and a small GOP size. This is especially true for RealVideo where
  622. the Linux player does not seem to be very fast, so it can miss
  623. frames. An example is:
  624. @example
  625. ffmpeg -g 3 -r 3 -t 10 -b 50k -s qcif -f rv10 /tmp/b.rm
  626. @end example
  627. @item The parameter 'q' which is displayed while encoding is the current
  628. quantizer. The value 1 indicates that a very good quality could
  629. be achieved. The value 31 indicates the worst quality. If q=31 appears
  630. too often, it means that the encoder cannot compress enough to meet
  631. your bitrate. You must either increase the bitrate, decrease the
  632. frame rate or decrease the frame size.
  633. @item If your computer is not fast enough, you can speed up the
  634. compression at the expense of the compression ratio. You can use
  635. '-me zero' to speed up motion estimation, and '-intra' to disable
  636. motion estimation completely (you have only I-frames, which means it
  637. is about as good as JPEG compression).
  638. @item To have very low audio bitrates, reduce the sampling frequency
  639. (down to 22050 kHz for MPEG audio, 22050 or 11025 for AC3).
  640. @item To have a constant quality (but a variable bitrate), use the option
  641. '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
  642. quality).
  643. @item When converting video files, you can use the '-sameq' option which
  644. uses the same quality factor in the encoder as in the decoder.
  645. It allows almost lossless encoding.
  646. @end itemize
  647. @chapter external libraries
  648. FFmpeg can be hooked up with a number of external libraries to add support
  649. for more formats.
  650. @section AMR
  651. AMR comes in two different flavors, WB and NB. FFmpeg can make use of the
  652. AMR WB (floating-point mode) and the AMR NB (both floating-point and
  653. fixed-point mode) reference decoders and encoders.
  654. @itemize
  655. @item For AMR WB floating-point download TS26.204 V5.1.0 from
  656. @url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.204/26204-510.zip}
  657. and extract the source to @file{libavcodec/amrwb_float/}.
  658. @item For AMR NB floating-point download TS26.104 REL-5 V5.1.0 from
  659. @url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.104/26104-510.zip}
  660. and extract the source to @file{libavcodec/amr_float/}.
  661. If you try this on Alpha, you may need to change @code{Word32} to
  662. @code{int} in @file{amr/typedef.h}.
  663. @item For AMR NB fixed-point download TS26.073 REL-5 V5.1.0 from
  664. @url{http://www.3gpp.org/ftp/Specs/archive/26_series/26.073/26073-510.zip}
  665. and extract the source to @file{libavcodec/amr}.
  666. You must also add @code{-DMMS_IO} and remove @code{-pedantic-errors}
  667. to/from @code{CFLAGS} in @file{libavcodec/amr/makefile}, i.e.
  668. ``@code{CFLAGS = -Wall -I. \$(CFLAGS_\$(MODE)) -D\$(VAD) -DMMS_IO}''.
  669. @end itemize
  670. @chapter Supported File Formats and Codecs
  671. You can use the @code{-formats} option to have an exhaustive list.
  672. @section File Formats
  673. FFmpeg supports the following file formats through the @code{libavformat}
  674. library:
  675. @multitable @columnfractions .4 .1 .1 .4
  676. @item Supported File Format @tab Encoding @tab Decoding @tab Comments
  677. @item MPEG audio @tab X @tab X
  678. @item MPEG-1 systems @tab X @tab X
  679. @tab muxed audio and video
  680. @item MPEG-2 PS @tab X @tab X
  681. @tab also known as @code{VOB} file
  682. @item MPEG-2 TS @tab @tab X
  683. @tab also known as DVB Transport Stream
  684. @item ASF@tab X @tab X
  685. @item AVI@tab X @tab X
  686. @item WAV@tab X @tab X
  687. @item Macromedia Flash@tab X @tab X
  688. @tab Only embedded audio is decoded.
  689. @item FLV @tab X @tab X
  690. @tab Macromedia Flash video files
  691. @item Real Audio and Video @tab X @tab X
  692. @item Raw AC3 @tab X @tab X
  693. @item Raw MJPEG @tab X @tab X
  694. @item Raw MPEG video @tab X @tab X
  695. @item Raw PCM8/16 bits, mulaw/Alaw@tab X @tab X
  696. @item Raw CRI ADX audio @tab X @tab X
  697. @item Raw Shorten audio @tab @tab X
  698. @item SUN AU format @tab X @tab X
  699. @item NUT @tab X @tab X @tab NUT Open Container Format
  700. @item QuickTime @tab X @tab X
  701. @item MPEG-4 @tab X @tab X
  702. @tab MPEG-4 is a variant of QuickTime.
  703. @item Raw MPEG4 video @tab X @tab X
  704. @item DV @tab X @tab X
  705. @item 4xm @tab @tab X
  706. @tab 4X Technologies format, used in some games.
  707. @item Playstation STR @tab @tab X
  708. @item Id RoQ @tab @tab X
  709. @tab Used in Quake III, Jedi Knight 2, other computer games.
  710. @item Interplay MVE @tab @tab X
  711. @tab Format used in various Interplay computer games.
  712. @item WC3 Movie @tab @tab X
  713. @tab Multimedia format used in Origin's Wing Commander III computer game.
  714. @item Sega FILM/CPK @tab @tab X
  715. @tab Used in many Sega Saturn console games.
  716. @item Westwood Studios VQA/AUD @tab @tab X
  717. @tab Multimedia formats used in Westwood Studios games.
  718. @item Id Cinematic (.cin) @tab @tab X
  719. @tab Used in Quake II.
  720. @item FLIC format @tab @tab X
  721. @tab .fli/.flc files
  722. @item Sierra VMD @tab @tab X
  723. @tab Used in Sierra CD-ROM games.
  724. @item Sierra Online @tab @tab X
  725. @tab .sol files used in Sierra Online games.
  726. @item Matroska @tab @tab X
  727. @item Electronic Arts Multimedia @tab @tab X
  728. @tab Used in various EA games; files have extensions like WVE and UV2.
  729. @item Nullsoft Video (NSV) format @tab @tab X
  730. @item ADTS AAC audio @tab X @tab X
  731. @item Creative VOC @tab X @tab X @tab Created for the Sound Blaster Pro.
  732. @item American Laser Games MM @tab @tab X
  733. @tab Multimedia format used in games like Mad Dog McCree
  734. @item AVS @tab @tab X
  735. @tab Multimedia format used by the Creature Shock game.
  736. @item Smacker @tab @tab X
  737. @tab Multimedia format used by many games.
  738. @item GXF @tab X @tab X
  739. @tab General eXchange Format SMPTE 360M, used by Thomson Grass Valley playout servers.
  740. @item CIN @tab @tab X
  741. @tab Multimedia format used by Delphine Software games.
  742. @item MXF @tab @tab X
  743. @tab Material eXchange Format SMPTE 377M, used by D-Cinema, broadcast industry.
  744. @item SEQ @tab @tab X
  745. @tab Tiertex .seq files used in the DOS CDROM version of the game Flashback.
  746. @end multitable
  747. @code{X} means that encoding (resp. decoding) is supported.
  748. @section Image Formats
  749. FFmpeg can read and write images for each frame of a video sequence. The
  750. following image formats are supported:
  751. @multitable @columnfractions .4 .1 .1 .4
  752. @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
  753. @item PGM, PPM @tab X @tab X
  754. @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support.
  755. @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
  756. @item JPEG @tab X @tab X @tab Progressive JPEG is not supported.
  757. @item .Y.U.V @tab X @tab X @tab one raw file per component
  758. @item animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated.
  759. @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet.
  760. @item Targa @tab @tab X @tab Targa (.TGA) image format.
  761. @item TIFF @tab @tab X @tab Only 24 bit/pixel images are supported.
  762. @item SGI @tab X @tab X @tab SGI RGB image format
  763. @end multitable
  764. @code{X} means that encoding (resp. decoding) is supported.
  765. @section Video Codecs
  766. @multitable @columnfractions .4 .1 .1 .4
  767. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  768. @item MPEG-1 video @tab X @tab X
  769. @item MPEG-2 video @tab X @tab X
  770. @item MPEG-4 @tab X @tab X
  771. @item MSMPEG4 V1 @tab X @tab X
  772. @item MSMPEG4 V2 @tab X @tab X
  773. @item MSMPEG4 V3 @tab X @tab X
  774. @item WMV7 @tab X @tab X
  775. @item WMV8 @tab X @tab X @tab not completely working
  776. @item WMV9 @tab @tab X @tab not completely working
  777. @item VC1 @tab @tab X
  778. @item H.261 @tab X @tab X
  779. @item H.263(+) @tab X @tab X @tab also known as RealVideo 1.0
  780. @item H.264 @tab @tab X
  781. @item RealVideo 1.0 @tab X @tab X
  782. @item RealVideo 2.0 @tab X @tab X
  783. @item MJPEG @tab X @tab X
  784. @item lossless MJPEG @tab X @tab X
  785. @item JPEG-LS @tab X @tab X @tab fourcc: MJLS, lossless and near-lossless is supported
  786. @item Apple MJPEG-B @tab @tab X
  787. @item Sunplus MJPEG @tab @tab X @tab fourcc: SP5X
  788. @item DV @tab X @tab X
  789. @item HuffYUV @tab X @tab X
  790. @item FFmpeg Video 1 @tab X @tab X @tab experimental lossless codec (fourcc: FFV1)
  791. @item FFmpeg Snow @tab X @tab X @tab experimental wavelet codec (fourcc: SNOW)
  792. @item Asus v1 @tab X @tab X @tab fourcc: ASV1
  793. @item Asus v2 @tab X @tab X @tab fourcc: ASV2
  794. @item Creative YUV @tab @tab X @tab fourcc: CYUV
  795. @item Sorenson Video 1 @tab X @tab X @tab fourcc: SVQ1
  796. @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
  797. @item On2 VP3 @tab @tab X @tab still experimental
  798. @item On2 VP5 @tab @tab X @tab fourcc: VP50
  799. @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62
  800. @item Theora @tab X @tab X @tab still experimental
  801. @item Intel Indeo 3 @tab @tab X
  802. @item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
  803. @item Flash Screen Video @tab X @tab X @tab fourcc: FSV1
  804. @item ATI VCR1 @tab @tab X @tab fourcc: VCR1
  805. @item ATI VCR2 @tab @tab X @tab fourcc: VCR2
  806. @item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
  807. @item 4X Video @tab @tab X @tab Used in certain computer games.
  808. @item Sony Playstation MDEC @tab @tab X
  809. @item Id RoQ @tab @tab X @tab Used in Quake III, Jedi Knight 2, other computer games.
  810. @item Xan/WC3 @tab @tab X @tab Used in Wing Commander III .MVE files.
  811. @item Interplay Video @tab @tab X @tab Used in Interplay .MVE files.
  812. @item Apple Animation @tab @tab X @tab fourcc: 'rle '
  813. @item Apple Graphics @tab @tab X @tab fourcc: 'smc '
  814. @item Apple Video @tab @tab X @tab fourcc: rpza
  815. @item Apple QuickDraw @tab @tab X @tab fourcc: qdrw
  816. @item Cinepak @tab @tab X
  817. @item Microsoft RLE @tab @tab X
  818. @item Microsoft Video-1 @tab @tab X
  819. @item Westwood VQA @tab @tab X
  820. @item Id Cinematic Video @tab @tab X @tab Used in Quake II.
  821. @item Planar RGB @tab @tab X @tab fourcc: 8BPS
  822. @item FLIC video @tab @tab X
  823. @item Duck TrueMotion v1 @tab @tab X @tab fourcc: DUCK
  824. @item Duck TrueMotion v2 @tab @tab X @tab fourcc: TM20
  825. @item VMD Video @tab @tab X @tab Used in Sierra VMD files.
  826. @item MSZH @tab @tab X @tab Part of LCL
  827. @item ZLIB @tab X @tab X @tab Part of LCL, encoder experimental
  828. @item TechSmith Camtasia @tab @tab X @tab fourcc: TSCC
  829. @item IBM Ultimotion @tab @tab X @tab fourcc: ULTI
  830. @item Miro VideoXL @tab @tab X @tab fourcc: VIXL
  831. @item QPEG @tab @tab X @tab fourccs: QPEG, Q1.0, Q1.1
  832. @item LOCO @tab @tab X @tab
  833. @item Winnov WNV1 @tab @tab X @tab
  834. @item Autodesk Animator Studio Codec @tab @tab X @tab fourcc: AASC
  835. @item Fraps FPS1 @tab @tab X @tab
  836. @item CamStudio @tab @tab X @tab fourcc: CSCD
  837. @item American Laser Games Video @tab @tab X @tab Used in games like Mad Dog McCree
  838. @item ZMBV @tab X @tab X @tab Encoder works only on PAL8
  839. @item AVS Video @tab @tab X @tab Video encoding used by the Creature Shock game.
  840. @item Smacker Video @tab @tab X @tab Video encoding used in Smacker.
  841. @item RTjpeg @tab @tab X @tab Video encoding used in NuppelVideo files.
  842. @item KMVC @tab @tab X @tab Codec used in Worms games.
  843. @item VMware Video @tab @tab X @tab Codec used in videos captured by VMware.
  844. @item Cin Video @tab @tab X @tab Codec used in Delphine Software games.
  845. @item Tiertex Seq Video @tab @tab X @tab Codec used in DOS CDROM FlashBack game.
  846. @end multitable
  847. @code{X} means that encoding (resp. decoding) is supported.
  848. @section Audio Codecs
  849. @multitable @columnfractions .4 .1 .1 .1 .7
  850. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  851. @item MPEG audio layer 2 @tab IX @tab IX
  852. @item MPEG audio layer 1/3 @tab IX @tab IX
  853. @tab MP3 encoding is supported through the external library LAME.
  854. @item AC3 @tab IX @tab IX
  855. @tab liba52 is used internally for decoding.
  856. @item Vorbis @tab X @tab X
  857. @item WMA V1/V2 @tab X @tab X
  858. @item AAC @tab X @tab X
  859. @tab Supported through the external library libfaac/libfaad.
  860. @item Microsoft ADPCM @tab X @tab X
  861. @item MS IMA ADPCM @tab X @tab X
  862. @item QT IMA ADPCM @tab @tab X
  863. @item 4X IMA ADPCM @tab @tab X
  864. @item G.726 ADPCM @tab X @tab X
  865. @item Duck DK3 IMA ADPCM @tab @tab X
  866. @tab Used in some Sega Saturn console games.
  867. @item Duck DK4 IMA ADPCM @tab @tab X
  868. @tab Used in some Sega Saturn console games.
  869. @item Westwood Studios IMA ADPCM @tab @tab X
  870. @tab Used in Westwood Studios games like Command and Conquer.
  871. @item SMJPEG IMA ADPCM @tab @tab X
  872. @tab Used in certain Loki game ports.
  873. @item CD-ROM XA ADPCM @tab @tab X
  874. @item CRI ADX ADPCM @tab X @tab X
  875. @tab Used in Sega Dreamcast games.
  876. @item Electronic Arts ADPCM @tab @tab X
  877. @tab Used in various EA titles.
  878. @item Creative ADPCM @tab @tab X
  879. @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2
  880. @item RA144 @tab @tab X
  881. @tab Real 14400 bit/s codec
  882. @item RA288 @tab @tab X
  883. @tab Real 28800 bit/s codec
  884. @item RADnet @tab X @tab IX
  885. @tab Real low bitrate AC3 codec, liba52 is used for decoding.
  886. @item AMR-NB @tab X @tab X
  887. @tab Supported through an external library.
  888. @item AMR-WB @tab X @tab X
  889. @tab Supported through an external library.
  890. @item DV audio @tab @tab X
  891. @item Id RoQ DPCM @tab @tab X
  892. @tab Used in Quake III, Jedi Knight 2, other computer games.
  893. @item Interplay MVE DPCM @tab @tab X
  894. @tab Used in various Interplay computer games.
  895. @item Xan DPCM @tab @tab X
  896. @tab Used in Origin's Wing Commander IV AVI files.
  897. @item Sierra Online DPCM @tab @tab X
  898. @tab Used in Sierra Online game audio files.
  899. @item Apple MACE 3 @tab @tab X
  900. @item Apple MACE 6 @tab @tab X
  901. @item FLAC lossless audio @tab @tab X
  902. @item Shorten lossless audio @tab @tab X
  903. @item Apple lossless audio @tab @tab X
  904. @tab QuickTime fourcc 'alac'
  905. @item FFmpeg Sonic @tab X @tab X
  906. @tab experimental lossy/lossless codec
  907. @item Qdesign QDM2 @tab @tab X
  908. @tab there are still some distortions
  909. @item Real COOK @tab @tab X
  910. @tab All versions except 5.1 are supported
  911. @item DSP Group TrueSpeech @tab @tab X
  912. @item True Audio (TTA) @tab @tab X
  913. @item Smacker Audio @tab @tab X
  914. @item WavPack Audio @tab @tab X
  915. @item Cin Audio @tab @tab X
  916. @tab Codec used in Delphine Software games.
  917. @item Intel Music Coder @tab @tab X
  918. @item Musepack @tab @tab X
  919. @tab Only SV7 is supported
  920. @end multitable
  921. @code{X} means that encoding (resp. decoding) is supported.
  922. @code{I} means that an integer-only version is available, too (ensures high
  923. performance on systems without hardware floating point support).
  924. @chapter Platform Specific information
  925. @section BSD
  926. BSD make will not build FFmpeg, you need to install and use GNU Make
  927. (@file{gmake}).
  928. @section Windows
  929. To get help and instructions for using FFmpeg under Windows, check out
  930. the FFmpeg Windows Help Forum at
  931. @url{http://arrozcru.no-ip.org/ffmpeg/}.
  932. @subsection Native Windows compilation
  933. @itemize
  934. @item Install the current versions of MSYS and MinGW from
  935. @url{http://www.mingw.org/}. You can find detailed installation
  936. instructions in the download section and the FAQ.
  937. @item If you want to test the FFplay, also download
  938. the MinGW development library of SDL 1.2.x
  939. (@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
  940. @url{http://www.libsdl.org}. Unpack it in a temporary directory, and
  941. unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
  942. directory. Edit the @file{sdl-config} script so that it gives the
  943. correct SDL directory when invoked.
  944. @item Extract the current version of FFmpeg.
  945. @item Start the MSYS shell (file @file{msys.bat}).
  946. @item Change to the FFmpeg directory and follow
  947. the instructions of how to compile FFmpeg (file
  948. @file{INSTALL}). Usually, launching @file{./configure} and @file{make}
  949. suffices. If you have problems using SDL, verify that
  950. @file{sdl-config} can be launched from the MSYS command line.
  951. @item You can install FFmpeg in @file{Program Files/FFmpeg} by typing
  952. @file{make install}. Don't forget to copy @file{SDL.dll} to the place
  953. you launch @file{ffplay} from.
  954. @end itemize
  955. Notes:
  956. @itemize
  957. @item The target @file{make wininstaller} can be used to create a
  958. Nullsoft based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
  959. must be copied to the FFmpeg directory in order to build the
  960. installer.
  961. @item By using @code{./configure --enable-shared} when configuring FFmpeg,
  962. you can build @file{avcodec.dll} and @file{avformat.dll}. With
  963. @code{make install} you install the FFmpeg DLLs and the associated
  964. headers in @file{Program Files/FFmpeg}.
  965. @item Visual C++ compatibility: If you used @code{./configure --enable-shared}
  966. when configuring FFmpeg, FFmpeg tries to use the Microsoft Visual
  967. C++ @code{lib} tool to build @code{avcodec.lib} and
  968. @code{avformat.lib}. With these libraries you can link your Visual C++
  969. code directly with the FFmpeg DLLs (see below).
  970. @end itemize
  971. @subsection Visual C++ compatibility
  972. FFmpeg will not compile under Visual C++ -- and it has too many
  973. dependencies on the GCC compiler to make a port viable. However,
  974. if you want to use the FFmpeg libraries in your own applications,
  975. you can still compile those applications using Visual C++. An
  976. important restriction to this is that you have to use the
  977. dynamically linked versions of the FFmpeg libraries (i.e. the
  978. DLLs), and you have to make sure that Visual-C++-compatible
  979. import libraries are created during the FFmpeg build process.
  980. This description of how to use the FFmpeg libraries with Visual C++ is
  981. based on Visual C++ 2005 Express Edition Beta 2. If you have a different
  982. version, you might have to modify the procedures slightly.
  983. Here are the step-by-step instructions for building the FFmpeg libraries
  984. so they can be used with Visual C++:
  985. @enumerate
  986. @item Install Visual C++ (if you haven't done so already).
  987. @item Install MinGW and MSYS as described above.
  988. @item Add a call to @file{vcvars32.bat} (which sets up the environment
  989. variables for the Visual C++ tools) as the first line of
  990. @file{msys.bat}. The standard location for @file{vcvars32.bat} is
  991. @file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
  992. and the standard location for @file{msys.bat} is
  993. @file{C:\msys\1.0\msys.bat}. If this corresponds to your setup, add the
  994. following line as the first line of @file{msys.bat}:
  995. @code{call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"}
  996. @item Start the MSYS shell (file @file{msys.bat}) and type @code{link.exe}.
  997. If you get a help message with the command line options of @code{link.exe},
  998. this means your environment variables are set up correctly, the
  999. Microsoft linker is on the path and will be used by FFmpeg to
  1000. create Visual-C++-compatible import libraries.
  1001. @item Extract the current version of FFmpeg and change to the FFmpeg directory.
  1002. @item Type the command
  1003. @code{./configure --enable-shared --disable-static --enable-memalign-hack}
  1004. to configure and, if that didn't produce any errors,
  1005. type @code{make} to build FFmpeg.
  1006. @item The subdirectories @file{libavformat}, @file{libavcodec}, and
  1007. @file{libavutil} should now contain the files @file{avformat.dll},
  1008. @file{avformat.lib}, @file{avcodec.dll}, @file{avcodec.lib},
  1009. @file{avutil.dll}, and @file{avutil.lib}, respectively. Copy the three
  1010. DLLs to your System32 directory (typically @file{C:\Windows\System32}).
  1011. @end enumerate
  1012. And here is how to use these libraries with Visual C++:
  1013. @enumerate
  1014. @item Create a new console application ("File / New / Project") and then
  1015. select "Win32 Console Application". On the appropriate page of the
  1016. Application Wizard, uncheck the "Precompiled headers" option.
  1017. @item Write the source code for your application, or, for testing, just
  1018. copy the code from an existing sample application into the source file
  1019. that Visual C++ has already created for you. (Note that your source
  1020. filehas to have a @code{.cpp} extension; otherwise, Visual C++ won't
  1021. compile the FFmpeg headers correctly because in C mode, it doesn't
  1022. recognize the @code{inline} keyword.) For example, you can copy
  1023. @file{output_example.c} from the FFmpeg distribution (but you will
  1024. have to make minor modifications so the code will compile under
  1025. C++, see below).
  1026. @item Open the "Project / Properties" dialog box. In the "Configuration"
  1027. combo box, select "All Configurations" so that the changes you make will
  1028. affect both debug and release builds. In the tree view on the left hand
  1029. side, select "C/C++ / General", then edit the "Additional Include
  1030. Directories" setting to contain the complete paths to the
  1031. @file{libavformat}, @file{libavcodec}, and @file{libavutil}
  1032. subdirectories of your FFmpeg directory. Note that the directories have
  1033. to be separated using semicolons. Now select "Linker / General" from the
  1034. tree view and edit the "Additional Library Directories" setting to
  1035. contain the same three directories.
  1036. @item Still in the "Project / Properties" dialog box, select "Linker / Input"
  1037. from the tree view, then add the files @file{avformat.lib},
  1038. @file{avcodec.lib}, and @file{avutil.lib} to the end of the "Additional
  1039. Dependencies". Note that the names of the libraries have to be separated
  1040. using spaces.
  1041. @item Now, select "C/C++ / Code Generation" from the tree view. Select
  1042. "Debug" in the "Configuration" combo box. Make sure that "Runtime
  1043. Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
  1044. the "Configuration" combo box and make sure that "Runtime Library" is
  1045. set to "Multi-threaded DLL".
  1046. @item Click "OK" to close the "Project / Properties" dialog box and build
  1047. the application. Hopefully, it should compile and run cleanly. If you
  1048. used @file{output_example.c} as your sample application, you will get a
  1049. few compiler errors, but they are easy to fix. The first type of error
  1050. occurs because Visual C++ doesn't allow an @code{int} to be converted to
  1051. an @code{enum} without a cast. To solve the problem, insert the required
  1052. casts (this error occurs once for a @code{CodecID} and once for a
  1053. @code{CodecType}). The second type of error occurs because C++ requires
  1054. the return value of @code{malloc} to be cast to the exact type of the
  1055. pointer it is being assigned to. Visual C++ will complain that, for
  1056. example, @code{(void *)} is being assigned to @code{(uint8_t *)} without
  1057. an explicit cast. So insert an explicit cast in these places to silence
  1058. the compiler. The third type of error occurs because the @code{snprintf}
  1059. library function is called @code{_snprintf} under Visual C++. So just
  1060. add an underscore to fix the problem. With these changes,
  1061. @file{output_example.c} should compile under Visual C++, and the
  1062. resulting executable should produce valid video files.
  1063. @end enumerate
  1064. @subsection Cross compilation for Windows with Linux
  1065. You must use the MinGW cross compilation tools available at
  1066. @url{http://www.mingw.org/}.
  1067. Then configure FFmpeg with the following options:
  1068. @example
  1069. ./configure --enable-mingw32 --cross-prefix=i386-mingw32msvc-
  1070. @end example
  1071. (you can change the cross-prefix according to the prefix chosen for the
  1072. MinGW tools).
  1073. Then you can easily test FFmpeg with Wine
  1074. (@url{http://www.winehq.com/}).
  1075. @subsection Compilation under Cygwin
  1076. Cygwin works very much like Unix.
  1077. Just install your Cygwin with all the "Base" packages, plus the
  1078. following "Devel" ones:
  1079. @example
  1080. binutils, gcc-core, make, subversion
  1081. @end example
  1082. Do not install binutils-20060709-1 (they are buggy on shared builds);
  1083. use binutils-20050610-1 instead.
  1084. Then run
  1085. @example
  1086. ./configure --enable-static --disable-shared
  1087. @end example
  1088. to make a static build or
  1089. @example
  1090. ./configure --enable-shared --disable-static
  1091. @end example
  1092. to build shared libraries.
  1093. If you want to build FFmpeg with additional libraries, download Cygwin
  1094. "Devel" packages for Ogg and Vorbis from any Cygwin packages repository
  1095. and/or SDL, xvid, faac, faad2 packages from Cygwin Ports,
  1096. (@url{http://cygwinports.dotsrc.org/}).
  1097. @subsection Crosscompilation for Windows under Cygwin
  1098. With Cygwin you can create Windows binaries that don't need the cygwin1.dll.
  1099. Just install your Cygwin as explained before, plus these additional
  1100. "Devel" packages:
  1101. @example
  1102. gcc-mingw-core, mingw-runtime, mingw-zlib
  1103. @end example
  1104. and add some special flags to your configure invocation.
  1105. For a static build run
  1106. @example
  1107. ./configure --enable-mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  1108. @end example
  1109. and for a build with shared libraries
  1110. @example
  1111. ./configure --enable-mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  1112. @end example
  1113. @section BeOS
  1114. The configure script should guess the configuration itself.
  1115. Networking support is currently not finished.
  1116. errno issues fixed by Andrew Bachmann.
  1117. Old stuff:
  1118. François Revol - revol at free dot fr - April 2002
  1119. The configure script should guess the configuration itself,
  1120. however I still didn't test building on the net_server version of BeOS.
  1121. FFserver is broken (needs poll() implementation).
  1122. There are still issues with errno codes, which are negative in BeOS, and
  1123. that FFmpeg negates when returning. This ends up turning errors into
  1124. valid results, then crashes.
  1125. (To be fixed)
  1126. @chapter Developers Guide
  1127. @section API
  1128. @itemize @bullet
  1129. @item libavcodec is the library containing the codecs (both encoding and
  1130. decoding). Look at @file{libavcodec/apiexample.c} to see how to use it.
  1131. @item libavformat is the library containing the file format handling (mux and
  1132. demux code for several formats). Look at @file{ffplay.c} to use it in a
  1133. player. See @file{output_example.c} to use it to generate audio or video
  1134. streams.
  1135. @end itemize
  1136. @section Integrating libavcodec or libavformat in your program
  1137. You can integrate all the source code of the libraries to link them
  1138. statically to avoid any version problem. All you need is to provide a
  1139. 'config.mak' and a 'config.h' in the parent directory. See the defines
  1140. generated by ./configure to understand what is needed.
  1141. You can use libavcodec or libavformat in your commercial program, but
  1142. @emph{any patch you make must be published}. The best way to proceed is
  1143. to send your patches to the FFmpeg mailing list.
  1144. @node Coding Rules
  1145. @section Coding Rules
  1146. FFmpeg is programmed in the ISO C90 language with a few additional
  1147. features from ISO C99, namely:
  1148. @itemize @bullet
  1149. @item
  1150. the @samp{inline} keyword;
  1151. @item
  1152. @samp{//} comments;
  1153. @item
  1154. designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
  1155. @item
  1156. compound literals (@samp{x = (struct s) @{ 17, 23 @};})
  1157. @end itemize
  1158. These features are supported by all compilers we care about, so we won't
  1159. accept patches to remove their use unless they absolutely don't impair
  1160. clarity and performance.
  1161. All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
  1162. compiles with several other compilers, such as the Compaq ccc compiler
  1163. or Sun Studio 9, and we would like to keep it that way unless it would
  1164. be exceedingly involved. To ensure compatibility, please don't use any
  1165. additional C99 features or GCC extensions. Especially watch out for:
  1166. @itemize @bullet
  1167. @item
  1168. mixing statements and declarations;
  1169. @item
  1170. @samp{long long} (use @samp{int64_t} instead);
  1171. @item
  1172. @samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
  1173. @item
  1174. GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
  1175. @end itemize
  1176. Indent size is 4.
  1177. The presentation is the one specified by 'indent -i4 -kr -nut'.
  1178. The TAB character is forbidden outside of Makefiles as is any
  1179. form of trailing whitespace. Commits containing either will be
  1180. rejected by the Subversion repository.
  1181. Main priority in FFmpeg is simplicity and small code size (=less
  1182. bugs).
  1183. Comments: Use the JavaDoc/Doxygen
  1184. format (see examples below) so that code documentation
  1185. can be generated automatically. All nontrivial functions should have a comment
  1186. above them explaining what the function does, even if it's just one sentence.
  1187. All structures and their member variables should be documented, too.
  1188. @example
  1189. /**
  1190. * @@file mpeg.c
  1191. * MPEG codec.
  1192. * @@author ...
  1193. */
  1194. /**
  1195. * Summary sentence.
  1196. * more text ...
  1197. * ...
  1198. */
  1199. typedef struct Foobar@{
  1200. int var1; /**< var1 description */
  1201. int var2; ///< var2 description
  1202. /** var3 description */
  1203. int var3;
  1204. @} Foobar;
  1205. /**
  1206. * Summary sentence.
  1207. * more text ...
  1208. * ...
  1209. * @@param my_parameter description of my_parameter
  1210. * @@return return value description
  1211. */
  1212. int myfunc(int my_parameter)
  1213. ...
  1214. @end example
  1215. fprintf and printf are forbidden in libavformat and libavcodec,
  1216. please use av_log() instead.
  1217. @section Development Policy
  1218. @enumerate
  1219. @item
  1220. You must not commit code which breaks FFmpeg! (Meaning unfinished but
  1221. enabled code which breaks compilation or compiles but does not work or
  1222. breaks the regression tests)
  1223. You can commit unfinished stuff (for testing etc), but it must be disabled
  1224. (#ifdef etc) by default so it does not interfere with other developers'
  1225. work.
  1226. @item
  1227. You don't have to over-test things. If it works for you, and you think it
  1228. should work for others, then commit. If your code has problems
  1229. (portability, triggers compiler bugs, unusual environment etc) they will be
  1230. reported and eventually fixed.
  1231. @item
  1232. Do not commit unrelated changes together, split them into self-contained
  1233. pieces.
  1234. @item
  1235. Do not change behavior of the program (renaming options etc) without
  1236. first discussing it on the ffmpeg-devel mailing list. Do not remove
  1237. functionality from the code. Just improve!
  1238. Note: Redundant code can be removed.
  1239. @item
  1240. Do not commit changes to the build system (Makefiles, configure script)
  1241. which change behavior, defaults etc, without asking first. The same
  1242. applies to compiler warning fixes, trivial looking fixes and to code
  1243. maintained by other developers. We usually have a reason for doing things
  1244. the way we do. Send your changes as patches to the ffmpeg-devel mailing
  1245. list, and if the code maintainers say OK, you may commit. This does not
  1246. apply to files you wrote and/or maintain.
  1247. @item
  1248. We refuse source indentation and other cosmetic changes if they are mixed
  1249. with functional changes, such commits will be rejected and removed. Every
  1250. developer has his own indentation style, you should not change it. Of course
  1251. if you (re)write something, you can use your own style, even though we would
  1252. prefer if the indentation throughout FFmpeg was consistent (Many projects
  1253. force a given indentation style - we don't.). If you really need to make
  1254. indentation changes (try to avoid this), separate them strictly from real
  1255. changes.
  1256. NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
  1257. then either do NOT change the indentation of the inner part within (don't
  1258. move it to the right)! or do so in a separate commit
  1259. @item
  1260. Always fill out the commit log message. Describe in a few lines what you
  1261. changed and why. You can refer to mailing list postings if you fix a
  1262. particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
  1263. @item
  1264. If you apply a patch by someone else, include the name and email address in
  1265. the log message. Since the ffmpeg-cvslog mailing list is publicly
  1266. archived you should add some SPAM protection to the email address. Send an
  1267. answer to ffmpeg-devel (or wherever you got the patch from) saying that
  1268. you applied the patch.
  1269. @item
  1270. Do NOT commit to code actively maintained by others without permission.
  1271. Send a patch to ffmpeg-devel instead. If noone answers within a reasonable
  1272. timeframe (12h for build failures and security fixes, 3 days small changes,
  1273. 1 week for big patches) then commit your patch if you think it's OK.
  1274. Also note, the maintainer can simply ask for more time to review!
  1275. @item
  1276. Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
  1277. are sent there and reviewed by all the other developers. Bugs and possible
  1278. improvements or general questions regarding commits are discussed there. We
  1279. expect you to react if problems with your code are uncovered.
  1280. @item
  1281. Update the documentation if you change behavior or add features. If you are
  1282. unsure how best to do this, send a patch to ffmpeg-devel, the documentation
  1283. maintainer(s) will review and commit your stuff.
  1284. @item
  1285. Never write to unallocated memory, never write over the end of arrays,
  1286. always check values read from some untrusted source before using them
  1287. as array index or other risky things.
  1288. @item
  1289. Remember to check if you need to bump versions for the specific libav
  1290. parts (libavutil, libavcodec, libavformat) you are changing. You need
  1291. to change the version integer and the version string.
  1292. Incrementing the first component means no backward compatibility to
  1293. previous versions (e.g. removal of a function from the public API).
  1294. Incrementing the second component means backward compatible change
  1295. (e.g. addition of a function to the public API).
  1296. Incrementing the third component means a noteworthy binary compatible
  1297. change (e.g. encoder bug fix that matters for the decoder).
  1298. @item
  1299. If you add a new codec, remember to update the changelog, add it to
  1300. the supported codecs table in the documentation and bump the second
  1301. component of the @file{libavcodec} version number appropriately. If
  1302. it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
  1303. is only a decoder.
  1304. @end enumerate
  1305. We think our rules are not too hard. If you have comments, contact us.
  1306. Note, these rules are mostly borrowed from the MPlayer project.
  1307. @section Submitting patches
  1308. First, (@pxref{Coding Rules}) above if you didn't yet.
  1309. When you submit your patch, try to send a unified diff (diff '-up'
  1310. option). I cannot read other diffs :-)
  1311. Also please do not submit patches which contain several unrelated changes.
  1312. Split them into individual self-contained patches; this makes reviewing
  1313. them much easier.
  1314. Run the regression tests before submitting a patch so that you can
  1315. verify that there are no big problems.
  1316. Patches should be posted as base64 encoded attachments (or any other
  1317. encoding which ensures that the patch won't be trashed during
  1318. transmission) to the ffmpeg-devel mailing list, see
  1319. @url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
  1320. It also helps quite a bit if you tell us what the patch does (for example
  1321. 'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
  1322. and has no lrint()')
  1323. We reply to all submitted patches and either apply or reject with some
  1324. explanation why, but sometimes we are quite busy so it can take a week or two.
  1325. @section Regression tests
  1326. Before submitting a patch (or committing to the repository), you should at least
  1327. test that you did not break anything.
  1328. The regression tests build a synthetic video stream and a synthetic
  1329. audio stream. These are then encoded and decoded with all codecs or
  1330. formats. The CRC (or MD5) of each generated file is recorded in a
  1331. result file. A 'diff' is launched to compare the reference results and
  1332. the result file.
  1333. The regression tests then go on to test the FFserver code with a
  1334. limited set of streams. It is important that this step runs correctly
  1335. as well.
  1336. Run 'make test' to test all the codecs and formats.
  1337. Run 'make fulltest' to test all the codecs, formats and FFserver.
  1338. [Of course, some patches may change the results of the regression tests. In
  1339. this case, the reference results of the regression tests shall be modified
  1340. accordingly].
  1341. @bye