You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

982 lines
27KB

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