ffmpeg-doc.texi 27 KB

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