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.

ffmpeg.html 96KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
  2. <html>
  3. <!-- Created by GNU Texinfo 5.2, -->
  4. <head>
  5. <meta charset="utf-8">
  6. <title>
  7. ffmpeg Documentation
  8. </title>
  9. <meta name="viewport" content="width=device-width,initial-scale=1.0">
  10. <link rel="stylesheet" type="text/css" href="bootstrap.min.css">
  11. <link rel="stylesheet" type="text/css" href="style.min.css">
  12. </head>
  13. <body>
  14. <div style="width: 95%; margin: auto">
  15. <h1>
  16. ffmpeg Documentation
  17. </h1>
  18. <div align="center">
  19. </div>
  20. <a name="SEC_Top"></a>
  21. <a name="SEC_Contents"></a>
  22. <h2 class="contents-heading">Table of Contents</h2>
  23. <div class="contents">
  24. <ul class="no-bullet">
  25. <li><a name="toc-Synopsis" href="#Synopsis">1 Synopsis</a></li>
  26. <li><a name="toc-Description" href="#Description">2 Description</a></li>
  27. <li><a name="toc-Detailed-description" href="#Detailed-description">3 Detailed description</a>
  28. <ul class="no-bullet">
  29. <li><a name="toc-Filtering" href="#Filtering">3.1 Filtering</a>
  30. <ul class="no-bullet">
  31. <li><a name="toc-Simple-filtergraphs" href="#Simple-filtergraphs">3.1.1 Simple filtergraphs</a></li>
  32. <li><a name="toc-Complex-filtergraphs" href="#Complex-filtergraphs">3.1.2 Complex filtergraphs</a></li>
  33. </ul></li>
  34. <li><a name="toc-Stream-copy" href="#Stream-copy">3.2 Stream copy</a></li>
  35. </ul></li>
  36. <li><a name="toc-Stream-selection" href="#Stream-selection">4 Stream selection</a></li>
  37. <li><a name="toc-Options" href="#Options">5 Options</a>
  38. <ul class="no-bullet">
  39. <li><a name="toc-Stream-specifiers-1" href="#Stream-specifiers-1">5.1 Stream specifiers</a></li>
  40. <li><a name="toc-Generic-options" href="#Generic-options">5.2 Generic options</a></li>
  41. <li><a name="toc-AVOptions" href="#AVOptions">5.3 AVOptions</a></li>
  42. <li><a name="toc-Main-options" href="#Main-options">5.4 Main options</a></li>
  43. <li><a name="toc-Video-Options" href="#Video-Options">5.5 Video Options</a></li>
  44. <li><a name="toc-Advanced-Video-options" href="#Advanced-Video-options">5.6 Advanced Video options</a></li>
  45. <li><a name="toc-Audio-Options" href="#Audio-Options">5.7 Audio Options</a></li>
  46. <li><a name="toc-Advanced-Audio-options" href="#Advanced-Audio-options">5.8 Advanced Audio options</a></li>
  47. <li><a name="toc-Subtitle-options" href="#Subtitle-options">5.9 Subtitle options</a></li>
  48. <li><a name="toc-Advanced-Subtitle-options" href="#Advanced-Subtitle-options">5.10 Advanced Subtitle options</a></li>
  49. <li><a name="toc-Advanced-options" href="#Advanced-options">5.11 Advanced options</a></li>
  50. <li><a name="toc-Preset-files" href="#Preset-files">5.12 Preset files</a>
  51. <ul class="no-bullet">
  52. <li><a name="toc-ffpreset-files" href="#ffpreset-files">5.12.1 ffpreset files</a></li>
  53. <li><a name="toc-avpreset-files" href="#avpreset-files">5.12.2 avpreset files</a></li>
  54. </ul></li>
  55. </ul></li>
  56. <li><a name="toc-Tips" href="#Tips">6 Tips</a></li>
  57. <li><a name="toc-Examples" href="#Examples">7 Examples</a>
  58. <ul class="no-bullet">
  59. <li><a name="toc-Video-and-Audio-grabbing" href="#Video-and-Audio-grabbing">7.1 Video and Audio grabbing</a></li>
  60. <li><a name="toc-X11-grabbing" href="#X11-grabbing">7.2 X11 grabbing</a></li>
  61. <li><a name="toc-Video-and-Audio-file-format-conversion" href="#Video-and-Audio-file-format-conversion">7.3 Video and Audio file format conversion</a></li>
  62. </ul></li>
  63. <li><a name="toc-See-Also" href="#See-Also">8 See Also</a></li>
  64. <li><a name="toc-Authors" href="#Authors">9 Authors</a></li>
  65. </ul>
  66. </div>
  67. <a name="Synopsis"></a>
  68. <h2 class="chapter">1 Synopsis<span class="pull-right"><a class="anchor hidden-xs" href="#Synopsis" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Synopsis" aria-hidden="true">TOC</a></span></h2>
  69. <p>ffmpeg [<var>global_options</var>] {[<var>input_file_options</var>] -i <samp>input_file</samp>} ... {[<var>output_file_options</var>] <samp>output_file</samp>} ...
  70. </p>
  71. <a name="Description"></a>
  72. <h2 class="chapter">2 Description<span class="pull-right"><a class="anchor hidden-xs" href="#Description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Description" aria-hidden="true">TOC</a></span></h2>
  73. <p><code>ffmpeg</code> is a very fast video and audio converter that can also grab from
  74. a live audio/video source. It can also convert between arbitrary sample
  75. rates and resize video on the fly with a high quality polyphase filter.
  76. </p>
  77. <p><code>ffmpeg</code> reads from an arbitrary number of input &quot;files&quot; (which can be regular
  78. files, pipes, network streams, grabbing devices, etc.), specified by the
  79. <code>-i</code> option, and writes to an arbitrary number of output &quot;files&quot;, which are
  80. specified by a plain output filename. Anything found on the command line which
  81. cannot be interpreted as an option is considered to be an output filename.
  82. </p>
  83. <p>Each input or output file can, in principle, contain any number of streams of
  84. different types (video/audio/subtitle/attachment/data). The allowed number and/or
  85. types of streams may be limited by the container format. Selecting which
  86. streams from which inputs will go into which output is either done automatically
  87. or with the <code>-map</code> option (see the Stream selection chapter).
  88. </p>
  89. <p>To refer to input files in options, you must use their indices (0-based). E.g.
  90. the first input file is <code>0</code>, the second is <code>1</code>, etc. Similarly, streams
  91. within a file are referred to by their indices. E.g. <code>2:3</code> refers to the
  92. fourth stream in the third input file. Also see the Stream specifiers chapter.
  93. </p>
  94. <p>As a general rule, options are applied to the next specified
  95. file. Therefore, order is important, and you can have the same
  96. option on the command line multiple times. Each occurrence is
  97. then applied to the next input or output file.
  98. Exceptions from this rule are the global options (e.g. verbosity level),
  99. which should be specified first.
  100. </p>
  101. <p>Do not mix input and output files &ndash; first specify all input files, then all
  102. output files. Also do not mix options which belong to different files. All
  103. options apply ONLY to the next input or output file and are reset between files.
  104. </p>
  105. <ul>
  106. <li> To set the video bitrate of the output file to 64 kbit/s:
  107. <div class="example">
  108. <pre class="example">ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
  109. </pre></div>
  110. </li><li> To force the frame rate of the output file to 24 fps:
  111. <div class="example">
  112. <pre class="example">ffmpeg -i input.avi -r 24 output.avi
  113. </pre></div>
  114. </li><li> To force the frame rate of the input file (valid for raw formats only)
  115. to 1 fps and the frame rate of the output file to 24 fps:
  116. <div class="example">
  117. <pre class="example">ffmpeg -r 1 -i input.m2v -r 24 output.avi
  118. </pre></div>
  119. </li></ul>
  120. <p>The format option may be needed for raw input files.
  121. </p>
  122. <a name="Detailed-description"></a>
  123. <h2 class="chapter">3 Detailed description<span class="pull-right"><a class="anchor hidden-xs" href="#Detailed-description" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Detailed-description" aria-hidden="true">TOC</a></span></h2>
  124. <p>The transcoding process in <code>ffmpeg</code> for each output can be described by
  125. the following diagram:
  126. </p>
  127. <div class="example">
  128. <pre class="example"> _______ ______________
  129. | | | |
  130. | input | demuxer | encoded data | decoder
  131. | file | ---------&gt; | packets | -----+
  132. |_______| |______________| |
  133. v
  134. _________
  135. | |
  136. | decoded |
  137. | frames |
  138. |_________|
  139. ________ ______________ |
  140. | | | | |
  141. | output | &lt;-------- | encoded data | &lt;----+
  142. | file | muxer | packets | encoder
  143. |________| |______________|
  144. </pre></div>
  145. <p><code>ffmpeg</code> calls the libavformat library (containing demuxers) to read
  146. input files and get packets containing encoded data from them. When there are
  147. multiple input files, <code>ffmpeg</code> tries to keep them synchronized by
  148. tracking lowest timestamp on any active input stream.
  149. </p>
  150. <p>Encoded packets are then passed to the decoder (unless streamcopy is selected
  151. for the stream, see further for a description). The decoder produces
  152. uncompressed frames (raw video/PCM audio/...) which can be processed further by
  153. filtering (see next section). After filtering, the frames are passed to the
  154. encoder, which encodes them and outputs encoded packets. Finally those are
  155. passed to the muxer, which writes the encoded packets to the output file.
  156. </p>
  157. <a name="Filtering"></a>
  158. <h3 class="section">3.1 Filtering<span class="pull-right"><a class="anchor hidden-xs" href="#Filtering" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Filtering" aria-hidden="true">TOC</a></span></h3>
  159. <p>Before encoding, <code>ffmpeg</code> can process raw audio and video frames using
  160. filters from the libavfilter library. Several chained filters form a filter
  161. graph. <code>ffmpeg</code> distinguishes between two types of filtergraphs:
  162. simple and complex.
  163. </p>
  164. <a name="Simple-filtergraphs"></a>
  165. <h4 class="subsection">3.1.1 Simple filtergraphs<span class="pull-right"><a class="anchor hidden-xs" href="#Simple-filtergraphs" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Simple-filtergraphs" aria-hidden="true">TOC</a></span></h4>
  166. <p>Simple filtergraphs are those that have exactly one input and output, both of
  167. the same type. In the above diagram they can be represented by simply inserting
  168. an additional step between decoding and encoding:
  169. </p>
  170. <div class="example">
  171. <pre class="example"> _________ ______________
  172. | | | |
  173. | decoded | | encoded data |
  174. | frames |\ _ | packets |
  175. |_________| \ /||______________|
  176. \ __________ /
  177. simple _\|| | / encoder
  178. filtergraph | filtered |/
  179. | frames |
  180. |__________|
  181. </pre></div>
  182. <p>Simple filtergraphs are configured with the per-stream <samp>-filter</samp> option
  183. (with <samp>-vf</samp> and <samp>-af</samp> aliases for video and audio respectively).
  184. A simple filtergraph for video can look for example like this:
  185. </p>
  186. <div class="example">
  187. <pre class="example"> _______ _____________ _______ ________
  188. | | | | | | | |
  189. | input | ---&gt; | deinterlace | ---&gt; | scale | ---&gt; | output |
  190. |_______| |_____________| |_______| |________|
  191. </pre></div>
  192. <p>Note that some filters change frame properties but not frame contents. E.g. the
  193. <code>fps</code> filter in the example above changes number of frames, but does not
  194. touch the frame contents. Another example is the <code>setpts</code> filter, which
  195. only sets timestamps and otherwise passes the frames unchanged.
  196. </p>
  197. <a name="Complex-filtergraphs"></a>
  198. <h4 class="subsection">3.1.2 Complex filtergraphs<span class="pull-right"><a class="anchor hidden-xs" href="#Complex-filtergraphs" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Complex-filtergraphs" aria-hidden="true">TOC</a></span></h4>
  199. <p>Complex filtergraphs are those which cannot be described as simply a linear
  200. processing chain applied to one stream. This is the case, for example, when the graph has
  201. more than one input and/or output, or when output stream type is different from
  202. input. They can be represented with the following diagram:
  203. </p>
  204. <div class="example">
  205. <pre class="example"> _________
  206. | |
  207. | input 0 |\ __________
  208. |_________| \ | |
  209. \ _________ /| output 0 |
  210. \ | | / |__________|
  211. _________ \| complex | /
  212. | | | |/
  213. | input 1 |----&gt;| filter |\
  214. |_________| | | \ __________
  215. /| graph | \ | |
  216. / | | \| output 1 |
  217. _________ / |_________| |__________|
  218. | | /
  219. | input 2 |/
  220. |_________|
  221. </pre></div>
  222. <p>Complex filtergraphs are configured with the <samp>-filter_complex</samp> option.
  223. Note that this option is global, since a complex filtergraph, by its nature,
  224. cannot be unambiguously associated with a single stream or file.
  225. </p>
  226. <p>The <samp>-lavfi</samp> option is equivalent to <samp>-filter_complex</samp>.
  227. </p>
  228. <p>A trivial example of a complex filtergraph is the <code>overlay</code> filter, which
  229. has two video inputs and one video output, containing one video overlaid on top
  230. of the other. Its audio counterpart is the <code>amix</code> filter.
  231. </p>
  232. <a name="Stream-copy"></a>
  233. <h3 class="section">3.2 Stream copy<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-copy" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-copy" aria-hidden="true">TOC</a></span></h3>
  234. <p>Stream copy is a mode selected by supplying the <code>copy</code> parameter to the
  235. <samp>-codec</samp> option. It makes <code>ffmpeg</code> omit the decoding and encoding
  236. step for the specified stream, so it does only demuxing and muxing. It is useful
  237. for changing the container format or modifying container-level metadata. The
  238. diagram above will, in this case, simplify to this:
  239. </p>
  240. <div class="example">
  241. <pre class="example"> _______ ______________ ________
  242. | | | | | |
  243. | input | demuxer | encoded data | muxer | output |
  244. | file | ---------&gt; | packets | -------&gt; | file |
  245. |_______| |______________| |________|
  246. </pre></div>
  247. <p>Since there is no decoding or encoding, it is very fast and there is no quality
  248. loss. However, it might not work in some cases because of many factors. Applying
  249. filters is obviously also impossible, since filters work on uncompressed data.
  250. </p>
  251. <a name="Stream-selection"></a>
  252. <h2 class="chapter">4 Stream selection<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-selection" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-selection" aria-hidden="true">TOC</a></span></h2>
  253. <p>By default, <code>ffmpeg</code> includes only one stream of each type (video, audio, subtitle)
  254. present in the input files and adds them to each output file. It picks the
  255. &quot;best&quot; of each based upon the following criteria: for video, it is the stream
  256. with the highest resolution, for audio, it is the stream with the most channels, for
  257. subtitles, it is the first subtitle stream. In the case where several streams of
  258. the same type rate equally, the stream with the lowest index is chosen.
  259. </p>
  260. <p>You can disable some of those defaults by using the <code>-vn/-an/-sn</code> options. For
  261. full manual control, use the <code>-map</code> option, which disables the defaults just
  262. described.
  263. </p>
  264. <a name="Options"></a>
  265. <h2 class="chapter">5 Options<span class="pull-right"><a class="anchor hidden-xs" href="#Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Options" aria-hidden="true">TOC</a></span></h2>
  266. <p>All the numerical options, if not specified otherwise, accept a string
  267. representing a number as input, which may be followed by one of the SI
  268. unit prefixes, for example: &rsquo;K&rsquo;, &rsquo;M&rsquo;, or &rsquo;G&rsquo;.
  269. </p>
  270. <p>If &rsquo;i&rsquo; is appended to the SI unit prefix, the complete prefix will be
  271. interpreted as a unit prefix for binary multiples, which are based on
  272. powers of 1024 instead of powers of 1000. Appending &rsquo;B&rsquo; to the SI unit
  273. prefix multiplies the value by 8. This allows using, for example:
  274. &rsquo;KB&rsquo;, &rsquo;MiB&rsquo;, &rsquo;G&rsquo; and &rsquo;B&rsquo; as number suffixes.
  275. </p>
  276. <p>Options which do not take arguments are boolean options, and set the
  277. corresponding value to true. They can be set to false by prefixing
  278. the option name with &quot;no&quot;. For example using &quot;-nofoo&quot;
  279. will set the boolean option with name &quot;foo&quot; to false.
  280. </p>
  281. <a name="Stream-specifiers"></a><a name="Stream-specifiers-1"></a>
  282. <h3 class="section">5.1 Stream specifiers<span class="pull-right"><a class="anchor hidden-xs" href="#Stream-specifiers-1" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Stream-specifiers-1" aria-hidden="true">TOC</a></span></h3>
  283. <p>Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
  284. are used to precisely specify which stream(s) a given option belongs to.
  285. </p>
  286. <p>A stream specifier is a string generally appended to the option name and
  287. separated from it by a colon. E.g. <code>-codec:a:1 ac3</code> contains the
  288. <code>a:1</code> stream specifier, which matches the second audio stream. Therefore, it
  289. would select the ac3 codec for the second audio stream.
  290. </p>
  291. <p>A stream specifier can match several streams, so that the option is applied to all
  292. of them. E.g. the stream specifier in <code>-b:a 128k</code> matches all audio
  293. streams.
  294. </p>
  295. <p>An empty stream specifier matches all streams. For example, <code>-codec copy</code>
  296. or <code>-codec: copy</code> would copy all the streams without reencoding.
  297. </p>
  298. <p>Possible forms of stream specifiers are:
  299. </p><dl compact="compact">
  300. <dt><samp><var>stream_index</var></samp></dt>
  301. <dd><p>Matches the stream with this index. E.g. <code>-threads:1 4</code> would set the
  302. thread count for the second stream to 4.
  303. </p></dd>
  304. <dt><samp><var>stream_type</var>[:<var>stream_index</var>]</samp></dt>
  305. <dd><p><var>stream_type</var> is one of following: &rsquo;v&rsquo; for video, &rsquo;a&rsquo; for audio, &rsquo;s&rsquo; for subtitle,
  306. &rsquo;d&rsquo; for data, and &rsquo;t&rsquo; for attachments. If <var>stream_index</var> is given, then it matches
  307. stream number <var>stream_index</var> of this type. Otherwise, it matches all
  308. streams of this type.
  309. </p></dd>
  310. <dt><samp>p:<var>program_id</var>[:<var>stream_index</var>]</samp></dt>
  311. <dd><p>If <var>stream_index</var> is given, then it matches the stream with number <var>stream_index</var>
  312. in the program with the id <var>program_id</var>. Otherwise, it matches all streams in the
  313. program.
  314. </p></dd>
  315. <dt><samp>#<var>stream_id</var> or i:<var>stream_id</var></samp></dt>
  316. <dd><p>Match the stream by stream id (e.g. PID in MPEG-TS container).
  317. </p></dd>
  318. <dt><samp>m:<var>key</var>[:<var>value</var>]</samp></dt>
  319. <dd><p>Matches streams with the metadata tag <var>key</var> having the specified value. If
  320. <var>value</var> is not given, matches streams that contain the given tag with any
  321. value.
  322. </p>
  323. <p>Note that in <code>ffmpeg</code>, matching by metadata will only work properly for
  324. input files.
  325. </p></dd>
  326. </dl>
  327. <a name="Generic-options"></a>
  328. <h3 class="section">5.2 Generic options<span class="pull-right"><a class="anchor hidden-xs" href="#Generic-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Generic-options" aria-hidden="true">TOC</a></span></h3>
  329. <p>These options are shared amongst the ff* tools.
  330. </p>
  331. <dl compact="compact">
  332. <dt><samp>-L</samp></dt>
  333. <dd><p>Show license.
  334. </p>
  335. </dd>
  336. <dt><samp>-h, -?, -help, --help [<var>arg</var>]</samp></dt>
  337. <dd><p>Show help. An optional parameter may be specified to print help about a specific
  338. item. If no argument is specified, only basic (non advanced) tool
  339. options are shown.
  340. </p>
  341. <p>Possible values of <var>arg</var> are:
  342. </p><dl compact="compact">
  343. <dt><samp>long</samp></dt>
  344. <dd><p>Print advanced tool options in addition to the basic tool options.
  345. </p>
  346. </dd>
  347. <dt><samp>full</samp></dt>
  348. <dd><p>Print complete list of options, including shared and private options
  349. for encoders, decoders, demuxers, muxers, filters, etc.
  350. </p>
  351. </dd>
  352. <dt><samp>decoder=<var>decoder_name</var></samp></dt>
  353. <dd><p>Print detailed information about the decoder named <var>decoder_name</var>. Use the
  354. <samp>-decoders</samp> option to get a list of all decoders.
  355. </p>
  356. </dd>
  357. <dt><samp>encoder=<var>encoder_name</var></samp></dt>
  358. <dd><p>Print detailed information about the encoder named <var>encoder_name</var>. Use the
  359. <samp>-encoders</samp> option to get a list of all encoders.
  360. </p>
  361. </dd>
  362. <dt><samp>demuxer=<var>demuxer_name</var></samp></dt>
  363. <dd><p>Print detailed information about the demuxer named <var>demuxer_name</var>. Use the
  364. <samp>-formats</samp> option to get a list of all demuxers and muxers.
  365. </p>
  366. </dd>
  367. <dt><samp>muxer=<var>muxer_name</var></samp></dt>
  368. <dd><p>Print detailed information about the muxer named <var>muxer_name</var>. Use the
  369. <samp>-formats</samp> option to get a list of all muxers and demuxers.
  370. </p>
  371. </dd>
  372. <dt><samp>filter=<var>filter_name</var></samp></dt>
  373. <dd><p>Print detailed information about the filter name <var>filter_name</var>. Use the
  374. <samp>-filters</samp> option to get a list of all filters.
  375. </p></dd>
  376. </dl>
  377. </dd>
  378. <dt><samp>-version</samp></dt>
  379. <dd><p>Show version.
  380. </p>
  381. </dd>
  382. <dt><samp>-formats</samp></dt>
  383. <dd><p>Show available formats (including devices).
  384. </p>
  385. </dd>
  386. <dt><samp>-devices</samp></dt>
  387. <dd><p>Show available devices.
  388. </p>
  389. </dd>
  390. <dt><samp>-codecs</samp></dt>
  391. <dd><p>Show all codecs known to libavcodec.
  392. </p>
  393. <p>Note that the term &rsquo;codec&rsquo; is used throughout this documentation as a shortcut
  394. for what is more correctly called a media bitstream format.
  395. </p>
  396. </dd>
  397. <dt><samp>-decoders</samp></dt>
  398. <dd><p>Show available decoders.
  399. </p>
  400. </dd>
  401. <dt><samp>-encoders</samp></dt>
  402. <dd><p>Show all available encoders.
  403. </p>
  404. </dd>
  405. <dt><samp>-bsfs</samp></dt>
  406. <dd><p>Show available bitstream filters.
  407. </p>
  408. </dd>
  409. <dt><samp>-protocols</samp></dt>
  410. <dd><p>Show available protocols.
  411. </p>
  412. </dd>
  413. <dt><samp>-filters</samp></dt>
  414. <dd><p>Show available libavfilter filters.
  415. </p>
  416. </dd>
  417. <dt><samp>-pix_fmts</samp></dt>
  418. <dd><p>Show available pixel formats.
  419. </p>
  420. </dd>
  421. <dt><samp>-sample_fmts</samp></dt>
  422. <dd><p>Show available sample formats.
  423. </p>
  424. </dd>
  425. <dt><samp>-layouts</samp></dt>
  426. <dd><p>Show channel names and standard channel layouts.
  427. </p>
  428. </dd>
  429. <dt><samp>-colors</samp></dt>
  430. <dd><p>Show recognized color names.
  431. </p>
  432. </dd>
  433. <dt><samp>-sources <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
  434. <dd><p>Show autodetected sources of the intput device.
  435. Some devices may provide system-dependent source names that cannot be autodetected.
  436. The returned list cannot be assumed to be always complete.
  437. </p><div class="example">
  438. <pre class="example">ffmpeg -sources pulse,server=
  439. </pre></div>
  440. </dd>
  441. <dt><samp>-sinks <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp></dt>
  442. <dd><p>Show autodetected sinks of the output device.
  443. Some devices may provide system-dependent sink names that cannot be autodetected.
  444. The returned list cannot be assumed to be always complete.
  445. </p><div class="example">
  446. <pre class="example">ffmpeg -sinks pulse,server=
  447. </pre></div>
  448. </dd>
  449. <dt><samp>-loglevel [repeat+]<var>loglevel</var> | -v [repeat+]<var>loglevel</var></samp></dt>
  450. <dd><p>Set the logging level used by the library.
  451. Adding &quot;repeat+&quot; indicates that repeated log output should not be compressed
  452. to the first line and the &quot;Last message repeated n times&quot; line will be
  453. omitted. &quot;repeat&quot; can also be used alone.
  454. If &quot;repeat&quot; is used alone, and with no prior loglevel set, the default
  455. loglevel will be used. If multiple loglevel parameters are given, using
  456. &rsquo;repeat&rsquo; will not change the loglevel.
  457. <var>loglevel</var> is a string or a number containing one of the following values:
  458. </p><dl compact="compact">
  459. <dt>&lsquo;<samp>quiet, -8</samp>&rsquo;</dt>
  460. <dd><p>Show nothing at all; be silent.
  461. </p></dd>
  462. <dt>&lsquo;<samp>panic, 0</samp>&rsquo;</dt>
  463. <dd><p>Only show fatal errors which could lead the process to crash, such as
  464. and assert failure. This is not currently used for anything.
  465. </p></dd>
  466. <dt>&lsquo;<samp>fatal, 8</samp>&rsquo;</dt>
  467. <dd><p>Only show fatal errors. These are errors after which the process absolutely
  468. cannot continue after.
  469. </p></dd>
  470. <dt>&lsquo;<samp>error, 16</samp>&rsquo;</dt>
  471. <dd><p>Show all errors, including ones which can be recovered from.
  472. </p></dd>
  473. <dt>&lsquo;<samp>warning, 24</samp>&rsquo;</dt>
  474. <dd><p>Show all warnings and errors. Any message related to possibly
  475. incorrect or unexpected events will be shown.
  476. </p></dd>
  477. <dt>&lsquo;<samp>info, 32</samp>&rsquo;</dt>
  478. <dd><p>Show informative messages during processing. This is in addition to
  479. warnings and errors. This is the default value.
  480. </p></dd>
  481. <dt>&lsquo;<samp>verbose, 40</samp>&rsquo;</dt>
  482. <dd><p>Same as <code>info</code>, except more verbose.
  483. </p></dd>
  484. <dt>&lsquo;<samp>debug, 48</samp>&rsquo;</dt>
  485. <dd><p>Show everything, including debugging information.
  486. </p></dd>
  487. </dl>
  488. <p>By default the program logs to stderr, if coloring is supported by the
  489. terminal, colors are used to mark errors and warnings. Log coloring
  490. can be disabled setting the environment variable
  491. <code>AV_LOG_FORCE_NOCOLOR</code> or <code>NO_COLOR</code>, or can be forced setting
  492. the environment variable <code>AV_LOG_FORCE_COLOR</code>.
  493. The use of the environment variable <code>NO_COLOR</code> is deprecated and
  494. will be dropped in a following FFmpeg version.
  495. </p>
  496. </dd>
  497. <dt><samp>-report</samp></dt>
  498. <dd><p>Dump full command line and console output to a file named
  499. <code><var>program</var>-<var>YYYYMMDD</var>-<var>HHMMSS</var>.log</code> in the current
  500. directory.
  501. This file can be useful for bug reports.
  502. It also implies <code>-loglevel verbose</code>.
  503. </p>
  504. <p>Setting the environment variable <code>FFREPORT</code> to any value has the
  505. same effect. If the value is a &rsquo;:&rsquo;-separated key=value sequence, these
  506. options will affect the report; option values must be escaped if they
  507. contain special characters or the options delimiter &rsquo;:&rsquo; (see the
  508. &ldquo;Quoting and escaping&rdquo; section in the ffmpeg-utils manual).
  509. </p>
  510. <p>The following options are recognized:
  511. </p><dl compact="compact">
  512. <dt><samp>file</samp></dt>
  513. <dd><p>set the file name to use for the report; <code>%p</code> is expanded to the name
  514. of the program, <code>%t</code> is expanded to a timestamp, <code>%%</code> is expanded
  515. to a plain <code>%</code>
  516. </p></dd>
  517. <dt><samp>level</samp></dt>
  518. <dd><p>set the log verbosity level using a numerical value (see <code>-loglevel</code>).
  519. </p></dd>
  520. </dl>
  521. <p>For example, to output a report to a file named <samp>ffreport.log</samp>
  522. using a log level of <code>32</code> (alias for log level <code>info</code>):
  523. </p>
  524. <div class="example">
  525. <pre class="example">FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
  526. </pre></div>
  527. <p>Errors in parsing the environment variable are not fatal, and will not
  528. appear in the report.
  529. </p>
  530. </dd>
  531. <dt><samp>-hide_banner</samp></dt>
  532. <dd><p>Suppress printing banner.
  533. </p>
  534. <p>All FFmpeg tools will normally show a copyright notice, build options
  535. and library versions. This option can be used to suppress printing
  536. this information.
  537. </p>
  538. </dd>
  539. <dt><samp>-cpuflags flags (<em>global</em>)</samp></dt>
  540. <dd><p>Allows setting and clearing cpu flags. This option is intended
  541. for testing. Do not use it unless you know what you&rsquo;re doing.
  542. </p><div class="example">
  543. <pre class="example">ffmpeg -cpuflags -sse+mmx ...
  544. ffmpeg -cpuflags mmx ...
  545. ffmpeg -cpuflags 0 ...
  546. </pre></div>
  547. <p>Possible flags for this option are:
  548. </p><dl compact="compact">
  549. <dt>&lsquo;<samp>x86</samp>&rsquo;</dt>
  550. <dd><dl compact="compact">
  551. <dt>&lsquo;<samp>mmx</samp>&rsquo;</dt>
  552. <dt>&lsquo;<samp>mmxext</samp>&rsquo;</dt>
  553. <dt>&lsquo;<samp>sse</samp>&rsquo;</dt>
  554. <dt>&lsquo;<samp>sse2</samp>&rsquo;</dt>
  555. <dt>&lsquo;<samp>sse2slow</samp>&rsquo;</dt>
  556. <dt>&lsquo;<samp>sse3</samp>&rsquo;</dt>
  557. <dt>&lsquo;<samp>sse3slow</samp>&rsquo;</dt>
  558. <dt>&lsquo;<samp>ssse3</samp>&rsquo;</dt>
  559. <dt>&lsquo;<samp>atom</samp>&rsquo;</dt>
  560. <dt>&lsquo;<samp>sse4.1</samp>&rsquo;</dt>
  561. <dt>&lsquo;<samp>sse4.2</samp>&rsquo;</dt>
  562. <dt>&lsquo;<samp>avx</samp>&rsquo;</dt>
  563. <dt>&lsquo;<samp>avx2</samp>&rsquo;</dt>
  564. <dt>&lsquo;<samp>xop</samp>&rsquo;</dt>
  565. <dt>&lsquo;<samp>fma3</samp>&rsquo;</dt>
  566. <dt>&lsquo;<samp>fma4</samp>&rsquo;</dt>
  567. <dt>&lsquo;<samp>3dnow</samp>&rsquo;</dt>
  568. <dt>&lsquo;<samp>3dnowext</samp>&rsquo;</dt>
  569. <dt>&lsquo;<samp>bmi1</samp>&rsquo;</dt>
  570. <dt>&lsquo;<samp>bmi2</samp>&rsquo;</dt>
  571. <dt>&lsquo;<samp>cmov</samp>&rsquo;</dt>
  572. </dl>
  573. </dd>
  574. <dt>&lsquo;<samp>ARM</samp>&rsquo;</dt>
  575. <dd><dl compact="compact">
  576. <dt>&lsquo;<samp>armv5te</samp>&rsquo;</dt>
  577. <dt>&lsquo;<samp>armv6</samp>&rsquo;</dt>
  578. <dt>&lsquo;<samp>armv6t2</samp>&rsquo;</dt>
  579. <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
  580. <dt>&lsquo;<samp>vfpv3</samp>&rsquo;</dt>
  581. <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
  582. <dt>&lsquo;<samp>setend</samp>&rsquo;</dt>
  583. </dl>
  584. </dd>
  585. <dt>&lsquo;<samp>AArch64</samp>&rsquo;</dt>
  586. <dd><dl compact="compact">
  587. <dt>&lsquo;<samp>armv8</samp>&rsquo;</dt>
  588. <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
  589. <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
  590. </dl>
  591. </dd>
  592. <dt>&lsquo;<samp>PowerPC</samp>&rsquo;</dt>
  593. <dd><dl compact="compact">
  594. <dt>&lsquo;<samp>altivec</samp>&rsquo;</dt>
  595. </dl>
  596. </dd>
  597. <dt>&lsquo;<samp>Specific Processors</samp>&rsquo;</dt>
  598. <dd><dl compact="compact">
  599. <dt>&lsquo;<samp>pentium2</samp>&rsquo;</dt>
  600. <dt>&lsquo;<samp>pentium3</samp>&rsquo;</dt>
  601. <dt>&lsquo;<samp>pentium4</samp>&rsquo;</dt>
  602. <dt>&lsquo;<samp>k6</samp>&rsquo;</dt>
  603. <dt>&lsquo;<samp>k62</samp>&rsquo;</dt>
  604. <dt>&lsquo;<samp>athlon</samp>&rsquo;</dt>
  605. <dt>&lsquo;<samp>athlonxp</samp>&rsquo;</dt>
  606. <dt>&lsquo;<samp>k8</samp>&rsquo;</dt>
  607. </dl>
  608. </dd>
  609. </dl>
  610. </dd>
  611. <dt><samp>-opencl_bench</samp></dt>
  612. <dd><p>This option is used to benchmark all available OpenCL devices and print the
  613. results. This option is only available when FFmpeg has been compiled with
  614. <code>--enable-opencl</code>.
  615. </p>
  616. <p>When FFmpeg is configured with <code>--enable-opencl</code>, the options for the
  617. global OpenCL context are set via <samp>-opencl_options</samp>. See the
  618. &quot;OpenCL Options&quot; section in the ffmpeg-utils manual for the complete list of
  619. supported options. Amongst others, these options include the ability to select
  620. a specific platform and device to run the OpenCL code on. By default, FFmpeg
  621. will run on the first device of the first platform. While the options for the
  622. global OpenCL context provide flexibility to the user in selecting the OpenCL
  623. device of their choice, most users would probably want to select the fastest
  624. OpenCL device for their system.
  625. </p>
  626. <p>This option assists the selection of the most efficient configuration by
  627. identifying the appropriate device for the user&rsquo;s system. The built-in
  628. benchmark is run on all the OpenCL devices and the performance is measured for
  629. each device. The devices in the results list are sorted based on their
  630. performance with the fastest device listed first. The user can subsequently
  631. invoke <code>ffmpeg</code> using the device deemed most appropriate via
  632. <samp>-opencl_options</samp> to obtain the best performance for the OpenCL
  633. accelerated code.
  634. </p>
  635. <p>Typical usage to use the fastest OpenCL device involve the following steps.
  636. </p>
  637. <p>Run the command:
  638. </p><div class="example">
  639. <pre class="example">ffmpeg -opencl_bench
  640. </pre></div>
  641. <p>Note down the platform ID (<var>pidx</var>) and device ID (<var>didx</var>) of the first
  642. i.e. fastest device in the list.
  643. Select the platform and device using the command:
  644. </p><div class="example">
  645. <pre class="example">ffmpeg -opencl_options platform_idx=<var>pidx</var>:device_idx=<var>didx</var> ...
  646. </pre></div>
  647. </dd>
  648. <dt><samp>-opencl_options options (<em>global</em>)</samp></dt>
  649. <dd><p>Set OpenCL environment options. This option is only available when
  650. FFmpeg has been compiled with <code>--enable-opencl</code>.
  651. </p>
  652. <p><var>options</var> must be a list of <var>key</var>=<var>value</var> option pairs
  653. separated by &rsquo;:&rsquo;. See the &ldquo;OpenCL Options&rdquo; section in the
  654. ffmpeg-utils manual for the list of supported options.
  655. </p></dd>
  656. </dl>
  657. <a name="AVOptions"></a>
  658. <h3 class="section">5.3 AVOptions<span class="pull-right"><a class="anchor hidden-xs" href="#AVOptions" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-AVOptions" aria-hidden="true">TOC</a></span></h3>
  659. <p>These options are provided directly by the libavformat, libavdevice and
  660. libavcodec libraries. To see the list of available AVOptions, use the
  661. <samp>-help</samp> option. They are separated into two categories:
  662. </p><dl compact="compact">
  663. <dt><samp>generic</samp></dt>
  664. <dd><p>These options can be set for any container, codec or device. Generic options
  665. are listed under AVFormatContext options for containers/devices and under
  666. AVCodecContext options for codecs.
  667. </p></dd>
  668. <dt><samp>private</samp></dt>
  669. <dd><p>These options are specific to the given container, device or codec. Private
  670. options are listed under their corresponding containers/devices/codecs.
  671. </p></dd>
  672. </dl>
  673. <p>For example to write an ID3v2.3 header instead of a default ID3v2.4 to
  674. an MP3 file, use the <samp>id3v2_version</samp> private option of the MP3
  675. muxer:
  676. </p><div class="example">
  677. <pre class="example">ffmpeg -i input.flac -id3v2_version 3 out.mp3
  678. </pre></div>
  679. <p>All codec AVOptions are per-stream, and thus a stream specifier
  680. should be attached to them.
  681. </p>
  682. <p>Note: the <samp>-nooption</samp> syntax cannot be used for boolean
  683. AVOptions, use <samp>-option 0</samp>/<samp>-option 1</samp>.
  684. </p>
  685. <p>Note: the old undocumented way of specifying per-stream AVOptions by
  686. prepending v/a/s to the options name is now obsolete and will be
  687. removed soon.
  688. </p>
  689. <a name="Main-options"></a>
  690. <h3 class="section">5.4 Main options<span class="pull-right"><a class="anchor hidden-xs" href="#Main-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Main-options" aria-hidden="true">TOC</a></span></h3>
  691. <dl compact="compact">
  692. <dt><samp>-f <var>fmt</var> (<em>input/output</em>)</samp></dt>
  693. <dd><p>Force input or output file format. The format is normally auto detected for input
  694. files and guessed from the file extension for output files, so this option is not
  695. needed in most cases.
  696. </p>
  697. </dd>
  698. <dt><samp>-i <var>filename</var> (<em>input</em>)</samp></dt>
  699. <dd><p>input file name
  700. </p>
  701. </dd>
  702. <dt><samp>-y (<em>global</em>)</samp></dt>
  703. <dd><p>Overwrite output files without asking.
  704. </p>
  705. </dd>
  706. <dt><samp>-n (<em>global</em>)</samp></dt>
  707. <dd><p>Do not overwrite output files, and exit immediately if a specified
  708. output file already exists.
  709. </p>
  710. </dd>
  711. <dt><samp>-c[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp></dt>
  712. <dt><samp>-codec[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp></dt>
  713. <dd><p>Select an encoder (when used before an output file) or a decoder (when used
  714. before an input file) for one or more streams. <var>codec</var> is the name of a
  715. decoder/encoder or a special value <code>copy</code> (output only) to indicate that
  716. the stream is not to be re-encoded.
  717. </p>
  718. <p>For example
  719. </p><div class="example">
  720. <pre class="example">ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
  721. </pre></div>
  722. <p>encodes all video streams with libx264 and copies all audio streams.
  723. </p>
  724. <p>For each stream, the last matching <code>c</code> option is applied, so
  725. </p><div class="example">
  726. <pre class="example">ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
  727. </pre></div>
  728. <p>will copy all the streams except the second video, which will be encoded with
  729. libx264, and the 138th audio, which will be encoded with libvorbis.
  730. </p>
  731. </dd>
  732. <dt><samp>-t <var>duration</var> (<em>input/output</em>)</samp></dt>
  733. <dd><p>When used as an input option (before <code>-i</code>), limit the <var>duration</var> of
  734. data read from the input file.
  735. </p>
  736. <p>When used as an output option (before an output filename), stop writing the
  737. output after its duration reaches <var>duration</var>.
  738. </p>
  739. <p><var>duration</var> may be a number in seconds, or in <code>hh:mm:ss[.xxx]</code> form.
  740. </p>
  741. <p>-to and -t are mutually exclusive and -t has priority.
  742. </p>
  743. </dd>
  744. <dt><samp>-to <var>position</var> (<em>output</em>)</samp></dt>
  745. <dd><p>Stop writing the output at <var>position</var>.
  746. <var>position</var> may be a number in seconds, or in <code>hh:mm:ss[.xxx]</code> form.
  747. </p>
  748. <p>-to and -t are mutually exclusive and -t has priority.
  749. </p>
  750. </dd>
  751. <dt><samp>-fs <var>limit_size</var> (<em>output</em>)</samp></dt>
  752. <dd><p>Set the file size limit, expressed in bytes.
  753. </p>
  754. </dd>
  755. <dt><samp>-ss <var>position</var> (<em>input/output</em>)</samp></dt>
  756. <dd><p>When used as an input option (before <code>-i</code>), seeks in this input file to
  757. <var>position</var>. Note the in most formats it is not possible to seek exactly, so
  758. <code>ffmpeg</code> will seek to the closest seek point before <var>position</var>.
  759. When transcoding and <samp>-accurate_seek</samp> is enabled (the default), this
  760. extra segment between the seek point and <var>position</var> will be decoded and
  761. discarded. When doing stream copy or when <samp>-noaccurate_seek</samp> is used, it
  762. will be preserved.
  763. </p>
  764. <p>When used as an output option (before an output filename), decodes but discards
  765. input until the timestamps reach <var>position</var>.
  766. </p>
  767. <p><var>position</var> may be either in seconds or in <code>hh:mm:ss[.xxx]</code> form.
  768. </p>
  769. </dd>
  770. <dt><samp>-itsoffset <var>offset</var> (<em>input</em>)</samp></dt>
  771. <dd><p>Set the input time offset.
  772. </p>
  773. <p><var>offset</var> must be a time duration specification,
  774. see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
  775. </p>
  776. <p>The offset is added to the timestamps of the input files. Specifying
  777. a positive offset means that the corresponding streams are delayed by
  778. the time duration specified in <var>offset</var>.
  779. </p>
  780. </dd>
  781. <dt><samp>-timestamp <var>date</var> (<em>output</em>)</samp></dt>
  782. <dd><p>Set the recording timestamp in the container.
  783. </p>
  784. <p><var>date</var> must be a time duration specification,
  785. see <a href="ffmpeg-utils.html#date-syntax">(ffmpeg-utils)the Date section in the ffmpeg-utils(1) manual</a>.
  786. </p>
  787. </dd>
  788. <dt><samp>-metadata[:metadata_specifier] <var>key</var>=<var>value</var> (<em>output,per-metadata</em>)</samp></dt>
  789. <dd><p>Set a metadata key/value pair.
  790. </p>
  791. <p>An optional <var>metadata_specifier</var> may be given to set metadata
  792. on streams or chapters. See <code>-map_metadata</code> documentation for
  793. details.
  794. </p>
  795. <p>This option overrides metadata set with <code>-map_metadata</code>. It is
  796. also possible to delete metadata by using an empty value.
  797. </p>
  798. <p>For example, for setting the title in the output file:
  799. </p><div class="example">
  800. <pre class="example">ffmpeg -i in.avi -metadata title=&quot;my title&quot; out.flv
  801. </pre></div>
  802. <p>To set the language of the first audio stream:
  803. </p><div class="example">
  804. <pre class="example">ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
  805. </pre></div>
  806. </dd>
  807. <dt><samp>-target <var>type</var> (<em>output</em>)</samp></dt>
  808. <dd><p>Specify target file type (<code>vcd</code>, <code>svcd</code>, <code>dvd</code>, <code>dv</code>,
  809. <code>dv50</code>). <var>type</var> may be prefixed with <code>pal-</code>, <code>ntsc-</code> or
  810. <code>film-</code> to use the corresponding standard. All the format options
  811. (bitrate, codecs, buffer sizes) are then set automatically. You can just type:
  812. </p>
  813. <div class="example">
  814. <pre class="example">ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  815. </pre></div>
  816. <p>Nevertheless you can specify additional options as long as you know
  817. they do not conflict with the standard, as in:
  818. </p>
  819. <div class="example">
  820. <pre class="example">ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  821. </pre></div>
  822. </dd>
  823. <dt><samp>-dframes <var>number</var> (<em>output</em>)</samp></dt>
  824. <dd><p>Set the number of data frames to output. This is an alias for <code>-frames:d</code>.
  825. </p>
  826. </dd>
  827. <dt><samp>-frames[:<var>stream_specifier</var>] <var>framecount</var> (<em>output,per-stream</em>)</samp></dt>
  828. <dd><p>Stop writing to the stream after <var>framecount</var> frames.
  829. </p>
  830. </dd>
  831. <dt><samp>-q[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp></dt>
  832. <dt><samp>-qscale[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp></dt>
  833. <dd><p>Use fixed quality scale (VBR). The meaning of <var>q</var>/<var>qscale</var> is
  834. codec-dependent.
  835. If <var>qscale</var> is used without a <var>stream_specifier</var> then it applies only
  836. to the video stream, this is to maintain compatibility with previous behavior
  837. and as specifying the same codec specific value to 2 different codecs that is
  838. audio and video generally is not what is intended when no stream_specifier is
  839. used.
  840. </p>
  841. <a name="filter_005foption"></a></dd>
  842. <dt><samp>-filter[:<var>stream_specifier</var>] <var>filtergraph</var> (<em>output,per-stream</em>)</samp></dt>
  843. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  844. filter the stream.
  845. </p>
  846. <p><var>filtergraph</var> is a description of the filtergraph to apply to
  847. the stream, and must have a single input and a single output of the
  848. same type of the stream. In the filtergraph, the input is associated
  849. to the label <code>in</code>, and the output to the label <code>out</code>. See
  850. the ffmpeg-filters manual for more information about the filtergraph
  851. syntax.
  852. </p>
  853. <p>See the <a href="#filter_005fcomplex_005foption">-filter_complex option</a> if you
  854. want to create filtergraphs with multiple inputs and/or outputs.
  855. </p>
  856. </dd>
  857. <dt><samp>-filter_script[:<var>stream_specifier</var>] <var>filename</var> (<em>output,per-stream</em>)</samp></dt>
  858. <dd><p>This option is similar to <samp>-filter</samp>, the only difference is that its
  859. argument is the name of the file from which a filtergraph description is to be
  860. read.
  861. </p>
  862. </dd>
  863. <dt><samp>-pre[:<var>stream_specifier</var>] <var>preset_name</var> (<em>output,per-stream</em>)</samp></dt>
  864. <dd><p>Specify the preset for matching stream(s).
  865. </p>
  866. </dd>
  867. <dt><samp>-stats (<em>global</em>)</samp></dt>
  868. <dd><p>Print encoding progress/statistics. It is on by default, to explicitly
  869. disable it you need to specify <code>-nostats</code>.
  870. </p>
  871. </dd>
  872. <dt><samp>-progress <var>url</var> (<em>global</em>)</samp></dt>
  873. <dd><p>Send program-friendly progress information to <var>url</var>.
  874. </p>
  875. <p>Progress information is written approximately every second and at the end of
  876. the encoding process. It is made of &quot;<var>key</var>=<var>value</var>&quot; lines. <var>key</var>
  877. consists of only alphanumeric characters. The last key of a sequence of
  878. progress information is always &quot;progress&quot;.
  879. </p>
  880. </dd>
  881. <dt><samp>-stdin</samp></dt>
  882. <dd><p>Enable interaction on standard input. On by default unless standard input is
  883. used as an input. To explicitly disable interaction you need to specify
  884. <code>-nostdin</code>.
  885. </p>
  886. <p>Disabling interaction on standard input is useful, for example, if
  887. ffmpeg is in the background process group. Roughly the same result can
  888. be achieved with <code>ffmpeg ... &lt; /dev/null</code> but it requires a
  889. shell.
  890. </p>
  891. </dd>
  892. <dt><samp>-debug_ts (<em>global</em>)</samp></dt>
  893. <dd><p>Print timestamp information. It is off by default. This option is
  894. mostly useful for testing and debugging purposes, and the output
  895. format may change from one version to another, so it should not be
  896. employed by portable scripts.
  897. </p>
  898. <p>See also the option <code>-fdebug ts</code>.
  899. </p>
  900. </dd>
  901. <dt><samp>-attach <var>filename</var> (<em>output</em>)</samp></dt>
  902. <dd><p>Add an attachment to the output file. This is supported by a few formats
  903. like Matroska for e.g. fonts used in rendering subtitles. Attachments
  904. are implemented as a specific type of stream, so this option will add
  905. a new stream to the file. It is then possible to use per-stream options
  906. on this stream in the usual way. Attachment streams created with this
  907. option will be created after all the other streams (i.e. those created
  908. with <code>-map</code> or automatic mappings).
  909. </p>
  910. <p>Note that for Matroska you also have to set the mimetype metadata tag:
  911. </p><div class="example">
  912. <pre class="example">ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
  913. </pre></div>
  914. <p>(assuming that the attachment stream will be third in the output file).
  915. </p>
  916. </dd>
  917. <dt><samp>-dump_attachment[:<var>stream_specifier</var>] <var>filename</var> (<em>input,per-stream</em>)</samp></dt>
  918. <dd><p>Extract the matching attachment stream into a file named <var>filename</var>. If
  919. <var>filename</var> is empty, then the value of the <code>filename</code> metadata tag
  920. will be used.
  921. </p>
  922. <p>E.g. to extract the first attachment to a file named &rsquo;out.ttf&rsquo;:
  923. </p><div class="example">
  924. <pre class="example">ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
  925. </pre></div>
  926. <p>To extract all attachments to files determined by the <code>filename</code> tag:
  927. </p><div class="example">
  928. <pre class="example">ffmpeg -dump_attachment:t &quot;&quot; -i INPUT
  929. </pre></div>
  930. <p>Technical note &ndash; attachments are implemented as codec extradata, so this
  931. option can actually be used to extract extradata from any stream, not just
  932. attachments.
  933. </p>
  934. </dd>
  935. </dl>
  936. <a name="Video-Options"></a>
  937. <h3 class="section">5.5 Video Options<span class="pull-right"><a class="anchor hidden-xs" href="#Video-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-Options" aria-hidden="true">TOC</a></span></h3>
  938. <dl compact="compact">
  939. <dt><samp>-vframes <var>number</var> (<em>output</em>)</samp></dt>
  940. <dd><p>Set the number of video frames to output. This is an alias for <code>-frames:v</code>.
  941. </p></dd>
  942. <dt><samp>-r[:<var>stream_specifier</var>] <var>fps</var> (<em>input/output,per-stream</em>)</samp></dt>
  943. <dd><p>Set frame rate (Hz value, fraction or abbreviation).
  944. </p>
  945. <p>As an input option, ignore any timestamps stored in the file and instead
  946. generate timestamps assuming constant frame rate <var>fps</var>.
  947. This is not the same as the <samp>-framerate</samp> option used for some input formats
  948. like image2 or v4l2 (it used to be the same in older versions of FFmpeg).
  949. If in doubt use <samp>-framerate</samp> instead of the input option <samp>-r</samp>.
  950. </p>
  951. <p>As an output option, duplicate or drop input frames to achieve constant output
  952. frame rate <var>fps</var>.
  953. </p>
  954. </dd>
  955. <dt><samp>-s[:<var>stream_specifier</var>] <var>size</var> (<em>input/output,per-stream</em>)</samp></dt>
  956. <dd><p>Set frame size.
  957. </p>
  958. <p>As an input option, this is a shortcut for the <samp>video_size</samp> private
  959. option, recognized by some demuxers for which the frame size is either not
  960. stored in the file or is configurable &ndash; e.g. raw video or video grabbers.
  961. </p>
  962. <p>As an output option, this inserts the <code>scale</code> video filter to the
  963. <em>end</em> of the corresponding filtergraph. Please use the <code>scale</code> filter
  964. directly to insert it at the beginning or some other place.
  965. </p>
  966. <p>The format is &lsquo;<samp>wxh</samp>&rsquo; (default - same as source).
  967. </p>
  968. </dd>
  969. <dt><samp>-aspect[:<var>stream_specifier</var>] <var>aspect</var> (<em>output,per-stream</em>)</samp></dt>
  970. <dd><p>Set the video display aspect ratio specified by <var>aspect</var>.
  971. </p>
  972. <p><var>aspect</var> can be a floating point number string, or a string of the
  973. form <var>num</var>:<var>den</var>, where <var>num</var> and <var>den</var> are the
  974. numerator and denominator of the aspect ratio. For example &quot;4:3&quot;,
  975. &quot;16:9&quot;, &quot;1.3333&quot;, and &quot;1.7777&quot; are valid argument values.
  976. </p>
  977. <p>If used together with <samp>-vcodec copy</samp>, it will affect the aspect ratio
  978. stored at container level, but not the aspect ratio stored in encoded
  979. frames, if it exists.
  980. </p>
  981. </dd>
  982. <dt><samp>-vn (<em>output</em>)</samp></dt>
  983. <dd><p>Disable video recording.
  984. </p>
  985. </dd>
  986. <dt><samp>-vcodec <var>codec</var> (<em>output</em>)</samp></dt>
  987. <dd><p>Set the video codec. This is an alias for <code>-codec:v</code>.
  988. </p>
  989. </dd>
  990. <dt><samp>-pass[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp></dt>
  991. <dd><p>Select the pass number (1 or 2). It is used to do two-pass
  992. video encoding. The statistics of the video are recorded in the first
  993. pass into a log file (see also the option -passlogfile),
  994. and in the second pass that log file is used to generate the video
  995. at the exact requested bitrate.
  996. On pass 1, you may just deactivate audio and set output to null,
  997. examples for Windows and Unix:
  998. </p><div class="example">
  999. <pre class="example">ffmpeg -i -c:v libxvid -pass 1 -an -f rawvideo -y NUL
  1000. ffmpeg -i -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
  1001. </pre></div>
  1002. </dd>
  1003. <dt><samp>-passlogfile[:<var>stream_specifier</var>] <var>prefix</var> (<em>output,per-stream</em>)</samp></dt>
  1004. <dd><p>Set two-pass log file name prefix to <var>prefix</var>, the default file name
  1005. prefix is &ldquo;ffmpeg2pass&rdquo;. The complete file name will be
  1006. <samp>PREFIX-N.log</samp>, where N is a number specific to the output
  1007. stream
  1008. </p>
  1009. </dd>
  1010. <dt><samp>-vf <var>filtergraph</var> (<em>output</em>)</samp></dt>
  1011. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  1012. filter the stream.
  1013. </p>
  1014. <p>This is an alias for <code>-filter:v</code>, see the <a href="#filter_005foption">-filter option</a>.
  1015. </p></dd>
  1016. </dl>
  1017. <a name="Advanced-Video-options"></a>
  1018. <h3 class="section">5.6 Advanced Video options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Video-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Video-options" aria-hidden="true">TOC</a></span></h3>
  1019. <dl compact="compact">
  1020. <dt><samp>-pix_fmt[:<var>stream_specifier</var>] <var>format</var> (<em>input/output,per-stream</em>)</samp></dt>
  1021. <dd><p>Set pixel format. Use <code>-pix_fmts</code> to show all the supported
  1022. pixel formats.
  1023. If the selected pixel format can not be selected, ffmpeg will print a
  1024. warning and select the best pixel format supported by the encoder.
  1025. If <var>pix_fmt</var> is prefixed by a <code>+</code>, ffmpeg will exit with an error
  1026. if the requested pixel format can not be selected, and automatic conversions
  1027. inside filtergraphs are disabled.
  1028. If <var>pix_fmt</var> is a single <code>+</code>, ffmpeg selects the same pixel format
  1029. as the input (or graph output) and automatic conversions are disabled.
  1030. </p>
  1031. </dd>
  1032. <dt><samp>-sws_flags <var>flags</var> (<em>input/output</em>)</samp></dt>
  1033. <dd><p>Set SwScaler flags.
  1034. </p></dd>
  1035. <dt><samp>-vdt <var>n</var></samp></dt>
  1036. <dd><p>Discard threshold.
  1037. </p>
  1038. </dd>
  1039. <dt><samp>-rc_override[:<var>stream_specifier</var>] <var>override</var> (<em>output,per-stream</em>)</samp></dt>
  1040. <dd><p>Rate control override for specific intervals, formatted as &quot;int,int,int&quot;
  1041. list separated with slashes. Two first values are the beginning and
  1042. end frame numbers, last one is quantizer to use if positive, or quality
  1043. factor if negative.
  1044. </p>
  1045. </dd>
  1046. <dt><samp>-ilme</samp></dt>
  1047. <dd><p>Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
  1048. Use this option if your input file is interlaced and you want
  1049. to keep the interlaced format for minimum losses.
  1050. The alternative is to deinterlace the input stream with
  1051. <samp>-deinterlace</samp>, but deinterlacing introduces losses.
  1052. </p></dd>
  1053. <dt><samp>-psnr</samp></dt>
  1054. <dd><p>Calculate PSNR of compressed frames.
  1055. </p></dd>
  1056. <dt><samp>-vstats</samp></dt>
  1057. <dd><p>Dump video coding statistics to <samp>vstats_HHMMSS.log</samp>.
  1058. </p></dd>
  1059. <dt><samp>-vstats_file <var>file</var></samp></dt>
  1060. <dd><p>Dump video coding statistics to <var>file</var>.
  1061. </p></dd>
  1062. <dt><samp>-top[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp></dt>
  1063. <dd><p>top=1/bottom=0/auto=-1 field first
  1064. </p></dd>
  1065. <dt><samp>-dc <var>precision</var></samp></dt>
  1066. <dd><p>Intra_dc_precision.
  1067. </p></dd>
  1068. <dt><samp>-vtag <var>fourcc/tag</var> (<em>output</em>)</samp></dt>
  1069. <dd><p>Force video tag/fourcc. This is an alias for <code>-tag:v</code>.
  1070. </p></dd>
  1071. <dt><samp>-qphist (<em>global</em>)</samp></dt>
  1072. <dd><p>Show QP histogram
  1073. </p></dd>
  1074. <dt><samp>-vbsf <var>bitstream_filter</var></samp></dt>
  1075. <dd><p>Deprecated see -bsf
  1076. </p>
  1077. </dd>
  1078. <dt><samp>-force_key_frames[:<var>stream_specifier</var>] <var>time</var>[,<var>time</var>...] (<em>output,per-stream</em>)</samp></dt>
  1079. <dt><samp>-force_key_frames[:<var>stream_specifier</var>] expr:<var>expr</var> (<em>output,per-stream</em>)</samp></dt>
  1080. <dd><p>Force key frames at the specified timestamps, more precisely at the first
  1081. frames after each specified time.
  1082. </p>
  1083. <p>If the argument is prefixed with <code>expr:</code>, the string <var>expr</var>
  1084. is interpreted like an expression and is evaluated for each frame. A
  1085. key frame is forced in case the evaluation is non-zero.
  1086. </p>
  1087. <p>If one of the times is &quot;<code>chapters</code>[<var>delta</var>]&quot;, it is expanded into
  1088. the time of the beginning of all chapters in the file, shifted by
  1089. <var>delta</var>, expressed as a time in seconds.
  1090. This option can be useful to ensure that a seek point is present at a
  1091. chapter mark or any other designated place in the output file.
  1092. </p>
  1093. <p>For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
  1094. before the beginning of every chapter:
  1095. </p><div class="example">
  1096. <pre class="example">-force_key_frames 0:05:00,chapters-0.1
  1097. </pre></div>
  1098. <p>The expression in <var>expr</var> can contain the following constants:
  1099. </p><dl compact="compact">
  1100. <dt><samp>n</samp></dt>
  1101. <dd><p>the number of current processed frame, starting from 0
  1102. </p></dd>
  1103. <dt><samp>n_forced</samp></dt>
  1104. <dd><p>the number of forced frames
  1105. </p></dd>
  1106. <dt><samp>prev_forced_n</samp></dt>
  1107. <dd><p>the number of the previous forced frame, it is <code>NAN</code> when no
  1108. keyframe was forced yet
  1109. </p></dd>
  1110. <dt><samp>prev_forced_t</samp></dt>
  1111. <dd><p>the time of the previous forced frame, it is <code>NAN</code> when no
  1112. keyframe was forced yet
  1113. </p></dd>
  1114. <dt><samp>t</samp></dt>
  1115. <dd><p>the time of the current processed frame
  1116. </p></dd>
  1117. </dl>
  1118. <p>For example to force a key frame every 5 seconds, you can specify:
  1119. </p><div class="example">
  1120. <pre class="example">-force_key_frames expr:gte(t,n_forced*5)
  1121. </pre></div>
  1122. <p>To force a key frame 5 seconds after the time of the last forced one,
  1123. starting from second 13:
  1124. </p><div class="example">
  1125. <pre class="example">-force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
  1126. </pre></div>
  1127. <p>Note that forcing too many keyframes is very harmful for the lookahead
  1128. algorithms of certain encoders: using fixed-GOP options or similar
  1129. would be more efficient.
  1130. </p>
  1131. </dd>
  1132. <dt><samp>-copyinkf[:<var>stream_specifier</var>] (<em>output,per-stream</em>)</samp></dt>
  1133. <dd><p>When doing stream copy, copy also non-key frames found at the
  1134. beginning.
  1135. </p>
  1136. </dd>
  1137. <dt><samp>-hwaccel[:<var>stream_specifier</var>] <var>hwaccel</var> (<em>input,per-stream</em>)</samp></dt>
  1138. <dd><p>Use hardware acceleration to decode the matching stream(s). The allowed values
  1139. of <var>hwaccel</var> are:
  1140. </p><dl compact="compact">
  1141. <dt><samp>none</samp></dt>
  1142. <dd><p>Do not use any hardware acceleration (the default).
  1143. </p>
  1144. </dd>
  1145. <dt><samp>auto</samp></dt>
  1146. <dd><p>Automatically select the hardware acceleration method.
  1147. </p>
  1148. </dd>
  1149. <dt><samp>vda</samp></dt>
  1150. <dd><p>Use Apple VDA hardware acceleration.
  1151. </p>
  1152. </dd>
  1153. <dt><samp>vdpau</samp></dt>
  1154. <dd><p>Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
  1155. </p>
  1156. </dd>
  1157. <dt><samp>dxva2</samp></dt>
  1158. <dd><p>Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
  1159. </p></dd>
  1160. </dl>
  1161. <p>This option has no effect if the selected hwaccel is not available or not
  1162. supported by the chosen decoder.
  1163. </p>
  1164. <p>Note that most acceleration methods are intended for playback and will not be
  1165. faster than software decoding on modern CPUs. Additionally, <code>ffmpeg</code>
  1166. will usually need to copy the decoded frames from the GPU memory into the system
  1167. memory, resulting in further performance loss. This option is thus mainly
  1168. useful for testing.
  1169. </p>
  1170. </dd>
  1171. <dt><samp>-hwaccel_device[:<var>stream_specifier</var>] <var>hwaccel_device</var> (<em>input,per-stream</em>)</samp></dt>
  1172. <dd><p>Select a device to use for hardware acceleration.
  1173. </p>
  1174. <p>This option only makes sense when the <samp>-hwaccel</samp> option is also
  1175. specified. Its exact meaning depends on the specific hardware acceleration
  1176. method chosen.
  1177. </p>
  1178. <dl compact="compact">
  1179. <dt><samp>vdpau</samp></dt>
  1180. <dd><p>For VDPAU, this option specifies the X11 display/screen to use. If this option
  1181. is not specified, the value of the <var>DISPLAY</var> environment variable is used
  1182. </p>
  1183. </dd>
  1184. <dt><samp>dxva2</samp></dt>
  1185. <dd><p>For DXVA2, this option should contain the number of the display adapter to use.
  1186. If this option is not specified, the default adapter is used.
  1187. </p></dd>
  1188. </dl>
  1189. </dd>
  1190. </dl>
  1191. <a name="Audio-Options"></a>
  1192. <h3 class="section">5.7 Audio Options<span class="pull-right"><a class="anchor hidden-xs" href="#Audio-Options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Audio-Options" aria-hidden="true">TOC</a></span></h3>
  1193. <dl compact="compact">
  1194. <dt><samp>-aframes <var>number</var> (<em>output</em>)</samp></dt>
  1195. <dd><p>Set the number of audio frames to output. This is an alias for <code>-frames:a</code>.
  1196. </p></dd>
  1197. <dt><samp>-ar[:<var>stream_specifier</var>] <var>freq</var> (<em>input/output,per-stream</em>)</samp></dt>
  1198. <dd><p>Set the audio sampling frequency. For output streams it is set by
  1199. default to the frequency of the corresponding input stream. For input
  1200. streams this option only makes sense for audio grabbing devices and raw
  1201. demuxers and is mapped to the corresponding demuxer options.
  1202. </p></dd>
  1203. <dt><samp>-aq <var>q</var> (<em>output</em>)</samp></dt>
  1204. <dd><p>Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
  1205. </p></dd>
  1206. <dt><samp>-ac[:<var>stream_specifier</var>] <var>channels</var> (<em>input/output,per-stream</em>)</samp></dt>
  1207. <dd><p>Set the number of audio channels. For output streams it is set by
  1208. default to the number of input audio channels. For input streams
  1209. this option only makes sense for audio grabbing devices and raw demuxers
  1210. and is mapped to the corresponding demuxer options.
  1211. </p></dd>
  1212. <dt><samp>-an (<em>output</em>)</samp></dt>
  1213. <dd><p>Disable audio recording.
  1214. </p></dd>
  1215. <dt><samp>-acodec <var>codec</var> (<em>input/output</em>)</samp></dt>
  1216. <dd><p>Set the audio codec. This is an alias for <code>-codec:a</code>.
  1217. </p></dd>
  1218. <dt><samp>-sample_fmt[:<var>stream_specifier</var>] <var>sample_fmt</var> (<em>output,per-stream</em>)</samp></dt>
  1219. <dd><p>Set the audio sample format. Use <code>-sample_fmts</code> to get a list
  1220. of supported sample formats.
  1221. </p>
  1222. </dd>
  1223. <dt><samp>-af <var>filtergraph</var> (<em>output</em>)</samp></dt>
  1224. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  1225. filter the stream.
  1226. </p>
  1227. <p>This is an alias for <code>-filter:a</code>, see the <a href="#filter_005foption">-filter option</a>.
  1228. </p></dd>
  1229. </dl>
  1230. <a name="Advanced-Audio-options"></a>
  1231. <h3 class="section">5.8 Advanced Audio options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Audio-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Audio-options" aria-hidden="true">TOC</a></span></h3>
  1232. <dl compact="compact">
  1233. <dt><samp>-atag <var>fourcc/tag</var> (<em>output</em>)</samp></dt>
  1234. <dd><p>Force audio tag/fourcc. This is an alias for <code>-tag:a</code>.
  1235. </p></dd>
  1236. <dt><samp>-absf <var>bitstream_filter</var></samp></dt>
  1237. <dd><p>Deprecated, see -bsf
  1238. </p></dd>
  1239. <dt><samp>-guess_layout_max <var>channels</var> (<em>input,per-stream</em>)</samp></dt>
  1240. <dd><p>If some input channel layout is not known, try to guess only if it
  1241. corresponds to at most the specified number of channels. For example, 2
  1242. tells to <code>ffmpeg</code> to recognize 1 channel as mono and 2 channels as
  1243. stereo but not 6 channels as 5.1. The default is to always try to guess. Use
  1244. 0 to disable all guessing.
  1245. </p></dd>
  1246. </dl>
  1247. <a name="Subtitle-options"></a>
  1248. <h3 class="section">5.9 Subtitle options<span class="pull-right"><a class="anchor hidden-xs" href="#Subtitle-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Subtitle-options" aria-hidden="true">TOC</a></span></h3>
  1249. <dl compact="compact">
  1250. <dt><samp>-scodec <var>codec</var> (<em>input/output</em>)</samp></dt>
  1251. <dd><p>Set the subtitle codec. This is an alias for <code>-codec:s</code>.
  1252. </p></dd>
  1253. <dt><samp>-sn (<em>output</em>)</samp></dt>
  1254. <dd><p>Disable subtitle recording.
  1255. </p></dd>
  1256. <dt><samp>-sbsf <var>bitstream_filter</var></samp></dt>
  1257. <dd><p>Deprecated, see -bsf
  1258. </p></dd>
  1259. </dl>
  1260. <a name="Advanced-Subtitle-options"></a>
  1261. <h3 class="section">5.10 Advanced Subtitle options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-Subtitle-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-Subtitle-options" aria-hidden="true">TOC</a></span></h3>
  1262. <dl compact="compact">
  1263. <dt><samp>-fix_sub_duration</samp></dt>
  1264. <dd><p>Fix subtitles durations. For each subtitle, wait for the next packet in the
  1265. same stream and adjust the duration of the first to avoid overlap. This is
  1266. necessary with some subtitles codecs, especially DVB subtitles, because the
  1267. duration in the original packet is only a rough estimate and the end is
  1268. actually marked by an empty subtitle frame. Failing to use this option when
  1269. necessary can result in exaggerated durations or muxing failures due to
  1270. non-monotonic timestamps.
  1271. </p>
  1272. <p>Note that this option will delay the output of all data until the next
  1273. subtitle packet is decoded: it may increase memory consumption and latency a
  1274. lot.
  1275. </p>
  1276. </dd>
  1277. <dt><samp>-canvas_size <var>size</var></samp></dt>
  1278. <dd><p>Set the size of the canvas used to render subtitles.
  1279. </p>
  1280. </dd>
  1281. </dl>
  1282. <a name="Advanced-options"></a>
  1283. <h3 class="section">5.11 Advanced options<span class="pull-right"><a class="anchor hidden-xs" href="#Advanced-options" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Advanced-options" aria-hidden="true">TOC</a></span></h3>
  1284. <dl compact="compact">
  1285. <dt><samp>-map [-]<var>input_file_id</var>[:<var>stream_specifier</var>][,<var>sync_file_id</var>[:<var>stream_specifier</var>]] | <var>[linklabel]</var> (<em>output</em>)</samp></dt>
  1286. <dd>
  1287. <p>Designate one or more input streams as a source for the output file. Each input
  1288. stream is identified by the input file index <var>input_file_id</var> and
  1289. the input stream index <var>input_stream_id</var> within the input
  1290. file. Both indices start at 0. If specified,
  1291. <var>sync_file_id</var>:<var>stream_specifier</var> sets which input stream
  1292. is used as a presentation sync reference.
  1293. </p>
  1294. <p>The first <code>-map</code> option on the command line specifies the
  1295. source for output stream 0, the second <code>-map</code> option specifies
  1296. the source for output stream 1, etc.
  1297. </p>
  1298. <p>A <code>-</code> character before the stream identifier creates a &quot;negative&quot; mapping.
  1299. It disables matching streams from already created mappings.
  1300. </p>
  1301. <p>An alternative <var>[linklabel]</var> form will map outputs from complex filter
  1302. graphs (see the <samp>-filter_complex</samp> option) to the output file.
  1303. <var>linklabel</var> must correspond to a defined output link label in the graph.
  1304. </p>
  1305. <p>For example, to map ALL streams from the first input file to output
  1306. </p><div class="example">
  1307. <pre class="example">ffmpeg -i INPUT -map 0 output
  1308. </pre></div>
  1309. <p>For example, if you have two audio streams in the first input file,
  1310. these streams are identified by &quot;0:0&quot; and &quot;0:1&quot;. You can use
  1311. <code>-map</code> to select which streams to place in an output file. For
  1312. example:
  1313. </p><div class="example">
  1314. <pre class="example">ffmpeg -i INPUT -map 0:1 out.wav
  1315. </pre></div>
  1316. <p>will map the input stream in <samp>INPUT</samp> identified by &quot;0:1&quot; to
  1317. the (single) output stream in <samp>out.wav</samp>.
  1318. </p>
  1319. <p>For example, to select the stream with index 2 from input file
  1320. <samp></samp> (specified by the identifier &quot;0:2&quot;), and stream with
  1321. index 6 from input <samp></samp> (specified by the identifier &quot;1:6&quot;),
  1322. and copy them to the output file <samp></samp>:
  1323. </p><div class="example">
  1324. <pre class="example">ffmpeg -i -i -c copy -map 0:2 -map 1:6
  1325. </pre></div>
  1326. <p>To select all video and the third audio stream from an input file:
  1327. </p><div class="example">
  1328. <pre class="example">ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
  1329. </pre></div>
  1330. <p>To map all the streams except the second audio, use negative mappings
  1331. </p><div class="example">
  1332. <pre class="example">ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
  1333. </pre></div>
  1334. <p>To pick the English audio stream:
  1335. </p><div class="example">
  1336. <pre class="example">ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
  1337. </pre></div>
  1338. <p>Note that using this option disables the default mappings for this output file.
  1339. </p>
  1340. </dd>
  1341. <dt><samp>-map_channel [<var>input_file_id</var>.<var>stream_specifier</var>.<var>channel_id</var>|-1][:<var>output_file_id</var>.<var>stream_specifier</var>]</samp></dt>
  1342. <dd><p>Map an audio channel from a given input to an output. If
  1343. <var>output_file_id</var>.<var>stream_specifier</var> is not set, the audio channel will
  1344. be mapped on all the audio streams.
  1345. </p>
  1346. <p>Using &quot;-1&quot; instead of
  1347. <var>input_file_id</var>.<var>stream_specifier</var>.<var>channel_id</var> will map a muted
  1348. channel.
  1349. </p>
  1350. <p>For example, assuming <var>INPUT</var> is a stereo audio file, you can switch the
  1351. two audio channels with the following command:
  1352. </p><div class="example">
  1353. <pre class="example">ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
  1354. </pre></div>
  1355. <p>If you want to mute the first channel and keep the second:
  1356. </p><div class="example">
  1357. <pre class="example">ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
  1358. </pre></div>
  1359. <p>The order of the &quot;-map_channel&quot; option specifies the order of the channels in
  1360. the output stream. The output channel layout is guessed from the number of
  1361. channels mapped (mono if one &quot;-map_channel&quot;, stereo if two, etc.). Using &quot;-ac&quot;
  1362. in combination of &quot;-map_channel&quot; makes the channel gain levels to be updated if
  1363. input and output channel layouts don&rsquo;t match (for instance two &quot;-map_channel&quot;
  1364. options and &quot;-ac 6&quot;).
  1365. </p>
  1366. <p>You can also extract each channel of an input to specific outputs; the following
  1367. command extracts two channels of the <var>INPUT</var> audio stream (file 0, stream 0)
  1368. to the respective <var>OUTPUT_CH0</var> and <var>OUTPUT_CH1</var> outputs:
  1369. </p><div class="example">
  1370. <pre class="example">ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
  1371. </pre></div>
  1372. <p>The following example splits the channels of a stereo input into two separate
  1373. streams, which are put into the same output file:
  1374. </p><div class="example">
  1375. <pre class="example">ffmpeg -i stereo.wav -map 0:0 -map 0:0 -map_channel 0.0.0:0.0 -map_channel 0.0.1:0.1 -y out.ogg
  1376. </pre></div>
  1377. <p>Note that currently each output stream can only contain channels from a single
  1378. input stream; you can&rsquo;t for example use &quot;-map_channel&quot; to pick multiple input
  1379. audio channels contained in different streams (from the same or different files)
  1380. and merge them into a single output stream. It is therefore not currently
  1381. possible, for example, to turn two separate mono streams into a single stereo
  1382. stream. However splitting a stereo stream into two single channel mono streams
  1383. is possible.
  1384. </p>
  1385. <p>If you need this feature, a possible workaround is to use the <em>amerge</em>
  1386. filter. For example, if you need to merge a media (here <samp>input.mkv</samp>) with 2
  1387. mono audio streams into one single stereo channel audio stream (and keep the
  1388. video stream), you can use the following command:
  1389. </p><div class="example">
  1390. <pre class="example">ffmpeg -i input.mkv -filter_complex &quot;[0:1] [0:2] amerge&quot; -c:a pcm_s16le -c:v copy output.mkv
  1391. </pre></div>
  1392. </dd>
  1393. <dt><samp>-map_metadata[:<var>metadata_spec_out</var>] <var>infile</var>[:<var>metadata_spec_in</var>] (<em>output,per-metadata</em>)</samp></dt>
  1394. <dd><p>Set metadata information of the next output file from <var>infile</var>. Note that
  1395. those are file indices (zero-based), not filenames.
  1396. Optional <var>metadata_spec_in/out</var> parameters specify, which metadata to copy.
  1397. A metadata specifier can have the following forms:
  1398. </p><dl compact="compact">
  1399. <dt><samp><var>g</var></samp></dt>
  1400. <dd><p>global metadata, i.e. metadata that applies to the whole file
  1401. </p>
  1402. </dd>
  1403. <dt><samp><var>s</var>[:<var>stream_spec</var>]</samp></dt>
  1404. <dd><p>per-stream metadata. <var>stream_spec</var> is a stream specifier as described
  1405. in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. In an input metadata specifier, the first
  1406. matching stream is copied from. In an output metadata specifier, all matching
  1407. streams are copied to.
  1408. </p>
  1409. </dd>
  1410. <dt><samp><var>c</var>:<var>chapter_index</var></samp></dt>
  1411. <dd><p>per-chapter metadata. <var>chapter_index</var> is the zero-based chapter index.
  1412. </p>
  1413. </dd>
  1414. <dt><samp><var>p</var>:<var>program_index</var></samp></dt>
  1415. <dd><p>per-program metadata. <var>program_index</var> is the zero-based program index.
  1416. </p></dd>
  1417. </dl>
  1418. <p>If metadata specifier is omitted, it defaults to global.
  1419. </p>
  1420. <p>By default, global metadata is copied from the first input file,
  1421. per-stream and per-chapter metadata is copied along with streams/chapters. These
  1422. default mappings are disabled by creating any mapping of the relevant type. A negative
  1423. file index can be used to create a dummy mapping that just disables automatic copying.
  1424. </p>
  1425. <p>For example to copy metadata from the first stream of the input file to global metadata
  1426. of the output file:
  1427. </p><div class="example">
  1428. <pre class="example">ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
  1429. </pre></div>
  1430. <p>To do the reverse, i.e. copy global metadata to all audio streams:
  1431. </p><div class="example">
  1432. <pre class="example">ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
  1433. </pre></div>
  1434. <p>Note that simple <code>0</code> would work as well in this example, since global
  1435. metadata is assumed by default.
  1436. </p>
  1437. </dd>
  1438. <dt><samp>-map_chapters <var>input_file_index</var> (<em>output</em>)</samp></dt>
  1439. <dd><p>Copy chapters from input file with index <var>input_file_index</var> to the next
  1440. output file. If no chapter mapping is specified, then chapters are copied from
  1441. the first input file with at least one chapter. Use a negative file index to
  1442. disable any chapter copying.
  1443. </p>
  1444. </dd>
  1445. <dt><samp>-benchmark (<em>global</em>)</samp></dt>
  1446. <dd><p>Show benchmarking information at the end of an encode.
  1447. Shows CPU time used and maximum memory consumption.
  1448. Maximum memory consumption is not supported on all systems,
  1449. it will usually display as 0 if not supported.
  1450. </p></dd>
  1451. <dt><samp>-benchmark_all (<em>global</em>)</samp></dt>
  1452. <dd><p>Show benchmarking information during the encode.
  1453. Shows CPU time used in various steps (audio/video encode/decode).
  1454. </p></dd>
  1455. <dt><samp>-timelimit <var>duration</var> (<em>global</em>)</samp></dt>
  1456. <dd><p>Exit after ffmpeg has been running for <var>duration</var> seconds.
  1457. </p></dd>
  1458. <dt><samp>-dump (<em>global</em>)</samp></dt>
  1459. <dd><p>Dump each input packet to stderr.
  1460. </p></dd>
  1461. <dt><samp>-hex (<em>global</em>)</samp></dt>
  1462. <dd><p>When dumping packets, also dump the payload.
  1463. </p></dd>
  1464. <dt><samp>-re (<em>input</em>)</samp></dt>
  1465. <dd><p>Read input at native frame rate. Mainly used to simulate a grab device.
  1466. or live input stream (e.g. when reading from a file). Should not be used
  1467. with actual grab devices or live input streams (where it can cause packet
  1468. loss).
  1469. By default <code>ffmpeg</code> attempts to read the input(s) as fast as possible.
  1470. This option will slow down the reading of the input(s) to the native frame rate
  1471. of the input(s). It is useful for real-time output (e.g. live streaming).
  1472. </p></dd>
  1473. <dt><samp>-loop_input</samp></dt>
  1474. <dd><p>Loop over the input stream. Currently it works only for image
  1475. streams. This option is used for automatic FFserver testing.
  1476. This option is deprecated, use -loop 1.
  1477. </p></dd>
  1478. <dt><samp>-loop_output <var>number_of_times</var></samp></dt>
  1479. <dd><p>Repeatedly loop output for formats that support looping such as animated GIF
  1480. (0 will loop the output infinitely).
  1481. This option is deprecated, use -loop.
  1482. </p></dd>
  1483. <dt><samp>-vsync <var>parameter</var></samp></dt>
  1484. <dd><p>Video sync method.
  1485. For compatibility reasons old values can be specified as numbers.
  1486. Newly added values will have to be specified as strings always.
  1487. </p>
  1488. <dl compact="compact">
  1489. <dt><samp>0, passthrough</samp></dt>
  1490. <dd><p>Each frame is passed with its timestamp from the demuxer to the muxer.
  1491. </p></dd>
  1492. <dt><samp>1, cfr</samp></dt>
  1493. <dd><p>Frames will be duplicated and dropped to achieve exactly the requested
  1494. constant frame rate.
  1495. </p></dd>
  1496. <dt><samp>2, vfr</samp></dt>
  1497. <dd><p>Frames are passed through with their timestamp or dropped so as to
  1498. prevent 2 frames from having the same timestamp.
  1499. </p></dd>
  1500. <dt><samp>drop</samp></dt>
  1501. <dd><p>As passthrough but destroys all timestamps, making the muxer generate
  1502. fresh timestamps based on frame-rate.
  1503. </p></dd>
  1504. <dt><samp>-1, auto</samp></dt>
  1505. <dd><p>Chooses between 1 and 2 depending on muxer capabilities. This is the
  1506. default method.
  1507. </p></dd>
  1508. </dl>
  1509. <p>Note that the timestamps may be further modified by the muxer, after this.
  1510. For example, in the case that the format option <samp>avoid_negative_ts</samp>
  1511. is enabled.
  1512. </p>
  1513. <p>With -map you can select from which stream the timestamps should be
  1514. taken. You can leave either video or audio unchanged and sync the
  1515. remaining stream(s) to the unchanged one.
  1516. </p>
  1517. </dd>
  1518. <dt><samp>-frame_drop_threshold <var>parameter</var></samp></dt>
  1519. <dd><p>Frame drop threshold, which specifies how much behind video frames can
  1520. be before they are dropped. In frame rate units, so 1.0 is one frame.
  1521. The default is -1.1. One possible usecase is to avoid framedrops in case
  1522. of noisy timestamps or to increase frame drop precision in case of exact
  1523. timestamps.
  1524. </p>
  1525. </dd>
  1526. <dt><samp>-async <var>samples_per_second</var></samp></dt>
  1527. <dd><p>Audio sync method. &quot;Stretches/squeezes&quot; the audio stream to match the timestamps,
  1528. the parameter is the maximum samples per second by which the audio is changed.
  1529. -async 1 is a special case where only the start of the audio stream is corrected
  1530. without any later correction.
  1531. </p>
  1532. <p>Note that the timestamps may be further modified by the muxer, after this.
  1533. For example, in the case that the format option <samp>avoid_negative_ts</samp>
  1534. is enabled.
  1535. </p>
  1536. <p>This option has been deprecated. Use the <code>aresample</code> audio filter instead.
  1537. </p>
  1538. </dd>
  1539. <dt><samp>-copyts</samp></dt>
  1540. <dd><p>Do not process input timestamps, but keep their values without trying
  1541. to sanitize them. In particular, do not remove the initial start time
  1542. offset value.
  1543. </p>
  1544. <p>Note that, depending on the <samp>vsync</samp> option or on specific muxer
  1545. processing (e.g. in case the format option <samp>avoid_negative_ts</samp>
  1546. is enabled) the output timestamps may mismatch with the input
  1547. timestamps even when this option is selected.
  1548. </p>
  1549. </dd>
  1550. <dt><samp>-start_at_zero</samp></dt>
  1551. <dd><p>When used with <samp>copyts</samp>, shift input timestamps so they start at zero.
  1552. </p>
  1553. <p>This means that using e.g. <code>-ss 50</code> will make output timestamps start at
  1554. 50 seconds, regardless of what timestamp the input file started at.
  1555. </p>
  1556. </dd>
  1557. <dt><samp>-copytb <var>mode</var></samp></dt>
  1558. <dd><p>Specify how to set the encoder timebase when stream copying. <var>mode</var> is an
  1559. integer numeric value, and can assume one of the following values:
  1560. </p>
  1561. <dl compact="compact">
  1562. <dt><samp>1</samp></dt>
  1563. <dd><p>Use the demuxer timebase.
  1564. </p>
  1565. <p>The time base is copied to the output encoder from the corresponding input
  1566. demuxer. This is sometimes required to avoid non monotonically increasing
  1567. timestamps when copying video streams with variable frame rate.
  1568. </p>
  1569. </dd>
  1570. <dt><samp>0</samp></dt>
  1571. <dd><p>Use the decoder timebase.
  1572. </p>
  1573. <p>The time base is copied to the output encoder from the corresponding input
  1574. decoder.
  1575. </p>
  1576. </dd>
  1577. <dt><samp>-1</samp></dt>
  1578. <dd><p>Try to make the choice automatically, in order to generate a sane output.
  1579. </p></dd>
  1580. </dl>
  1581. <p>Default value is -1.
  1582. </p>
  1583. </dd>
  1584. <dt><samp>-shortest (<em>output</em>)</samp></dt>
  1585. <dd><p>Finish encoding when the shortest input stream ends.
  1586. </p></dd>
  1587. <dt><samp>-dts_delta_threshold</samp></dt>
  1588. <dd><p>Timestamp discontinuity delta threshold.
  1589. </p></dd>
  1590. <dt><samp>-muxdelay <var>seconds</var> (<em>input</em>)</samp></dt>
  1591. <dd><p>Set the maximum demux-decode delay.
  1592. </p></dd>
  1593. <dt><samp>-muxpreload <var>seconds</var> (<em>input</em>)</samp></dt>
  1594. <dd><p>Set the initial demux-decode delay.
  1595. </p></dd>
  1596. <dt><samp>-streamid <var>output-stream-index</var>:<var>new-value</var> (<em>output</em>)</samp></dt>
  1597. <dd><p>Assign a new stream-id value to an output stream. This option should be
  1598. specified prior to the output filename to which it applies.
  1599. For the situation where multiple output files exist, a streamid
  1600. may be reassigned to a different value.
  1601. </p>
  1602. <p>For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
  1603. an output mpegts file:
  1604. </p><div class="example">
  1605. <pre class="example">ffmpeg -i infile -streamid 0:33 -streamid 1:36 out.ts
  1606. </pre></div>
  1607. </dd>
  1608. <dt><samp>-bsf[:<var>stream_specifier</var>] <var>bitstream_filters</var> (<em>output,per-stream</em>)</samp></dt>
  1609. <dd><p>Set bitstream filters for matching streams. <var>bitstream_filters</var> is
  1610. a comma-separated list of bitstream filters. Use the <code>-bsfs</code> option
  1611. to get the list of bitstream filters.
  1612. </p><div class="example">
  1613. <pre class="example">ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
  1614. </pre></div>
  1615. <div class="example">
  1616. <pre class="example">ffmpeg -i -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
  1617. </pre></div>
  1618. </dd>
  1619. <dt><samp>-tag[:<var>stream_specifier</var>] <var>codec_tag</var> (<em>input/output,per-stream</em>)</samp></dt>
  1620. <dd><p>Force a tag/fourcc for matching streams.
  1621. </p>
  1622. </dd>
  1623. <dt><samp>-timecode <var>hh</var>:<var>mm</var>:<var>ss</var>SEP<var>ff</var></samp></dt>
  1624. <dd><p>Specify Timecode for writing. <var>SEP</var> is &rsquo;:&rsquo; for non drop timecode and &rsquo;;&rsquo;
  1625. (or &rsquo;.&rsquo;) for drop.
  1626. </p><div class="example">
  1627. <pre class="example">ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
  1628. </pre></div>
  1629. <a name="filter_005fcomplex_005foption"></a></dd>
  1630. <dt><samp>-filter_complex <var>filtergraph</var> (<em>global</em>)</samp></dt>
  1631. <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  1632. outputs. For simple graphs &ndash; those with one input and one output of the same
  1633. type &ndash; see the <samp>-filter</samp> options. <var>filtergraph</var> is a description of
  1634. the filtergraph, as described in the &ldquo;Filtergraph syntax&rdquo; section of the
  1635. ffmpeg-filters manual.
  1636. </p>
  1637. <p>Input link labels must refer to input streams using the
  1638. <code>[file_index:stream_specifier]</code> syntax (i.e. the same as <samp>-map</samp>
  1639. uses). If <var>stream_specifier</var> matches multiple streams, the first one will be
  1640. used. An unlabeled input will be connected to the first unused input stream of
  1641. the matching type.
  1642. </p>
  1643. <p>Output link labels are referred to with <samp>-map</samp>. Unlabeled outputs are
  1644. added to the first output file.
  1645. </p>
  1646. <p>Note that with this option it is possible to use only lavfi sources without
  1647. normal input files.
  1648. </p>
  1649. <p>For example, to overlay an image over video
  1650. </p><div class="example">
  1651. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
  1652. '[out]' out.mkv
  1653. </pre></div>
  1654. <p>Here <code>[0:v]</code> refers to the first video stream in the first input file,
  1655. which is linked to the first (main) input of the overlay filter. Similarly the
  1656. first video stream in the second input is linked to the second (overlay) input
  1657. of overlay.
  1658. </p>
  1659. <p>Assuming there is only one video stream in each input file, we can omit input
  1660. labels, so the above is equivalent to
  1661. </p><div class="example">
  1662. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
  1663. '[out]' out.mkv
  1664. </pre></div>
  1665. <p>Furthermore we can omit the output label and the single output from the filter
  1666. graph will be added to the output file automatically, so we can simply write
  1667. </p><div class="example">
  1668. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
  1669. </pre></div>
  1670. <p>To generate 5 seconds of pure red video using lavfi <code>color</code> source:
  1671. </p><div class="example">
  1672. <pre class="example">ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
  1673. </pre></div>
  1674. </dd>
  1675. <dt><samp>-lavfi <var>filtergraph</var> (<em>global</em>)</samp></dt>
  1676. <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  1677. outputs. Equivalent to <samp>-filter_complex</samp>.
  1678. </p>
  1679. </dd>
  1680. <dt><samp>-filter_complex_script <var>filename</var> (<em>global</em>)</samp></dt>
  1681. <dd><p>This option is similar to <samp>-filter_complex</samp>, the only difference is that
  1682. its argument is the name of the file from which a complex filtergraph
  1683. description is to be read.
  1684. </p>
  1685. </dd>
  1686. <dt><samp>-accurate_seek (<em>input</em>)</samp></dt>
  1687. <dd><p>This option enables or disables accurate seeking in input files with the
  1688. <samp>-ss</samp> option. It is enabled by default, so seeking is accurate when
  1689. transcoding. Use <samp>-noaccurate_seek</samp> to disable it, which may be useful
  1690. e.g. when copying some streams and transcoding the others.
  1691. </p>
  1692. </dd>
  1693. <dt><samp>-thread_message_queue <var>size</var> (<em>input</em>)</samp></dt>
  1694. <dd><p>This option sets the maximum number of queued packets when reading from the
  1695. file or device. With low latency / high rate live streams, packets may be
  1696. discarded if they are not read in a timely manner; raising this value can
  1697. avoid it.
  1698. </p>
  1699. </dd>
  1700. <dt><samp>-override_ffserver (<em>global</em>)</samp></dt>
  1701. <dd><p>Overrides the input specifications from <code>ffserver</code>. Using this
  1702. option you can map any input stream to <code>ffserver</code> and control
  1703. many aspects of the encoding from <code>ffmpeg</code>. Without this
  1704. option <code>ffmpeg</code> will transmit to <code>ffserver</code> what is
  1705. requested by <code>ffserver</code>.
  1706. </p>
  1707. <p>The option is intended for cases where features are needed that cannot be
  1708. specified to <code>ffserver</code> but can be to <code>ffmpeg</code>.
  1709. </p>
  1710. </dd>
  1711. <dt><samp>-sdp_file <var>file</var> (<em>global</em>)</samp></dt>
  1712. <dd><p>Print sdp information to <var>file</var>.
  1713. This allows dumping sdp information when at least one output isn&rsquo;t an
  1714. rtp stream.
  1715. </p>
  1716. </dd>
  1717. <dt><samp>-discard (<em>input</em>)</samp></dt>
  1718. <dd><p>Allows discarding specific streams or frames of streams at the demuxer.
  1719. Not all demuxers support this.
  1720. </p>
  1721. <dl compact="compact">
  1722. <dt><samp>none</samp></dt>
  1723. <dd><p>Discard no frame.
  1724. </p>
  1725. </dd>
  1726. <dt><samp>default</samp></dt>
  1727. <dd><p>Default, which discards no frames.
  1728. </p>
  1729. </dd>
  1730. <dt><samp>noref</samp></dt>
  1731. <dd><p>Discard all non-reference frames.
  1732. </p>
  1733. </dd>
  1734. <dt><samp>bidir</samp></dt>
  1735. <dd><p>Discard all bidirectional frames.
  1736. </p>
  1737. </dd>
  1738. <dt><samp>nokey</samp></dt>
  1739. <dd><p>Discard all frames excepts keyframes.
  1740. </p>
  1741. </dd>
  1742. <dt><samp>all</samp></dt>
  1743. <dd><p>Discard all frames.
  1744. </p></dd>
  1745. </dl>
  1746. </dd>
  1747. </dl>
  1748. <p>As a special exception, you can use a bitmap subtitle stream as input: it
  1749. will be converted into a video with the same size as the largest video in
  1750. the file, or 720x576 if no video is present. Note that this is an
  1751. experimental and temporary solution. It will be removed once libavfilter has
  1752. proper support for subtitles.
  1753. </p>
  1754. <p>For example, to hardcode subtitles on top of a DVB-T recording stored in
  1755. MPEG-TS format, delaying the subtitles by 1 second:
  1756. </p><div class="example">
  1757. <pre class="example">ffmpeg -i input.ts -filter_complex \
  1758. '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
  1759. -sn -map '#0x2dc' output.mkv
  1760. </pre></div>
  1761. <p>(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
  1762. audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
  1763. </p>
  1764. <a name="Preset-files"></a>
  1765. <h3 class="section">5.12 Preset files<span class="pull-right"><a class="anchor hidden-xs" href="#Preset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Preset-files" aria-hidden="true">TOC</a></span></h3>
  1766. <p>A preset file contains a sequence of <var>option</var>=<var>value</var> pairs,
  1767. one for each line, specifying a sequence of options which would be
  1768. awkward to specify on the command line. Lines starting with the hash
  1769. (&rsquo;#&rsquo;) character are ignored and are used to provide comments. Check
  1770. the <samp>presets</samp> directory in the FFmpeg source tree for examples.
  1771. </p>
  1772. <p>There are two types of preset files: ffpreset and avpreset files.
  1773. </p>
  1774. <a name="ffpreset-files"></a>
  1775. <h4 class="subsection">5.12.1 ffpreset files<span class="pull-right"><a class="anchor hidden-xs" href="#ffpreset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-ffpreset-files" aria-hidden="true">TOC</a></span></h4>
  1776. <p>ffpreset files are specified with the <code>vpre</code>, <code>apre</code>,
  1777. <code>spre</code>, and <code>fpre</code> options. The <code>fpre</code> option takes the
  1778. filename of the preset instead of a preset name as input and can be
  1779. used for any kind of codec. For the <code>vpre</code>, <code>apre</code>, and
  1780. <code>spre</code> options, the options specified in a preset file are
  1781. applied to the currently selected codec of the same type as the preset
  1782. option.
  1783. </p>
  1784. <p>The argument passed to the <code>vpre</code>, <code>apre</code>, and <code>spre</code>
  1785. preset options identifies the preset file to use according to the
  1786. following rules:
  1787. </p>
  1788. <p>First ffmpeg searches for a file named <var>arg</var>.ffpreset in the
  1789. directories <samp>$FFMPEG_DATADIR</samp> (if set), and <samp>$HOME/.ffmpeg</samp>, and in
  1790. the datadir defined at configuration time (usually <samp>PREFIX/share/ffmpeg</samp>)
  1791. or in a <samp>ffpresets</samp> folder along the executable on win32,
  1792. in that order. For example, if the argument is <code>libvpx-1080p</code>, it will
  1793. search for the file <samp>libvpx-1080p.ffpreset</samp>.
  1794. </p>
  1795. <p>If no such file is found, then ffmpeg will search for a file named
  1796. <var>codec_name</var>-<var>arg</var>.ffpreset in the above-mentioned
  1797. directories, where <var>codec_name</var> is the name of the codec to which
  1798. the preset file options will be applied. For example, if you select
  1799. the video codec with <code>-vcodec libvpx</code> and use <code>-vpre 1080p</code>,
  1800. then it will search for the file <samp>libvpx-1080p.ffpreset</samp>.
  1801. </p>
  1802. <a name="avpreset-files"></a>
  1803. <h4 class="subsection">5.12.2 avpreset files<span class="pull-right"><a class="anchor hidden-xs" href="#avpreset-files" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-avpreset-files" aria-hidden="true">TOC</a></span></h4>
  1804. <p>avpreset files are specified with the <code>pre</code> option. They work similar to
  1805. ffpreset files, but they only allow encoder- specific options. Therefore, an
  1806. <var>option</var>=<var>value</var> pair specifying an encoder cannot be used.
  1807. </p>
  1808. <p>When the <code>pre</code> option is specified, ffmpeg will look for files with the
  1809. suffix .avpreset in the directories <samp>$AVCONV_DATADIR</samp> (if set), and
  1810. <samp>$HOME/.avconv</samp>, and in the datadir defined at configuration time (usually
  1811. <samp>PREFIX/share/ffmpeg</samp>), in that order.
  1812. </p>
  1813. <p>First ffmpeg searches for a file named <var>codec_name</var>-<var>arg</var>.avpreset in
  1814. the above-mentioned directories, where <var>codec_name</var> is the name of the codec
  1815. to which the preset file options will be applied. For example, if you select the
  1816. video codec with <code>-vcodec libvpx</code> and use <code>-pre 1080p</code>, then it will
  1817. search for the file <samp>libvpx-1080p.avpreset</samp>.
  1818. </p>
  1819. <p>If no such file is found, then ffmpeg will search for a file named
  1820. <var>arg</var>.avpreset in the same directories.
  1821. </p>
  1822. <a name="Tips"></a>
  1823. <h2 class="chapter">6 Tips<span class="pull-right"><a class="anchor hidden-xs" href="#Tips" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Tips" aria-hidden="true">TOC</a></span></h2>
  1824. <ul>
  1825. <li> For streaming at very low bitrates, use a low frame rate
  1826. and a small GOP size. This is especially true for RealVideo where
  1827. the Linux player does not seem to be very fast, so it can miss
  1828. frames. An example is:
  1829. <div class="example">
  1830. <pre class="example">ffmpeg -g 3 -r 3 -t 10 -b:v 50k -s qcif -f rv10 /tmp/b.rm
  1831. </pre></div>
  1832. </li><li> The parameter &rsquo;q&rsquo; which is displayed while encoding is the current
  1833. quantizer. The value 1 indicates that a very good quality could
  1834. be achieved. The value 31 indicates the worst quality. If q=31 appears
  1835. too often, it means that the encoder cannot compress enough to meet
  1836. your bitrate. You must either increase the bitrate, decrease the
  1837. frame rate or decrease the frame size.
  1838. </li><li> If your computer is not fast enough, you can speed up the
  1839. compression at the expense of the compression ratio. You can use
  1840. &rsquo;-me zero&rsquo; to speed up motion estimation, and &rsquo;-g 0&rsquo; to disable
  1841. motion estimation completely (you have only I-frames, which means it
  1842. is about as good as JPEG compression).
  1843. </li><li> To have very low audio bitrates, reduce the sampling frequency
  1844. (down to 22050 Hz for MPEG audio, 22050 or 11025 for AC-3).
  1845. </li><li> To have a constant quality (but a variable bitrate), use the option
  1846. &rsquo;-qscale n&rsquo; when &rsquo;n&rsquo; is between 1 (excellent quality) and 31 (worst
  1847. quality).
  1848. </li></ul>
  1849. <a name="Examples"></a>
  1850. <h2 class="chapter">7 Examples<span class="pull-right"><a class="anchor hidden-xs" href="#Examples" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Examples" aria-hidden="true">TOC</a></span></h2>
  1851. <a name="Video-and-Audio-grabbing"></a>
  1852. <h3 class="section">7.1 Video and Audio grabbing<span class="pull-right"><a class="anchor hidden-xs" href="#Video-and-Audio-grabbing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-and-Audio-grabbing" aria-hidden="true">TOC</a></span></h3>
  1853. <p>If you specify the input format and device then ffmpeg can grab video
  1854. and audio directly.
  1855. </p>
  1856. <div class="example">
  1857. <pre class="example">ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  1858. </pre></div>
  1859. <p>Or with an ALSA audio source (mono input, card id 1) instead of OSS:
  1860. </p><div class="example">
  1861. <pre class="example">ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
  1862. </pre></div>
  1863. <p>Note that you must activate the right video source and channel before
  1864. launching ffmpeg with any TV viewer such as
  1865. <a href="">xawtv</a> by Gerd Knorr. You also
  1866. have to set the audio recording levels correctly with a
  1867. standard mixer.
  1868. </p>
  1869. <a name="X11-grabbing"></a>
  1870. <h3 class="section">7.2 X11 grabbing<span class="pull-right"><a class="anchor hidden-xs" href="#X11-grabbing" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-X11-grabbing" aria-hidden="true">TOC</a></span></h3>
  1871. <p>Grab the X11 display with ffmpeg via
  1872. </p>
  1873. <div class="example">
  1874. <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
  1875. </pre></div>
  1876. <p>0.0 is display.screen number of your X11 server, same as
  1877. the DISPLAY environment variable.
  1878. </p>
  1879. <div class="example">
  1880. <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
  1881. </pre></div>
  1882. <p>0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  1883. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  1884. </p>
  1885. <a name="Video-and-Audio-file-format-conversion"></a>
  1886. <h3 class="section">7.3 Video and Audio file format conversion<span class="pull-right"><a class="anchor hidden-xs" href="#Video-and-Audio-file-format-conversion" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Video-and-Audio-file-format-conversion" aria-hidden="true">TOC</a></span></h3>
  1887. <p>Any supported file format and protocol can serve as input to ffmpeg:
  1888. </p>
  1889. <p>Examples:
  1890. </p><ul>
  1891. <li> You can use YUV files as input:
  1892. <div class="example">
  1893. <pre class="example">ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  1894. </pre></div>
  1895. <p>It will use the files:
  1896. </p><div class="example">
  1897. <pre class="example">/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  1898. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  1899. </pre></div>
  1900. <p>The Y files use twice the resolution of the U and V files. They are
  1901. raw files, without header. They can be generated by all decent video
  1902. decoders. You must specify the size of the image with the <samp>-s</samp> option
  1903. if ffmpeg cannot guess it.
  1904. </p>
  1905. </li><li> You can input from a raw YUV420P file:
  1906. <div class="example">
  1907. <pre class="example">ffmpeg -i /tmp/test.yuv /tmp/out.avi
  1908. </pre></div>
  1909. <p>test.yuv is a file containing raw YUV planar data. Each frame is composed
  1910. of the Y plane followed by the U and V planes at half vertical and
  1911. horizontal resolution.
  1912. </p>
  1913. </li><li> You can output to a raw YUV420P file:
  1914. <div class="example">
  1915. <pre class="example">ffmpeg -i mydivx.avi hugefile.yuv
  1916. </pre></div>
  1917. </li><li> You can set several input files and output files:
  1918. <div class="example">
  1919. <pre class="example">ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  1920. </pre></div>
  1921. <p>Converts the audio file a.wav and the raw YUV video file a.yuv
  1922. to MPEG file a.mpg.
  1923. </p>
  1924. </li><li> You can also do audio and video conversions at the same time:
  1925. <div class="example">
  1926. <pre class="example">ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  1927. </pre></div>
  1928. <p>Converts a.wav to MPEG audio at 22050 Hz sample rate.
  1929. </p>
  1930. </li><li> You can encode to several formats at the same time and define a
  1931. mapping from input stream to output streams:
  1932. <div class="example">
  1933. <pre class="example">ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
  1934. </pre></div>
  1935. <p>Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. &rsquo;-map
  1936. file:index&rsquo; specifies which input stream is used for each output
  1937. stream, in the order of the definition of output streams.
  1938. </p>
  1939. </li><li> You can transcode decrypted VOBs:
  1940. <div class="example">
  1941. <pre class="example">ffmpeg -i snatch_1.vob -f avi -c:v mpeg4 -b:v 800k -g 300 -bf 2 -c:a libmp3lame -b:a 128k snatch.avi
  1942. </pre></div>
  1943. <p>This is a typical DVD ripping example; the input is a VOB file, the
  1944. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  1945. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  1946. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  1947. input video. Furthermore, the audio stream is MP3-encoded so you need
  1948. to enable LAME support by passing <code>--enable-libmp3lame</code> to configure.
  1949. The mapping is particularly useful for DVD transcoding
  1950. to get the desired audio language.
  1951. </p>
  1952. <p>NOTE: To see the supported input formats, use <code>ffmpeg -formats</code>.
  1953. </p>
  1954. </li><li> You can extract images from a video, or create a video from many images:
  1955. <p>For extracting images from a video:
  1956. </p><div class="example">
  1957. <pre class="example">ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  1958. </pre></div>
  1959. <p>This will extract one video frame per second from the video and will
  1960. output them in files named <samp>foo-001.jpeg</samp>, <samp>foo-002.jpeg</samp>,
  1961. etc. Images will be rescaled to fit the new WxH values.
  1962. </p>
  1963. <p>If you want to extract just a limited number of frames, you can use the
  1964. above command in combination with the -vframes or -t option, or in
  1965. combination with -ss to start extracting from a certain point in time.
  1966. </p>
  1967. <p>For creating a video from many images:
  1968. </p><div class="example">
  1969. <pre class="example">ffmpeg -f image2 -i foo-%03d.jpeg -r 12 -s WxH foo.avi
  1970. </pre></div>
  1971. <p>The syntax <code>foo-%03d.jpeg</code> specifies to use a decimal number
  1972. composed of three digits padded with zeroes to express the sequence
  1973. number. It is the same syntax supported by the C printf function, but
  1974. only formats accepting a normal integer are suitable.
  1975. </p>
  1976. <p>When importing an image sequence, -i also supports expanding
  1977. shell-like wildcard patterns (globbing) internally, by selecting the
  1978. image2-specific <code>-pattern_type glob</code> option.
  1979. </p>
  1980. <p>For example, for creating a video from filenames matching the glob pattern
  1981. <code>foo-*.jpeg</code>:
  1982. </p><div class="example">
  1983. <pre class="example">ffmpeg -f image2 -pattern_type glob -i 'foo-*.jpeg' -r 12 -s WxH foo.avi
  1984. </pre></div>
  1985. </li><li> You can put many streams of the same type in the output:
  1986. <div class="example">
  1987. <pre class="example">ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
  1988. </pre></div>
  1989. <p>The resulting output file <samp>test12.nut</samp> will contain the first four streams
  1990. from the input files in reverse order.
  1991. </p>
  1992. </li><li> To force CBR video output:
  1993. <div class="example">
  1994. <pre class="example">ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
  1995. </pre></div>
  1996. </li><li> The four options lmin, lmax, mblmin and mblmax use &rsquo;lambda&rsquo; units,
  1997. but you may use the QP2LAMBDA constant to easily convert from &rsquo;q&rsquo; units:
  1998. <div class="example">
  1999. <pre class="example">ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  2000. </pre></div>
  2001. </li></ul>
  2002. <a name="See-Also"></a>
  2003. <h2 class="chapter">8 See Also<span class="pull-right"><a class="anchor hidden-xs" href="#See-Also" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-See-Also" aria-hidden="true">TOC</a></span></h2>
  2004. <p><a href="ffmpeg-all.html">ffmpeg-all</a>,
  2005. <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>, <a href="ffserver.html">ffserver</a>,
  2006. <a href="ffmpeg-utils.html">ffmpeg-utils</a>,
  2007. <a href="ffmpeg-scaler.html">ffmpeg-scaler</a>,
  2008. <a href="ffmpeg-resampler.html">ffmpeg-resampler</a>,
  2009. <a href="ffmpeg-codecs.html">ffmpeg-codecs</a>,
  2010. <a href="ffmpeg-bitstream-filters.html">ffmpeg-bitstream-filters</a>,
  2011. <a href="ffmpeg-formats.html">ffmpeg-formats</a>,
  2012. <a href="ffmpeg-devices.html">ffmpeg-devices</a>,
  2013. <a href="ffmpeg-protocols.html">ffmpeg-protocols</a>,
  2014. <a href="ffmpeg-filters.html">ffmpeg-filters</a>
  2015. </p>
  2016. <a name="Authors"></a>
  2017. <h2 class="chapter">9 Authors<span class="pull-right"><a class="anchor hidden-xs" href="#Authors" aria-hidden="true">#</a> <a class="anchor hidden-xs"href="#toc-Authors" aria-hidden="true">TOC</a></span></h2>
  2018. <p>The FFmpeg developers.
  2019. </p>
  2020. <p>For details about the authorship, see the Git history of the project
  2021. (git://, e.g. by typing the command
  2022. <code>git log</code> in the FFmpeg source directory, or browsing the
  2023. online repository at <a href=""></a>.
  2024. </p>
  2025. <p>Maintainers for the specific components are listed in the file
  2026. <samp>MAINTAINERS</samp> in the source code tree.
  2027. </p>
  2028. <p style="font-size: small;">
  2029. This document was generated using <a href=""><em>makeinfo</em></a>.
  2030. </p>
  2031. </div>
  2032. </body>
  2033. </html>