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.

1073 lines
31KB

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