ffmpeg.texi 31 KB

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