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.

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