ffmpeg-doc.texi 57 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667
  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 64k /tmp/a.mp2 -ab 128k /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 128k 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 bit/s (default = 64k).
  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 384k test.mpg -acodec mp2 -ab 192k -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. @item DXA @tab @tab X
  747. @tab This format is used in non-Windows version of Feeble Files game and
  748. different game cutscenes repacked for use with ScummVM.
  749. @item THP @tab @tab X
  750. @tab Used on the Nintendo GameCube.
  751. @item C93 @tab @tab X
  752. @tab Used in the game Cyberia from Interplay.
  753. @item Bethsoft VID @tab @tab X
  754. @tab Used in some games from Bethesda Softworks.
  755. @item CRYO APC @tab @tab X
  756. @tab Audio format used in some games by CRYO Interactive Entertainment.
  757. @end multitable
  758. @code{X} means that encoding (resp. decoding) is supported.
  759. @section Image Formats
  760. FFmpeg can read and write images for each frame of a video sequence. The
  761. following image formats are supported:
  762. @multitable @columnfractions .4 .1 .1 .4
  763. @item Supported Image Format @tab Encoding @tab Decoding @tab Comments
  764. @item PGM, PPM @tab X @tab X
  765. @item PAM @tab X @tab X @tab PAM is a PNM extension with alpha support.
  766. @item PGMYUV @tab X @tab X @tab PGM with U and V components in YUV 4:2:0
  767. @item JPEG @tab X @tab X @tab Progressive JPEG is not supported.
  768. @item .Y.U.V @tab X @tab X @tab one raw file per component
  769. @item animated GIF @tab X @tab X @tab Only uncompressed GIFs are generated.
  770. @item PNG @tab X @tab X @tab 2 bit and 4 bit/pixel not supported yet.
  771. @item Targa @tab @tab X @tab Targa (.TGA) image format.
  772. @item TIFF @tab X @tab X @tab YUV, JPEG and some extension is not supported yet.
  773. @item SGI @tab X @tab X @tab SGI RGB image format
  774. @end multitable
  775. @code{X} means that encoding (resp. decoding) is supported.
  776. @section Video Codecs
  777. @multitable @columnfractions .4 .1 .1 .4
  778. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  779. @item MPEG-1 video @tab X @tab X
  780. @item MPEG-2 video @tab X @tab X
  781. @item MPEG-4 @tab X @tab X
  782. @item MSMPEG4 V1 @tab X @tab X
  783. @item MSMPEG4 V2 @tab X @tab X
  784. @item MSMPEG4 V3 @tab X @tab X
  785. @item WMV7 @tab X @tab X
  786. @item WMV8 @tab X @tab X @tab not completely working
  787. @item WMV9 @tab @tab X @tab not completely working
  788. @item VC1 @tab @tab X
  789. @item H.261 @tab X @tab X
  790. @item H.263(+) @tab X @tab X @tab also known as RealVideo 1.0
  791. @item H.264 @tab @tab X
  792. @item RealVideo 1.0 @tab X @tab X
  793. @item RealVideo 2.0 @tab X @tab X
  794. @item MJPEG @tab X @tab X
  795. @item lossless MJPEG @tab X @tab X
  796. @item JPEG-LS @tab X @tab X @tab fourcc: MJLS, lossless and near-lossless is supported
  797. @item Apple MJPEG-B @tab @tab X
  798. @item Sunplus MJPEG @tab @tab X @tab fourcc: SP5X
  799. @item DV @tab X @tab X
  800. @item HuffYUV @tab X @tab X
  801. @item FFmpeg Video 1 @tab X @tab X @tab experimental lossless codec (fourcc: FFV1)
  802. @item FFmpeg Snow @tab X @tab X @tab experimental wavelet codec (fourcc: SNOW)
  803. @item Asus v1 @tab X @tab X @tab fourcc: ASV1
  804. @item Asus v2 @tab X @tab X @tab fourcc: ASV2
  805. @item Creative YUV @tab @tab X @tab fourcc: CYUV
  806. @item Sorenson Video 1 @tab X @tab X @tab fourcc: SVQ1
  807. @item Sorenson Video 3 @tab @tab X @tab fourcc: SVQ3
  808. @item On2 VP3 @tab @tab X @tab still experimental
  809. @item On2 VP5 @tab @tab X @tab fourcc: VP50
  810. @item On2 VP6 @tab @tab X @tab fourcc: VP60,VP61,VP62
  811. @item Theora @tab X @tab X @tab still experimental
  812. @item Intel Indeo 3 @tab @tab X
  813. @item FLV @tab X @tab X @tab Sorenson H.263 used in Flash
  814. @item Flash Screen Video @tab X @tab X @tab fourcc: FSV1
  815. @item ATI VCR1 @tab @tab X @tab fourcc: VCR1
  816. @item ATI VCR2 @tab @tab X @tab fourcc: VCR2
  817. @item Cirrus Logic AccuPak @tab @tab X @tab fourcc: CLJR
  818. @item 4X Video @tab @tab X @tab Used in certain computer games.
  819. @item Sony Playstation MDEC @tab @tab X
  820. @item Id RoQ @tab @tab X @tab Used in Quake III, Jedi Knight 2, other computer games.
  821. @item Xan/WC3 @tab @tab X @tab Used in Wing Commander III .MVE files.
  822. @item Interplay Video @tab @tab X @tab Used in Interplay .MVE files.
  823. @item Apple Animation @tab @tab X @tab fourcc: 'rle '
  824. @item Apple Graphics @tab @tab X @tab fourcc: 'smc '
  825. @item Apple Video @tab @tab X @tab fourcc: rpza
  826. @item Apple QuickDraw @tab @tab X @tab fourcc: qdrw
  827. @item Cinepak @tab @tab X
  828. @item Microsoft RLE @tab @tab X
  829. @item Microsoft Video-1 @tab @tab X
  830. @item Westwood VQA @tab @tab X
  831. @item Id Cinematic Video @tab @tab X @tab Used in Quake II.
  832. @item Planar RGB @tab @tab X @tab fourcc: 8BPS
  833. @item FLIC video @tab @tab X
  834. @item Duck TrueMotion v1 @tab @tab X @tab fourcc: DUCK
  835. @item Duck TrueMotion v2 @tab @tab X @tab fourcc: TM20
  836. @item VMD Video @tab @tab X @tab Used in Sierra VMD files.
  837. @item MSZH @tab @tab X @tab Part of LCL
  838. @item ZLIB @tab X @tab X @tab Part of LCL, encoder experimental
  839. @item TechSmith Camtasia @tab @tab X @tab fourcc: TSCC
  840. @item IBM Ultimotion @tab @tab X @tab fourcc: ULTI
  841. @item Miro VideoXL @tab @tab X @tab fourcc: VIXL
  842. @item QPEG @tab @tab X @tab fourccs: QPEG, Q1.0, Q1.1
  843. @item LOCO @tab @tab X @tab
  844. @item Winnov WNV1 @tab @tab X @tab
  845. @item Autodesk Animator Studio Codec @tab @tab X @tab fourcc: AASC
  846. @item Fraps FPS1 @tab @tab X @tab
  847. @item CamStudio @tab @tab X @tab fourcc: CSCD
  848. @item American Laser Games Video @tab @tab X @tab Used in games like Mad Dog McCree
  849. @item ZMBV @tab X @tab X @tab Encoder works only on PAL8
  850. @item AVS Video @tab @tab X @tab Video encoding used by the Creature Shock game.
  851. @item Smacker Video @tab @tab X @tab Video encoding used in Smacker.
  852. @item RTjpeg @tab @tab X @tab Video encoding used in NuppelVideo files.
  853. @item KMVC @tab @tab X @tab Codec used in Worms games.
  854. @item VMware Video @tab @tab X @tab Codec used in videos captured by VMware.
  855. @item Cin Video @tab @tab X @tab Codec used in Delphine Software games.
  856. @item Tiertex Seq Video @tab @tab X @tab Codec used in DOS CDROM FlashBack game.
  857. @item DXA Video @tab @tab X @tab Codec originally used in Feeble Files game.
  858. @item AVID DNxHD @tab @tab X @tab aka SMPTE VC3
  859. @item C93 Video @tab @tab X @tab Codec used in Cyberia game.
  860. @item THP @tab @tab X @tab Used on the Nintendo GameCube.
  861. @item Bethsoft VID @tab @tab X @tab Used in some games from Bethesda Softworks.
  862. @end multitable
  863. @code{X} means that encoding (resp. decoding) is supported.
  864. @section Audio Codecs
  865. @multitable @columnfractions .4 .1 .1 .1 .7
  866. @item Supported Codec @tab Encoding @tab Decoding @tab Comments
  867. @item MPEG audio layer 2 @tab IX @tab IX
  868. @item MPEG audio layer 1/3 @tab IX @tab IX
  869. @tab MP3 encoding is supported through the external library LAME.
  870. @item AC3 @tab IX @tab IX
  871. @tab liba52 is used internally for decoding.
  872. @item Vorbis @tab X @tab X
  873. @item WMA V1/V2 @tab X @tab X
  874. @item AAC @tab X @tab X
  875. @tab Supported through the external library libfaac/libfaad.
  876. @item Microsoft ADPCM @tab X @tab X
  877. @item MS IMA ADPCM @tab X @tab X
  878. @item QT IMA ADPCM @tab @tab X
  879. @item 4X IMA ADPCM @tab @tab X
  880. @item G.726 ADPCM @tab X @tab X
  881. @item Duck DK3 IMA ADPCM @tab @tab X
  882. @tab Used in some Sega Saturn console games.
  883. @item Duck DK4 IMA ADPCM @tab @tab X
  884. @tab Used in some Sega Saturn console games.
  885. @item Westwood Studios IMA ADPCM @tab @tab X
  886. @tab Used in Westwood Studios games like Command and Conquer.
  887. @item SMJPEG IMA ADPCM @tab @tab X
  888. @tab Used in certain Loki game ports.
  889. @item CD-ROM XA ADPCM @tab @tab X
  890. @item CRI ADX ADPCM @tab X @tab X
  891. @tab Used in Sega Dreamcast games.
  892. @item Electronic Arts ADPCM @tab @tab X
  893. @tab Used in various EA titles.
  894. @item Creative ADPCM @tab @tab X
  895. @tab 16 -> 4, 8 -> 4, 8 -> 3, 8 -> 2
  896. @item THP ADPCM @tab @tab X
  897. @tab Used on the Nintendo GameCube.
  898. @item RA144 @tab @tab X
  899. @tab Real 14400 bit/s codec
  900. @item RA288 @tab @tab X
  901. @tab Real 28800 bit/s codec
  902. @item RADnet @tab X @tab IX
  903. @tab Real low bitrate AC3 codec, liba52 is used for decoding.
  904. @item AMR-NB @tab X @tab X
  905. @tab Supported through an external library.
  906. @item AMR-WB @tab X @tab X
  907. @tab Supported through an external library.
  908. @item DV audio @tab @tab X
  909. @item Id RoQ DPCM @tab @tab X
  910. @tab Used in Quake III, Jedi Knight 2, other computer games.
  911. @item Interplay MVE DPCM @tab @tab X
  912. @tab Used in various Interplay computer games.
  913. @item Xan DPCM @tab @tab X
  914. @tab Used in Origin's Wing Commander IV AVI files.
  915. @item Sierra Online DPCM @tab @tab X
  916. @tab Used in Sierra Online game audio files.
  917. @item Apple MACE 3 @tab @tab X
  918. @item Apple MACE 6 @tab @tab X
  919. @item FLAC lossless audio @tab X @tab X
  920. @item Shorten lossless audio @tab @tab X
  921. @item Apple lossless audio @tab @tab X
  922. @tab QuickTime fourcc 'alac'
  923. @item FFmpeg Sonic @tab X @tab X
  924. @tab experimental lossy/lossless codec
  925. @item Qdesign QDM2 @tab @tab X
  926. @tab there are still some distortions
  927. @item Real COOK @tab @tab X
  928. @tab All versions except 5.1 are supported
  929. @item DSP Group TrueSpeech @tab @tab X
  930. @item True Audio (TTA) @tab @tab X
  931. @item Smacker Audio @tab @tab X
  932. @item WavPack Audio @tab @tab X
  933. @item Cin Audio @tab @tab X
  934. @tab Codec used in Delphine Software games.
  935. @item Intel Music Coder @tab @tab X
  936. @item Musepack @tab @tab X
  937. @tab Only SV7 is supported
  938. @item DT$ Coherent Audio @tab @tab X
  939. @end multitable
  940. @code{X} means that encoding (resp. decoding) is supported.
  941. @code{I} means that an integer-only version is available, too (ensures high
  942. performance on systems without hardware floating point support).
  943. @chapter Platform Specific information
  944. @section BSD
  945. BSD make will not build FFmpeg, you need to install and use GNU Make
  946. (@file{gmake}).
  947. @section Windows
  948. To get help and instructions for using FFmpeg under Windows, check out
  949. the FFmpeg Windows Help Forum at
  950. @url{http://arrozcru.no-ip.org/ffmpeg/}.
  951. @subsection Native Windows compilation
  952. @itemize
  953. @item Install the current versions of MSYS and MinGW from
  954. @url{http://www.mingw.org/}. You can find detailed installation
  955. instructions in the download section and the FAQ.
  956. NOTE: Use at least bash 3.1. Older versions are known to be failing on the
  957. configure script.
  958. @item If you want to test the FFplay, also download
  959. the MinGW development library of SDL 1.2.x
  960. (@file{SDL-devel-1.2.x-mingw32.tar.gz}) from
  961. @url{http://www.libsdl.org}. Unpack it in a temporary directory, and
  962. unpack the archive @file{i386-mingw32msvc.tar.gz} in the MinGW tool
  963. directory. Edit the @file{sdl-config} script so that it gives the
  964. correct SDL directory when invoked.
  965. @item Extract the current version of FFmpeg.
  966. @item Start the MSYS shell (file @file{msys.bat}).
  967. @item Change to the FFmpeg directory and follow
  968. the instructions of how to compile FFmpeg (file
  969. @file{INSTALL}). Usually, launching @file{./configure} and @file{make}
  970. suffices. If you have problems using SDL, verify that
  971. @file{sdl-config} can be launched from the MSYS command line.
  972. @item You can install FFmpeg in @file{Program Files/FFmpeg} by typing
  973. @file{make install}. Do not forget to copy @file{SDL.dll} to the place
  974. you launch @file{ffplay} from.
  975. @end itemize
  976. Notes:
  977. @itemize
  978. @item The target @file{make wininstaller} can be used to create a
  979. Nullsoft based Windows installer for FFmpeg and FFplay. @file{SDL.dll}
  980. must be copied to the FFmpeg directory in order to build the
  981. installer.
  982. @item By using @code{./configure --enable-shared} when configuring FFmpeg,
  983. you can build @file{avcodec.dll} and @file{avformat.dll}. With
  984. @code{make install} you install the FFmpeg DLLs and the associated
  985. headers in @file{Program Files/FFmpeg}.
  986. @item Visual C++ compatibility: If you used @code{./configure --enable-shared}
  987. when configuring FFmpeg, FFmpeg tries to use the Microsoft Visual
  988. C++ @code{lib} tool to build @code{avcodec.lib} and
  989. @code{avformat.lib}. With these libraries you can link your Visual C++
  990. code directly with the FFmpeg DLLs (see below).
  991. @end itemize
  992. @subsection Visual C++ compatibility
  993. FFmpeg will not compile under Visual C++ -- and it has too many
  994. dependencies on the GCC compiler to make a port viable. However,
  995. if you want to use the FFmpeg libraries in your own applications,
  996. you can still compile those applications using Visual C++. An
  997. important restriction to this is that you have to use the
  998. dynamically linked versions of the FFmpeg libraries (i.e. the
  999. DLLs), and you have to make sure that Visual-C++-compatible
  1000. import libraries are created during the FFmpeg build process.
  1001. This description of how to use the FFmpeg libraries with Visual C++ is
  1002. based on Visual C++ 2005 Express Edition Beta 2. If you have a different
  1003. version, you might have to modify the procedures slightly.
  1004. Here are the step-by-step instructions for building the FFmpeg libraries
  1005. so they can be used with Visual C++:
  1006. @enumerate
  1007. @item Install Visual C++ (if you have not done so already).
  1008. @item Install MinGW and MSYS as described above.
  1009. @item Add a call to @file{vcvars32.bat} (which sets up the environment
  1010. variables for the Visual C++ tools) as the first line of
  1011. @file{msys.bat}. The standard location for @file{vcvars32.bat} is
  1012. @file{C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat},
  1013. and the standard location for @file{msys.bat} is
  1014. @file{C:\msys\1.0\msys.bat}. If this corresponds to your setup, add the
  1015. following line as the first line of @file{msys.bat}:
  1016. @code{call "C:\Program Files\Microsoft Visual Studio 8\VC\bin\vcvars32.bat"}
  1017. @item Start the MSYS shell (file @file{msys.bat}) and type @code{link.exe}.
  1018. If you get a help message with the command line options of @code{link.exe},
  1019. this means your environment variables are set up correctly, the
  1020. Microsoft linker is on the path and will be used by FFmpeg to
  1021. create Visual-C++-compatible import libraries.
  1022. @item Extract the current version of FFmpeg and change to the FFmpeg directory.
  1023. @item Type the command
  1024. @code{./configure --enable-shared --disable-static --enable-memalign-hack}
  1025. to configure and, if that did not produce any errors,
  1026. type @code{make} to build FFmpeg.
  1027. @item The subdirectories @file{libavformat}, @file{libavcodec}, and
  1028. @file{libavutil} should now contain the files @file{avformat.dll},
  1029. @file{avformat.lib}, @file{avcodec.dll}, @file{avcodec.lib},
  1030. @file{avutil.dll}, and @file{avutil.lib}, respectively. Copy the three
  1031. DLLs to your System32 directory (typically @file{C:\Windows\System32}).
  1032. @end enumerate
  1033. And here is how to use these libraries with Visual C++:
  1034. @enumerate
  1035. @item Create a new console application ("File / New / Project") and then
  1036. select "Win32 Console Application". On the appropriate page of the
  1037. Application Wizard, uncheck the "Precompiled headers" option.
  1038. @item Write the source code for your application, or, for testing, just
  1039. copy the code from an existing sample application into the source file
  1040. that Visual C++ has already created for you. (Note that your source
  1041. filehas to have a @code{.cpp} extension; otherwise, Visual C++ will not
  1042. compile the FFmpeg headers correctly because in C mode, it does not
  1043. recognize the @code{inline} keyword.) For example, you can copy
  1044. @file{output_example.c} from the FFmpeg distribution (but you will
  1045. have to make minor modifications so the code will compile under
  1046. C++, see below).
  1047. @item Open the "Project / Properties" dialog box. In the "Configuration"
  1048. combo box, select "All Configurations" so that the changes you make will
  1049. affect both debug and release builds. In the tree view on the left hand
  1050. side, select "C/C++ / General", then edit the "Additional Include
  1051. Directories" setting to contain the complete paths to the
  1052. @file{libavformat}, @file{libavcodec}, and @file{libavutil}
  1053. subdirectories of your FFmpeg directory. Note that the directories have
  1054. to be separated using semicolons. Now select "Linker / General" from the
  1055. tree view and edit the "Additional Library Directories" setting to
  1056. contain the same three directories.
  1057. @item Still in the "Project / Properties" dialog box, select "Linker / Input"
  1058. from the tree view, then add the files @file{avformat.lib},
  1059. @file{avcodec.lib}, and @file{avutil.lib} to the end of the "Additional
  1060. Dependencies". Note that the names of the libraries have to be separated
  1061. using spaces.
  1062. @item Now, select "C/C++ / Code Generation" from the tree view. Select
  1063. "Debug" in the "Configuration" combo box. Make sure that "Runtime
  1064. Library" is set to "Multi-threaded Debug DLL". Then, select "Release" in
  1065. the "Configuration" combo box and make sure that "Runtime Library" is
  1066. set to "Multi-threaded DLL".
  1067. @item Click "OK" to close the "Project / Properties" dialog box and build
  1068. the application. Hopefully, it should compile and run cleanly. If you
  1069. used @file{output_example.c} as your sample application, you will get a
  1070. few compiler errors, but they are easy to fix. The first type of error
  1071. occurs because Visual C++ does not allow an @code{int} to be converted to
  1072. an @code{enum} without a cast. To solve the problem, insert the required
  1073. casts (this error occurs once for a @code{CodecID} and once for a
  1074. @code{CodecType}). The second type of error occurs because C++ requires
  1075. the return value of @code{malloc} to be cast to the exact type of the
  1076. pointer it is being assigned to. Visual C++ will complain that, for
  1077. example, @code{(void *)} is being assigned to @code{(uint8_t *)} without
  1078. an explicit cast. So insert an explicit cast in these places to silence
  1079. the compiler. The third type of error occurs because the @code{snprintf}
  1080. library function is called @code{_snprintf} under Visual C++. So just
  1081. add an underscore to fix the problem. With these changes,
  1082. @file{output_example.c} should compile under Visual C++, and the
  1083. resulting executable should produce valid video files.
  1084. @end enumerate
  1085. @subsection Cross compilation for Windows with Linux
  1086. You must use the MinGW cross compilation tools available at
  1087. @url{http://www.mingw.org/}.
  1088. Then configure FFmpeg with the following options:
  1089. @example
  1090. ./configure --target-os=mingw32 --cross-prefix=i386-mingw32msvc-
  1091. @end example
  1092. (you can change the cross-prefix according to the prefix chosen for the
  1093. MinGW tools).
  1094. Then you can easily test FFmpeg with Wine
  1095. (@url{http://www.winehq.com/}).
  1096. @subsection Compilation under Cygwin
  1097. Cygwin works very much like Unix.
  1098. Just install your Cygwin with all the "Base" packages, plus the
  1099. following "Devel" ones:
  1100. @example
  1101. binutils, gcc-core, make, subversion
  1102. @end example
  1103. Do not install binutils-20060709-1 (they are buggy on shared builds);
  1104. use binutils-20050610-1 instead.
  1105. Then run
  1106. @example
  1107. ./configure --enable-static --disable-shared
  1108. @end example
  1109. to make a static build or
  1110. @example
  1111. ./configure --enable-shared --disable-static
  1112. @end example
  1113. to build shared libraries.
  1114. If you want to build FFmpeg with additional libraries, download Cygwin
  1115. "Devel" packages for Ogg and Vorbis from any Cygwin packages repository
  1116. and/or SDL, xvid, faac, faad2 packages from Cygwin Ports,
  1117. (@url{http://cygwinports.dotsrc.org/}).
  1118. @subsection Crosscompilation for Windows under Cygwin
  1119. With Cygwin you can create Windows binaries that do not need the cygwin1.dll.
  1120. Just install your Cygwin as explained before, plus these additional
  1121. "Devel" packages:
  1122. @example
  1123. gcc-mingw-core, mingw-runtime, mingw-zlib
  1124. @end example
  1125. and add some special flags to your configure invocation.
  1126. For a static build run
  1127. @example
  1128. ./configure --target-os=mingw32 --enable-memalign-hack --enable-static --disable-shared --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  1129. @end example
  1130. and for a build with shared libraries
  1131. @example
  1132. ./configure --target-os=mingw32 --enable-memalign-hack --enable-shared --disable-static --extra-cflags=-mno-cygwin --extra-libs=-mno-cygwin
  1133. @end example
  1134. @section BeOS
  1135. The configure script should guess the configuration itself.
  1136. Networking support is currently not finished.
  1137. errno issues fixed by Andrew Bachmann.
  1138. Old stuff:
  1139. François Revol - revol at free dot fr - April 2002
  1140. The configure script should guess the configuration itself,
  1141. however I still did not test building on the net_server version of BeOS.
  1142. FFserver is broken (needs poll() implementation).
  1143. There are still issues with errno codes, which are negative in BeOS, and
  1144. that FFmpeg negates when returning. This ends up turning errors into
  1145. valid results, then crashes.
  1146. (To be fixed)
  1147. @chapter Developers Guide
  1148. @section API
  1149. @itemize @bullet
  1150. @item libavcodec is the library containing the codecs (both encoding and
  1151. decoding). Look at @file{libavcodec/apiexample.c} to see how to use it.
  1152. @item libavformat is the library containing the file format handling (mux and
  1153. demux code for several formats). Look at @file{ffplay.c} to use it in a
  1154. player. See @file{output_example.c} to use it to generate audio or video
  1155. streams.
  1156. @end itemize
  1157. @section Integrating libavcodec or libavformat in your program
  1158. You can integrate all the source code of the libraries to link them
  1159. statically to avoid any version problem. All you need is to provide a
  1160. 'config.mak' and a 'config.h' in the parent directory. See the defines
  1161. generated by ./configure to understand what is needed.
  1162. You can use libavcodec or libavformat in your commercial program, but
  1163. @emph{any patch you make must be published}. The best way to proceed is
  1164. to send your patches to the FFmpeg mailing list.
  1165. @node Coding Rules
  1166. @section Coding Rules
  1167. FFmpeg is programmed in the ISO C90 language with a few additional
  1168. features from ISO C99, namely:
  1169. @itemize @bullet
  1170. @item
  1171. the @samp{inline} keyword;
  1172. @item
  1173. @samp{//} comments;
  1174. @item
  1175. designated struct initializers (@samp{struct s x = @{ .i = 17 @};})
  1176. @item
  1177. compound literals (@samp{x = (struct s) @{ 17, 23 @};})
  1178. @end itemize
  1179. These features are supported by all compilers we care about, so we will not
  1180. accept patches to remove their use unless they absolutely do not impair
  1181. clarity and performance.
  1182. All code must compile with GCC 2.95 and GCC 3.3. Currently, FFmpeg also
  1183. compiles with several other compilers, such as the Compaq ccc compiler
  1184. or Sun Studio 9, and we would like to keep it that way unless it would
  1185. be exceedingly involved. To ensure compatibility, please do not use any
  1186. additional C99 features or GCC extensions. Especially watch out for:
  1187. @itemize @bullet
  1188. @item
  1189. mixing statements and declarations;
  1190. @item
  1191. @samp{long long} (use @samp{int64_t} instead);
  1192. @item
  1193. @samp{__attribute__} not protected by @samp{#ifdef __GNUC__} or similar;
  1194. @item
  1195. GCC statement expressions (@samp{(x = (@{ int y = 4; y; @})}).
  1196. @end itemize
  1197. Indent size is 4.
  1198. The presentation is the one specified by 'indent -i4 -kr -nut'.
  1199. The TAB character is forbidden outside of Makefiles as is any
  1200. form of trailing whitespace. Commits containing either will be
  1201. rejected by the Subversion repository.
  1202. Main priority in FFmpeg is simplicity and small code size (=less
  1203. bugs).
  1204. Comments: Use the JavaDoc/Doxygen
  1205. format (see examples below) so that code documentation
  1206. can be generated automatically. All nontrivial functions should have a comment
  1207. above them explaining what the function does, even if it is just one sentence.
  1208. All structures and their member variables should be documented, too.
  1209. @example
  1210. /**
  1211. * @@file mpeg.c
  1212. * MPEG codec.
  1213. * @@author ...
  1214. */
  1215. /**
  1216. * Summary sentence.
  1217. * more text ...
  1218. * ...
  1219. */
  1220. typedef struct Foobar@{
  1221. int var1; /**< var1 description */
  1222. int var2; ///< var2 description
  1223. /** var3 description */
  1224. int var3;
  1225. @} Foobar;
  1226. /**
  1227. * Summary sentence.
  1228. * more text ...
  1229. * ...
  1230. * @@param my_parameter description of my_parameter
  1231. * @@return return value description
  1232. */
  1233. int myfunc(int my_parameter)
  1234. ...
  1235. @end example
  1236. fprintf and printf are forbidden in libavformat and libavcodec,
  1237. please use av_log() instead.
  1238. @section Development Policy
  1239. @enumerate
  1240. @item
  1241. You must not commit code which breaks FFmpeg! (Meaning unfinished but
  1242. enabled code which breaks compilation or compiles but does not work or
  1243. breaks the regression tests)
  1244. You can commit unfinished stuff (for testing etc), but it must be disabled
  1245. (#ifdef etc) by default so it does not interfere with other developers'
  1246. work.
  1247. @item
  1248. You do not have to over-test things. If it works for you, and you think it
  1249. should work for others, then commit. If your code has problems
  1250. (portability, triggers compiler bugs, unusual environment etc) they will be
  1251. reported and eventually fixed.
  1252. @item
  1253. Do not commit unrelated changes together, split them into self-contained
  1254. pieces. Also do not forget that if part B depends on part A, but A does not
  1255. depend on B, then A can and should be committed first and separate from B.
  1256. Keeping changes well split into self-contained parts makes reviewing and
  1257. understanding them on the commit log mailing list easier. This also helps
  1258. in case of debugging later on.
  1259. Also if you have doubts about splitting or not splitting, do not hesitate to
  1260. ask/disscuss it on the developer mailing list.
  1261. @item
  1262. Do not change behavior of the program (renaming options etc) without
  1263. first discussing it on the ffmpeg-devel mailing list. Do not remove
  1264. functionality from the code. Just improve!
  1265. Note: Redundant code can be removed.
  1266. @item
  1267. Do not commit changes to the build system (Makefiles, configure script)
  1268. which change behavior, defaults etc, without asking first. The same
  1269. applies to compiler warning fixes, trivial looking fixes and to code
  1270. maintained by other developers. We usually have a reason for doing things
  1271. the way we do. Send your changes as patches to the ffmpeg-devel mailing
  1272. list, and if the code maintainers say OK, you may commit. This does not
  1273. apply to files you wrote and/or maintain.
  1274. @item
  1275. We refuse source indentation and other cosmetic changes if they are mixed
  1276. with functional changes, such commits will be rejected and removed. Every
  1277. developer has his own indentation style, you should not change it. Of course
  1278. if you (re)write something, you can use your own style, even though we would
  1279. prefer if the indentation throughout FFmpeg was consistent (Many projects
  1280. force a given indentation style - we do not.). If you really need to make
  1281. indentation changes (try to avoid this), separate them strictly from real
  1282. changes.
  1283. NOTE: If you had to put if()@{ .. @} over a large (> 5 lines) chunk of code,
  1284. then either do NOT change the indentation of the inner part within (do not
  1285. move it to the right)! or do so in a separate commit
  1286. @item
  1287. Always fill out the commit log message. Describe in a few lines what you
  1288. changed and why. You can refer to mailing list postings if you fix a
  1289. particular bug. Comments such as "fixed!" or "Changed it." are unacceptable.
  1290. @item
  1291. If you apply a patch by someone else, include the name and email address in
  1292. the log message. Since the ffmpeg-cvslog mailing list is publicly
  1293. archived you should add some SPAM protection to the email address. Send an
  1294. answer to ffmpeg-devel (or wherever you got the patch from) saying that
  1295. you applied the patch.
  1296. @item
  1297. Do NOT commit to code actively maintained by others without permission.
  1298. Send a patch to ffmpeg-devel instead. If noone answers within a reasonable
  1299. timeframe (12h for build failures and security fixes, 3 days small changes,
  1300. 1 week for big patches) then commit your patch if you think it is OK.
  1301. Also note, the maintainer can simply ask for more time to review!
  1302. @item
  1303. Subscribe to the ffmpeg-cvslog mailing list. The diffs of all commits
  1304. are sent there and reviewed by all the other developers. Bugs and possible
  1305. improvements or general questions regarding commits are discussed there. We
  1306. expect you to react if problems with your code are uncovered.
  1307. @item
  1308. Update the documentation if you change behavior or add features. If you are
  1309. unsure how best to do this, send a patch to ffmpeg-devel, the documentation
  1310. maintainer(s) will review and commit your stuff.
  1311. @item
  1312. Try to keep important discussions and requests (also) on the public
  1313. developer mailing list, so that all developers can benefit from them.
  1314. @item
  1315. Never write to unallocated memory, never write over the end of arrays,
  1316. always check values read from some untrusted source before using them
  1317. as array index or other risky things.
  1318. @item
  1319. Remember to check if you need to bump versions for the specific libav
  1320. parts (libavutil, libavcodec, libavformat) you are changing. You need
  1321. to change the version integer and the version string.
  1322. Incrementing the first component means no backward compatibility to
  1323. previous versions (e.g. removal of a function from the public API).
  1324. Incrementing the second component means backward compatible change
  1325. (e.g. addition of a function to the public API).
  1326. Incrementing the third component means a noteworthy binary compatible
  1327. change (e.g. encoder bug fix that matters for the decoder).
  1328. @item
  1329. If you add a new codec, remember to update the changelog, add it to
  1330. the supported codecs table in the documentation and bump the second
  1331. component of the @file{libavcodec} version number appropriately. If
  1332. it has a fourcc, add it to @file{libavformat/avienc.c}, even if it
  1333. is only a decoder.
  1334. @item
  1335. Do not change code to hide warnings without ensuring that the underlying
  1336. logic is correct and thus the warning was inappropriate.
  1337. @end enumerate
  1338. We think our rules are not too hard. If you have comments, contact us.
  1339. Note, these rules are mostly borrowed from the MPlayer project.
  1340. @section Submitting patches
  1341. First, (@pxref{Coding Rules}) above if you did not yet.
  1342. When you submit your patch, try to send a unified diff (diff '-up'
  1343. option). I cannot read other diffs :-)
  1344. Also please do not submit patches which contain several unrelated changes.
  1345. Split them into individual self-contained patches; this makes reviewing
  1346. them much easier.
  1347. Run the regression tests before submitting a patch so that you can
  1348. verify that there are no big problems.
  1349. Patches should be posted as base64 encoded attachments (or any other
  1350. encoding which ensures that the patch will not be trashed during
  1351. transmission) to the ffmpeg-devel mailing list, see
  1352. @url{http://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-devel}
  1353. It also helps quite a bit if you tell us what the patch does (for example
  1354. 'replaces lrint by lrintf'), and why (for example '*BSD isn't C99 compliant
  1355. and has no lrint()')
  1356. @section Patch review process
  1357. All patches posted to ffmpeg-devel will be reviewed, unless they contain a
  1358. clear note that the patch is not for SVN.
  1359. Reviews and comments will be posted as replies to the patch on the
  1360. mailing list. The patch submitter then has to take care of every comment,
  1361. that can be by resubmitting a changed patch or by disscussion. Resubmitted
  1362. patches will themselves be reviewed like any other patch. If at some point
  1363. a patch passes review with no comments then it is approved, that can for
  1364. simple and small patches happen immediately while large patches will generally
  1365. have to be changed and reviewed many times before they are approved.
  1366. After a patch is approved it will be committed to the repository.
  1367. We will review all submitted patches, but sometimes we are quite busy so
  1368. especially for large patches this can take several weeks.
  1369. When resubmitting patches, please do not make any significant changes
  1370. not related to the comments received during review. Such patches will
  1371. be rejected. Instead, submit significant changes or new features as
  1372. separate patches.
  1373. @section Regression tests
  1374. Before submitting a patch (or committing to the repository), you should at least
  1375. test that you did not break anything.
  1376. The regression tests build a synthetic video stream and a synthetic
  1377. audio stream. These are then encoded and decoded with all codecs or
  1378. formats. The CRC (or MD5) of each generated file is recorded in a
  1379. result file. A 'diff' is launched to compare the reference results and
  1380. the result file.
  1381. The regression tests then go on to test the FFserver code with a
  1382. limited set of streams. It is important that this step runs correctly
  1383. as well.
  1384. Run 'make test' to test all the codecs and formats.
  1385. Run 'make fulltest' to test all the codecs, formats and FFserver.
  1386. [Of course, some patches may change the results of the regression tests. In
  1387. this case, the reference results of the regression tests shall be modified
  1388. accordingly].
  1389. @bye