ffmpeg.texi 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129
  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 -vframes @var{number}
  121. Set the number of video frames to record.
  122. @item -r @var{fps}
  123. Set frame rate (Hz value, fraction or abbreviation), (default = 25).
  124. @item -s @var{size}
  125. Set frame size. The format is @samp{wxh} (ffserver default = 160x128).
  126. There is no default for input streams,
  127. for output streams it is set by default to the size of the source stream.
  128. The following abbreviations are recognized:
  129. @table @samp
  130. @item sqcif
  131. 128x96
  132. @item qcif
  133. 176x144
  134. @item cif
  135. 352x288
  136. @item 4cif
  137. 704x576
  138. @item 16cif
  139. 1408x1152
  140. @item qqvga
  141. 160x120
  142. @item qvga
  143. 320x240
  144. @item vga
  145. 640x480
  146. @item svga
  147. 800x600
  148. @item xga
  149. 1024x768
  150. @item uxga
  151. 1600x1200
  152. @item qxga
  153. 2048x1536
  154. @item sxga
  155. 1280x1024
  156. @item qsxga
  157. 2560x2048
  158. @item hsxga
  159. 5120x4096
  160. @item wvga
  161. 852x480
  162. @item wxga
  163. 1366x768
  164. @item wsxga
  165. 1600x1024
  166. @item wuxga
  167. 1920x1200
  168. @item woxga
  169. 2560x1600
  170. @item wqsxga
  171. 3200x2048
  172. @item wquxga
  173. 3840x2400
  174. @item whsxga
  175. 6400x4096
  176. @item whuxga
  177. 7680x4800
  178. @item cga
  179. 320x200
  180. @item ega
  181. 640x350
  182. @item hd480
  183. 852x480
  184. @item hd720
  185. 1280x720
  186. @item hd1080
  187. 1920x1080
  188. @end table
  189. @item -aspect @var{aspect}
  190. Set the video display aspect ratio specified by @var{aspect}.
  191. @var{aspect} can be a floating point number string, or a string of the
  192. form @var{num}:@var{den}, where @var{num} and @var{den} are the
  193. numerator and denominator of the aspect ratio. For example "4:3",
  194. "16:9", "1.3333", and "1.7777" are valid argument values.
  195. @item -croptop @var{size}
  196. @item -cropbottom @var{size}
  197. @item -cropleft @var{size}
  198. @item -cropright @var{size}
  199. All the crop options have been removed. Use -vf
  200. crop=width:height:x:y instead.
  201. @item -padtop @var{size}
  202. @item -padbottom @var{size}
  203. @item -padleft @var{size}
  204. @item -padright @var{size}
  205. @item -padcolor @var{hex_color}
  206. All the pad options have been removed. Use -vf
  207. pad=width:height:x:y:color instead.
  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 quantizer 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 (see section "Expression Evaluation")
  312. (default = @code{tex^qComp}).
  313. When computing the rate control equation expression, besides the
  314. standard functions defined in the section "Expression Evaluation", the
  315. following functions are available:
  316. @table @var
  317. @item bits2qp(bits)
  318. @item qp2bits(qp)
  319. @end table
  320. and the following constants are available:
  321. @table @var
  322. @item iTex
  323. @item pTex
  324. @item tex
  325. @item mv
  326. @item fCode
  327. @item iCount
  328. @item mcVar
  329. @item var
  330. @item isI
  331. @item isP
  332. @item isB
  333. @item avgQP
  334. @item qComp
  335. @item avgIITex
  336. @item avgPITex
  337. @item avgPPTex
  338. @item avgBPTex
  339. @item avgTex
  340. @end table
  341. @item -rc_override @var{override}
  342. Rate control override for specific intervals, formated as "int,int,int"
  343. list separated with slashes. Two first values are the beginning and
  344. end frame numbers, last one is quantizer to use if positive, or quality
  345. factor if negative.
  346. @item -me_method @var{method}
  347. Set motion estimation method to @var{method}.
  348. Available methods are (from lowest to best quality):
  349. @table @samp
  350. @item zero
  351. Try just the (0, 0) vector.
  352. @item phods
  353. @item log
  354. @item x1
  355. @item hex
  356. @item umh
  357. @item epzs
  358. (default method)
  359. @item full
  360. exhaustive search (slow and marginally better than epzs)
  361. @end table
  362. @item -dct_algo @var{algo}
  363. Set DCT algorithm to @var{algo}. Available values are:
  364. @table @samp
  365. @item 0
  366. FF_DCT_AUTO (default)
  367. @item 1
  368. FF_DCT_FASTINT
  369. @item 2
  370. FF_DCT_INT
  371. @item 3
  372. FF_DCT_MMX
  373. @item 4
  374. FF_DCT_MLIB
  375. @item 5
  376. FF_DCT_ALTIVEC
  377. @end table
  378. @item -idct_algo @var{algo}
  379. Set IDCT algorithm to @var{algo}. Available values are:
  380. @table @samp
  381. @item 0
  382. FF_IDCT_AUTO (default)
  383. @item 1
  384. FF_IDCT_INT
  385. @item 2
  386. FF_IDCT_SIMPLE
  387. @item 3
  388. FF_IDCT_SIMPLEMMX
  389. @item 4
  390. FF_IDCT_LIBMPEG2MMX
  391. @item 5
  392. FF_IDCT_PS2
  393. @item 6
  394. FF_IDCT_MLIB
  395. @item 7
  396. FF_IDCT_ARM
  397. @item 8
  398. FF_IDCT_ALTIVEC
  399. @item 9
  400. FF_IDCT_SH4
  401. @item 10
  402. FF_IDCT_SIMPLEARM
  403. @end table
  404. @item -er @var{n}
  405. Set error resilience to @var{n}.
  406. @table @samp
  407. @item 1
  408. FF_ER_CAREFUL (default)
  409. @item 2
  410. FF_ER_COMPLIANT
  411. @item 3
  412. FF_ER_AGGRESSIVE
  413. @item 4
  414. FF_ER_EXPLODE
  415. @end table
  416. @item -ec @var{bit_mask}
  417. Set error concealment to @var{bit_mask}. @var{bit_mask} is a bit mask of
  418. the following values:
  419. @table @samp
  420. @item 1
  421. FF_EC_GUESS_MVS (default = enabled)
  422. @item 2
  423. FF_EC_DEBLOCK (default = enabled)
  424. @end table
  425. @item -bf @var{frames}
  426. Use 'frames' B-frames (supported for MPEG-1, MPEG-2 and MPEG-4).
  427. @item -mbd @var{mode}
  428. macroblock decision
  429. @table @samp
  430. @item 0
  431. FF_MB_DECISION_SIMPLE: Use mb_cmp (cannot change it yet in ffmpeg).
  432. @item 1
  433. FF_MB_DECISION_BITS: Choose the one which needs the fewest bits.
  434. @item 2
  435. FF_MB_DECISION_RD: rate distortion
  436. @end table
  437. @item -4mv
  438. Use four motion vector by macroblock (MPEG-4 only).
  439. @item -part
  440. Use data partitioning (MPEG-4 only).
  441. @item -bug @var{param}
  442. Work around encoder bugs that are not auto-detected.
  443. @item -strict @var{strictness}
  444. How strictly to follow the standards.
  445. @item -aic
  446. Enable Advanced intra coding (h263+).
  447. @item -umv
  448. Enable Unlimited Motion Vector (h263+)
  449. @item -deinterlace
  450. Deinterlace pictures.
  451. @item -ilme
  452. Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
  453. Use this option if your input file is interlaced and you want
  454. to keep the interlaced format for minimum losses.
  455. The alternative is to deinterlace the input stream with
  456. @option{-deinterlace}, but deinterlacing introduces losses.
  457. @item -psnr
  458. Calculate PSNR of compressed frames.
  459. @item -vstats
  460. Dump video coding statistics to @file{vstats_HHMMSS.log}.
  461. @item -vstats_file @var{file}
  462. Dump video coding statistics to @var{file}.
  463. @item -top @var{n}
  464. top=1/bottom=0/auto=-1 field first
  465. @item -dc @var{precision}
  466. Intra_dc_precision.
  467. @item -vtag @var{fourcc/tag}
  468. Force video tag/fourcc.
  469. @item -qphist
  470. Show QP histogram.
  471. @item -vbsf @var{bitstream_filter}
  472. Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump", "mjpeg2jpeg".
  473. @example
  474. ffmpeg -i h264.mp4 -vcodec copy -vbsf h264_mp4toannexb -an out.h264
  475. @end example
  476. @item -force_key_frames @var{time}[,@var{time}...]
  477. Force key frames at the specified timestamps, more precisely at the first
  478. frames after each specified time.
  479. This option can be useful to ensure that a seek point is present at a
  480. chapter mark or any other designated place in the output file.
  481. The timestamps must be specified in ascending order.
  482. @end table
  483. @section Audio Options
  484. @table @option
  485. @item -aframes @var{number}
  486. Set the number of audio frames to record.
  487. @item -ar @var{freq}
  488. Set the audio sampling frequency. For output streams it is set by
  489. default to the frequency of the corresponding input stream. For input
  490. streams this option only makes sense for audio grabbing devices and raw
  491. demuxers and is mapped to the corresponding demuxer options.
  492. @item -aq @var{q}
  493. Set the audio quality (codec-specific, VBR).
  494. @item -ac @var{channels}
  495. Set the number of audio channels. For output streams it is set by
  496. default to the number of input audio channels. For input streams
  497. this option only makes sense for audio grabbing devices and raw demuxers
  498. and is mapped to the corresponding demuxer options.
  499. @item -an
  500. Disable audio recording.
  501. @item -acodec @var{codec}
  502. Force audio codec to @var{codec}. Use the @code{copy} special value to
  503. specify that the raw codec data must be copied as is.
  504. @item -newaudio
  505. Add a new audio track to the output file. If you want to specify parameters,
  506. do so before @code{-newaudio} (@code{-acodec}, @code{-ab}, etc..).
  507. Mapping will be done automatically, if the number of output streams is equal to
  508. the number of input streams, else it will pick the first one that matches. You
  509. can override the mapping using @code{-map} as usual.
  510. Example:
  511. @example
  512. ffmpeg -i file.mpg -vcodec copy -acodec ac3 -ab 384k test.mpg -acodec mp2 -ab 192k -newaudio
  513. @end example
  514. @item -alang @var{code}
  515. Set the ISO 639 language code (3 letters) of the current audio stream.
  516. @end table
  517. @section Advanced Audio options:
  518. @table @option
  519. @item -atag @var{fourcc/tag}
  520. Force audio tag/fourcc.
  521. @item -audio_service_type @var{type}
  522. Set the type of service that the audio stream contains.
  523. @table @option
  524. @item ma
  525. Main Audio Service (default)
  526. @item ef
  527. Effects
  528. @item vi
  529. Visually Impaired
  530. @item hi
  531. Hearing Impaired
  532. @item di
  533. Dialogue
  534. @item co
  535. Commentary
  536. @item em
  537. Emergency
  538. @item vo
  539. Voice Over
  540. @item ka
  541. Karaoke
  542. @end table
  543. @item -absf @var{bitstream_filter}
  544. Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
  545. @end table
  546. @section Subtitle options:
  547. @table @option
  548. @item -scodec @var{codec}
  549. Force subtitle codec ('copy' to copy stream).
  550. @item -newsubtitle
  551. Add a new subtitle stream to the current output stream.
  552. @item -slang @var{code}
  553. Set the ISO 639 language code (3 letters) of the current subtitle stream.
  554. @item -sn
  555. Disable subtitle recording.
  556. @item -sbsf @var{bitstream_filter}
  557. Bitstream filters available are "mov2textsub", "text2movsub".
  558. @example
  559. ffmpeg -i file.mov -an -vn -sbsf mov2textsub -scodec copy -f rawvideo sub.txt
  560. @end example
  561. @end table
  562. @section Audio/Video grab options
  563. @table @option
  564. @item -vc @var{channel}
  565. Set video grab channel (DV1394 only).
  566. @item -tvstd @var{standard}
  567. Set television standard (NTSC, PAL (SECAM)).
  568. @item -isync
  569. Synchronize read on input.
  570. @end table
  571. @section Advanced options
  572. @table @option
  573. @item -map @var{input_file_id}.@var{input_stream_id}[:@var{sync_file_id}.@var{sync_stream_id}]
  574. Designate an input stream as a source for the output file. Each input
  575. stream is identified by the input file index @var{input_file_id} and
  576. the input stream index @var{input_stream_id} within the input
  577. file. Both indexes start at 0. If specified,
  578. @var{sync_file_id}.@var{sync_stream_id} sets which input stream
  579. is used as a presentation sync reference.
  580. The @code{-map} options must be specified just after the output file.
  581. If any @code{-map} options are used, the number of @code{-map} options
  582. on the command line must match the number of streams in the output
  583. file. The first @code{-map} option on the command line specifies the
  584. source for output stream 0, the second @code{-map} option specifies
  585. the source for output stream 1, etc.
  586. For example, if you have two audio streams in the first input file,
  587. these streams are identified by "0.0" and "0.1". You can use
  588. @code{-map} to select which stream to place in an output file. For
  589. example:
  590. @example
  591. ffmpeg -i INPUT out.wav -map 0.1
  592. @end example
  593. will map the input stream in @file{INPUT} identified by "0.1" to
  594. the (single) output stream in @file{out.wav}.
  595. For example, to select the stream with index 2 from input file
  596. @file{a.mov} (specified by the identifier "0.2"), and stream with
  597. index 6 from input @file{b.mov} (specified by the identifier "1.6"),
  598. and copy them to the output file @file{out.mov}:
  599. @example
  600. ffmpeg -i a.mov -i b.mov -vcodec copy -acodec copy out.mov -map 0.2 -map 1.6
  601. @end example
  602. To add more streams to the output file, you can use the
  603. @code{-newaudio}, @code{-newvideo}, @code{-newsubtitle} options.
  604. @item -map_meta_data @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}]
  605. Deprecated, use @var{-map_metadata} instead.
  606. @item -map_metadata @var{outfile}[,@var{metadata}]:@var{infile}[,@var{metadata}]
  607. Set metadata information of @var{outfile} from @var{infile}. Note that those
  608. are file indices (zero-based), not filenames.
  609. Optional @var{metadata} parameters specify, which metadata to copy - (g)lobal
  610. (i.e. metadata that applies to the whole file), per-(s)tream, per-(c)hapter or
  611. per-(p)rogram. All metadata specifiers other than global must be followed by the
  612. stream/chapter/program number. If metadata specifier is omitted, it defaults to
  613. global.
  614. By default, global metadata is copied from the first input file to all output files,
  615. per-stream and per-chapter metadata is copied along with streams/chapters. These
  616. default mappings are disabled by creating any mapping of the relevant type. A negative
  617. file index can be used to create a dummy mapping that just disables automatic copying.
  618. For example to copy metadata from the first stream of the input file to global metadata
  619. of the output file:
  620. @example
  621. ffmpeg -i in.ogg -map_metadata 0:0,s0 out.mp3
  622. @end example
  623. @item -map_chapters @var{outfile}:@var{infile}
  624. Copy chapters from @var{infile} to @var{outfile}. If no chapter mapping is specified,
  625. then chapters are copied from the first input file with at least one chapter to all
  626. output files. Use a negative file index to disable any chapter copying.
  627. @item -debug @var{category}
  628. Print specific debug info.
  629. @var{category} is a number or a string containing one of the following values:
  630. @table @samp
  631. @item bitstream
  632. @item buffers
  633. picture buffer allocations
  634. @item bugs
  635. @item dct_coeff
  636. @item er
  637. error recognition
  638. @item mb_type
  639. macroblock (MB) type
  640. @item mmco
  641. memory management control operations (H.264)
  642. @item mv
  643. motion vector
  644. @item pict
  645. picture info
  646. @item pts
  647. @item qp
  648. per-block quantization parameter (QP)
  649. @item rc
  650. rate control
  651. @item skip
  652. @item startcode
  653. @item thread_ops
  654. threading operations
  655. @item vis_mb_type
  656. visualize block types
  657. @item vis_qp
  658. visualize quantization parameter (QP), lower QP are tinted greener
  659. @end table
  660. @item -benchmark
  661. Show benchmarking information at the end of an encode.
  662. Shows CPU time used and maximum memory consumption.
  663. Maximum memory consumption is not supported on all systems,
  664. it will usually display as 0 if not supported.
  665. @item -dump
  666. Dump each input packet.
  667. @item -hex
  668. When dumping packets, also dump the payload.
  669. @item -bitexact
  670. Only use bit exact algorithms (for codec testing).
  671. @item -ps @var{size}
  672. Set RTP payload size in bytes.
  673. @item -re
  674. Read input at native frame rate. Mainly used to simulate a grab device.
  675. @item -loop_input
  676. Loop over the input stream. Currently it works only for image
  677. streams. This option is used for automatic FFserver testing.
  678. This option is deprecated, use -loop 1.
  679. @item -loop_output @var{number_of_times}
  680. Repeatedly loop output for formats that support looping such as animated GIF
  681. (0 will loop the output infinitely).
  682. This option is deprecated, use -loop.
  683. @item -threads @var{count}
  684. Thread count.
  685. @item -vsync @var{parameter}
  686. Video sync method.
  687. @table @option
  688. @item 0
  689. Each frame is passed with its timestamp from the demuxer to the muxer.
  690. @item 1
  691. Frames will be duplicated and dropped to achieve exactly the requested
  692. constant framerate.
  693. @item 2
  694. Frames are passed through with their timestamp or dropped so as to
  695. prevent 2 frames from having the same timestamp.
  696. @item -1
  697. Chooses between 1 and 2 depending on muxer capabilities. This is the
  698. default method.
  699. @end table
  700. With -map you can select from which stream the timestamps should be
  701. taken. You can leave either video or audio unchanged and sync the
  702. remaining stream(s) to the unchanged one.
  703. @item -async @var{samples_per_second}
  704. Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
  705. the parameter is the maximum samples per second by which the audio is changed.
  706. -async 1 is a special case where only the start of the audio stream is corrected
  707. without any later correction.
  708. @item -copyts
  709. Copy timestamps from input to output.
  710. @item -copytb
  711. Copy input stream time base from input to output when stream copying.
  712. @item -shortest
  713. Finish encoding when the shortest input stream ends.
  714. @item -dts_delta_threshold
  715. Timestamp discontinuity delta threshold.
  716. @item -muxdelay @var{seconds}
  717. Set the maximum demux-decode delay.
  718. @item -muxpreload @var{seconds}
  719. Set the initial demux-decode delay.
  720. @item -streamid @var{output-stream-index}:@var{new-value}
  721. Assign a new stream-id value to an output stream. This option should be
  722. specified prior to the output filename to which it applies.
  723. For the situation where multiple output files exist, a streamid
  724. may be reassigned to a different value.
  725. For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
  726. an output mpegts file:
  727. @example
  728. ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
  729. @end example
  730. @end table
  731. @section Preset files
  732. A preset file contains a sequence of @var{option}=@var{value} pairs,
  733. one for each line, specifying a sequence of options which would be
  734. awkward to specify on the command line. Lines starting with the hash
  735. ('#') character are ignored and are used to provide comments. Check
  736. the @file{ffpresets} directory in the FFmpeg source tree for examples.
  737. Preset files are specified with the @code{vpre}, @code{apre},
  738. @code{spre}, and @code{fpre} options. The @code{fpre} option takes the
  739. filename of the preset instead of a preset name as input and can be
  740. used for any kind of codec. For the @code{vpre}, @code{apre}, and
  741. @code{spre} options, the options specified in a preset file are
  742. applied to the currently selected codec of the same type as the preset
  743. option.
  744. The argument passed to the @code{vpre}, @code{apre}, and @code{spre}
  745. preset options identifies the preset file to use according to the
  746. following rules:
  747. First ffmpeg searches for a file named @var{arg}.ffpreset in the
  748. directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
  749. the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
  750. or in a @file{ffpresets} folder along the executable on win32,
  751. in that order. For example, if the argument is @code{libx264-max}, it will
  752. search for the file @file{libx264-max.ffpreset}.
  753. If no such file is found, then ffmpeg will search for a file named
  754. @var{codec_name}-@var{arg}.ffpreset in the above-mentioned
  755. directories, where @var{codec_name} is the name of the codec to which
  756. the preset file options will be applied. For example, if you select
  757. the video codec with @code{-vcodec libx264} and use @code{-vpre max},
  758. then it will search for the file @file{libx264-max.ffpreset}.
  759. @c man end
  760. @chapter Tips
  761. @c man begin TIPS
  762. @itemize
  763. @item
  764. For streaming at very low bitrate application, use a low frame rate
  765. and a small GOP size. This is especially true for RealVideo where
  766. the Linux player does not seem to be very fast, so it can miss
  767. frames. An example is:
  768. @example
  769. ffmpeg -g 3 -r 3 -t 10 -b 50k -s qcif -f rv10 /tmp/b.rm
  770. @end example
  771. @item
  772. The parameter 'q' which is displayed while encoding is the current
  773. quantizer. The value 1 indicates that a very good quality could
  774. be achieved. The value 31 indicates the worst quality. If q=31 appears
  775. too often, it means that the encoder cannot compress enough to meet
  776. your bitrate. You must either increase the bitrate, decrease the
  777. frame rate or decrease the frame size.
  778. @item
  779. If your computer is not fast enough, you can speed up the
  780. compression at the expense of the compression ratio. You can use
  781. '-me zero' to speed up motion estimation, and '-intra' to disable
  782. motion estimation completely (you have only I-frames, which means it
  783. is about as good as JPEG compression).
  784. @item
  785. To have very low audio bitrates, reduce the sampling frequency
  786. (down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
  787. @item
  788. To have a constant quality (but a variable bitrate), use the option
  789. '-qscale n' when 'n' is between 1 (excellent quality) and 31 (worst
  790. quality).
  791. @item
  792. When converting video files, you can use the '-sameq' option which
  793. uses the same quality factor in the encoder as in the decoder.
  794. It allows almost lossless encoding.
  795. @end itemize
  796. @c man end TIPS
  797. @chapter Examples
  798. @c man begin EXAMPLES
  799. @section Video and Audio grabbing
  800. If you specify the input format and device then ffmpeg can grab video
  801. and audio directly.
  802. @example
  803. ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  804. @end example
  805. Note that you must activate the right video source and channel before
  806. launching ffmpeg with any TV viewer such as
  807. @uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also
  808. have to set the audio recording levels correctly with a
  809. standard mixer.
  810. @section X11 grabbing
  811. Grab the X11 display with ffmpeg via
  812. @example
  813. ffmpeg -f x11grab -s cif -r 25 -i :0.0 /tmp/out.mpg
  814. @end example
  815. 0.0 is display.screen number of your X11 server, same as
  816. the DISPLAY environment variable.
  817. @example
  818. ffmpeg -f x11grab -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg
  819. @end example
  820. 10 is the x-offset and 20 the y-offset for the grabbing.
  821. @example
  822. ffmpeg -f x11grab -follow_mouse centered -s cif -r 25 -i :0.0 /tmp/out.mpg
  823. @end example
  824. The grabbing region follows the mouse pointer, which stays at the center of
  825. region.
  826. @example
  827. ffmpeg -f x11grab -follow_mouse 100 -s cif -r 25 -i :0.0 /tmp/out.mpg
  828. @end example
  829. Only follows when mouse pointer reaches within 100 pixels to the edge of
  830. region.
  831. @example
  832. ffmpeg -f x11grab -show_region 1 -s cif -r 25 -i :0.0+10,20 /tmp/out.mpg
  833. @end example
  834. The grabbing region will be indicated on screen.
  835. @example
  836. ffmpeg -f x11grab -follow_mouse centered -show_region 1 -s cif -r 25 -i :0.0 /tmp/out.mpg
  837. @end example
  838. The grabbing region indication will follow the mouse pointer.
  839. @section Video and Audio file format conversion
  840. Any supported file format and protocol can serve as input to ffmpeg:
  841. Examples:
  842. @itemize
  843. @item
  844. You can use YUV files as input:
  845. @example
  846. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  847. @end example
  848. It will use the files:
  849. @example
  850. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  851. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  852. @end example
  853. The Y files use twice the resolution of the U and V files. They are
  854. raw files, without header. They can be generated by all decent video
  855. decoders. You must specify the size of the image with the @option{-s} option
  856. if ffmpeg cannot guess it.
  857. @item
  858. You can input from a raw YUV420P file:
  859. @example
  860. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  861. @end example
  862. test.yuv is a file containing raw YUV planar data. Each frame is composed
  863. of the Y plane followed by the U and V planes at half vertical and
  864. horizontal resolution.
  865. @item
  866. You can output to a raw YUV420P file:
  867. @example
  868. ffmpeg -i mydivx.avi hugefile.yuv
  869. @end example
  870. @item
  871. You can set several input files and output files:
  872. @example
  873. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  874. @end example
  875. Converts the audio file a.wav and the raw YUV video file a.yuv
  876. to MPEG file a.mpg.
  877. @item
  878. You can also do audio and video conversions at the same time:
  879. @example
  880. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  881. @end example
  882. Converts a.wav to MPEG audio at 22050 Hz sample rate.
  883. @item
  884. You can encode to several formats at the same time and define a
  885. mapping from input stream to output streams:
  886. @example
  887. ffmpeg -i /tmp/a.wav -ab 64k /tmp/a.mp2 -ab 128k /tmp/b.mp2 -map 0:0 -map 0:0
  888. @end example
  889. Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
  890. file:index' specifies which input stream is used for each output
  891. stream, in the order of the definition of output streams.
  892. @item
  893. You can transcode decrypted VOBs:
  894. @example
  895. ffmpeg -i snatch_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -bf 2 -acodec libmp3lame -ab 128k snatch.avi
  896. @end example
  897. This is a typical DVD ripping example; the input is a VOB file, the
  898. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  899. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  900. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  901. input video. Furthermore, the audio stream is MP3-encoded so you need
  902. to enable LAME support by passing @code{--enable-libmp3lame} to configure.
  903. The mapping is particularly useful for DVD transcoding
  904. to get the desired audio language.
  905. NOTE: To see the supported input formats, use @code{ffmpeg -formats}.
  906. @item
  907. You can extract images from a video, or create a video from many images:
  908. For extracting images from a video:
  909. @example
  910. ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  911. @end example
  912. This will extract one video frame per second from the video and will
  913. output them in files named @file{foo-001.jpeg}, @file{foo-002.jpeg},
  914. etc. Images will be rescaled to fit the new WxH values.
  915. If you want to extract just a limited number of frames, you can use the
  916. above command in combination with the -vframes or -t option, or in
  917. combination with -ss to start extracting from a certain point in time.
  918. For creating a video from many images:
  919. @example
  920. ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
  921. @end example
  922. The syntax @code{foo-%03d.jpeg} specifies to use a decimal number
  923. composed of three digits padded with zeroes to express the sequence
  924. number. It is the same syntax supported by the C printf function, but
  925. only formats accepting a normal integer are suitable.
  926. @item
  927. You can put many streams of the same type in the output:
  928. @example
  929. ffmpeg -i test1.avi -i test2.avi -vcodec copy -acodec copy -vcodec copy -acodec copy test12.avi -newvideo -newaudio
  930. @end example
  931. In addition to the first video and audio streams, the resulting
  932. output file @file{test12.avi} will contain the second video
  933. and the second audio stream found in the input streams list.
  934. The @code{-newvideo}, @code{-newaudio} and @code{-newsubtitle}
  935. options have to be specified immediately after the name of the output
  936. file to which you want to add them.
  937. @end itemize
  938. @c man end EXAMPLES
  939. @include eval.texi
  940. @include decoders.texi
  941. @include encoders.texi
  942. @include demuxers.texi
  943. @include muxers.texi
  944. @include indevs.texi
  945. @include outdevs.texi
  946. @include protocols.texi
  947. @include bitstream_filters.texi
  948. @include filters.texi
  949. @include metadata.texi
  950. @ignore
  951. @setfilename ffmpeg
  952. @settitle ffmpeg video converter
  953. @c man begin SEEALSO
  954. ffplay(1), ffprobe(1), ffserver(1) and the FFmpeg HTML documentation
  955. @c man end
  956. @c man begin AUTHORS
  957. The FFmpeg developers
  958. @c man end
  959. @end ignore
  960. @bye