You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1000 lines
27KB

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