ffmpeg.texi 29 KB

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