ffmpeg.texi 35 KB

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