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.

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