ffmpeg-doc.texi 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  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 Synopsis
  9. The generic syntax is:
  10. @example
  11. @c man begin SYNOPSIS
  12. ffmpeg [[infile options][@option{-i} @var{infile}]]... @{[outfile options] @var{outfile}@}...
  13. @c man end
  14. @end example
  15. @chapter Description
  16. @c man begin DESCRIPTION
  17. FFmpeg is a very fast video and audio converter. It can also grab from
  18. a live audio/video source.
  19. The command line interface is designed to be intuitive, in the sense
  20. that FFmpeg tries to figure out all parameters that can possibly be
  21. derived automatically. You usually only have to specify the target
  22. bitrate you want.
  23. FFmpeg can also convert from any sample rate to any other, and resize
  24. video on the fly with a high quality polyphase filter.
  25. As a general rule, options are applied to the next specified
  26. file. Therefore, order is important, and you can have the same
  27. option on the command line multiple times. Each occurrence is
  28. then applied to the next input or output file.
  29. * To set the video bitrate of the output file to 64kbit/s:
  30. @example
  31. ffmpeg -i input.avi -b 64k output.avi
  32. @end example
  33. * To force the frame rate of the output file to 24 fps:
  34. @example
  35. ffmpeg -i input.avi -r 24 output.avi
  36. @end example
  37. * To force the frame rate of the input file (valid for raw formats only)
  38. to 1 fps and the frame rate of the output file to 24 fps:
  39. @example
  40. ffmpeg -r 1 -i input.m2v -r 24 output.avi
  41. @end example
  42. The format option may be needed for raw input files.
  43. By default, FFmpeg tries to convert as losslessly as possible: It
  44. uses the same audio and video parameters for the outputs as the one
  45. specified for the inputs.
  46. @c man end DESCRIPTION
  47. @chapter Options
  48. @c man begin OPTIONS
  49. @include fftools-common-opts.texi
  50. @section Main options
  51. @table @option
  52. @item -f @var{fmt}
  53. Force format.
  54. @item -i @var{filename}
  55. input file name
  56. @item -y
  57. Overwrite output files.
  58. @item -t @var{duration}
  59. Restrict the transcoded/captured video sequence
  60. to the duration specified in seconds.
  61. @code{hh:mm:ss[.xxx]} syntax is also supported.
  62. @item -fs @var{limit_size}
  63. Set the file size limit.
  64. @item -ss @var{position}
  65. Seek to given time position in seconds.
  66. @code{hh:mm:ss[.xxx]} syntax is also supported.
  67. @item -itsoffset @var{offset}
  68. Set the input time offset in seconds.
  69. @code{[-]hh:mm:ss[.xxx]} syntax is also supported.
  70. This option affects all the input files that follow it.
  71. The offset is added to the timestamps of the input files.
  72. Specifying a positive offset means that the corresponding
  73. streams are delayed by 'offset' seconds.
  74. @item -timestamp @var{time}
  75. Set the timestamp.
  76. @item -metadata @var{key}=@var{value}
  77. Set a metadata key/value pair.
  78. For example, for setting the title in the output file:
  79. @example
  80. ffmpeg -i in.avi -metadata title="my title" out.flv
  81. @end example
  82. @item -v @var{number}
  83. Set the logging verbosity level.
  84. @item -target @var{type}
  85. Specify target file type ("vcd", "svcd", "dvd", "dv", "dv50", "pal-vcd",
  86. "ntsc-svcd", ... ). All the format options (bitrate, codecs,
  87. buffer sizes) are then set automatically. You can just type:
  88. @example
  89. ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  90. @end example
  91. Nevertheless you can specify additional options as long as you know
  92. they do not conflict with the standard, as in:
  93. @example
  94. ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  95. @end example
  96. @item -dframes @var{number}
  97. Set the number of data frames to record.
  98. @item -scodec @var{codec}
  99. Force subtitle codec ('copy' to copy stream).
  100. @item -newsubtitle
  101. Add a new subtitle stream to the current output stream.
  102. @item -slang @var{code}
  103. Set the ISO 639 language code (3 letters) of the current subtitle stream.
  104. @end table
  105. @section Video Options
  106. @table @option
  107. @item -b @var{bitrate}
  108. Set the video bitrate in bit/s (default = 200 kb/s).
  109. @item -vframes @var{number}
  110. Set the number of video frames to record.
  111. @item -r @var{fps}
  112. Set frame rate (Hz value, fraction or abbreviation), (default = 25).
  113. @item -s @var{size}
  114. Set frame size. The format is @samp{wxh} (ffserver default = 160x128, ffmpeg default = same as source).
  115. The following abbreviations are recognized:
  116. @table @samp
  117. @item sqcif
  118. 128x96
  119. @item qcif
  120. 176x144
  121. @item cif
  122. 352x288
  123. @item 4cif
  124. 704x576
  125. @item 16cif
  126. 1408x1152
  127. @item qqvga
  128. 160x120
  129. @item qvga
  130. 320x240
  131. @item vga
  132. 640x480
  133. @item svga
  134. 800x600
  135. @item xga
  136. 1024x768
  137. @item uxga
  138. 1600x1200
  139. @item qxga
  140. 2048x1536
  141. @item sxga
  142. 1280x1024
  143. @item qsxga
  144. 2560x2048
  145. @item hsxga
  146. 5120x4096
  147. @item wvga
  148. 852x480
  149. @item wxga
  150. 1366x768
  151. @item wsxga
  152. 1600x1024
  153. @item wuxga
  154. 1920x1200
  155. @item woxga
  156. 2560x1600
  157. @item wqsxga
  158. 3200x2048
  159. @item wquxga
  160. 3840x2400
  161. @item whsxga
  162. 6400x4096
  163. @item whuxga
  164. 7680x4800
  165. @item cga
  166. 320x200
  167. @item ega
  168. 640x350
  169. @item hd480
  170. 852x480
  171. @item hd720
  172. 1280x720
  173. @item hd1080
  174. 1920x1080
  175. @end table
  176. @item -aspect @var{aspect}
  177. Set aspect ratio (4:3, 16:9 or 1.3333, 1.7777).
  178. @item -croptop @var{size}
  179. Set top crop band size (in pixels).
  180. @item -cropbottom @var{size}
  181. Set bottom crop band size (in pixels).
  182. @item -cropleft @var{size}
  183. Set left crop band size (in pixels).
  184. @item -cropright @var{size}
  185. Set right crop band size (in pixels).
  186. @item -padtop @var{size}
  187. Set top pad band size (in pixels).
  188. @item -padbottom @var{size}
  189. Set bottom pad band size (in pixels).
  190. @item -padleft @var{size}
  191. Set left pad band size (in pixels).
  192. @item -padright @var{size}
  193. Set right pad band size (in pixels).
  194. @item -padcolor @var{hex_color}
  195. Set color of padded bands. The value for padcolor is expressed
  196. as a six digit hexadecimal number where the first two digits
  197. represent red, the middle two digits green and last two digits
  198. blue (default = 000000 (black)).
  199. @item -vn
  200. Disable video recording.
  201. @item -bt @var{tolerance}
  202. Set video bitrate tolerance (in bits, default 4000k).
  203. Has a minimum value of: (target_bitrate/target_framerate).
  204. In 1-pass mode, bitrate tolerance specifies how far ratecontrol is
  205. willing to deviate from the target average bitrate value. This is
  206. not related to min/max bitrate. Lowering tolerance too much has
  207. an adverse effect on quality.
  208. @item -maxrate @var{bitrate}
  209. Set max video bitrate (in bit/s).
  210. Requires -bufsize to be set.
  211. @item -minrate @var{bitrate}
  212. Set min video bitrate (in bit/s).
  213. Most useful in setting up a CBR encode:
  214. @example
  215. ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
  216. @end example
  217. It is of little use elsewise.
  218. @item -bufsize @var{size}
  219. Set video buffer verifier buffer size (in bits).
  220. @item -vcodec @var{codec}
  221. Force video codec to @var{codec}. Use the @code{copy} special value to
  222. tell that the raw codec data must be copied as is.
  223. @item -sameq
  224. Use same video quality as source (implies VBR).
  225. @item -pass @var{n}
  226. Select the pass number (1 or 2). It is used to do two-pass
  227. video encoding. The statistics of the video are recorded in the first
  228. pass into a log file (see also the option -passlogfile),
  229. and in the second pass that log file is used to generate the video
  230. at the exact requested bitrate.
  231. On pass 1, you may just deactivate audio and set output to null,
  232. examples for Windows and Unix:
  233. @example
  234. ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y NUL
  235. ffmpeg -i foo.mov -vcodec libxvid -pass 1 -an -f rawvideo -y /dev/null
  236. @end example
  237. @item -passlogfile @var{prefix}
  238. Set two-pass log file name prefix to @var{prefix}, the default file name
  239. prefix is ``ffmpeg2pass''. The complete file name will be
  240. @file{PREFIX-N.log}, where N is a number specific to the output
  241. stream.
  242. @item -newvideo
  243. Add a new video stream to the current output stream.
  244. @item -vlang @var{code}
  245. Set the ISO 639 language code (3 letters) of the current video stream.
  246. @end table
  247. @section Advanced Video Options
  248. @table @option
  249. @item -pix_fmt @var{format}
  250. Set pixel format. Use 'list' as parameter to show all the supported
  251. pixel formats.
  252. @item -sws_flags @var{flags}
  253. Set SwScaler flags.
  254. @item -g @var{gop_size}
  255. Set the group of pictures size.
  256. @item -intra
  257. Use only intra frames.
  258. @item -vdt @var{n}
  259. Discard threshold.
  260. @item -qscale @var{q}
  261. Use fixed video quantizer scale (VBR).
  262. @item -qmin @var{q}
  263. minimum video quantizer scale (VBR)
  264. @item -qmax @var{q}
  265. maximum video quantizer scale (VBR)
  266. @item -qdiff @var{q}
  267. maximum difference between the quantizer scales (VBR)
  268. @item -qblur @var{blur}
  269. video quantizer scale blur (VBR) (range 0.0 - 1.0)
  270. @item -qcomp @var{compression}
  271. video quantizer scale compression (VBR) (default 0.5).
  272. Constant of ratecontrol equation. Recommended range for default rc_eq: 0.0-1.0
  273. @item -lmin @var{lambda}
  274. minimum video lagrange factor (VBR)
  275. @item -lmax @var{lambda}
  276. max video lagrange factor (VBR)
  277. @item -mblmin @var{lambda}
  278. minimum macroblock quantizer scale (VBR)
  279. @item -mblmax @var{lambda}
  280. maximum macroblock quantizer scale (VBR)
  281. These four options (lmin, lmax, mblmin, mblmax) use 'lambda' units,
  282. but you may use the QP2LAMBDA constant to easily convert from 'q' units:
  283. @example
  284. ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  285. @end example
  286. @item -rc_init_cplx @var{complexity}
  287. initial complexity for single pass encoding
  288. @item -b_qfactor @var{factor}
  289. qp factor between P- and B-frames
  290. @item -i_qfactor @var{factor}
  291. qp factor between P- and I-frames
  292. @item -b_qoffset @var{offset}
  293. qp offset between P- and B-frames
  294. @item -i_qoffset @var{offset}
  295. qp offset between P- and I-frames
  296. @item -rc_eq @var{equation}
  297. Set rate control equation (@pxref{FFmpeg formula
  298. evaluator}) (default = @code{tex^qComp}).
  299. @item -rc_override @var{override}
  300. rate control override for specific intervals
  301. @item -me_method @var{method}
  302. Set motion estimation method to @var{method}.
  303. Available methods are (from lowest to best quality):
  304. @table @samp
  305. @item zero
  306. Try just the (0, 0) vector.
  307. @item phods
  308. @item log
  309. @item x1
  310. @item hex
  311. @item umh
  312. @item epzs
  313. (default method)
  314. @item full
  315. exhaustive search (slow and marginally better than epzs)
  316. @end table
  317. @item -dct_algo @var{algo}
  318. Set DCT algorithm to @var{algo}. Available values are:
  319. @table @samp
  320. @item 0
  321. FF_DCT_AUTO (default)
  322. @item 1
  323. FF_DCT_FASTINT
  324. @item 2
  325. FF_DCT_INT
  326. @item 3
  327. FF_DCT_MMX
  328. @item 4
  329. FF_DCT_MLIB
  330. @item 5
  331. FF_DCT_ALTIVEC
  332. @end table
  333. @item -idct_algo @var{algo}
  334. Set IDCT algorithm to @var{algo}. Available values are:
  335. @table @samp
  336. @item 0
  337. FF_IDCT_AUTO (default)
  338. @item 1
  339. FF_IDCT_INT
  340. @item 2
  341. FF_IDCT_SIMPLE
  342. @item 3
  343. FF_IDCT_SIMPLEMMX
  344. @item 4
  345. FF_IDCT_LIBMPEG2MMX
  346. @item 5
  347. FF_IDCT_PS2
  348. @item 6
  349. FF_IDCT_MLIB
  350. @item 7
  351. FF_IDCT_ARM
  352. @item 8
  353. FF_IDCT_ALTIVEC
  354. @item 9
  355. FF_IDCT_SH4
  356. @item 10
  357. FF_IDCT_SIMPLEARM
  358. @end table
  359. @item -er @var{n}
  360. Set error resilience to @var{n}.
  361. @table @samp
  362. @item 1
  363. FF_ER_CAREFUL (default)
  364. @item 2
  365. FF_ER_COMPLIANT
  366. @item 3
  367. FF_ER_AGGRESSIVE
  368. @item 4
  369. FF_ER_VERY_AGGRESSIVE
  370. @end table
  371. @item -ec @var{bit_mask}
  372. Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
  373. the following values:
  374. @table @samp
  375. @item 1
  376. FF_EC_GUESS_MVS (default = enabled)
  377. @item 2
  378. FF_EC_DEBLOCK (default = enabled)
  379. @end table
  380. @item -bf @var{frames}
  381. Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
  382. @item -mbd @var{mode}
  383. macroblock decision
  384. @table @samp
  385. @item 0
  386. FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in FFmpeg).
  387. @item 1
  388. FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
  389. @item 2
  390. FF_MB_DECISION_RD: rate distortion
  391. @end table
  392. @item -4mv
  393. Use four motion vector by macroblock (MPEG-4 only).
  394. @item -part
  395. Use data partitioning (MPEG-4 only).
  396. @item -bug @var{param}
  397. Work around encoder bugs that are not auto-detected.
  398. @item -strict @var{strictness}
  399. How strictly to follow the standards.
  400. @item -aic
  401. Enable Advanced intra coding (h263+).
  402. @item -umv
  403. Enable Unlimited Motion Vector (h263+)
  404. @item -deinterlace
  405. Deinterlace pictures.
  406. @item -ilme
  407. Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
  408. Use this option if your input file is interlaced and you want
  409. to keep the interlaced format for minimum losses.
  410. The alternative is to deinterlace the input stream with
  411. @option{-deinterlace}, but deinterlacing introduces losses.
  412. @item -psnr
  413. Calculate PSNR of compressed frames.
  414. @item -vstats
  415. Dump video coding statistics to @file{vstats_HHMMSS.log}.
  416. @item -vstats_file @var{file}
  417. Dump video coding statistics to @var{file}.
  418. @item -top @var{n}
  419. top=1/bottom=0/auto=-1 field first
  420. @item -dc @var{precision}
  421. Intra_dc_precision.
  422. @item -vtag @var{fourcc/tag}
  423. Force video tag/fourcc.
  424. @item -qphist
  425. Show QP histogram.
  426. @item -vbsf @var{bitstream_filter}
  427. Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump".
  428. @example
  429. ffmpeg -i h264.mp4 -vcodec copy -vbsf h264_mp4toannexb -an out.h264
  430. @end example
  431. @end table
  432. @section Audio Options
  433. @table @option
  434. @item -aframes @var{number}
  435. Set the number of audio frames to record.
  436. @item -ar @var{freq}
  437. Set the audio sampling frequency (default = 44100 Hz).
  438. @item -ab @var{bitrate}
  439. Set the audio bitrate in bit/s (default = 64k).
  440. @item -aq @var{q}
  441. Set the audio quality (codec-specific, VBR).
  442. @item -ac @var{channels}
  443. Set the number of audio channels (default = 1).
  444. @item -an
  445. Disable audio recording.
  446. @item -acodec @var{codec}
  447. Force audio codec to @var{codec}. Use the @code{copy} special value to
  448. specify that the raw codec data must be copied as is.
  449. @item -newaudio
  450. Add a new audio track to the output file. If you want to specify parameters,
  451. do so before @code{-newaudio} (@code{-acodec}, @code{-ab}, etc..).
  452. Mapping will be done automatically, if the number of output streams is equal to
  453. the number of input streams, else it will pick the first one that matches. You
  454. can override the mapping using @code{-map} as usual.
  455. Example:
  456. @example
  457. ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384k test.mpg -acodec mp2 -ab 192k -newaudio
  458. @end example
  459. @item -alang @var{code}
  460. Set the ISO 639 language code (3 letters) of the current audio stream.
  461. @end table
  462. @section Advanced Audio options:
  463. @table @option
  464. @item -atag @var{fourcc/tag}
  465. Force audio tag/fourcc.
  466. @item -absf @var{bitstream_filter}
  467. Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
  468. @end table
  469. @section Subtitle options:
  470. @table @option
  471. @item -scodec @var{codec}
  472. Force subtitle codec ('copy' to copy stream).
  473. @item -newsubtitle
  474. Add a new subtitle stream to the current output stream.
  475. @item -slang @var{code}
  476. Set the ISO 639 language code (3 letters) of the current subtitle stream.
  477. @item -sn
  478. Disable subtitle recording.
  479. @item -sbsf @var{bitstream_filter}
  480. Bitstream filters available are "mov2textsub", "text2movsub".
  481. @example
  482. ffmpeg -i file.mov -an -vn -sbsf mov2textsub -scodec copy -f rawvideo sub.txt
  483. @end example
  484. @end table
  485. @section Audio/Video grab options
  486. @table @option
  487. @item -vc @var{channel}
  488. Set video grab channel (DV1394 only).
  489. @item -tvstd @var{standard}
  490. Set television standard (NTSC, PAL (SECAM)).
  491. @item -isync
  492. Synchronize read on input.
  493. @end table
  494. @section Advanced options
  495. @table @option
  496. @item -map @var{input_stream_id}[:@var{sync_stream_id}]
  497. Set stream mapping from input streams to output streams.
  498. Just enumerate the input streams in the order you want them in the output.
  499. @var{sync_stream_id} if specified sets the input stream to sync
  500. against.
  501. @item -map_meta_data @var{outfile}:@var{infile}
  502. Set meta data information of @var{outfile} from @var{infile}.
  503. @item -debug
  504. Print specific debug info.
  505. @item -benchmark
  506. Show benchmarking information at the end of an encode.
  507. Shows CPU time used and maximum memory consumption.
  508. Maximum memory consumption is not supported on all systems,
  509. it will usually display as 0 if not supported.
  510. @item -dump
  511. Dump each input packet.
  512. @item -hex
  513. When dumping packets, also dump the payload.
  514. @item -bitexact
  515. Only use bit exact algorithms (for codec testing).
  516. @item -ps @var{size}
  517. Set RTP payload size in bytes.
  518. @item -re
  519. Read input at native frame rate. Mainly used to simulate a grab device.
  520. @item -loop_input
  521. Loop over the input stream. Currently it works only for image
  522. streams. This option is used for automatic FFserver testing.
  523. @item -loop_output @var{number_of_times}
  524. Repeatedly loop output for formats that support looping such as animated GIF
  525. (0 will loop the output infinitely).
  526. @item -threads @var{count}
  527. Thread count.
  528. @item -vsync @var{parameter}
  529. Video sync method.
  530. 0 Each frame is passed with its timestamp from the demuxer to the muxer
  531. 1 Frames will be duplicated and dropped to achieve exactly the requested
  532. constant framerate.
  533. 2 Frames are passed through with their timestamp or dropped so as to prevent
  534. 2 frames from having the same timestamp
  535. -1 Chooses between 1 and 2 depending on muxer capabilities. This is the default method.
  536. With -map you can select from
  537. which stream the timestamps should be taken. You can leave either video or
  538. audio unchanged and sync the remaining stream(s) to the unchanged one.
  539. @item -async @var{samples_per_second}
  540. Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
  541. the parameter is the maximum samples per second by which the audio is changed.
  542. -async 1 is a special case where only the start of the audio stream is corrected
  543. without any later correction.
  544. @item -copyts
  545. Copy timestamps from input to output.
  546. @item -shortest
  547. Finish encoding when the shortest input stream ends.
  548. @item -dts_delta_threshold
  549. Timestamp discontinuity delta threshold.
  550. @item -muxdelay @var{seconds}
  551. Set the maximum demux-decode delay.
  552. @item -muxpreload @var{seconds}
  553. Set the initial demux-decode delay.
  554. @end table
  555. @section Preset files
  556. A preset file contains a sequence of @var{option}=@var{value} pairs,
  557. one for each line, specifying a sequence of options which would be
  558. awkward to specify on the command line. Lines starting with the hash
  559. ('#') character are ignored and are used to provide comments. Check
  560. the @file{ffpresets} directory in the FFmpeg source tree for examples.
  561. Preset files are specified with the @code{vpre}, @code{apre},
  562. @code{spre}, and @code{fpre} options. The @code{fpre} option takes the
  563. filename of the preset instead of a preset name as input and can be
  564. used for any kind of codec. For the @code{vpre}, @code{apre}, and
  565. @code{spre} options, the options specified in a preset file are
  566. applied to the currently selected codec of the same type as the preset
  567. option.
  568. The argument passed to the @code{vpre}, @code{apre}, and @code{spre}
  569. preset options identifies the preset file to use according to the
  570. following rules:
  571. First ffmpeg searches for a file named @var{arg}.ffpreset in the
  572. directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
  573. the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
  574. in that order. For example, if the argument is @code{libx264-max}, it will
  575. search for the file @file{libx264-max.ffpreset}.
  576. If no such file is found, then ffmpeg will search for a file named
  577. @var{codec_name}-@var{arg}.ffpreset in the above-mentioned
  578. directories, where @var{codec_name} is the name of the codec to which
  579. the preset file options will be applied. For example, if you select
  580. the video codec with @code{-vcodec libx264} and use @code{-vpre max},
  581. then it will search for the file @file{libx264-max.ffpreset}.
  582. @anchor{FFmpeg formula evaluator}
  583. @section FFmpeg formula evaluator
  584. When evaluating a rate control string, FFmpeg uses an internal formula
  585. evaluator.
  586. The following binary operators are available: @code{+}, @code{-},
  587. @code{*}, @code{/}, @code{^}.
  588. The following unary operators are available: @code{+}, @code{-},
  589. @code{(...)}.
  590. The following statements are available: @code{ld}, @code{st},
  591. @code{while}.
  592. The following functions are available:
  593. @table @var
  594. @item sinh(x)
  595. @item cosh(x)
  596. @item tanh(x)
  597. @item sin(x)
  598. @item cos(x)
  599. @item tan(x)
  600. @item atan(x)
  601. @item asin(x)
  602. @item acos(x)
  603. @item exp(x)
  604. @item log(x)
  605. @item abs(x)
  606. @item squish(x)
  607. @item gauss(x)
  608. @item mod(x, y)
  609. @item max(x, y)
  610. @item min(x, y)
  611. @item eq(x, y)
  612. @item gte(x, y)
  613. @item gt(x, y)
  614. @item lte(x, y)
  615. @item lt(x, y)
  616. @item bits2qp(bits)
  617. @item qp2bits(qp)
  618. @end table
  619. The following constants are available:
  620. @table @var
  621. @item PI
  622. @item E
  623. @item iTex
  624. @item pTex
  625. @item tex
  626. @item mv
  627. @item fCode
  628. @item iCount
  629. @item mcVar
  630. @item var
  631. @item isI
  632. @item isP
  633. @item isB
  634. @item avgQP
  635. @item qComp
  636. @item avgIITex
  637. @item avgPITex
  638. @item avgPPTex
  639. @item avgBPTex
  640. @item avgTex
  641. @end table
  642. @c man end
  643. @section Protocols
  644. The file name can be @file{-} to read from standard input or to write
  645. to standard output.
  646. FFmpeg also handles many protocols specified with an URL syntax.
  647. Use 'ffmpeg -protocols' to see a list of the supported protocols.
  648. The protocol @code{http:} is currently used only to communicate with
  649. FFserver (see the FFserver documentation). When FFmpeg will be a
  650. video player it will also be used for streaming :-)
  651. @chapter Tips
  652. @c man begin TIPS
  653. @itemize
  654. @item
  655. For streaming at very low bitrate application, use a low frame rate
  656. and a small GOP size. This is especially true for RealVideo where
  657. the Linux player does not seem to be very fast, so it can miss
  658. frames. An example is:
  659. @example
  660. ffmpeg -g 3 -r 3 -t 10 -b 50k -s qcif -f rv10 /tmp/b.rm
  661. @end example
  662. @item
  663. The parameter 'q' which is displayed while encoding is the current
  664. quantizer. The value 1 indicates that a very good quality could
  665. be achieved. The value 31 indicates the worst quality. If q=31 appears
  666. too often, it means that the encoder cannot compress enough to meet
  667. your bitrate. You must either increase the bitrate, decrease the
  668. frame rate or decrease the frame size.
  669. @item
  670. If your computer is not fast enough, you can speed up the
  671. compression at the expense of the compression ratio. You can use
  672. '-me zero' to speed up motion estimation, and '-intra' to disable
  673. motion estimation completely (you have only I-frames, which means it
  674. is about as good as JPEG compression).
  675. @item
  676. To have very low audio bitrates, reduce the sampling frequency
  677. (down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
  678. @item
  679. To have a constant quality (but a variable bitrate), use the option
  680. '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
  681. quality).
  682. @item
  683. When converting video files, you can use the '-sameq' option which
  684. uses the same quality factor in the encoder as in the decoder.
  685. It allows almost lossless encoding.
  686. @end itemize
  687. @c man end TIPS
  688. @chapter Examples
  689. @c man begin EXAMPLES
  690. @section Video and Audio grabbing
  691. FFmpeg can grab video and audio from devices given that you specify the input
  692. format and device.
  693. @example
  694. ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  695. @end example
  696. Note that you must activate the right video source and channel before
  697. launching FFmpeg with any TV viewer such as xawtv
  698. (@url{http://linux.bytesex.org/xawtv/}) by Gerd Knorr. You also
  699. have to set the audio recording levels correctly with a
  700. standard mixer.
  701. @section X11 grabbing
  702. FFmpeg can grab the X11 display.
  703. @example
  704. ffmpeg -f x11grab -s cif -i :0.0 /tmp/out.mpg
  705. @end example
  706. 0.0 is display.screen number of your X11 server, same as
  707. the DISPLAY environment variable.
  708. @example
  709. ffmpeg -f x11grab -s cif -i :0.0+10,20 /tmp/out.mpg
  710. @end example
  711. 0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  712. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  713. @section Video and Audio file format conversion
  714. * FFmpeg can use any supported file format and protocol as input:
  715. Examples:
  716. * You can use YUV files as input:
  717. @example
  718. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  719. @end example
  720. It will use the files:
  721. @example
  722. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  723. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  724. @end example
  725. The Y files use twice the resolution of the U and V files. They are
  726. raw files, without header. They can be generated by all decent video
  727. decoders. You must specify the size of the image with the @option{-s} option
  728. if FFmpeg cannot guess it.
  729. * You can input from a raw YUV420P file:
  730. @example
  731. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  732. @end example
  733. test.yuv is a file containing raw YUV planar data. Each frame is composed
  734. of the Y plane followed by the U and V planes at half vertical and
  735. horizontal resolution.
  736. * You can output to a raw YUV420P file:
  737. @example
  738. ffmpeg -i mydivx.avi hugefile.yuv
  739. @end example
  740. * You can set several input files and output files:
  741. @example
  742. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  743. @end example
  744. Converts the audio file a.wav and the raw YUV video file a.yuv
  745. to MPEG file a.mpg.
  746. * You can also do audio and video conversions at the same time:
  747. @example
  748. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  749. @end example
  750. Converts a.wav to MPEG audio at 22050 Hz sample rate.
  751. * You can encode to several formats at the same time and define a
  752. mapping from input stream to output streams:
  753. @example
  754. ffmpeg -i /tmp/a.wav -ab 64k /tmp/a.mp2 -ab 128k /tmp/b.mp2 -map 0:0 -map 0:0
  755. @end example
  756. Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
  757. file:index' specifies which input stream is used for each output
  758. stream, in the order of the definition of output streams.
  759. * You can transcode decrypted VOBs:
  760. @example
  761. ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k snatch.avi
  762. @end example
  763. This is a typical DVD ripping example; the input is a VOB file, the
  764. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  765. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  766. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  767. input video. Furthermore, the audio stream is MP3-encoded so you need
  768. to enable LAME support by passing @code{--enable-libmp3lame} to configure.
  769. The mapping is particularly useful for DVD transcoding
  770. to get the desired audio language.
  771. NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
  772. * You can extract images from a video, or create a video from many images:
  773. For extracting images from a video:
  774. @example
  775. ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  776. @end example
  777. This will extract one video frame per second from the video and will
  778. output them in files named @file{foo-001.jpeg}, @file{foo-002.jpeg},
  779. etc. Images will be rescaled to fit the new WxH values.
  780. If you want to extract just a limited number of frames, you can use the
  781. above command in combination with the -vframes or -t option, or in
  782. combination with -ss to start extracting from a certain point in time.
  783. For creating a video from many images:
  784. @example
  785. ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
  786. @end example
  787. The syntax @code{foo-%03d.jpeg} specifies to use a decimal number
  788. composed of three digits padded with zeroes to express the sequence
  789. number. It is the same syntax supported by the C printf function, but
  790. only formats accepting a normal integer are suitable.
  791. * You can put many streams of the same type in the output:
  792. @example
  793. ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy -vcodec copy -acodec copy test12.avi -newvideo -newaudio
  794. @end example
  795. In addition to the first video and audio streams, the resulting
  796. output file @file{test12.avi} will contain the second video
  797. and the second audio stream found in the input streams list.
  798. The @code{-newvideo}, @code{-newaudio} and @code{-newsubtitle}
  799. options have to be specified immediately after the name of the output
  800. file to which you want to add them.
  801. @c man end EXAMPLES
  802. @ignore
  803. @setfilename ffmpeg
  804. @settitle FFmpeg video converter
  805. @c man begin SEEALSO
  806. ffplay(1), ffprobe(1), ffserver(1) and the FFmpeg HTML documentation
  807. @c man end
  808. @c man begin AUTHORS
  809. The FFmpeg developers
  810. @c man end
  811. @end ignore
  812. @bye