ffmpeg.texi 32 KB

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