星火直播PC
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 122KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  6. <title>FFmpeg documentation</title>
  7. <link rel="stylesheet" href="bootstrap.min.css" />
  8. <link rel="stylesheet" href="style.min.css" />
  9. <meta name="description" content="ffmpeg Documentation: ">
  10. <meta name="keywords" content="FFmpeg documentation : ffmpeg ">
  11. <meta name="Generator" content="texi2html 5.0">
  12. <!-- Created on March 9, 2020 by texi2html 5.0 -->
  13. <!--
  14. texi2html was written by:
  15. Lionel Cons <Lionel.Cons@cern.ch> (original author)
  16. Karl Berry <karl@freefriends.org>
  17. Olaf Bachmann <obachman@mathematik.uni-kl.de>
  18. and many others.
  19. Maintained by: Many creative people.
  20. Send bugs and suggestions to <texi2html-bug@nongnu.org>
  21. -->
  22. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  23. </head>
  24. <body>
  25. <div class="container">
  26. <h1 class="titlefont">ffmpeg Documentation</h1>
  27. <hr>
  28. <a name="SEC_Top"></a>
  29. <a name="SEC_Contents"></a>
  30. <h1>Table of Contents</h1>
  31. <div class="contents">
  32. <ul class="no-bullet">
  33. <li><a name="toc-Synopsis" href="#Synopsis">1 Synopsis</a></li>
  34. <li><a name="toc-Description-1" href="#Description-1">2 Description</a></li>
  35. <li><a name="toc-Detailed-description" href="#Detailed-description">3 Detailed description</a>
  36. <ul class="no-bullet">
  37. <li><a name="toc-Filtering" href="#Filtering">3.1 Filtering</a>
  38. <ul class="no-bullet">
  39. <li><a name="toc-Simple-filtergraphs" href="#Simple-filtergraphs">3.1.1 Simple filtergraphs</a></li>
  40. <li><a name="toc-Complex-filtergraphs" href="#Complex-filtergraphs">3.1.2 Complex filtergraphs</a></li>
  41. </ul></li>
  42. <li><a name="toc-Stream-copy" href="#Stream-copy">3.2 Stream copy</a></li>
  43. </ul></li>
  44. <li><a name="toc-Stream-selection" href="#Stream-selection">4 Stream selection</a>
  45. <ul class="no-bullet">
  46. <li><a name="toc-Description" href="#Description">4.1 Description</a>
  47. <ul class="no-bullet">
  48. <li><a name="toc-Automatic-stream-selection" href="#Automatic-stream-selection">4.1.1 Automatic stream selection</a></li>
  49. <li><a name="toc-Manual-stream-selection" href="#Manual-stream-selection">4.1.2 Manual stream selection</a></li>
  50. <li><a name="toc-Complex-filtergraphs-1" href="#Complex-filtergraphs-1">4.1.3 Complex filtergraphs</a></li>
  51. <li><a name="toc-Stream-handling" href="#Stream-handling">4.1.4 Stream handling</a></li>
  52. </ul></li>
  53. <li><a name="toc-Examples-1" href="#Examples-1">4.2 Examples</a></li>
  54. </ul></li>
  55. <li><a name="toc-Options" href="#Options">5 Options</a>
  56. <ul class="no-bullet">
  57. <li><a name="toc-Stream-specifiers-1" href="#Stream-specifiers-1">5.1 Stream specifiers</a></li>
  58. <li><a name="toc-Generic-options" href="#Generic-options">5.2 Generic options</a></li>
  59. <li><a name="toc-AVOptions" href="#AVOptions">5.3 AVOptions</a></li>
  60. <li><a name="toc-Main-options" href="#Main-options">5.4 Main options</a></li>
  61. <li><a name="toc-Video-Options" href="#Video-Options">5.5 Video Options</a></li>
  62. <li><a name="toc-Advanced-Video-options" href="#Advanced-Video-options">5.6 Advanced Video options</a></li>
  63. <li><a name="toc-Audio-Options" href="#Audio-Options">5.7 Audio Options</a></li>
  64. <li><a name="toc-Advanced-Audio-options" href="#Advanced-Audio-options">5.8 Advanced Audio options</a></li>
  65. <li><a name="toc-Subtitle-options" href="#Subtitle-options">5.9 Subtitle options</a></li>
  66. <li><a name="toc-Advanced-Subtitle-options" href="#Advanced-Subtitle-options">5.10 Advanced Subtitle options</a></li>
  67. <li><a name="toc-Advanced-options" href="#Advanced-options">5.11 Advanced options</a></li>
  68. <li><a name="toc-Preset-files" href="#Preset-files">5.12 Preset files</a>
  69. <ul class="no-bullet">
  70. <li><a name="toc-ffpreset-files" href="#ffpreset-files">5.12.1 ffpreset files</a></li>
  71. <li><a name="toc-avpreset-files" href="#avpreset-files">5.12.2 avpreset files</a></li>
  72. </ul>
  73. </li>
  74. </ul></li>
  75. <li><a name="toc-Examples" href="#Examples">6 Examples</a>
  76. <ul class="no-bullet">
  77. <li><a name="toc-Video-and-Audio-grabbing" href="#Video-and-Audio-grabbing">6.1 Video and Audio grabbing</a></li>
  78. <li><a name="toc-X11-grabbing" href="#X11-grabbing">6.2 X11 grabbing</a></li>
  79. <li><a name="toc-Video-and-Audio-file-format-conversion" href="#Video-and-Audio-file-format-conversion">6.3 Video and Audio file format conversion</a></li>
  80. </ul></li>
  81. <li><a name="toc-See-Also" href="#See-Also">7 See Also</a></li>
  82. <li><a name="toc-Authors" href="#Authors">8 Authors</a></li>
  83. </ul>
  84. </div>
  85. <hr size="6">
  86. <a name="Synopsis"></a>
  87. <h1 class="chapter"><a href="ffmpeg.html#toc-Synopsis">1 Synopsis</a></h1>
  88. <p>ffmpeg [<var>global_options</var>] {[<var>input_file_options</var>] -i &lsquo;<tt>input_url</tt>&rsquo;} ... {[<var>output_file_options</var>] &lsquo;<tt>output_url</tt>&rsquo;} ...
  89. </p>
  90. <a name="Description-1"></a>
  91. <h1 class="chapter"><a href="ffmpeg.html#toc-Description-1">2 Description</a></h1>
  92. <p><code>ffmpeg</code> is a very fast video and audio converter that can also grab from
  93. a live audio/video source. It can also convert between arbitrary sample
  94. rates and resize video on the fly with a high quality polyphase filter.
  95. </p>
  96. <p><code>ffmpeg</code> reads from an arbitrary number of input &quot;files&quot; (which can be regular
  97. files, pipes, network streams, grabbing devices, etc.), specified by the
  98. <code>-i</code> option, and writes to an arbitrary number of output &quot;files&quot;, which are
  99. specified by a plain output url. Anything found on the command line which
  100. cannot be interpreted as an option is considered to be an output url.
  101. </p>
  102. <p>Each input or output url can, in principle, contain any number of streams of
  103. different types (video/audio/subtitle/attachment/data). The allowed number and/or
  104. types of streams may be limited by the container format. Selecting which
  105. streams from which inputs will go into which output is either done automatically
  106. or with the <code>-map</code> option (see the Stream selection chapter).
  107. </p>
  108. <p>To refer to input files in options, you must use their indices (0-based). E.g.
  109. the first input file is <code>0</code>, the second is <code>1</code>, etc. Similarly, streams
  110. within a file are referred to by their indices. E.g. <code>2:3</code> refers to the
  111. fourth stream in the third input file. Also see the Stream specifiers chapter.
  112. </p>
  113. <p>As a general rule, options are applied to the next specified
  114. file. Therefore, order is important, and you can have the same
  115. option on the command line multiple times. Each occurrence is
  116. then applied to the next input or output file.
  117. Exceptions from this rule are the global options (e.g. verbosity level),
  118. which should be specified first.
  119. </p>
  120. <p>Do not mix input and output files &ndash; first specify all input files, then all
  121. output files. Also do not mix options which belong to different files. All
  122. options apply ONLY to the next input or output file and are reset between files.
  123. </p>
  124. <ul>
  125. <li>
  126. To set the video bitrate of the output file to 64 kbit/s:
  127. <div class="example">
  128. <pre class="example">ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
  129. </pre></div>
  130. </li><li>
  131. To force the frame rate of the output file to 24 fps:
  132. <div class="example">
  133. <pre class="example">ffmpeg -i input.avi -r 24 output.avi
  134. </pre></div>
  135. </li><li>
  136. To force the frame rate of the input file (valid for raw formats only)
  137. to 1 fps and the frame rate of the output file to 24 fps:
  138. <div class="example">
  139. <pre class="example">ffmpeg -r 1 -i input.m2v -r 24 output.avi
  140. </pre></div>
  141. </li></ul>
  142. <p>The format option may be needed for raw input files.
  143. </p>
  144. <a name="Detailed-description"></a>
  145. <h1 class="chapter"><a href="ffmpeg.html#toc-Detailed-description">3 Detailed description</a></h1>
  146. <p>The transcoding process in <code>ffmpeg</code> for each output can be described by
  147. the following diagram:
  148. </p>
  149. <pre class="verbatim"> _______ ______________
  150. | | | |
  151. | input | demuxer | encoded data | decoder
  152. | file | ---------&gt; | packets | -----+
  153. |_______| |______________| |
  154. v
  155. _________
  156. | |
  157. | decoded |
  158. | frames |
  159. |_________|
  160. ________ ______________ |
  161. | | | | |
  162. | output | &lt;-------- | encoded data | &lt;----+
  163. | file | muxer | packets | encoder
  164. |________| |______________|
  165. </pre>
  166. <p><code>ffmpeg</code> calls the libavformat library (containing demuxers) to read
  167. input files and get packets containing encoded data from them. When there are
  168. multiple input files, <code>ffmpeg</code> tries to keep them synchronized by
  169. tracking lowest timestamp on any active input stream.
  170. </p>
  171. <p>Encoded packets are then passed to the decoder (unless streamcopy is selected
  172. for the stream, see further for a description). The decoder produces
  173. uncompressed frames (raw video/PCM audio/...) which can be processed further by
  174. filtering (see next section). After filtering, the frames are passed to the
  175. encoder, which encodes them and outputs encoded packets. Finally those are
  176. passed to the muxer, which writes the encoded packets to the output file.
  177. </p>
  178. <a name="Filtering"></a>
  179. <h2 class="section"><a href="ffmpeg.html#toc-Filtering">3.1 Filtering</a></h2>
  180. <p>Before encoding, <code>ffmpeg</code> can process raw audio and video frames using
  181. filters from the libavfilter library. Several chained filters form a filter
  182. graph. <code>ffmpeg</code> distinguishes between two types of filtergraphs:
  183. simple and complex.
  184. </p>
  185. <a name="Simple-filtergraphs"></a>
  186. <h3 class="subsection"><a href="ffmpeg.html#toc-Simple-filtergraphs">3.1.1 Simple filtergraphs</a></h3>
  187. <p>Simple filtergraphs are those that have exactly one input and output, both of
  188. the same type. In the above diagram they can be represented by simply inserting
  189. an additional step between decoding and encoding:
  190. </p>
  191. <pre class="verbatim"> _________ ______________
  192. | | | |
  193. | decoded | | encoded data |
  194. | frames |\ _ | packets |
  195. |_________| \ /||______________|
  196. \ __________ /
  197. simple _\|| | / encoder
  198. filtergraph | filtered |/
  199. | frames |
  200. |__________|
  201. </pre>
  202. <p>Simple filtergraphs are configured with the per-stream &lsquo;<samp>-filter</samp>&rsquo; option
  203. (with &lsquo;<samp>-vf</samp>&rsquo; and &lsquo;<samp>-af</samp>&rsquo; aliases for video and audio respectively).
  204. A simple filtergraph for video can look for example like this:
  205. </p>
  206. <pre class="verbatim"> _______ _____________ _______ ________
  207. | | | | | | | |
  208. | input | ---&gt; | deinterlace | ---&gt; | scale | ---&gt; | output |
  209. |_______| |_____________| |_______| |________|
  210. </pre>
  211. <p>Note that some filters change frame properties but not frame contents. E.g. the
  212. <code>fps</code> filter in the example above changes number of frames, but does not
  213. touch the frame contents. Another example is the <code>setpts</code> filter, which
  214. only sets timestamps and otherwise passes the frames unchanged.
  215. </p>
  216. <a name="Complex-filtergraphs"></a>
  217. <h3 class="subsection"><a href="ffmpeg.html#toc-Complex-filtergraphs">3.1.2 Complex filtergraphs</a></h3>
  218. <p>Complex filtergraphs are those which cannot be described as simply a linear
  219. processing chain applied to one stream. This is the case, for example, when the graph has
  220. more than one input and/or output, or when output stream type is different from
  221. input. They can be represented with the following diagram:
  222. </p>
  223. <pre class="verbatim"> _________
  224. | |
  225. | input 0 |\ __________
  226. |_________| \ | |
  227. \ _________ /| output 0 |
  228. \ | | / |__________|
  229. _________ \| complex | /
  230. | | | |/
  231. | input 1 |----&gt;| filter |\
  232. |_________| | | \ __________
  233. /| graph | \ | |
  234. / | | \| output 1 |
  235. _________ / |_________| |__________|
  236. | | /
  237. | input 2 |/
  238. |_________|
  239. </pre>
  240. <p>Complex filtergraphs are configured with the &lsquo;<samp>-filter_complex</samp>&rsquo; option.
  241. Note that this option is global, since a complex filtergraph, by its nature,
  242. cannot be unambiguously associated with a single stream or file.
  243. </p>
  244. <p>The &lsquo;<samp>-lavfi</samp>&rsquo; option is equivalent to &lsquo;<samp>-filter_complex</samp>&rsquo;.
  245. </p>
  246. <p>A trivial example of a complex filtergraph is the <code>overlay</code> filter, which
  247. has two video inputs and one video output, containing one video overlaid on top
  248. of the other. Its audio counterpart is the <code>amix</code> filter.
  249. </p>
  250. <a name="Stream-copy"></a>
  251. <h2 class="section"><a href="ffmpeg.html#toc-Stream-copy">3.2 Stream copy</a></h2>
  252. <p>Stream copy is a mode selected by supplying the <code>copy</code> parameter to the
  253. &lsquo;<samp>-codec</samp>&rsquo; option. It makes <code>ffmpeg</code> omit the decoding and encoding
  254. step for the specified stream, so it does only demuxing and muxing. It is useful
  255. for changing the container format or modifying container-level metadata. The
  256. diagram above will, in this case, simplify to this:
  257. </p>
  258. <pre class="verbatim"> _______ ______________ ________
  259. | | | | | |
  260. | input | demuxer | encoded data | muxer | output |
  261. | file | ---------&gt; | packets | -------&gt; | file |
  262. |_______| |______________| |________|
  263. </pre>
  264. <p>Since there is no decoding or encoding, it is very fast and there is no quality
  265. loss. However, it might not work in some cases because of many factors. Applying
  266. filters is obviously also impossible, since filters work on uncompressed data.
  267. </p>
  268. <a name="Stream-selection"></a>
  269. <h1 class="chapter"><a href="ffmpeg.html#toc-Stream-selection">4 Stream selection</a></h1>
  270. <p><code>ffmpeg</code> provides the <code>-map</code> option for manual control of stream selection in each
  271. output file. Users can skip <code>-map</code> and let ffmpeg perform automatic stream selection as
  272. described below. The <code>-vn / -an / -sn / -dn</code> options can be used to skip inclusion of
  273. video, audio, subtitle and data streams respectively, whether manually mapped or automatically
  274. selected, except for those streams which are outputs of complex filtergraphs.
  275. </p>
  276. <a name="Description"></a>
  277. <h2 class="section"><a href="ffmpeg.html#toc-Description">4.1 Description</a></h2>
  278. <p>The sub-sections that follow describe the various rules that are involved in stream selection.
  279. The examples that follow next show how these rules are applied in practice.
  280. </p>
  281. <p>While every effort is made to accurately reflect the behavior of the program, FFmpeg is under
  282. continuous development and the code may have changed since the time of this writing.
  283. </p>
  284. <a name="Automatic-stream-selection"></a>
  285. <h3 class="subsection"><a href="ffmpeg.html#toc-Automatic-stream-selection">4.1.1 Automatic stream selection</a></h3>
  286. <p>In the absence of any map options for a particular output file, ffmpeg inspects the output
  287. format to check which type of streams can be included in it, viz. video, audio and/or
  288. subtitles. For each acceptable stream type, ffmpeg will pick one stream, when available,
  289. from among all the inputs.
  290. </p>
  291. <p>It will select that stream based upon the following criteria:
  292. </p><ul>
  293. <li>
  294. for video, it is the stream with the highest resolution,
  295. </li><li>
  296. for audio, it is the stream with the most channels,
  297. </li><li>
  298. for subtitles, it is the first subtitle stream found but there&rsquo;s a caveat.
  299. The output format&rsquo;s default subtitle encoder can be either text-based or image-based,
  300. and only a subtitle stream of the same type will be chosen.
  301. </li></ul>
  302. <p>In the case where several streams of the same type rate equally, the stream with the lowest
  303. index is chosen.
  304. </p>
  305. <p>Data or attachment streams are not automatically selected and can only be included
  306. using <code>-map</code>.
  307. </p><a name="Manual-stream-selection"></a>
  308. <h3 class="subsection"><a href="ffmpeg.html#toc-Manual-stream-selection">4.1.2 Manual stream selection</a></h3>
  309. <p>When <code>-map</code> is used, only user-mapped streams are included in that output file,
  310. with one possible exception for filtergraph outputs described below.
  311. </p>
  312. <a name="Complex-filtergraphs-1"></a>
  313. <h3 class="subsection"><a href="ffmpeg.html#toc-Complex-filtergraphs-1">4.1.3 Complex filtergraphs</a></h3>
  314. <p>If there are any complex filtergraph output streams with unlabeled pads, they will be added
  315. to the first output file. This will lead to a fatal error if the stream type is not supported
  316. by the output format. In the absence of the map option, the inclusion of these streams leads
  317. to the automatic stream selection of their types being skipped. If map options are present,
  318. these filtergraph streams are included in addition to the mapped streams.
  319. </p>
  320. <p>Complex filtergraph output streams with labeled pads must be mapped once and exactly once.
  321. </p>
  322. <a name="Stream-handling"></a>
  323. <h3 class="subsection"><a href="ffmpeg.html#toc-Stream-handling">4.1.4 Stream handling</a></h3>
  324. <p>Stream handling is independent of stream selection, with an exception for subtitles described
  325. below. Stream handling is set via the <code>-codec</code> option addressed to streams within a
  326. specific <em>output</em> file. In particular, codec options are applied by ffmpeg after the
  327. stream selection process and thus do not influence the latter. If no <code>-codec</code> option is
  328. specified for a stream type, ffmpeg will select the default encoder registered by the output
  329. file muxer.
  330. </p>
  331. <p>An exception exists for subtitles. If a subtitle encoder is specified for an output file, the
  332. first subtitle stream found of any type, text or image, will be included. ffmpeg does not validate
  333. if the specified encoder can convert the selected stream or if the converted stream is acceptable
  334. within the output format. This applies generally as well: when the user sets an encoder manually,
  335. the stream selection process cannot check if the encoded stream can be muxed into the output file.
  336. If it cannot, ffmpeg will abort and <em>all</em> output files will fail to be processed.
  337. </p>
  338. <a name="Examples-1"></a>
  339. <h2 class="section"><a href="ffmpeg.html#toc-Examples-1">4.2 Examples</a></h2>
  340. <p>The following examples illustrate the behavior, quirks and limitations of ffmpeg&rsquo;s stream
  341. selection methods.
  342. </p>
  343. <p>They assume the following three input files.
  344. </p>
  345. <pre class="verbatim">
  346. input file 'A.avi'
  347. stream 0: video 640x360
  348. stream 1: audio 2 channels
  349. input file 'B.mp4'
  350. stream 0: video 1920x1080
  351. stream 1: audio 2 channels
  352. stream 2: subtitles (text)
  353. stream 3: audio 5.1 channels
  354. stream 4: subtitles (text)
  355. input file 'C.mkv'
  356. stream 0: video 1280x720
  357. stream 1: audio 2 channels
  358. stream 2: subtitles (image)
  359. </pre>
  360. <a name="Example_003a-automatic-stream-selection"></a>
  361. <h4 class="subsubheading">Example: automatic stream selection</h4>
  362. <div class="example">
  363. <pre class="example">ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov
  364. </pre></div>
  365. <p>There are three output files specified, and for the first two, no <code>-map</code> options
  366. are set, so ffmpeg will select streams for these two files automatically.
  367. </p>
  368. <p>&lsquo;<tt>out1.mkv</tt>&rsquo; is a Matroska container file and accepts video, audio and subtitle streams,
  369. so ffmpeg will try to select one of each type.<br>
  370. For video, it will select <code>stream 0</code> from &lsquo;<tt>B.mp4</tt>&rsquo;, which has the highest
  371. resolution among all the input video streams.<br>
  372. For audio, it will select <code>stream 3</code> from &lsquo;<tt>B.mp4</tt>&rsquo;, since it has the greatest
  373. number of channels.<br>
  374. For subtitles, it will select <code>stream 2</code> from &lsquo;<tt>B.mp4</tt>&rsquo;, which is the first subtitle
  375. stream from among &lsquo;<tt>A.avi</tt>&rsquo; and &lsquo;<tt>B.mp4</tt>&rsquo;.
  376. </p>
  377. <p>&lsquo;<tt>out2.wav</tt>&rsquo; accepts only audio streams, so only <code>stream 3</code> from &lsquo;<tt>B.mp4</tt>&rsquo; is
  378. selected.
  379. </p>
  380. <p>For &lsquo;<tt>out3.mov</tt>&rsquo;, since a <code>-map</code> option is set, no automatic stream selection will
  381. occur. The <code>-map 1:a</code> option will select all audio streams from the second input
  382. &lsquo;<tt>B.mp4</tt>&rsquo;. No other streams will be included in this output file.
  383. </p>
  384. <p>For the first two outputs, all included streams will be transcoded. The encoders chosen will
  385. be the default ones registered by each output format, which may not match the codec of the
  386. selected input streams.
  387. </p>
  388. <p>For the third output, codec option for audio streams has been set
  389. to <code>copy</code>, so no decoding-filtering-encoding operations will occur, or <em>can</em> occur.
  390. Packets of selected streams shall be conveyed from the input file and muxed within the output
  391. file.
  392. </p>
  393. <a name="Example_003a-automatic-subtitles-selection"></a>
  394. <h4 class="subsubheading">Example: automatic subtitles selection</h4>
  395. <div class="example">
  396. <pre class="example">ffmpeg -i C.mkv out1.mkv -c:s dvdsub -an out2.mkv
  397. </pre></div>
  398. <p>Although &lsquo;<tt>out1.mkv</tt>&rsquo; is a Matroska container file which accepts subtitle streams, only a
  399. video and audio stream shall be selected. The subtitle stream of &lsquo;<tt>C.mkv</tt>&rsquo; is image-based
  400. and the default subtitle encoder of the Matroska muxer is text-based, so a transcode operation
  401. for the subtitles is expected to fail and hence the stream isn&rsquo;t selected. However, in
  402. &lsquo;<tt>out2.mkv</tt>&rsquo;, a subtitle encoder is specified in the command and so, the subtitle stream is
  403. selected, in addition to the video stream. The presence of <code>-an</code> disables audio stream
  404. selection for &lsquo;<tt>out2.mkv</tt>&rsquo;.
  405. </p>
  406. <a name="Example_003a-unlabeled-filtergraph-outputs"></a>
  407. <h4 class="subsubheading">Example: unlabeled filtergraph outputs</h4>
  408. <div class="example">
  409. <pre class="example">ffmpeg -i A.avi -i C.mkv -i B.mp4 -filter_complex &quot;overlay&quot; out1.mp4 out2.srt
  410. </pre></div>
  411. <p>A filtergraph is setup here using the <code>-filter_complex</code> option and consists of a single
  412. video filter. The <code>overlay</code> filter requires exactly two video inputs, but none are
  413. specified, so the first two available video streams are used, those of &lsquo;<tt>A.avi</tt>&rsquo; and
  414. &lsquo;<tt>C.mkv</tt>&rsquo;. The output pad of the filter has no label and so is sent to the first output file
  415. &lsquo;<tt>out1.mp4</tt>&rsquo;. Due to this, automatic selection of the video stream is skipped, which would
  416. have selected the stream in &lsquo;<tt>B.mp4</tt>&rsquo;. The audio stream with most channels viz. <code>stream 3</code>
  417. in &lsquo;<tt>B.mp4</tt>&rsquo;, is chosen automatically. No subtitle stream is chosen however, since the MP4
  418. format has no default subtitle encoder registered, and the user hasn&rsquo;t specified a subtitle encoder.
  419. </p>
  420. <p>The 2nd output file, &lsquo;<tt>out2.srt</tt>&rsquo;, only accepts text-based subtitle streams. So, even though
  421. the first subtitle stream available belongs to &lsquo;<tt>C.mkv</tt>&rsquo;, it is image-based and hence skipped.
  422. The selected stream, <code>stream 2</code> in &lsquo;<tt>B.mp4</tt>&rsquo;, is the first text-based subtitle stream.
  423. </p>
  424. <a name="Example_003a-labeled-filtergraph-outputs"></a>
  425. <h4 class="subsubheading">Example: labeled filtergraph outputs</h4>
  426. <div class="example">
  427. <pre class="example">ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex &quot;[1:v]hue=s=0[outv];overlay;aresample&quot; \
  428. -map '[outv]' -an out1.mp4 \
  429. out2.mkv \
  430. -map '[outv]' -map 1:a:0 out3.mkv
  431. </pre></div>
  432. <p>The above command will fail, as the output pad labelled <code>[outv]</code> has been mapped twice.
  433. None of the output files shall be processed.
  434. </p>
  435. <div class="example">
  436. <pre class="example">ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex &quot;[1:v]hue=s=0[outv];overlay;aresample&quot; \
  437. -an out1.mp4 \
  438. out2.mkv \
  439. -map 1:a:0 out3.mkv
  440. </pre></div>
  441. <p>This command above will also fail as the hue filter output has a label, <code>[outv]</code>,
  442. and hasn&rsquo;t been mapped anywhere.
  443. </p>
  444. <p>The command should be modified as follows,
  445. </p><div class="example">
  446. <pre class="example">ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex &quot;[1:v]hue=s=0,split=2[outv1][outv2];overlay;aresample&quot; \
  447. -map '[outv1]' -an out1.mp4 \
  448. out2.mkv \
  449. -map '[outv2]' -map 1:a:0 out3.mkv
  450. </pre></div>
  451. <p>The video stream from &lsquo;<tt>B.mp4</tt>&rsquo; is sent to the hue filter, whose output is cloned once using
  452. the split filter, and both outputs labelled. Then a copy each is mapped to the first and third
  453. output files.
  454. </p>
  455. <p>The overlay filter, requiring two video inputs, uses the first two unused video streams. Those
  456. are the streams from &lsquo;<tt>A.avi</tt>&rsquo; and &lsquo;<tt>C.mkv</tt>&rsquo;. The overlay output isn&rsquo;t labelled, so it is
  457. sent to the first output file &lsquo;<tt>out1.mp4</tt>&rsquo;, regardless of the presence of the <code>-map</code> option.
  458. </p>
  459. <p>The aresample filter is sent the first unused audio stream, that of &lsquo;<tt>A.avi</tt>&rsquo;. Since this filter
  460. output is also unlabelled, it too is mapped to the first output file. The presence of <code>-an</code>
  461. only suppresses automatic or manual stream selection of audio streams, not outputs sent from
  462. filtergraphs. Both these mapped streams shall be ordered before the mapped stream in &lsquo;<tt>out1.mp4</tt>&rsquo;.
  463. </p>
  464. <p>The video, audio and subtitle streams mapped to <code>out2.mkv</code> are entirely determined by
  465. automatic stream selection.
  466. </p>
  467. <p>&lsquo;<tt>out3.mkv</tt>&rsquo; consists of the cloned video output from the hue filter and the first audio
  468. stream from &lsquo;<tt>B.mp4</tt>&rsquo;.
  469. <br>
  470. </p>
  471. <a name="Options"></a>
  472. <h1 class="chapter"><a href="ffmpeg.html#toc-Options">5 Options</a></h1>
  473. <p>All the numerical options, if not specified otherwise, accept a string
  474. representing a number as input, which may be followed by one of the SI
  475. unit prefixes, for example: &rsquo;K&rsquo;, &rsquo;M&rsquo;, or &rsquo;G&rsquo;.
  476. </p>
  477. <p>If &rsquo;i&rsquo; is appended to the SI unit prefix, the complete prefix will be
  478. interpreted as a unit prefix for binary multiples, which are based on
  479. powers of 1024 instead of powers of 1000. Appending &rsquo;B&rsquo; to the SI unit
  480. prefix multiplies the value by 8. This allows using, for example:
  481. &rsquo;KB&rsquo;, &rsquo;MiB&rsquo;, &rsquo;G&rsquo; and &rsquo;B&rsquo; as number suffixes.
  482. </p>
  483. <p>Options which do not take arguments are boolean options, and set the
  484. corresponding value to true. They can be set to false by prefixing
  485. the option name with &quot;no&quot;. For example using &quot;-nofoo&quot;
  486. will set the boolean option with name &quot;foo&quot; to false.
  487. </p>
  488. <p><a name="Stream-specifiers"></a>
  489. </p><a name="Stream-specifiers-1"></a>
  490. <h2 class="section"><a href="ffmpeg.html#toc-Stream-specifiers-1">5.1 Stream specifiers</a></h2>
  491. <p>Some options are applied per-stream, e.g. bitrate or codec. Stream specifiers
  492. are used to precisely specify which stream(s) a given option belongs to.
  493. </p>
  494. <p>A stream specifier is a string generally appended to the option name and
  495. separated from it by a colon. E.g. <code>-codec:a:1 ac3</code> contains the
  496. <code>a:1</code> stream specifier, which matches the second audio stream. Therefore, it
  497. would select the ac3 codec for the second audio stream.
  498. </p>
  499. <p>A stream specifier can match several streams, so that the option is applied to all
  500. of them. E.g. the stream specifier in <code>-b:a 128k</code> matches all audio
  501. streams.
  502. </p>
  503. <p>An empty stream specifier matches all streams. For example, <code>-codec copy</code>
  504. or <code>-codec: copy</code> would copy all the streams without reencoding.
  505. </p>
  506. <p>Possible forms of stream specifiers are:
  507. </p><dl compact="compact">
  508. <dt>&lsquo;<samp><var>stream_index</var></samp>&rsquo;</dt>
  509. <dd><p>Matches the stream with this index. E.g. <code>-threads:1 4</code> would set the
  510. thread count for the second stream to 4. If <var>stream_index</var> is used as an
  511. additional stream specifier (see below), then it selects stream number
  512. <var>stream_index</var> from the matching streams. Stream numbering is based on the
  513. order of the streams as detected by libavformat except when a program ID is
  514. also specified. In this case it is based on the ordering of the streams in the
  515. program.
  516. </p></dd>
  517. <dt>&lsquo;<samp><var>stream_type</var>[:<var>additional_stream_specifier</var>]</samp>&rsquo;</dt>
  518. <dd><p><var>stream_type</var> is one of following: &rsquo;v&rsquo; or &rsquo;V&rsquo; for video, &rsquo;a&rsquo; for audio, &rsquo;s&rsquo;
  519. for subtitle, &rsquo;d&rsquo; for data, and &rsquo;t&rsquo; for attachments. &rsquo;v&rsquo; matches all video
  520. streams, &rsquo;V&rsquo; only matches video streams which are not attached pictures, video
  521. thumbnails or cover arts. If <var>additional_stream_specifier</var> is used, then
  522. it matches streams which both have this type and match the
  523. <var>additional_stream_specifier</var>. Otherwise, it matches all streams of the
  524. specified type.
  525. </p></dd>
  526. <dt>&lsquo;<samp>p:<var>program_id</var>[:<var>additional_stream_specifier</var>]</samp>&rsquo;</dt>
  527. <dd><p>Matches streams which are in the program with the id <var>program_id</var>. If
  528. <var>additional_stream_specifier</var> is used, then it matches streams which both
  529. are part of the program and match the <var>additional_stream_specifier</var>.
  530. </p>
  531. </dd>
  532. <dt>&lsquo;<samp>#<var>stream_id</var> or i:<var>stream_id</var></samp>&rsquo;</dt>
  533. <dd><p>Match the stream by stream id (e.g. PID in MPEG-TS container).
  534. </p></dd>
  535. <dt>&lsquo;<samp>m:<var>key</var>[:<var>value</var>]</samp>&rsquo;</dt>
  536. <dd><p>Matches streams with the metadata tag <var>key</var> having the specified value. If
  537. <var>value</var> is not given, matches streams that contain the given tag with any
  538. value.
  539. </p></dd>
  540. <dt>&lsquo;<samp>u</samp>&rsquo;</dt>
  541. <dd><p>Matches streams with usable configuration, the codec must be defined and the
  542. essential information such as video dimension or audio sample rate must be present.
  543. </p>
  544. <p>Note that in <code>ffmpeg</code>, matching by metadata will only work properly for
  545. input files.
  546. </p></dd>
  547. </dl>
  548. <a name="Generic-options"></a>
  549. <h2 class="section"><a href="ffmpeg.html#toc-Generic-options">5.2 Generic options</a></h2>
  550. <p>These options are shared amongst the ff* tools.
  551. </p>
  552. <dl compact="compact">
  553. <dt>&lsquo;<samp>-L</samp>&rsquo;</dt>
  554. <dd><p>Show license.
  555. </p>
  556. </dd>
  557. <dt>&lsquo;<samp>-h, -?, -help, --help [<var>arg</var>]</samp>&rsquo;</dt>
  558. <dd><p>Show help. An optional parameter may be specified to print help about a specific
  559. item. If no argument is specified, only basic (non advanced) tool
  560. options are shown.
  561. </p>
  562. <p>Possible values of <var>arg</var> are:
  563. </p><dl compact="compact">
  564. <dt>&lsquo;<samp>long</samp>&rsquo;</dt>
  565. <dd><p>Print advanced tool options in addition to the basic tool options.
  566. </p>
  567. </dd>
  568. <dt>&lsquo;<samp>full</samp>&rsquo;</dt>
  569. <dd><p>Print complete list of options, including shared and private options
  570. for encoders, decoders, demuxers, muxers, filters, etc.
  571. </p>
  572. </dd>
  573. <dt>&lsquo;<samp>decoder=<var>decoder_name</var></samp>&rsquo;</dt>
  574. <dd><p>Print detailed information about the decoder named <var>decoder_name</var>. Use the
  575. &lsquo;<samp>-decoders</samp>&rsquo; option to get a list of all decoders.
  576. </p>
  577. </dd>
  578. <dt>&lsquo;<samp>encoder=<var>encoder_name</var></samp>&rsquo;</dt>
  579. <dd><p>Print detailed information about the encoder named <var>encoder_name</var>. Use the
  580. &lsquo;<samp>-encoders</samp>&rsquo; option to get a list of all encoders.
  581. </p>
  582. </dd>
  583. <dt>&lsquo;<samp>demuxer=<var>demuxer_name</var></samp>&rsquo;</dt>
  584. <dd><p>Print detailed information about the demuxer named <var>demuxer_name</var>. Use the
  585. &lsquo;<samp>-formats</samp>&rsquo; option to get a list of all demuxers and muxers.
  586. </p>
  587. </dd>
  588. <dt>&lsquo;<samp>muxer=<var>muxer_name</var></samp>&rsquo;</dt>
  589. <dd><p>Print detailed information about the muxer named <var>muxer_name</var>. Use the
  590. &lsquo;<samp>-formats</samp>&rsquo; option to get a list of all muxers and demuxers.
  591. </p>
  592. </dd>
  593. <dt>&lsquo;<samp>filter=<var>filter_name</var></samp>&rsquo;</dt>
  594. <dd><p>Print detailed information about the filter name <var>filter_name</var>. Use the
  595. &lsquo;<samp>-filters</samp>&rsquo; option to get a list of all filters.
  596. </p>
  597. </dd>
  598. <dt>&lsquo;<samp>bsf=<var>bitstream_filter_name</var></samp>&rsquo;</dt>
  599. <dd><p>Print detailed information about the bitstream filter name <var>bitstream_filter_name</var>.
  600. Use the &lsquo;<samp>-bsfs</samp>&rsquo; option to get a list of all bitstream filters.
  601. </p></dd>
  602. </dl>
  603. </dd>
  604. <dt>&lsquo;<samp>-version</samp>&rsquo;</dt>
  605. <dd><p>Show version.
  606. </p>
  607. </dd>
  608. <dt>&lsquo;<samp>-formats</samp>&rsquo;</dt>
  609. <dd><p>Show available formats (including devices).
  610. </p>
  611. </dd>
  612. <dt>&lsquo;<samp>-demuxers</samp>&rsquo;</dt>
  613. <dd><p>Show available demuxers.
  614. </p>
  615. </dd>
  616. <dt>&lsquo;<samp>-muxers</samp>&rsquo;</dt>
  617. <dd><p>Show available muxers.
  618. </p>
  619. </dd>
  620. <dt>&lsquo;<samp>-devices</samp>&rsquo;</dt>
  621. <dd><p>Show available devices.
  622. </p>
  623. </dd>
  624. <dt>&lsquo;<samp>-codecs</samp>&rsquo;</dt>
  625. <dd><p>Show all codecs known to libavcodec.
  626. </p>
  627. <p>Note that the term &rsquo;codec&rsquo; is used throughout this documentation as a shortcut
  628. for what is more correctly called a media bitstream format.
  629. </p>
  630. </dd>
  631. <dt>&lsquo;<samp>-decoders</samp>&rsquo;</dt>
  632. <dd><p>Show available decoders.
  633. </p>
  634. </dd>
  635. <dt>&lsquo;<samp>-encoders</samp>&rsquo;</dt>
  636. <dd><p>Show all available encoders.
  637. </p>
  638. </dd>
  639. <dt>&lsquo;<samp>-bsfs</samp>&rsquo;</dt>
  640. <dd><p>Show available bitstream filters.
  641. </p>
  642. </dd>
  643. <dt>&lsquo;<samp>-protocols</samp>&rsquo;</dt>
  644. <dd><p>Show available protocols.
  645. </p>
  646. </dd>
  647. <dt>&lsquo;<samp>-filters</samp>&rsquo;</dt>
  648. <dd><p>Show available libavfilter filters.
  649. </p>
  650. </dd>
  651. <dt>&lsquo;<samp>-pix_fmts</samp>&rsquo;</dt>
  652. <dd><p>Show available pixel formats.
  653. </p>
  654. </dd>
  655. <dt>&lsquo;<samp>-sample_fmts</samp>&rsquo;</dt>
  656. <dd><p>Show available sample formats.
  657. </p>
  658. </dd>
  659. <dt>&lsquo;<samp>-layouts</samp>&rsquo;</dt>
  660. <dd><p>Show channel names and standard channel layouts.
  661. </p>
  662. </dd>
  663. <dt>&lsquo;<samp>-colors</samp>&rsquo;</dt>
  664. <dd><p>Show recognized color names.
  665. </p>
  666. </dd>
  667. <dt>&lsquo;<samp>-sources <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp>&rsquo;</dt>
  668. <dd><p>Show autodetected sources of the input device.
  669. Some devices may provide system-dependent source names that cannot be autodetected.
  670. The returned list cannot be assumed to be always complete.
  671. </p><div class="example">
  672. <pre class="example">ffmpeg -sources pulse,server=192.168.0.4
  673. </pre></div>
  674. </dd>
  675. <dt>&lsquo;<samp>-sinks <var>device</var>[,<var>opt1</var>=<var>val1</var>[,<var>opt2</var>=<var>val2</var>]...]</samp>&rsquo;</dt>
  676. <dd><p>Show autodetected sinks of the output device.
  677. Some devices may provide system-dependent sink names that cannot be autodetected.
  678. The returned list cannot be assumed to be always complete.
  679. </p><div class="example">
  680. <pre class="example">ffmpeg -sinks pulse,server=192.168.0.4
  681. </pre></div>
  682. </dd>
  683. <dt>&lsquo;<samp>-loglevel [<var>flags</var>+]<var>loglevel</var> | -v [<var>flags</var>+]<var>loglevel</var></samp>&rsquo;</dt>
  684. <dd><p>Set logging level and flags used by the library.
  685. </p>
  686. <p>The optional <var>flags</var> prefix can consist of the following values:
  687. </p><dl compact="compact">
  688. <dt>&lsquo;<samp>repeat</samp>&rsquo;</dt>
  689. <dd><p>Indicates that repeated log output should not be compressed to the first line
  690. and the &quot;Last message repeated n times&quot; line will be omitted.
  691. </p></dd>
  692. <dt>&lsquo;<samp>level</samp>&rsquo;</dt>
  693. <dd><p>Indicates that log output should add a <code>[level]</code> prefix to each message
  694. line. This can be used as an alternative to log coloring, e.g. when dumping the
  695. log to file.
  696. </p></dd>
  697. </dl>
  698. <p>Flags can also be used alone by adding a &rsquo;+&rsquo;/&rsquo;-&rsquo; prefix to set/reset a single
  699. flag without affecting other <var>flags</var> or changing <var>loglevel</var>. When
  700. setting both <var>flags</var> and <var>loglevel</var>, a &rsquo;+&rsquo; separator is expected
  701. between the last <var>flags</var> value and before <var>loglevel</var>.
  702. </p>
  703. <p><var>loglevel</var> is a string or a number containing one of the following values:
  704. </p><dl compact="compact">
  705. <dt>&lsquo;<samp>quiet, -8</samp>&rsquo;</dt>
  706. <dd><p>Show nothing at all; be silent.
  707. </p></dd>
  708. <dt>&lsquo;<samp>panic, 0</samp>&rsquo;</dt>
  709. <dd><p>Only show fatal errors which could lead the process to crash, such as
  710. an assertion failure. This is not currently used for anything.
  711. </p></dd>
  712. <dt>&lsquo;<samp>fatal, 8</samp>&rsquo;</dt>
  713. <dd><p>Only show fatal errors. These are errors after which the process absolutely
  714. cannot continue.
  715. </p></dd>
  716. <dt>&lsquo;<samp>error, 16</samp>&rsquo;</dt>
  717. <dd><p>Show all errors, including ones which can be recovered from.
  718. </p></dd>
  719. <dt>&lsquo;<samp>warning, 24</samp>&rsquo;</dt>
  720. <dd><p>Show all warnings and errors. Any message related to possibly
  721. incorrect or unexpected events will be shown.
  722. </p></dd>
  723. <dt>&lsquo;<samp>info, 32</samp>&rsquo;</dt>
  724. <dd><p>Show informative messages during processing. This is in addition to
  725. warnings and errors. This is the default value.
  726. </p></dd>
  727. <dt>&lsquo;<samp>verbose, 40</samp>&rsquo;</dt>
  728. <dd><p>Same as <code>info</code>, except more verbose.
  729. </p></dd>
  730. <dt>&lsquo;<samp>debug, 48</samp>&rsquo;</dt>
  731. <dd><p>Show everything, including debugging information.
  732. </p></dd>
  733. <dt>&lsquo;<samp>trace, 56</samp>&rsquo;</dt>
  734. </dl>
  735. <p>For example to enable repeated log output, add the <code>level</code> prefix, and set
  736. <var>loglevel</var> to <code>verbose</code>:
  737. </p><div class="example">
  738. <pre class="example">ffmpeg -loglevel repeat+level+verbose -i input output
  739. </pre></div>
  740. <p>Another example that enables repeated log output without affecting current
  741. state of <code>level</code> prefix flag or <var>loglevel</var>:
  742. </p><div class="example">
  743. <pre class="example">ffmpeg [...] -loglevel +repeat
  744. </pre></div>
  745. <p>By default the program logs to stderr. If coloring is supported by the
  746. terminal, colors are used to mark errors and warnings. Log coloring
  747. can be disabled setting the environment variable
  748. <code>AV_LOG_FORCE_NOCOLOR</code>, or can be forced setting
  749. the environment variable <code>AV_LOG_FORCE_COLOR</code>.
  750. </p>
  751. </dd>
  752. <dt>&lsquo;<samp>-report</samp>&rsquo;</dt>
  753. <dd><p>Dump full command line and log output to a file named
  754. <code><var>program</var>-<var>YYYYMMDD</var>-<var>HHMMSS</var>.log</code> in the current
  755. directory.
  756. This file can be useful for bug reports.
  757. It also implies <code>-loglevel debug</code>.
  758. </p>
  759. <p>Setting the environment variable <code>FFREPORT</code> to any value has the
  760. same effect. If the value is a &rsquo;:&rsquo;-separated key=value sequence, these
  761. options will affect the report; option values must be escaped if they
  762. contain special characters or the options delimiter &rsquo;:&rsquo; (see the
  763. &ldquo;Quoting and escaping&rdquo; section in the ffmpeg-utils manual).
  764. </p>
  765. <p>The following options are recognized:
  766. </p><dl compact="compact">
  767. <dt>&lsquo;<samp>file</samp>&rsquo;</dt>
  768. <dd><p>set the file name to use for the report; <code>%p</code> is expanded to the name
  769. of the program, <code>%t</code> is expanded to a timestamp, <code>%%</code> is expanded
  770. to a plain <code>%</code>
  771. </p></dd>
  772. <dt>&lsquo;<samp>level</samp>&rsquo;</dt>
  773. <dd><p>set the log verbosity level using a numerical value (see <code>-loglevel</code>).
  774. </p></dd>
  775. </dl>
  776. <p>For example, to output a report to a file named &lsquo;<tt>ffreport.log</tt>&rsquo;
  777. using a log level of <code>32</code> (alias for log level <code>info</code>):
  778. </p>
  779. <div class="example">
  780. <pre class="example">FFREPORT=file=ffreport.log:level=32 ffmpeg -i input output
  781. </pre></div>
  782. <p>Errors in parsing the environment variable are not fatal, and will not
  783. appear in the report.
  784. </p>
  785. </dd>
  786. <dt>&lsquo;<samp>-hide_banner</samp>&rsquo;</dt>
  787. <dd><p>Suppress printing banner.
  788. </p>
  789. <p>All FFmpeg tools will normally show a copyright notice, build options
  790. and library versions. This option can be used to suppress printing
  791. this information.
  792. </p>
  793. </dd>
  794. <dt>&lsquo;<samp>-cpuflags flags (<em>global</em>)</samp>&rsquo;</dt>
  795. <dd><p>Allows setting and clearing cpu flags. This option is intended
  796. for testing. Do not use it unless you know what you&rsquo;re doing.
  797. </p><div class="example">
  798. <pre class="example">ffmpeg -cpuflags -sse+mmx ...
  799. ffmpeg -cpuflags mmx ...
  800. ffmpeg -cpuflags 0 ...
  801. </pre></div>
  802. <p>Possible flags for this option are:
  803. </p><dl compact="compact">
  804. <dt>&lsquo;<samp>x86</samp>&rsquo;</dt>
  805. <dd><dl compact="compact">
  806. <dt>&lsquo;<samp>mmx</samp>&rsquo;</dt>
  807. <dt>&lsquo;<samp>mmxext</samp>&rsquo;</dt>
  808. <dt>&lsquo;<samp>sse</samp>&rsquo;</dt>
  809. <dt>&lsquo;<samp>sse2</samp>&rsquo;</dt>
  810. <dt>&lsquo;<samp>sse2slow</samp>&rsquo;</dt>
  811. <dt>&lsquo;<samp>sse3</samp>&rsquo;</dt>
  812. <dt>&lsquo;<samp>sse3slow</samp>&rsquo;</dt>
  813. <dt>&lsquo;<samp>ssse3</samp>&rsquo;</dt>
  814. <dt>&lsquo;<samp>atom</samp>&rsquo;</dt>
  815. <dt>&lsquo;<samp>sse4.1</samp>&rsquo;</dt>
  816. <dt>&lsquo;<samp>sse4.2</samp>&rsquo;</dt>
  817. <dt>&lsquo;<samp>avx</samp>&rsquo;</dt>
  818. <dt>&lsquo;<samp>avx2</samp>&rsquo;</dt>
  819. <dt>&lsquo;<samp>xop</samp>&rsquo;</dt>
  820. <dt>&lsquo;<samp>fma3</samp>&rsquo;</dt>
  821. <dt>&lsquo;<samp>fma4</samp>&rsquo;</dt>
  822. <dt>&lsquo;<samp>3dnow</samp>&rsquo;</dt>
  823. <dt>&lsquo;<samp>3dnowext</samp>&rsquo;</dt>
  824. <dt>&lsquo;<samp>bmi1</samp>&rsquo;</dt>
  825. <dt>&lsquo;<samp>bmi2</samp>&rsquo;</dt>
  826. <dt>&lsquo;<samp>cmov</samp>&rsquo;</dt>
  827. </dl>
  828. </dd>
  829. <dt>&lsquo;<samp>ARM</samp>&rsquo;</dt>
  830. <dd><dl compact="compact">
  831. <dt>&lsquo;<samp>armv5te</samp>&rsquo;</dt>
  832. <dt>&lsquo;<samp>armv6</samp>&rsquo;</dt>
  833. <dt>&lsquo;<samp>armv6t2</samp>&rsquo;</dt>
  834. <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
  835. <dt>&lsquo;<samp>vfpv3</samp>&rsquo;</dt>
  836. <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
  837. <dt>&lsquo;<samp>setend</samp>&rsquo;</dt>
  838. </dl>
  839. </dd>
  840. <dt>&lsquo;<samp>AArch64</samp>&rsquo;</dt>
  841. <dd><dl compact="compact">
  842. <dt>&lsquo;<samp>armv8</samp>&rsquo;</dt>
  843. <dt>&lsquo;<samp>vfp</samp>&rsquo;</dt>
  844. <dt>&lsquo;<samp>neon</samp>&rsquo;</dt>
  845. </dl>
  846. </dd>
  847. <dt>&lsquo;<samp>PowerPC</samp>&rsquo;</dt>
  848. <dd><dl compact="compact">
  849. <dt>&lsquo;<samp>altivec</samp>&rsquo;</dt>
  850. </dl>
  851. </dd>
  852. <dt>&lsquo;<samp>Specific Processors</samp>&rsquo;</dt>
  853. <dd><dl compact="compact">
  854. <dt>&lsquo;<samp>pentium2</samp>&rsquo;</dt>
  855. <dt>&lsquo;<samp>pentium3</samp>&rsquo;</dt>
  856. <dt>&lsquo;<samp>pentium4</samp>&rsquo;</dt>
  857. <dt>&lsquo;<samp>k6</samp>&rsquo;</dt>
  858. <dt>&lsquo;<samp>k62</samp>&rsquo;</dt>
  859. <dt>&lsquo;<samp>athlon</samp>&rsquo;</dt>
  860. <dt>&lsquo;<samp>athlonxp</samp>&rsquo;</dt>
  861. <dt>&lsquo;<samp>k8</samp>&rsquo;</dt>
  862. </dl>
  863. </dd>
  864. </dl>
  865. </dd>
  866. </dl>
  867. <a name="AVOptions"></a>
  868. <h2 class="section"><a href="ffmpeg.html#toc-AVOptions">5.3 AVOptions</a></h2>
  869. <p>These options are provided directly by the libavformat, libavdevice and
  870. libavcodec libraries. To see the list of available AVOptions, use the
  871. &lsquo;<samp>-help</samp>&rsquo; option. They are separated into two categories:
  872. </p><dl compact="compact">
  873. <dt>&lsquo;<samp>generic</samp>&rsquo;</dt>
  874. <dd><p>These options can be set for any container, codec or device. Generic options
  875. are listed under AVFormatContext options for containers/devices and under
  876. AVCodecContext options for codecs.
  877. </p></dd>
  878. <dt>&lsquo;<samp>private</samp>&rsquo;</dt>
  879. <dd><p>These options are specific to the given container, device or codec. Private
  880. options are listed under their corresponding containers/devices/codecs.
  881. </p></dd>
  882. </dl>
  883. <p>For example to write an ID3v2.3 header instead of a default ID3v2.4 to
  884. an MP3 file, use the &lsquo;<samp>id3v2_version</samp>&rsquo; private option of the MP3
  885. muxer:
  886. </p><div class="example">
  887. <pre class="example">ffmpeg -i input.flac -id3v2_version 3 out.mp3
  888. </pre></div>
  889. <p>All codec AVOptions are per-stream, and thus a stream specifier
  890. should be attached to them:
  891. </p><div class="example">
  892. <pre class="example">ffmpeg -i multichannel.mxf -map 0:v:0 -map 0:a:0 -map 0:a:0 -c:a:0 ac3 -b:a:0 640k -ac:a:1 2 -c:a:1 aac -b:2 128k out.mp4
  893. </pre></div>
  894. <p>In the above example, a multichannel audio stream is mapped twice for output.
  895. The first instance is encoded with codec ac3 and bitrate 640k.
  896. The second instance is downmixed to 2 channels and encoded with codec aac. A bitrate of 128k is specified for it using
  897. absolute index of the output stream.
  898. </p>
  899. <p>Note: the &lsquo;<samp>-nooption</samp>&rsquo; syntax cannot be used for boolean
  900. AVOptions, use &lsquo;<samp>-option 0</samp>&rsquo;/&lsquo;<samp>-option 1</samp>&rsquo;.
  901. </p>
  902. <p>Note: the old undocumented way of specifying per-stream AVOptions by
  903. prepending v/a/s to the options name is now obsolete and will be
  904. removed soon.
  905. </p>
  906. <a name="Main-options"></a>
  907. <h2 class="section"><a href="ffmpeg.html#toc-Main-options">5.4 Main options</a></h2>
  908. <dl compact="compact">
  909. <dt>&lsquo;<samp>-f <var>fmt</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  910. <dd><p>Force input or output file format. The format is normally auto detected for input
  911. files and guessed from the file extension for output files, so this option is not
  912. needed in most cases.
  913. </p>
  914. </dd>
  915. <dt>&lsquo;<samp>-i <var>url</var> (<em>input</em>)</samp>&rsquo;</dt>
  916. <dd><p>input file url
  917. </p>
  918. </dd>
  919. <dt>&lsquo;<samp>-y (<em>global</em>)</samp>&rsquo;</dt>
  920. <dd><p>Overwrite output files without asking.
  921. </p>
  922. </dd>
  923. <dt>&lsquo;<samp>-n (<em>global</em>)</samp>&rsquo;</dt>
  924. <dd><p>Do not overwrite output files, and exit immediately if a specified
  925. output file already exists.
  926. </p>
  927. </dd>
  928. <dt>&lsquo;<samp>-stream_loop <var>number</var> (<em>input</em>)</samp>&rsquo;</dt>
  929. <dd><p>Set number of times input stream shall be looped. Loop 0 means no loop,
  930. loop -1 means infinite loop.
  931. </p>
  932. </dd>
  933. <dt>&lsquo;<samp>-c[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  934. <dt>&lsquo;<samp>-codec[:<var>stream_specifier</var>] <var>codec</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  935. <dd><p>Select an encoder (when used before an output file) or a decoder (when used
  936. before an input file) for one or more streams. <var>codec</var> is the name of a
  937. decoder/encoder or a special value <code>copy</code> (output only) to indicate that
  938. the stream is not to be re-encoded.
  939. </p>
  940. <p>For example
  941. </p><div class="example">
  942. <pre class="example">ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
  943. </pre></div>
  944. <p>encodes all video streams with libx264 and copies all audio streams.
  945. </p>
  946. <p>For each stream, the last matching <code>c</code> option is applied, so
  947. </p><div class="example">
  948. <pre class="example">ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
  949. </pre></div>
  950. <p>will copy all the streams except the second video, which will be encoded with
  951. libx264, and the 138th audio, which will be encoded with libvorbis.
  952. </p>
  953. </dd>
  954. <dt>&lsquo;<samp>-t <var>duration</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  955. <dd><p>When used as an input option (before <code>-i</code>), limit the <var>duration</var> of
  956. data read from the input file.
  957. </p>
  958. <p>When used as an output option (before an output url), stop writing the
  959. output after its duration reaches <var>duration</var>.
  960. </p>
  961. <p><var>duration</var> must be a time duration specification,
  962. see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
  963. </p>
  964. <p>-to and -t are mutually exclusive and -t has priority.
  965. </p>
  966. </dd>
  967. <dt>&lsquo;<samp>-to <var>position</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  968. <dd><p>Stop writing the output or reading the input at <var>position</var>.
  969. <var>position</var> must be a time duration specification,
  970. see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
  971. </p>
  972. <p>-to and -t are mutually exclusive and -t has priority.
  973. </p>
  974. </dd>
  975. <dt>&lsquo;<samp>-fs <var>limit_size</var> (<em>output</em>)</samp>&rsquo;</dt>
  976. <dd><p>Set the file size limit, expressed in bytes. No further chunk of bytes is written
  977. after the limit is exceeded. The size of the output file is slightly more than the
  978. requested file size.
  979. </p>
  980. </dd>
  981. <dt>&lsquo;<samp>-ss <var>position</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  982. <dd><p>When used as an input option (before <code>-i</code>), seeks in this input file to
  983. <var>position</var>. Note that in most formats it is not possible to seek exactly,
  984. so <code>ffmpeg</code> will seek to the closest seek point before <var>position</var>.
  985. When transcoding and &lsquo;<samp>-accurate_seek</samp>&rsquo; is enabled (the default), this
  986. extra segment between the seek point and <var>position</var> will be decoded and
  987. discarded. When doing stream copy or when &lsquo;<samp>-noaccurate_seek</samp>&rsquo; is used, it
  988. will be preserved.
  989. </p>
  990. <p>When used as an output option (before an output url), decodes but discards
  991. input until the timestamps reach <var>position</var>.
  992. </p>
  993. <p><var>position</var> must be a time duration specification,
  994. see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
  995. </p>
  996. </dd>
  997. <dt>&lsquo;<samp>-sseof <var>position</var> (<em>input</em>)</samp>&rsquo;</dt>
  998. <dd>
  999. <p>Like the <code>-ss</code> option but relative to the &quot;end of file&quot;. That is negative
  1000. values are earlier in the file, 0 is at EOF.
  1001. </p>
  1002. </dd>
  1003. <dt>&lsquo;<samp>-itsoffset <var>offset</var> (<em>input</em>)</samp>&rsquo;</dt>
  1004. <dd><p>Set the input time offset.
  1005. </p>
  1006. <p><var>offset</var> must be a time duration specification,
  1007. see <a href="ffmpeg-utils.html#time-duration-syntax">(ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual</a>.
  1008. </p>
  1009. <p>The offset is added to the timestamps of the input files. Specifying
  1010. a positive offset means that the corresponding streams are delayed by
  1011. the time duration specified in <var>offset</var>.
  1012. </p>
  1013. </dd>
  1014. <dt>&lsquo;<samp>-itsscale <var>scale</var> (<em>input,per-stream</em>)</samp>&rsquo;</dt>
  1015. <dd><p>Rescale input timestamps. <var>scale</var> should be a floating point number.
  1016. </p>
  1017. </dd>
  1018. <dt>&lsquo;<samp>-timestamp <var>date</var> (<em>output</em>)</samp>&rsquo;</dt>
  1019. <dd><p>Set the recording timestamp in the container.
  1020. </p>
  1021. <p><var>date</var> must be a date specification,
  1022. see <a href="ffmpeg-utils.html#date-syntax">(ffmpeg-utils)the Date section in the ffmpeg-utils(1) manual</a>.
  1023. </p>
  1024. </dd>
  1025. <dt>&lsquo;<samp>-metadata[:metadata_specifier] <var>key</var>=<var>value</var> (<em>output,per-metadata</em>)</samp>&rsquo;</dt>
  1026. <dd><p>Set a metadata key/value pair.
  1027. </p>
  1028. <p>An optional <var>metadata_specifier</var> may be given to set metadata
  1029. on streams, chapters or programs. See <code>-map_metadata</code>
  1030. documentation for details.
  1031. </p>
  1032. <p>This option overrides metadata set with <code>-map_metadata</code>. It is
  1033. also possible to delete metadata by using an empty value.
  1034. </p>
  1035. <p>For example, for setting the title in the output file:
  1036. </p><div class="example">
  1037. <pre class="example">ffmpeg -i in.avi -metadata title=&quot;my title&quot; out.flv
  1038. </pre></div>
  1039. <p>To set the language of the first audio stream:
  1040. </p><div class="example">
  1041. <pre class="example">ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
  1042. </pre></div>
  1043. </dd>
  1044. <dt>&lsquo;<samp>-disposition[:stream_specifier] <var>value</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1045. <dd><p>Sets the disposition for a stream.
  1046. </p>
  1047. <p>This option overrides the disposition copied from the input stream. It is also
  1048. possible to delete the disposition by setting it to 0.
  1049. </p>
  1050. <p>The following dispositions are recognized:
  1051. </p><dl compact="compact">
  1052. <dt>&lsquo;<samp>default</samp>&rsquo;</dt>
  1053. <dt>&lsquo;<samp>dub</samp>&rsquo;</dt>
  1054. <dt>&lsquo;<samp>original</samp>&rsquo;</dt>
  1055. <dt>&lsquo;<samp>comment</samp>&rsquo;</dt>
  1056. <dt>&lsquo;<samp>lyrics</samp>&rsquo;</dt>
  1057. <dt>&lsquo;<samp>karaoke</samp>&rsquo;</dt>
  1058. <dt>&lsquo;<samp>forced</samp>&rsquo;</dt>
  1059. <dt>&lsquo;<samp>hearing_impaired</samp>&rsquo;</dt>
  1060. <dt>&lsquo;<samp>visual_impaired</samp>&rsquo;</dt>
  1061. <dt>&lsquo;<samp>clean_effects</samp>&rsquo;</dt>
  1062. <dt>&lsquo;<samp>attached_pic</samp>&rsquo;</dt>
  1063. <dt>&lsquo;<samp>captions</samp>&rsquo;</dt>
  1064. <dt>&lsquo;<samp>descriptions</samp>&rsquo;</dt>
  1065. <dt>&lsquo;<samp>dependent</samp>&rsquo;</dt>
  1066. <dt>&lsquo;<samp>metadata</samp>&rsquo;</dt>
  1067. </dl>
  1068. <p>For example, to make the second audio stream the default stream:
  1069. </p><div class="example">
  1070. <pre class="example">ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv
  1071. </pre></div>
  1072. <p>To make the second subtitle stream the default stream and remove the default
  1073. disposition from the first subtitle stream:
  1074. </p><div class="example">
  1075. <pre class="example">ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv
  1076. </pre></div>
  1077. <p>To add an embedded cover/thumbnail:
  1078. </p><div class="example">
  1079. <pre class="example">ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
  1080. </pre></div>
  1081. <p>Not all muxers support embedded thumbnails, and those who do, only support a few formats, like JPEG or PNG.
  1082. </p>
  1083. </dd>
  1084. <dt>&lsquo;<samp>-program [title=<var>title</var>:][program_num=<var>program_num</var>:]st=<var>stream</var>[:st=<var>stream</var>...] (<em>output</em>)</samp>&rsquo;</dt>
  1085. <dd>
  1086. <p>Creates a program with the specified <var>title</var>, <var>program_num</var> and adds the specified
  1087. <var>stream</var>(s) to it.
  1088. </p>
  1089. </dd>
  1090. <dt>&lsquo;<samp>-target <var>type</var> (<em>output</em>)</samp>&rsquo;</dt>
  1091. <dd><p>Specify target file type (<code>vcd</code>, <code>svcd</code>, <code>dvd</code>, <code>dv</code>,
  1092. <code>dv50</code>). <var>type</var> may be prefixed with <code>pal-</code>, <code>ntsc-</code> or
  1093. <code>film-</code> to use the corresponding standard. All the format options
  1094. (bitrate, codecs, buffer sizes) are then set automatically. You can just type:
  1095. </p>
  1096. <div class="example">
  1097. <pre class="example">ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  1098. </pre></div>
  1099. <p>Nevertheless you can specify additional options as long as you know
  1100. they do not conflict with the standard, as in:
  1101. </p>
  1102. <div class="example">
  1103. <pre class="example">ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  1104. </pre></div>
  1105. </dd>
  1106. <dt>&lsquo;<samp>-dn (<em>input/output</em>)</samp>&rsquo;</dt>
  1107. <dd><p>As an input option, blocks all data streams of a file from being filtered or
  1108. being automatically selected or mapped for any output. See <code>-discard</code>
  1109. option to disable streams individually.
  1110. </p>
  1111. <p>As an output option, disables data recording i.e. automatic selection or
  1112. mapping of any data stream. For full manual control see the <code>-map</code>
  1113. option.
  1114. </p>
  1115. </dd>
  1116. <dt>&lsquo;<samp>-dframes <var>number</var> (<em>output</em>)</samp>&rsquo;</dt>
  1117. <dd><p>Set the number of data frames to output. This is an obsolete alias for
  1118. <code>-frames:d</code>, which you should use instead.
  1119. </p>
  1120. </dd>
  1121. <dt>&lsquo;<samp>-frames[:<var>stream_specifier</var>] <var>framecount</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1122. <dd><p>Stop writing to the stream after <var>framecount</var> frames.
  1123. </p>
  1124. </dd>
  1125. <dt>&lsquo;<samp>-q[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1126. <dt>&lsquo;<samp>-qscale[:<var>stream_specifier</var>] <var>q</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1127. <dd><p>Use fixed quality scale (VBR). The meaning of <var>q</var>/<var>qscale</var> is
  1128. codec-dependent.
  1129. If <var>qscale</var> is used without a <var>stream_specifier</var> then it applies only
  1130. to the video stream, this is to maintain compatibility with previous behavior
  1131. and as specifying the same codec specific value to 2 different codecs that is
  1132. audio and video generally is not what is intended when no stream_specifier is
  1133. used.
  1134. </p>
  1135. <p><a name="filter_005foption"></a>
  1136. </p></dd>
  1137. <dt>&lsquo;<samp>-filter[:<var>stream_specifier</var>] <var>filtergraph</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1138. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  1139. filter the stream.
  1140. </p>
  1141. <p><var>filtergraph</var> is a description of the filtergraph to apply to
  1142. the stream, and must have a single input and a single output of the
  1143. same type of the stream. In the filtergraph, the input is associated
  1144. to the label <code>in</code>, and the output to the label <code>out</code>. See
  1145. the ffmpeg-filters manual for more information about the filtergraph
  1146. syntax.
  1147. </p>
  1148. <p>See the <a href="#filter_005fcomplex_005foption">-filter_complex option</a> if you
  1149. want to create filtergraphs with multiple inputs and/or outputs.
  1150. </p>
  1151. </dd>
  1152. <dt>&lsquo;<samp>-filter_script[:<var>stream_specifier</var>] <var>filename</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1153. <dd><p>This option is similar to &lsquo;<samp>-filter</samp>&rsquo;, the only difference is that its
  1154. argument is the name of the file from which a filtergraph description is to be
  1155. read.
  1156. </p>
  1157. </dd>
  1158. <dt>&lsquo;<samp>-filter_threads <var>nb_threads</var> (<em>global</em>)</samp>&rsquo;</dt>
  1159. <dd><p>Defines how many threads are used to process a filter pipeline. Each pipeline
  1160. will produce a thread pool with this many threads available for parallel processing.
  1161. The default is the number of available CPUs.
  1162. </p>
  1163. </dd>
  1164. <dt>&lsquo;<samp>-pre[:<var>stream_specifier</var>] <var>preset_name</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1165. <dd><p>Specify the preset for matching stream(s).
  1166. </p>
  1167. </dd>
  1168. <dt>&lsquo;<samp>-stats (<em>global</em>)</samp>&rsquo;</dt>
  1169. <dd><p>Print encoding progress/statistics. It is on by default, to explicitly
  1170. disable it you need to specify <code>-nostats</code>.
  1171. </p>
  1172. </dd>
  1173. <dt>&lsquo;<samp>-progress <var>url</var> (<em>global</em>)</samp>&rsquo;</dt>
  1174. <dd><p>Send program-friendly progress information to <var>url</var>.
  1175. </p>
  1176. <p>Progress information is written approximately every second and at the end of
  1177. the encoding process. It is made of &quot;<var>key</var>=<var>value</var>&quot; lines. <var>key</var>
  1178. consists of only alphanumeric characters. The last key of a sequence of
  1179. progress information is always &quot;progress&quot;.
  1180. </p>
  1181. <p><a name="stdin-option"></a>
  1182. </p></dd>
  1183. <dt>&lsquo;<samp>-stdin</samp>&rsquo;</dt>
  1184. <dd><p>Enable interaction on standard input. On by default unless standard input is
  1185. used as an input. To explicitly disable interaction you need to specify
  1186. <code>-nostdin</code>.
  1187. </p>
  1188. <p>Disabling interaction on standard input is useful, for example, if
  1189. ffmpeg is in the background process group. Roughly the same result can
  1190. be achieved with <code>ffmpeg ... &lt; /dev/null</code> but it requires a
  1191. shell.
  1192. </p>
  1193. </dd>
  1194. <dt>&lsquo;<samp>-debug_ts (<em>global</em>)</samp>&rsquo;</dt>
  1195. <dd><p>Print timestamp information. It is off by default. This option is
  1196. mostly useful for testing and debugging purposes, and the output
  1197. format may change from one version to another, so it should not be
  1198. employed by portable scripts.
  1199. </p>
  1200. <p>See also the option <code>-fdebug ts</code>.
  1201. </p>
  1202. </dd>
  1203. <dt>&lsquo;<samp>-attach <var>filename</var> (<em>output</em>)</samp>&rsquo;</dt>
  1204. <dd><p>Add an attachment to the output file. This is supported by a few formats
  1205. like Matroska for e.g. fonts used in rendering subtitles. Attachments
  1206. are implemented as a specific type of stream, so this option will add
  1207. a new stream to the file. It is then possible to use per-stream options
  1208. on this stream in the usual way. Attachment streams created with this
  1209. option will be created after all the other streams (i.e. those created
  1210. with <code>-map</code> or automatic mappings).
  1211. </p>
  1212. <p>Note that for Matroska you also have to set the mimetype metadata tag:
  1213. </p><div class="example">
  1214. <pre class="example">ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
  1215. </pre></div>
  1216. <p>(assuming that the attachment stream will be third in the output file).
  1217. </p>
  1218. </dd>
  1219. <dt>&lsquo;<samp>-dump_attachment[:<var>stream_specifier</var>] <var>filename</var> (<em>input,per-stream</em>)</samp>&rsquo;</dt>
  1220. <dd><p>Extract the matching attachment stream into a file named <var>filename</var>. If
  1221. <var>filename</var> is empty, then the value of the <code>filename</code> metadata tag
  1222. will be used.
  1223. </p>
  1224. <p>E.g. to extract the first attachment to a file named &rsquo;out.ttf&rsquo;:
  1225. </p><div class="example">
  1226. <pre class="example">ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
  1227. </pre></div>
  1228. <p>To extract all attachments to files determined by the <code>filename</code> tag:
  1229. </p><div class="example">
  1230. <pre class="example">ffmpeg -dump_attachment:t &quot;&quot; -i INPUT
  1231. </pre></div>
  1232. <p>Technical note &ndash; attachments are implemented as codec extradata, so this
  1233. option can actually be used to extract extradata from any stream, not just
  1234. attachments.
  1235. </p>
  1236. </dd>
  1237. <dt>&lsquo;<samp>-noautorotate</samp>&rsquo;</dt>
  1238. <dd><p>Disable automatically rotating video based on file metadata.
  1239. </p>
  1240. </dd>
  1241. </dl>
  1242. <a name="Video-Options"></a>
  1243. <h2 class="section"><a href="ffmpeg.html#toc-Video-Options">5.5 Video Options</a></h2>
  1244. <dl compact="compact">
  1245. <dt>&lsquo;<samp>-vframes <var>number</var> (<em>output</em>)</samp>&rsquo;</dt>
  1246. <dd><p>Set the number of video frames to output. This is an obsolete alias for
  1247. <code>-frames:v</code>, which you should use instead.
  1248. </p></dd>
  1249. <dt>&lsquo;<samp>-r[:<var>stream_specifier</var>] <var>fps</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  1250. <dd><p>Set frame rate (Hz value, fraction or abbreviation).
  1251. </p>
  1252. <p>As an input option, ignore any timestamps stored in the file and instead
  1253. generate timestamps assuming constant frame rate <var>fps</var>.
  1254. This is not the same as the &lsquo;<samp>-framerate</samp>&rsquo; option used for some input formats
  1255. like image2 or v4l2 (it used to be the same in older versions of FFmpeg).
  1256. If in doubt use &lsquo;<samp>-framerate</samp>&rsquo; instead of the input option &lsquo;<samp>-r</samp>&rsquo;.
  1257. </p>
  1258. <p>As an output option, duplicate or drop input frames to achieve constant output
  1259. frame rate <var>fps</var>.
  1260. </p>
  1261. </dd>
  1262. <dt>&lsquo;<samp>-s[:<var>stream_specifier</var>] <var>size</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  1263. <dd><p>Set frame size.
  1264. </p>
  1265. <p>As an input option, this is a shortcut for the &lsquo;<samp>video_size</samp>&rsquo; private
  1266. option, recognized by some demuxers for which the frame size is either not
  1267. stored in the file or is configurable &ndash; e.g. raw video or video grabbers.
  1268. </p>
  1269. <p>As an output option, this inserts the <code>scale</code> video filter to the
  1270. <em>end</em> of the corresponding filtergraph. Please use the <code>scale</code> filter
  1271. directly to insert it at the beginning or some other place.
  1272. </p>
  1273. <p>The format is &lsquo;<samp>wxh</samp>&rsquo; (default - same as source).
  1274. </p>
  1275. </dd>
  1276. <dt>&lsquo;<samp>-aspect[:<var>stream_specifier</var>] <var>aspect</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1277. <dd><p>Set the video display aspect ratio specified by <var>aspect</var>.
  1278. </p>
  1279. <p><var>aspect</var> can be a floating point number string, or a string of the
  1280. form <var>num</var>:<var>den</var>, where <var>num</var> and <var>den</var> are the
  1281. numerator and denominator of the aspect ratio. For example &quot;4:3&quot;,
  1282. &quot;16:9&quot;, &quot;1.3333&quot;, and &quot;1.7777&quot; are valid argument values.
  1283. </p>
  1284. <p>If used together with &lsquo;<samp>-vcodec copy</samp>&rsquo;, it will affect the aspect ratio
  1285. stored at container level, but not the aspect ratio stored in encoded
  1286. frames, if it exists.
  1287. </p>
  1288. </dd>
  1289. <dt>&lsquo;<samp>-vn (<em>input/output</em>)</samp>&rsquo;</dt>
  1290. <dd><p>As an input option, blocks all video streams of a file from being filtered or
  1291. being automatically selected or mapped for any output. See <code>-discard</code>
  1292. option to disable streams individually.
  1293. </p>
  1294. <p>As an output option, disables video recording i.e. automatic selection or
  1295. mapping of any video stream. For full manual control see the <code>-map</code>
  1296. option.
  1297. </p>
  1298. </dd>
  1299. <dt>&lsquo;<samp>-vcodec <var>codec</var> (<em>output</em>)</samp>&rsquo;</dt>
  1300. <dd><p>Set the video codec. This is an alias for <code>-codec:v</code>.
  1301. </p>
  1302. </dd>
  1303. <dt>&lsquo;<samp>-pass[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1304. <dd><p>Select the pass number (1 or 2). It is used to do two-pass
  1305. video encoding. The statistics of the video are recorded in the first
  1306. pass into a log file (see also the option -passlogfile),
  1307. and in the second pass that log file is used to generate the video
  1308. at the exact requested bitrate.
  1309. On pass 1, you may just deactivate audio and set output to null,
  1310. examples for Windows and Unix:
  1311. </p><div class="example">
  1312. <pre class="example">ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
  1313. ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
  1314. </pre></div>
  1315. </dd>
  1316. <dt>&lsquo;<samp>-passlogfile[:<var>stream_specifier</var>] <var>prefix</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1317. <dd><p>Set two-pass log file name prefix to <var>prefix</var>, the default file name
  1318. prefix is &ldquo;ffmpeg2pass&rdquo;. The complete file name will be
  1319. &lsquo;<tt>PREFIX-N.log</tt>&rsquo;, where N is a number specific to the output
  1320. stream
  1321. </p>
  1322. </dd>
  1323. <dt>&lsquo;<samp>-vf <var>filtergraph</var> (<em>output</em>)</samp>&rsquo;</dt>
  1324. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  1325. filter the stream.
  1326. </p>
  1327. <p>This is an alias for <code>-filter:v</code>, see the <a href="#filter_005foption">-filter option</a>.
  1328. </p></dd>
  1329. </dl>
  1330. <a name="Advanced-Video-options"></a>
  1331. <h2 class="section"><a href="ffmpeg.html#toc-Advanced-Video-options">5.6 Advanced Video options</a></h2>
  1332. <dl compact="compact">
  1333. <dt>&lsquo;<samp>-pix_fmt[:<var>stream_specifier</var>] <var>format</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  1334. <dd><p>Set pixel format. Use <code>-pix_fmts</code> to show all the supported
  1335. pixel formats.
  1336. If the selected pixel format can not be selected, ffmpeg will print a
  1337. warning and select the best pixel format supported by the encoder.
  1338. If <var>pix_fmt</var> is prefixed by a <code>+</code>, ffmpeg will exit with an error
  1339. if the requested pixel format can not be selected, and automatic conversions
  1340. inside filtergraphs are disabled.
  1341. If <var>pix_fmt</var> is a single <code>+</code>, ffmpeg selects the same pixel format
  1342. as the input (or graph output) and automatic conversions are disabled.
  1343. </p>
  1344. </dd>
  1345. <dt>&lsquo;<samp>-sws_flags <var>flags</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  1346. <dd><p>Set SwScaler flags.
  1347. </p>
  1348. </dd>
  1349. <dt>&lsquo;<samp>-rc_override[:<var>stream_specifier</var>] <var>override</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1350. <dd><p>Rate control override for specific intervals, formatted as &quot;int,int,int&quot;
  1351. list separated with slashes. Two first values are the beginning and
  1352. end frame numbers, last one is quantizer to use if positive, or quality
  1353. factor if negative.
  1354. </p>
  1355. </dd>
  1356. <dt>&lsquo;<samp>-ilme</samp>&rsquo;</dt>
  1357. <dd><p>Force interlacing support in encoder (MPEG-2 and MPEG-4 only).
  1358. Use this option if your input file is interlaced and you want
  1359. to keep the interlaced format for minimum losses.
  1360. The alternative is to deinterlace the input stream with
  1361. &lsquo;<samp>-deinterlace</samp>&rsquo;, but deinterlacing introduces losses.
  1362. </p></dd>
  1363. <dt>&lsquo;<samp>-psnr</samp>&rsquo;</dt>
  1364. <dd><p>Calculate PSNR of compressed frames.
  1365. </p></dd>
  1366. <dt>&lsquo;<samp>-vstats</samp>&rsquo;</dt>
  1367. <dd><p>Dump video coding statistics to &lsquo;<tt>vstats_HHMMSS.log</tt>&rsquo;.
  1368. </p></dd>
  1369. <dt>&lsquo;<samp>-vstats_file <var>file</var></samp>&rsquo;</dt>
  1370. <dd><p>Dump video coding statistics to <var>file</var>.
  1371. </p></dd>
  1372. <dt>&lsquo;<samp>-vstats_version <var>file</var></samp>&rsquo;</dt>
  1373. <dd><p>Specifies which version of the vstats format to use. Default is 2.
  1374. </p>
  1375. <p>version = 1 :
  1376. </p>
  1377. <p><code>frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s</code>
  1378. </p>
  1379. <p>version &gt; 1:
  1380. </p>
  1381. <p><code>out= %2d st= %2d frame= %5d q= %2.1f PSNR= %6.2f f_size= %6d s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s</code>
  1382. </p></dd>
  1383. <dt>&lsquo;<samp>-top[:<var>stream_specifier</var>] <var>n</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1384. <dd><p>top=1/bottom=0/auto=-1 field first
  1385. </p></dd>
  1386. <dt>&lsquo;<samp>-dc <var>precision</var></samp>&rsquo;</dt>
  1387. <dd><p>Intra_dc_precision.
  1388. </p></dd>
  1389. <dt>&lsquo;<samp>-vtag <var>fourcc/tag</var> (<em>output</em>)</samp>&rsquo;</dt>
  1390. <dd><p>Force video tag/fourcc. This is an alias for <code>-tag:v</code>.
  1391. </p></dd>
  1392. <dt>&lsquo;<samp>-qphist (<em>global</em>)</samp>&rsquo;</dt>
  1393. <dd><p>Show QP histogram
  1394. </p></dd>
  1395. <dt>&lsquo;<samp>-vbsf <var>bitstream_filter</var></samp>&rsquo;</dt>
  1396. <dd><p>Deprecated see -bsf
  1397. </p>
  1398. </dd>
  1399. <dt>&lsquo;<samp>-force_key_frames[:<var>stream_specifier</var>] <var>time</var>[,<var>time</var>...] (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1400. <dt>&lsquo;<samp>-force_key_frames[:<var>stream_specifier</var>] expr:<var>expr</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1401. <dt>&lsquo;<samp>-force_key_frames[:<var>stream_specifier</var>] source (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1402. <dd>
  1403. <p><var>force_key_frames</var> can take arguments of the following form:
  1404. </p>
  1405. <dl compact="compact">
  1406. <dt>&lsquo;<samp><var>time</var>[,<var>time</var>...]</samp>&rsquo;</dt>
  1407. <dd><p>If the argument consists of timestamps, ffmpeg will round the specified times to the nearest
  1408. output timestamp as per the encoder time base and force a keyframe at the first frame having
  1409. timestamp equal or greater than the computed timestamp. Note that if the encoder time base is too
  1410. coarse, then the keyframes may be forced on frames with timestamps lower than the specified time.
  1411. The default encoder time base is the inverse of the output framerate but may be set otherwise
  1412. via <code>-enc_time_base</code>.
  1413. </p>
  1414. <p>If one of the times is &quot;<code>chapters</code>[<var>delta</var>]&quot;, it is expanded into
  1415. the time of the beginning of all chapters in the file, shifted by
  1416. <var>delta</var>, expressed as a time in seconds.
  1417. This option can be useful to ensure that a seek point is present at a
  1418. chapter mark or any other designated place in the output file.
  1419. </p>
  1420. <p>For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
  1421. before the beginning of every chapter:
  1422. </p><div class="example">
  1423. <pre class="example">-force_key_frames 0:05:00,chapters-0.1
  1424. </pre></div>
  1425. </dd>
  1426. <dt>&lsquo;<samp>expr:<var>expr</var></samp>&rsquo;</dt>
  1427. <dd><p>If the argument is prefixed with <code>expr:</code>, the string <var>expr</var>
  1428. is interpreted like an expression and is evaluated for each frame. A
  1429. key frame is forced in case the evaluation is non-zero.
  1430. </p>
  1431. <p>The expression in <var>expr</var> can contain the following constants:
  1432. </p><dl compact="compact">
  1433. <dt>&lsquo;<samp>n</samp>&rsquo;</dt>
  1434. <dd><p>the number of current processed frame, starting from 0
  1435. </p></dd>
  1436. <dt>&lsquo;<samp>n_forced</samp>&rsquo;</dt>
  1437. <dd><p>the number of forced frames
  1438. </p></dd>
  1439. <dt>&lsquo;<samp>prev_forced_n</samp>&rsquo;</dt>
  1440. <dd><p>the number of the previous forced frame, it is <code>NAN</code> when no
  1441. keyframe was forced yet
  1442. </p></dd>
  1443. <dt>&lsquo;<samp>prev_forced_t</samp>&rsquo;</dt>
  1444. <dd><p>the time of the previous forced frame, it is <code>NAN</code> when no
  1445. keyframe was forced yet
  1446. </p></dd>
  1447. <dt>&lsquo;<samp>t</samp>&rsquo;</dt>
  1448. <dd><p>the time of the current processed frame
  1449. </p></dd>
  1450. </dl>
  1451. <p>For example to force a key frame every 5 seconds, you can specify:
  1452. </p><div class="example">
  1453. <pre class="example">-force_key_frames expr:gte(t,n_forced*5)
  1454. </pre></div>
  1455. <p>To force a key frame 5 seconds after the time of the last forced one,
  1456. starting from second 13:
  1457. </p><div class="example">
  1458. <pre class="example">-force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
  1459. </pre></div>
  1460. </dd>
  1461. <dt>&lsquo;<samp>source</samp>&rsquo;</dt>
  1462. <dd><p>If the argument is <code>source</code>, ffmpeg will force a key frame if
  1463. the current frame being encoded is marked as a key frame in its source.
  1464. </p>
  1465. </dd>
  1466. </dl>
  1467. <p>Note that forcing too many keyframes is very harmful for the lookahead
  1468. algorithms of certain encoders: using fixed-GOP options or similar
  1469. would be more efficient.
  1470. </p>
  1471. </dd>
  1472. <dt>&lsquo;<samp>-copyinkf[:<var>stream_specifier</var>] (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1473. <dd><p>When doing stream copy, copy also non-key frames found at the
  1474. beginning.
  1475. </p>
  1476. </dd>
  1477. <dt>&lsquo;<samp>-init_hw_device <var>type</var>[=<var>name</var>][:<var>device</var>[,<var>key=value</var>...]]</samp>&rsquo;</dt>
  1478. <dd><p>Initialise a new hardware device of type <var>type</var> called <var>name</var>, using the
  1479. given device parameters.
  1480. If no name is specified it will receive a default name of the form &quot;<var>type</var>%d&quot;.
  1481. </p>
  1482. <p>The meaning of <var>device</var> and the following arguments depends on the
  1483. device type:
  1484. </p><dl compact="compact">
  1485. <dt>&lsquo;<samp>cuda</samp>&rsquo;</dt>
  1486. <dd><p><var>device</var> is the number of the CUDA device.
  1487. </p>
  1488. </dd>
  1489. <dt>&lsquo;<samp>dxva2</samp>&rsquo;</dt>
  1490. <dd><p><var>device</var> is the number of the Direct3D 9 display adapter.
  1491. </p>
  1492. </dd>
  1493. <dt>&lsquo;<samp>vaapi</samp>&rsquo;</dt>
  1494. <dd><p><var>device</var> is either an X11 display name or a DRM render node.
  1495. If not specified, it will attempt to open the default X11 display (<em>$DISPLAY</em>)
  1496. and then the first DRM render node (<em>/dev/dri/renderD128</em>).
  1497. </p>
  1498. </dd>
  1499. <dt>&lsquo;<samp>vdpau</samp>&rsquo;</dt>
  1500. <dd><p><var>device</var> is an X11 display name.
  1501. If not specified, it will attempt to open the default X11 display (<em>$DISPLAY</em>).
  1502. </p>
  1503. </dd>
  1504. <dt>&lsquo;<samp>qsv</samp>&rsquo;</dt>
  1505. <dd><p><var>device</var> selects a value in &lsquo;<samp>MFX_IMPL_*</samp>&rsquo;. Allowed values are:
  1506. </p><dl compact="compact">
  1507. <dt>&lsquo;<samp>auto</samp>&rsquo;</dt>
  1508. <dt>&lsquo;<samp>sw</samp>&rsquo;</dt>
  1509. <dt>&lsquo;<samp>hw</samp>&rsquo;</dt>
  1510. <dt>&lsquo;<samp>auto_any</samp>&rsquo;</dt>
  1511. <dt>&lsquo;<samp>hw_any</samp>&rsquo;</dt>
  1512. <dt>&lsquo;<samp>hw2</samp>&rsquo;</dt>
  1513. <dt>&lsquo;<samp>hw3</samp>&rsquo;</dt>
  1514. <dt>&lsquo;<samp>hw4</samp>&rsquo;</dt>
  1515. </dl>
  1516. <p>If not specified, &lsquo;<samp>auto_any</samp>&rsquo; is used.
  1517. (Note that it may be easier to achieve the desired result for QSV by creating the
  1518. platform-appropriate subdevice (&lsquo;<samp>dxva2</samp>&rsquo; or &lsquo;<samp>vaapi</samp>&rsquo;) and then deriving a
  1519. QSV device from that.)
  1520. </p>
  1521. </dd>
  1522. <dt>&lsquo;<samp>opencl</samp>&rsquo;</dt>
  1523. <dd><p><var>device</var> selects the platform and device as <em>platform_index.device_index</em>.
  1524. </p>
  1525. <p>The set of devices can also be filtered using the key-value pairs to find only
  1526. devices matching particular platform or device strings.
  1527. </p>
  1528. <p>The strings usable as filters are:
  1529. </p><dl compact="compact">
  1530. <dt>&lsquo;<samp>platform_profile</samp>&rsquo;</dt>
  1531. <dt>&lsquo;<samp>platform_version</samp>&rsquo;</dt>
  1532. <dt>&lsquo;<samp>platform_name</samp>&rsquo;</dt>
  1533. <dt>&lsquo;<samp>platform_vendor</samp>&rsquo;</dt>
  1534. <dt>&lsquo;<samp>platform_extensions</samp>&rsquo;</dt>
  1535. <dt>&lsquo;<samp>device_name</samp>&rsquo;</dt>
  1536. <dt>&lsquo;<samp>device_vendor</samp>&rsquo;</dt>
  1537. <dt>&lsquo;<samp>driver_version</samp>&rsquo;</dt>
  1538. <dt>&lsquo;<samp>device_version</samp>&rsquo;</dt>
  1539. <dt>&lsquo;<samp>device_profile</samp>&rsquo;</dt>
  1540. <dt>&lsquo;<samp>device_extensions</samp>&rsquo;</dt>
  1541. <dt>&lsquo;<samp>device_type</samp>&rsquo;</dt>
  1542. </dl>
  1543. <p>The indices and filters must together uniquely select a device.
  1544. </p>
  1545. <p>Examples:
  1546. </p><dl compact="compact">
  1547. <dt><em>-init_hw_device opencl:0.1</em></dt>
  1548. <dd><p>Choose the second device on the first platform.
  1549. </p>
  1550. </dd>
  1551. <dt><em>-init_hw_device opencl:,device_name=Foo9000</em></dt>
  1552. <dd><p>Choose the device with a name containing the string <em>Foo9000</em>.
  1553. </p>
  1554. </dd>
  1555. <dt><em>-init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16</em></dt>
  1556. <dd><p>Choose the GPU device on the second platform supporting the <em>cl_khr_fp16</em>
  1557. extension.
  1558. </p></dd>
  1559. </dl>
  1560. </dd>
  1561. <dt>&lsquo;<samp>vulkan</samp>&rsquo;</dt>
  1562. <dd><p>If <var>device</var> is an integer, it selects the device by its index in a
  1563. system-dependent list of devices. If <var>device</var> is any other string, it
  1564. selects the first device with a name containing that string as a substring.
  1565. </p>
  1566. <p>Examples:
  1567. </p><dl compact="compact">
  1568. <dt><em>-init_hw_device vulkan:1</em></dt>
  1569. <dd><p>Choose the second device on the system.
  1570. </p>
  1571. </dd>
  1572. <dt><em>-init_hw_device vulkan:RADV</em></dt>
  1573. <dd><p>Choose the first device with a name containing the string <em>RADV</em>.
  1574. </p></dd>
  1575. </dl>
  1576. </dd>
  1577. </dl>
  1578. </dd>
  1579. <dt>&lsquo;<samp>-init_hw_device <var>type</var>[=<var>name</var>]@<var>source</var></samp>&rsquo;</dt>
  1580. <dd><p>Initialise a new hardware device of type <var>type</var> called <var>name</var>,
  1581. deriving it from the existing device with the name <var>source</var>.
  1582. </p>
  1583. </dd>
  1584. <dt>&lsquo;<samp>-init_hw_device list</samp>&rsquo;</dt>
  1585. <dd><p>List all hardware device types supported in this build of ffmpeg.
  1586. </p>
  1587. </dd>
  1588. <dt>&lsquo;<samp>-filter_hw_device <var>name</var></samp>&rsquo;</dt>
  1589. <dd><p>Pass the hardware device called <var>name</var> to all filters in any filter graph.
  1590. This can be used to set the device to upload to with the <code>hwupload</code> filter,
  1591. or the device to map to with the <code>hwmap</code> filter. Other filters may also
  1592. make use of this parameter when they require a hardware device. Note that this
  1593. is typically only required when the input is not already in hardware frames -
  1594. when it is, filters will derive the device they require from the context of the
  1595. frames they receive as input.
  1596. </p>
  1597. <p>This is a global setting, so all filters will receive the same device.
  1598. </p>
  1599. </dd>
  1600. <dt>&lsquo;<samp>-hwaccel[:<var>stream_specifier</var>] <var>hwaccel</var> (<em>input,per-stream</em>)</samp>&rsquo;</dt>
  1601. <dd><p>Use hardware acceleration to decode the matching stream(s). The allowed values
  1602. of <var>hwaccel</var> are:
  1603. </p><dl compact="compact">
  1604. <dt>&lsquo;<samp>none</samp>&rsquo;</dt>
  1605. <dd><p>Do not use any hardware acceleration (the default).
  1606. </p>
  1607. </dd>
  1608. <dt>&lsquo;<samp>auto</samp>&rsquo;</dt>
  1609. <dd><p>Automatically select the hardware acceleration method.
  1610. </p>
  1611. </dd>
  1612. <dt>&lsquo;<samp>vdpau</samp>&rsquo;</dt>
  1613. <dd><p>Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
  1614. </p>
  1615. </dd>
  1616. <dt>&lsquo;<samp>dxva2</samp>&rsquo;</dt>
  1617. <dd><p>Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
  1618. </p>
  1619. </dd>
  1620. <dt>&lsquo;<samp>vaapi</samp>&rsquo;</dt>
  1621. <dd><p>Use VAAPI (Video Acceleration API) hardware acceleration.
  1622. </p>
  1623. </dd>
  1624. <dt>&lsquo;<samp>qsv</samp>&rsquo;</dt>
  1625. <dd><p>Use the Intel QuickSync Video acceleration for video transcoding.
  1626. </p>
  1627. <p>Unlike most other values, this option does not enable accelerated decoding (that
  1628. is used automatically whenever a qsv decoder is selected), but accelerated
  1629. transcoding, without copying the frames into the system memory.
  1630. </p>
  1631. <p>For it to work, both the decoder and the encoder must support QSV acceleration
  1632. and no filters must be used.
  1633. </p></dd>
  1634. </dl>
  1635. <p>This option has no effect if the selected hwaccel is not available or not
  1636. supported by the chosen decoder.
  1637. </p>
  1638. <p>Note that most acceleration methods are intended for playback and will not be
  1639. faster than software decoding on modern CPUs. Additionally, <code>ffmpeg</code>
  1640. will usually need to copy the decoded frames from the GPU memory into the system
  1641. memory, resulting in further performance loss. This option is thus mainly
  1642. useful for testing.
  1643. </p>
  1644. </dd>
  1645. <dt>&lsquo;<samp>-hwaccel_device[:<var>stream_specifier</var>] <var>hwaccel_device</var> (<em>input,per-stream</em>)</samp>&rsquo;</dt>
  1646. <dd><p>Select a device to use for hardware acceleration.
  1647. </p>
  1648. <p>This option only makes sense when the &lsquo;<samp>-hwaccel</samp>&rsquo; option is also specified.
  1649. It can either refer to an existing device created with &lsquo;<samp>-init_hw_device</samp>&rsquo;
  1650. by name, or it can create a new device as if
  1651. &lsquo;<samp>-init_hw_device</samp>&rsquo; <var>type</var>:<var>hwaccel_device</var>
  1652. were called immediately before.
  1653. </p>
  1654. </dd>
  1655. <dt>&lsquo;<samp>-hwaccels</samp>&rsquo;</dt>
  1656. <dd><p>List all hardware acceleration methods supported in this build of ffmpeg.
  1657. </p>
  1658. </dd>
  1659. </dl>
  1660. <a name="Audio-Options"></a>
  1661. <h2 class="section"><a href="ffmpeg.html#toc-Audio-Options">5.7 Audio Options</a></h2>
  1662. <dl compact="compact">
  1663. <dt>&lsquo;<samp>-aframes <var>number</var> (<em>output</em>)</samp>&rsquo;</dt>
  1664. <dd><p>Set the number of audio frames to output. This is an obsolete alias for
  1665. <code>-frames:a</code>, which you should use instead.
  1666. </p></dd>
  1667. <dt>&lsquo;<samp>-ar[:<var>stream_specifier</var>] <var>freq</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  1668. <dd><p>Set the audio sampling frequency. For output streams it is set by
  1669. default to the frequency of the corresponding input stream. For input
  1670. streams this option only makes sense for audio grabbing devices and raw
  1671. demuxers and is mapped to the corresponding demuxer options.
  1672. </p></dd>
  1673. <dt>&lsquo;<samp>-aq <var>q</var> (<em>output</em>)</samp>&rsquo;</dt>
  1674. <dd><p>Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
  1675. </p></dd>
  1676. <dt>&lsquo;<samp>-ac[:<var>stream_specifier</var>] <var>channels</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  1677. <dd><p>Set the number of audio channels. For output streams it is set by
  1678. default to the number of input audio channels. For input streams
  1679. this option only makes sense for audio grabbing devices and raw demuxers
  1680. and is mapped to the corresponding demuxer options.
  1681. </p></dd>
  1682. <dt>&lsquo;<samp>-an (<em>input/output</em>)</samp>&rsquo;</dt>
  1683. <dd><p>As an input option, blocks all audio streams of a file from being filtered or
  1684. being automatically selected or mapped for any output. See <code>-discard</code>
  1685. option to disable streams individually.
  1686. </p>
  1687. <p>As an output option, disables audio recording i.e. automatic selection or
  1688. mapping of any audio stream. For full manual control see the <code>-map</code>
  1689. option.
  1690. </p></dd>
  1691. <dt>&lsquo;<samp>-acodec <var>codec</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  1692. <dd><p>Set the audio codec. This is an alias for <code>-codec:a</code>.
  1693. </p></dd>
  1694. <dt>&lsquo;<samp>-sample_fmt[:<var>stream_specifier</var>] <var>sample_fmt</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  1695. <dd><p>Set the audio sample format. Use <code>-sample_fmts</code> to get a list
  1696. of supported sample formats.
  1697. </p>
  1698. </dd>
  1699. <dt>&lsquo;<samp>-af <var>filtergraph</var> (<em>output</em>)</samp>&rsquo;</dt>
  1700. <dd><p>Create the filtergraph specified by <var>filtergraph</var> and use it to
  1701. filter the stream.
  1702. </p>
  1703. <p>This is an alias for <code>-filter:a</code>, see the <a href="#filter_005foption">-filter option</a>.
  1704. </p></dd>
  1705. </dl>
  1706. <a name="Advanced-Audio-options"></a>
  1707. <h2 class="section"><a href="ffmpeg.html#toc-Advanced-Audio-options">5.8 Advanced Audio options</a></h2>
  1708. <dl compact="compact">
  1709. <dt>&lsquo;<samp>-atag <var>fourcc/tag</var> (<em>output</em>)</samp>&rsquo;</dt>
  1710. <dd><p>Force audio tag/fourcc. This is an alias for <code>-tag:a</code>.
  1711. </p></dd>
  1712. <dt>&lsquo;<samp>-absf <var>bitstream_filter</var></samp>&rsquo;</dt>
  1713. <dd><p>Deprecated, see -bsf
  1714. </p></dd>
  1715. <dt>&lsquo;<samp>-guess_layout_max <var>channels</var> (<em>input,per-stream</em>)</samp>&rsquo;</dt>
  1716. <dd><p>If some input channel layout is not known, try to guess only if it
  1717. corresponds to at most the specified number of channels. For example, 2
  1718. tells to <code>ffmpeg</code> to recognize 1 channel as mono and 2 channels as
  1719. stereo but not 6 channels as 5.1. The default is to always try to guess. Use
  1720. 0 to disable all guessing.
  1721. </p></dd>
  1722. </dl>
  1723. <a name="Subtitle-options"></a>
  1724. <h2 class="section"><a href="ffmpeg.html#toc-Subtitle-options">5.9 Subtitle options</a></h2>
  1725. <dl compact="compact">
  1726. <dt>&lsquo;<samp>-scodec <var>codec</var> (<em>input/output</em>)</samp>&rsquo;</dt>
  1727. <dd><p>Set the subtitle codec. This is an alias for <code>-codec:s</code>.
  1728. </p></dd>
  1729. <dt>&lsquo;<samp>-sn (<em>input/output</em>)</samp>&rsquo;</dt>
  1730. <dd><p>As an input option, blocks all subtitle streams of a file from being filtered or
  1731. being automatically selected or mapped for any output. See <code>-discard</code>
  1732. option to disable streams individually.
  1733. </p>
  1734. <p>As an output option, disables subtitle recording i.e. automatic selection or
  1735. mapping of any subtitle stream. For full manual control see the <code>-map</code>
  1736. option.
  1737. </p></dd>
  1738. <dt>&lsquo;<samp>-sbsf <var>bitstream_filter</var></samp>&rsquo;</dt>
  1739. <dd><p>Deprecated, see -bsf
  1740. </p></dd>
  1741. </dl>
  1742. <a name="Advanced-Subtitle-options"></a>
  1743. <h2 class="section"><a href="ffmpeg.html#toc-Advanced-Subtitle-options">5.10 Advanced Subtitle options</a></h2>
  1744. <dl compact="compact">
  1745. <dt>&lsquo;<samp>-fix_sub_duration</samp>&rsquo;</dt>
  1746. <dd><p>Fix subtitles durations. For each subtitle, wait for the next packet in the
  1747. same stream and adjust the duration of the first to avoid overlap. This is
  1748. necessary with some subtitles codecs, especially DVB subtitles, because the
  1749. duration in the original packet is only a rough estimate and the end is
  1750. actually marked by an empty subtitle frame. Failing to use this option when
  1751. necessary can result in exaggerated durations or muxing failures due to
  1752. non-monotonic timestamps.
  1753. </p>
  1754. <p>Note that this option will delay the output of all data until the next
  1755. subtitle packet is decoded: it may increase memory consumption and latency a
  1756. lot.
  1757. </p>
  1758. </dd>
  1759. <dt>&lsquo;<samp>-canvas_size <var>size</var></samp>&rsquo;</dt>
  1760. <dd><p>Set the size of the canvas used to render subtitles.
  1761. </p>
  1762. </dd>
  1763. </dl>
  1764. <a name="Advanced-options"></a>
  1765. <h2 class="section"><a href="ffmpeg.html#toc-Advanced-options">5.11 Advanced options</a></h2>
  1766. <dl compact="compact">
  1767. <dt>&lsquo;<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>&rsquo;</dt>
  1768. <dd>
  1769. <p>Designate one or more input streams as a source for the output file. Each input
  1770. stream is identified by the input file index <var>input_file_id</var> and
  1771. the input stream index <var>input_stream_id</var> within the input
  1772. file. Both indices start at 0. If specified,
  1773. <var>sync_file_id</var>:<var>stream_specifier</var> sets which input stream
  1774. is used as a presentation sync reference.
  1775. </p>
  1776. <p>The first <code>-map</code> option on the command line specifies the
  1777. source for output stream 0, the second <code>-map</code> option specifies
  1778. the source for output stream 1, etc.
  1779. </p>
  1780. <p>A <code>-</code> character before the stream identifier creates a &quot;negative&quot; mapping.
  1781. It disables matching streams from already created mappings.
  1782. </p>
  1783. <p>A trailing <code>?</code> after the stream index will allow the map to be
  1784. optional: if the map matches no streams the map will be ignored instead
  1785. of failing. Note the map will still fail if an invalid input file index
  1786. is used; such as if the map refers to a non-existent input.
  1787. </p>
  1788. <p>An alternative <var>[linklabel]</var> form will map outputs from complex filter
  1789. graphs (see the &lsquo;<samp>-filter_complex</samp>&rsquo; option) to the output file.
  1790. <var>linklabel</var> must correspond to a defined output link label in the graph.
  1791. </p>
  1792. <p>For example, to map ALL streams from the first input file to output
  1793. </p><div class="example">
  1794. <pre class="example">ffmpeg -i INPUT -map 0 output
  1795. </pre></div>
  1796. <p>For example, if you have two audio streams in the first input file,
  1797. these streams are identified by &quot;0:0&quot; and &quot;0:1&quot;. You can use
  1798. <code>-map</code> to select which streams to place in an output file. For
  1799. example:
  1800. </p><div class="example">
  1801. <pre class="example">ffmpeg -i INPUT -map 0:1 out.wav
  1802. </pre></div>
  1803. <p>will map the input stream in &lsquo;<tt>INPUT</tt>&rsquo; identified by &quot;0:1&quot; to
  1804. the (single) output stream in &lsquo;<tt>out.wav</tt>&rsquo;.
  1805. </p>
  1806. <p>For example, to select the stream with index 2 from input file
  1807. &lsquo;<tt>a.mov</tt>&rsquo; (specified by the identifier &quot;0:2&quot;), and stream with
  1808. index 6 from input &lsquo;<tt>b.mov</tt>&rsquo; (specified by the identifier &quot;1:6&quot;),
  1809. and copy them to the output file &lsquo;<tt>out.mov</tt>&rsquo;:
  1810. </p><div class="example">
  1811. <pre class="example">ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
  1812. </pre></div>
  1813. <p>To select all video and the third audio stream from an input file:
  1814. </p><div class="example">
  1815. <pre class="example">ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
  1816. </pre></div>
  1817. <p>To map all the streams except the second audio, use negative mappings
  1818. </p><div class="example">
  1819. <pre class="example">ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
  1820. </pre></div>
  1821. <p>To map the video and audio streams from the first input, and using the
  1822. trailing <code>?</code>, ignore the audio mapping if no audio streams exist in
  1823. the first input:
  1824. </p><div class="example">
  1825. <pre class="example">ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
  1826. </pre></div>
  1827. <p>To pick the English audio stream:
  1828. </p><div class="example">
  1829. <pre class="example">ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
  1830. </pre></div>
  1831. <p>Note that using this option disables the default mappings for this output file.
  1832. </p>
  1833. </dd>
  1834. <dt>&lsquo;<samp>-ignore_unknown</samp>&rsquo;</dt>
  1835. <dd><p>Ignore input streams with unknown type instead of failing if copying
  1836. such streams is attempted.
  1837. </p>
  1838. </dd>
  1839. <dt>&lsquo;<samp>-copy_unknown</samp>&rsquo;</dt>
  1840. <dd><p>Allow input streams with unknown type to be copied instead of failing if copying
  1841. such streams is attempted.
  1842. </p>
  1843. </dd>
  1844. <dt>&lsquo;<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>&rsquo;</dt>
  1845. <dd><p>Map an audio channel from a given input to an output. If
  1846. <var>output_file_id</var>.<var>stream_specifier</var> is not set, the audio channel will
  1847. be mapped on all the audio streams.
  1848. </p>
  1849. <p>Using &quot;-1&quot; instead of
  1850. <var>input_file_id</var>.<var>stream_specifier</var>.<var>channel_id</var> will map a muted
  1851. channel.
  1852. </p>
  1853. <p>A trailing <code>?</code> will allow the map_channel to be
  1854. optional: if the map_channel matches no channel the map_channel will be ignored instead
  1855. of failing.
  1856. </p>
  1857. <p>For example, assuming <var>INPUT</var> is a stereo audio file, you can switch the
  1858. two audio channels with the following command:
  1859. </p><div class="example">
  1860. <pre class="example">ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
  1861. </pre></div>
  1862. <p>If you want to mute the first channel and keep the second:
  1863. </p><div class="example">
  1864. <pre class="example">ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
  1865. </pre></div>
  1866. <p>The order of the &quot;-map_channel&quot; option specifies the order of the channels in
  1867. the output stream. The output channel layout is guessed from the number of
  1868. channels mapped (mono if one &quot;-map_channel&quot;, stereo if two, etc.). Using &quot;-ac&quot;
  1869. in combination of &quot;-map_channel&quot; makes the channel gain levels to be updated if
  1870. input and output channel layouts don&rsquo;t match (for instance two &quot;-map_channel&quot;
  1871. options and &quot;-ac 6&quot;).
  1872. </p>
  1873. <p>You can also extract each channel of an input to specific outputs; the following
  1874. command extracts two channels of the <var>INPUT</var> audio stream (file 0, stream 0)
  1875. to the respective <var>OUTPUT_CH0</var> and <var>OUTPUT_CH1</var> outputs:
  1876. </p><div class="example">
  1877. <pre class="example">ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
  1878. </pre></div>
  1879. <p>The following example splits the channels of a stereo input into two separate
  1880. streams, which are put into the same output file:
  1881. </p><div class="example">
  1882. <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
  1883. </pre></div>
  1884. <p>Note that currently each output stream can only contain channels from a single
  1885. input stream; you can&rsquo;t for example use &quot;-map_channel&quot; to pick multiple input
  1886. audio channels contained in different streams (from the same or different files)
  1887. and merge them into a single output stream. It is therefore not currently
  1888. possible, for example, to turn two separate mono streams into a single stereo
  1889. stream. However splitting a stereo stream into two single channel mono streams
  1890. is possible.
  1891. </p>
  1892. <p>If you need this feature, a possible workaround is to use the <em>amerge</em>
  1893. filter. For example, if you need to merge a media (here &lsquo;<tt>input.mkv</tt>&rsquo;) with 2
  1894. mono audio streams into one single stereo channel audio stream (and keep the
  1895. video stream), you can use the following command:
  1896. </p><div class="example">
  1897. <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
  1898. </pre></div>
  1899. <p>To map the first two audio channels from the first input, and using the
  1900. trailing <code>?</code>, ignore the audio channel mapping if the first input is
  1901. mono instead of stereo:
  1902. </p><div class="example">
  1903. <pre class="example">ffmpeg -i INPUT -map_channel 0.0.0 -map_channel 0.0.1? OUTPUT
  1904. </pre></div>
  1905. </dd>
  1906. <dt>&lsquo;<samp>-map_metadata[:<var>metadata_spec_out</var>] <var>infile</var>[:<var>metadata_spec_in</var>] (<em>output,per-metadata</em>)</samp>&rsquo;</dt>
  1907. <dd><p>Set metadata information of the next output file from <var>infile</var>. Note that
  1908. those are file indices (zero-based), not filenames.
  1909. Optional <var>metadata_spec_in/out</var> parameters specify, which metadata to copy.
  1910. A metadata specifier can have the following forms:
  1911. </p><dl compact="compact">
  1912. <dt>&lsquo;<samp><var>g</var></samp>&rsquo;</dt>
  1913. <dd><p>global metadata, i.e. metadata that applies to the whole file
  1914. </p>
  1915. </dd>
  1916. <dt>&lsquo;<samp><var>s</var>[:<var>stream_spec</var>]</samp>&rsquo;</dt>
  1917. <dd><p>per-stream metadata. <var>stream_spec</var> is a stream specifier as described
  1918. in the <a href="#Stream-specifiers">Stream specifiers</a> chapter. In an input metadata specifier, the first
  1919. matching stream is copied from. In an output metadata specifier, all matching
  1920. streams are copied to.
  1921. </p>
  1922. </dd>
  1923. <dt>&lsquo;<samp><var>c</var>:<var>chapter_index</var></samp>&rsquo;</dt>
  1924. <dd><p>per-chapter metadata. <var>chapter_index</var> is the zero-based chapter index.
  1925. </p>
  1926. </dd>
  1927. <dt>&lsquo;<samp><var>p</var>:<var>program_index</var></samp>&rsquo;</dt>
  1928. <dd><p>per-program metadata. <var>program_index</var> is the zero-based program index.
  1929. </p></dd>
  1930. </dl>
  1931. <p>If metadata specifier is omitted, it defaults to global.
  1932. </p>
  1933. <p>By default, global metadata is copied from the first input file,
  1934. per-stream and per-chapter metadata is copied along with streams/chapters. These
  1935. default mappings are disabled by creating any mapping of the relevant type. A negative
  1936. file index can be used to create a dummy mapping that just disables automatic copying.
  1937. </p>
  1938. <p>For example to copy metadata from the first stream of the input file to global metadata
  1939. of the output file:
  1940. </p><div class="example">
  1941. <pre class="example">ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
  1942. </pre></div>
  1943. <p>To do the reverse, i.e. copy global metadata to all audio streams:
  1944. </p><div class="example">
  1945. <pre class="example">ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
  1946. </pre></div>
  1947. <p>Note that simple <code>0</code> would work as well in this example, since global
  1948. metadata is assumed by default.
  1949. </p>
  1950. </dd>
  1951. <dt>&lsquo;<samp>-map_chapters <var>input_file_index</var> (<em>output</em>)</samp>&rsquo;</dt>
  1952. <dd><p>Copy chapters from input file with index <var>input_file_index</var> to the next
  1953. output file. If no chapter mapping is specified, then chapters are copied from
  1954. the first input file with at least one chapter. Use a negative file index to
  1955. disable any chapter copying.
  1956. </p>
  1957. </dd>
  1958. <dt>&lsquo;<samp>-benchmark (<em>global</em>)</samp>&rsquo;</dt>
  1959. <dd><p>Show benchmarking information at the end of an encode.
  1960. Shows real, system and user time used and maximum memory consumption.
  1961. Maximum memory consumption is not supported on all systems,
  1962. it will usually display as 0 if not supported.
  1963. </p></dd>
  1964. <dt>&lsquo;<samp>-benchmark_all (<em>global</em>)</samp>&rsquo;</dt>
  1965. <dd><p>Show benchmarking information during the encode.
  1966. Shows real, system and user time used in various steps (audio/video encode/decode).
  1967. </p></dd>
  1968. <dt>&lsquo;<samp>-timelimit <var>duration</var> (<em>global</em>)</samp>&rsquo;</dt>
  1969. <dd><p>Exit after ffmpeg has been running for <var>duration</var> seconds in CPU user time.
  1970. </p></dd>
  1971. <dt>&lsquo;<samp>-dump (<em>global</em>)</samp>&rsquo;</dt>
  1972. <dd><p>Dump each input packet to stderr.
  1973. </p></dd>
  1974. <dt>&lsquo;<samp>-hex (<em>global</em>)</samp>&rsquo;</dt>
  1975. <dd><p>When dumping packets, also dump the payload.
  1976. </p></dd>
  1977. <dt>&lsquo;<samp>-re (<em>input</em>)</samp>&rsquo;</dt>
  1978. <dd><p>Read input at native frame rate. Mainly used to simulate a grab device,
  1979. or live input stream (e.g. when reading from a file). Should not be used
  1980. with actual grab devices or live input streams (where it can cause packet
  1981. loss).
  1982. By default <code>ffmpeg</code> attempts to read the input(s) as fast as possible.
  1983. This option will slow down the reading of the input(s) to the native frame rate
  1984. of the input(s). It is useful for real-time output (e.g. live streaming).
  1985. </p></dd>
  1986. <dt>&lsquo;<samp>-vsync <var>parameter</var></samp>&rsquo;</dt>
  1987. <dd><p>Video sync method.
  1988. For compatibility reasons old values can be specified as numbers.
  1989. Newly added values will have to be specified as strings always.
  1990. </p>
  1991. <dl compact="compact">
  1992. <dt>&lsquo;<samp>0, passthrough</samp>&rsquo;</dt>
  1993. <dd><p>Each frame is passed with its timestamp from the demuxer to the muxer.
  1994. </p></dd>
  1995. <dt>&lsquo;<samp>1, cfr</samp>&rsquo;</dt>
  1996. <dd><p>Frames will be duplicated and dropped to achieve exactly the requested
  1997. constant frame rate.
  1998. </p></dd>
  1999. <dt>&lsquo;<samp>2, vfr</samp>&rsquo;</dt>
  2000. <dd><p>Frames are passed through with their timestamp or dropped so as to
  2001. prevent 2 frames from having the same timestamp.
  2002. </p></dd>
  2003. <dt>&lsquo;<samp>drop</samp>&rsquo;</dt>
  2004. <dd><p>As passthrough but destroys all timestamps, making the muxer generate
  2005. fresh timestamps based on frame-rate.
  2006. </p></dd>
  2007. <dt>&lsquo;<samp>-1, auto</samp>&rsquo;</dt>
  2008. <dd><p>Chooses between 1 and 2 depending on muxer capabilities. This is the
  2009. default method.
  2010. </p></dd>
  2011. </dl>
  2012. <p>Note that the timestamps may be further modified by the muxer, after this.
  2013. For example, in the case that the format option &lsquo;<samp>avoid_negative_ts</samp>&rsquo;
  2014. is enabled.
  2015. </p>
  2016. <p>With -map you can select from which stream the timestamps should be
  2017. taken. You can leave either video or audio unchanged and sync the
  2018. remaining stream(s) to the unchanged one.
  2019. </p>
  2020. </dd>
  2021. <dt>&lsquo;<samp>-frame_drop_threshold <var>parameter</var></samp>&rsquo;</dt>
  2022. <dd><p>Frame drop threshold, which specifies how much behind video frames can
  2023. be before they are dropped. In frame rate units, so 1.0 is one frame.
  2024. The default is -1.1. One possible usecase is to avoid framedrops in case
  2025. of noisy timestamps or to increase frame drop precision in case of exact
  2026. timestamps.
  2027. </p>
  2028. </dd>
  2029. <dt>&lsquo;<samp>-async <var>samples_per_second</var></samp>&rsquo;</dt>
  2030. <dd><p>Audio sync method. &quot;Stretches/squeezes&quot; the audio stream to match the timestamps,
  2031. the parameter is the maximum samples per second by which the audio is changed.
  2032. -async 1 is a special case where only the start of the audio stream is corrected
  2033. without any later correction.
  2034. </p>
  2035. <p>Note that the timestamps may be further modified by the muxer, after this.
  2036. For example, in the case that the format option &lsquo;<samp>avoid_negative_ts</samp>&rsquo;
  2037. is enabled.
  2038. </p>
  2039. <p>This option has been deprecated. Use the <code>aresample</code> audio filter instead.
  2040. </p>
  2041. </dd>
  2042. <dt>&lsquo;<samp>-copyts</samp>&rsquo;</dt>
  2043. <dd><p>Do not process input timestamps, but keep their values without trying
  2044. to sanitize them. In particular, do not remove the initial start time
  2045. offset value.
  2046. </p>
  2047. <p>Note that, depending on the &lsquo;<samp>vsync</samp>&rsquo; option or on specific muxer
  2048. processing (e.g. in case the format option &lsquo;<samp>avoid_negative_ts</samp>&rsquo;
  2049. is enabled) the output timestamps may mismatch with the input
  2050. timestamps even when this option is selected.
  2051. </p>
  2052. </dd>
  2053. <dt>&lsquo;<samp>-start_at_zero</samp>&rsquo;</dt>
  2054. <dd><p>When used with &lsquo;<samp>copyts</samp>&rsquo;, shift input timestamps so they start at zero.
  2055. </p>
  2056. <p>This means that using e.g. <code>-ss 50</code> will make output timestamps start at
  2057. 50 seconds, regardless of what timestamp the input file started at.
  2058. </p>
  2059. </dd>
  2060. <dt>&lsquo;<samp>-copytb <var>mode</var></samp>&rsquo;</dt>
  2061. <dd><p>Specify how to set the encoder timebase when stream copying. <var>mode</var> is an
  2062. integer numeric value, and can assume one of the following values:
  2063. </p>
  2064. <dl compact="compact">
  2065. <dt>&lsquo;<samp>1</samp>&rsquo;</dt>
  2066. <dd><p>Use the demuxer timebase.
  2067. </p>
  2068. <p>The time base is copied to the output encoder from the corresponding input
  2069. demuxer. This is sometimes required to avoid non monotonically increasing
  2070. timestamps when copying video streams with variable frame rate.
  2071. </p>
  2072. </dd>
  2073. <dt>&lsquo;<samp>0</samp>&rsquo;</dt>
  2074. <dd><p>Use the decoder timebase.
  2075. </p>
  2076. <p>The time base is copied to the output encoder from the corresponding input
  2077. decoder.
  2078. </p>
  2079. </dd>
  2080. <dt>&lsquo;<samp>-1</samp>&rsquo;</dt>
  2081. <dd><p>Try to make the choice automatically, in order to generate a sane output.
  2082. </p></dd>
  2083. </dl>
  2084. <p>Default value is -1.
  2085. </p>
  2086. </dd>
  2087. <dt>&lsquo;<samp>-enc_time_base[:<var>stream_specifier</var>] <var>timebase</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  2088. <dd><p>Set the encoder timebase. <var>timebase</var> is a floating point number,
  2089. and can assume one of the following values:
  2090. </p>
  2091. <dl compact="compact">
  2092. <dt>&lsquo;<samp>0</samp>&rsquo;</dt>
  2093. <dd><p>Assign a default value according to the media type.
  2094. </p>
  2095. <p>For video - use 1/framerate, for audio - use 1/samplerate.
  2096. </p>
  2097. </dd>
  2098. <dt>&lsquo;<samp>-1</samp>&rsquo;</dt>
  2099. <dd><p>Use the input stream timebase when possible.
  2100. </p>
  2101. <p>If an input stream is not available, the default timebase will be used.
  2102. </p>
  2103. </dd>
  2104. <dt>&lsquo;<samp>&gt;0</samp>&rsquo;</dt>
  2105. <dd><p>Use the provided number as the timebase.
  2106. </p>
  2107. <p>This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000)
  2108. or as a floating point number (e.g. 0.04166, 2.0833e-5)
  2109. </p></dd>
  2110. </dl>
  2111. <p>Default value is 0.
  2112. </p>
  2113. </dd>
  2114. <dt>&lsquo;<samp>-bitexact (<em>input/output</em>)</samp>&rsquo;</dt>
  2115. <dd><p>Enable bitexact mode for (de)muxer and (de/en)coder
  2116. </p></dd>
  2117. <dt>&lsquo;<samp>-shortest (<em>output</em>)</samp>&rsquo;</dt>
  2118. <dd><p>Finish encoding when the shortest input stream ends.
  2119. </p></dd>
  2120. <dt>&lsquo;<samp>-dts_delta_threshold</samp>&rsquo;</dt>
  2121. <dd><p>Timestamp discontinuity delta threshold.
  2122. </p></dd>
  2123. <dt>&lsquo;<samp>-dts_error_threshold <var>seconds</var></samp>&rsquo;</dt>
  2124. <dd><p>Timestamp error delta threshold. This threshold use to discard crazy/damaged
  2125. timestamps and the default is 30 hours which is arbitrarily picked and quite
  2126. conservative.
  2127. </p></dd>
  2128. <dt>&lsquo;<samp>-muxdelay <var>seconds</var> (<em>output</em>)</samp>&rsquo;</dt>
  2129. <dd><p>Set the maximum demux-decode delay.
  2130. </p></dd>
  2131. <dt>&lsquo;<samp>-muxpreload <var>seconds</var> (<em>output</em>)</samp>&rsquo;</dt>
  2132. <dd><p>Set the initial demux-decode delay.
  2133. </p></dd>
  2134. <dt>&lsquo;<samp>-streamid <var>output-stream-index</var>:<var>new-value</var> (<em>output</em>)</samp>&rsquo;</dt>
  2135. <dd><p>Assign a new stream-id value to an output stream. This option should be
  2136. specified prior to the output filename to which it applies.
  2137. For the situation where multiple output files exist, a streamid
  2138. may be reassigned to a different value.
  2139. </p>
  2140. <p>For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
  2141. an output mpegts file:
  2142. </p><div class="example">
  2143. <pre class="example">ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
  2144. </pre></div>
  2145. </dd>
  2146. <dt>&lsquo;<samp>-bsf[:<var>stream_specifier</var>] <var>bitstream_filters</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  2147. <dd><p>Set bitstream filters for matching streams. <var>bitstream_filters</var> is
  2148. a comma-separated list of bitstream filters. Use the <code>-bsfs</code> option
  2149. to get the list of bitstream filters.
  2150. </p><div class="example">
  2151. <pre class="example">ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
  2152. </pre></div>
  2153. <div class="example">
  2154. <pre class="example">ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
  2155. </pre></div>
  2156. </dd>
  2157. <dt>&lsquo;<samp>-tag[:<var>stream_specifier</var>] <var>codec_tag</var> (<em>input/output,per-stream</em>)</samp>&rsquo;</dt>
  2158. <dd><p>Force a tag/fourcc for matching streams.
  2159. </p>
  2160. </dd>
  2161. <dt>&lsquo;<samp>-timecode <var>hh</var>:<var>mm</var>:<var>ss</var>SEP<var>ff</var></samp>&rsquo;</dt>
  2162. <dd><p>Specify Timecode for writing. <var>SEP</var> is &rsquo;:&rsquo; for non drop timecode and &rsquo;;&rsquo;
  2163. (or &rsquo;.&rsquo;) for drop.
  2164. </p><div class="example">
  2165. <pre class="example">ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
  2166. </pre></div>
  2167. <p><a name="filter_005fcomplex_005foption"></a>
  2168. </p></dd>
  2169. <dt>&lsquo;<samp>-filter_complex <var>filtergraph</var> (<em>global</em>)</samp>&rsquo;</dt>
  2170. <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  2171. outputs. For simple graphs &ndash; those with one input and one output of the same
  2172. type &ndash; see the &lsquo;<samp>-filter</samp>&rsquo; options. <var>filtergraph</var> is a description of
  2173. the filtergraph, as described in the &ldquo;Filtergraph syntax&rdquo; section of the
  2174. ffmpeg-filters manual.
  2175. </p>
  2176. <p>Input link labels must refer to input streams using the
  2177. <code>[file_index:stream_specifier]</code> syntax (i.e. the same as &lsquo;<samp>-map</samp>&rsquo;
  2178. uses). If <var>stream_specifier</var> matches multiple streams, the first one will be
  2179. used. An unlabeled input will be connected to the first unused input stream of
  2180. the matching type.
  2181. </p>
  2182. <p>Output link labels are referred to with &lsquo;<samp>-map</samp>&rsquo;. Unlabeled outputs are
  2183. added to the first output file.
  2184. </p>
  2185. <p>Note that with this option it is possible to use only lavfi sources without
  2186. normal input files.
  2187. </p>
  2188. <p>For example, to overlay an image over video
  2189. </p><div class="example">
  2190. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
  2191. '[out]' out.mkv
  2192. </pre></div>
  2193. <p>Here <code>[0:v]</code> refers to the first video stream in the first input file,
  2194. which is linked to the first (main) input of the overlay filter. Similarly the
  2195. first video stream in the second input is linked to the second (overlay) input
  2196. of overlay.
  2197. </p>
  2198. <p>Assuming there is only one video stream in each input file, we can omit input
  2199. labels, so the above is equivalent to
  2200. </p><div class="example">
  2201. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
  2202. '[out]' out.mkv
  2203. </pre></div>
  2204. <p>Furthermore we can omit the output label and the single output from the filter
  2205. graph will be added to the output file automatically, so we can simply write
  2206. </p><div class="example">
  2207. <pre class="example">ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
  2208. </pre></div>
  2209. <p>To generate 5 seconds of pure red video using lavfi <code>color</code> source:
  2210. </p><div class="example">
  2211. <pre class="example">ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
  2212. </pre></div>
  2213. </dd>
  2214. <dt>&lsquo;<samp>-filter_complex_threads <var>nb_threads</var> (<em>global</em>)</samp>&rsquo;</dt>
  2215. <dd><p>Defines how many threads are used to process a filter_complex graph.
  2216. Similar to filter_threads but used for <code>-filter_complex</code> graphs only.
  2217. The default is the number of available CPUs.
  2218. </p>
  2219. </dd>
  2220. <dt>&lsquo;<samp>-lavfi <var>filtergraph</var> (<em>global</em>)</samp>&rsquo;</dt>
  2221. <dd><p>Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  2222. outputs. Equivalent to &lsquo;<samp>-filter_complex</samp>&rsquo;.
  2223. </p>
  2224. </dd>
  2225. <dt>&lsquo;<samp>-filter_complex_script <var>filename</var> (<em>global</em>)</samp>&rsquo;</dt>
  2226. <dd><p>This option is similar to &lsquo;<samp>-filter_complex</samp>&rsquo;, the only difference is that
  2227. its argument is the name of the file from which a complex filtergraph
  2228. description is to be read.
  2229. </p>
  2230. </dd>
  2231. <dt>&lsquo;<samp>-accurate_seek (<em>input</em>)</samp>&rsquo;</dt>
  2232. <dd><p>This option enables or disables accurate seeking in input files with the
  2233. &lsquo;<samp>-ss</samp>&rsquo; option. It is enabled by default, so seeking is accurate when
  2234. transcoding. Use &lsquo;<samp>-noaccurate_seek</samp>&rsquo; to disable it, which may be useful
  2235. e.g. when copying some streams and transcoding the others.
  2236. </p>
  2237. </dd>
  2238. <dt>&lsquo;<samp>-seek_timestamp (<em>input</em>)</samp>&rsquo;</dt>
  2239. <dd><p>This option enables or disables seeking by timestamp in input files with the
  2240. &lsquo;<samp>-ss</samp>&rsquo; option. It is disabled by default. If enabled, the argument
  2241. to the &lsquo;<samp>-ss</samp>&rsquo; option is considered an actual timestamp, and is not
  2242. offset by the start time of the file. This matters only for files which do
  2243. not start from timestamp 0, such as transport streams.
  2244. </p>
  2245. </dd>
  2246. <dt>&lsquo;<samp>-thread_queue_size <var>size</var> (<em>input</em>)</samp>&rsquo;</dt>
  2247. <dd><p>This option sets the maximum number of queued packets when reading from the
  2248. file or device. With low latency / high rate live streams, packets may be
  2249. discarded if they are not read in a timely manner; raising this value can
  2250. avoid it.
  2251. </p>
  2252. </dd>
  2253. <dt>&lsquo;<samp>-sdp_file <var>file</var> (<em>global</em>)</samp>&rsquo;</dt>
  2254. <dd><p>Print sdp information for an output stream to <var>file</var>.
  2255. This allows dumping sdp information when at least one output isn&rsquo;t an
  2256. rtp stream. (Requires at least one of the output formats to be rtp).
  2257. </p>
  2258. </dd>
  2259. <dt>&lsquo;<samp>-discard (<em>input</em>)</samp>&rsquo;</dt>
  2260. <dd><p>Allows discarding specific streams or frames from streams.
  2261. Any input stream can be fully discarded, using value <code>all</code> whereas
  2262. selective discarding of frames from a stream occurs at the demuxer
  2263. and is not supported by all demuxers.
  2264. </p>
  2265. <dl compact="compact">
  2266. <dt>&lsquo;<samp>none</samp>&rsquo;</dt>
  2267. <dd><p>Discard no frame.
  2268. </p>
  2269. </dd>
  2270. <dt>&lsquo;<samp>default</samp>&rsquo;</dt>
  2271. <dd><p>Default, which discards no frames.
  2272. </p>
  2273. </dd>
  2274. <dt>&lsquo;<samp>noref</samp>&rsquo;</dt>
  2275. <dd><p>Discard all non-reference frames.
  2276. </p>
  2277. </dd>
  2278. <dt>&lsquo;<samp>bidir</samp>&rsquo;</dt>
  2279. <dd><p>Discard all bidirectional frames.
  2280. </p>
  2281. </dd>
  2282. <dt>&lsquo;<samp>nokey</samp>&rsquo;</dt>
  2283. <dd><p>Discard all frames excepts keyframes.
  2284. </p>
  2285. </dd>
  2286. <dt>&lsquo;<samp>all</samp>&rsquo;</dt>
  2287. <dd><p>Discard all frames.
  2288. </p></dd>
  2289. </dl>
  2290. </dd>
  2291. <dt>&lsquo;<samp>-abort_on <var>flags</var> (<em>global</em>)</samp>&rsquo;</dt>
  2292. <dd><p>Stop and abort on various conditions. The following flags are available:
  2293. </p>
  2294. <dl compact="compact">
  2295. <dt>&lsquo;<samp>empty_output</samp>&rsquo;</dt>
  2296. <dd><p>No packets were passed to the muxer, the output is empty.
  2297. </p></dd>
  2298. </dl>
  2299. </dd>
  2300. <dt>&lsquo;<samp>-xerror (<em>global</em>)</samp>&rsquo;</dt>
  2301. <dd><p>Stop and exit on error
  2302. </p>
  2303. </dd>
  2304. <dt>&lsquo;<samp>-max_muxing_queue_size <var>packets</var> (<em>output,per-stream</em>)</samp>&rsquo;</dt>
  2305. <dd><p>When transcoding audio and/or video streams, ffmpeg will not begin writing into
  2306. the output until it has one packet for each such stream. While waiting for that
  2307. to happen, packets for other streams are buffered. This option sets the size of
  2308. this buffer, in packets, for the matching output stream.
  2309. </p>
  2310. <p>The default value of this option should be high enough for most uses, so only
  2311. touch this option if you are sure that you need it.
  2312. </p>
  2313. </dd>
  2314. </dl>
  2315. <p>As a special exception, you can use a bitmap subtitle stream as input: it
  2316. will be converted into a video with the same size as the largest video in
  2317. the file, or 720x576 if no video is present. Note that this is an
  2318. experimental and temporary solution. It will be removed once libavfilter has
  2319. proper support for subtitles.
  2320. </p>
  2321. <p>For example, to hardcode subtitles on top of a DVB-T recording stored in
  2322. MPEG-TS format, delaying the subtitles by 1 second:
  2323. </p><div class="example">
  2324. <pre class="example">ffmpeg -i input.ts -filter_complex \
  2325. '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
  2326. -sn -map '#0x2dc' output.mkv
  2327. </pre></div>
  2328. <p>(0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
  2329. audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
  2330. </p>
  2331. <a name="Preset-files"></a>
  2332. <h2 class="section"><a href="ffmpeg.html#toc-Preset-files">5.12 Preset files</a></h2>
  2333. <p>A preset file contains a sequence of <var>option</var>=<var>value</var> pairs,
  2334. one for each line, specifying a sequence of options which would be
  2335. awkward to specify on the command line. Lines starting with the hash
  2336. (&rsquo;#&rsquo;) character are ignored and are used to provide comments. Check
  2337. the &lsquo;<tt>presets</tt>&rsquo; directory in the FFmpeg source tree for examples.
  2338. </p>
  2339. <p>There are two types of preset files: ffpreset and avpreset files.
  2340. </p>
  2341. <a name="ffpreset-files"></a>
  2342. <h3 class="subsection"><a href="ffmpeg.html#toc-ffpreset-files">5.12.1 ffpreset files</a></h3>
  2343. <p>ffpreset files are specified with the <code>vpre</code>, <code>apre</code>,
  2344. <code>spre</code>, and <code>fpre</code> options. The <code>fpre</code> option takes the
  2345. filename of the preset instead of a preset name as input and can be
  2346. used for any kind of codec. For the <code>vpre</code>, <code>apre</code>, and
  2347. <code>spre</code> options, the options specified in a preset file are
  2348. applied to the currently selected codec of the same type as the preset
  2349. option.
  2350. </p>
  2351. <p>The argument passed to the <code>vpre</code>, <code>apre</code>, and <code>spre</code>
  2352. preset options identifies the preset file to use according to the
  2353. following rules:
  2354. </p>
  2355. <p>First ffmpeg searches for a file named <var>arg</var>.ffpreset in the
  2356. directories &lsquo;<tt>$FFMPEG_DATADIR</tt>&rsquo; (if set), and &lsquo;<tt>$HOME/.ffmpeg</tt>&rsquo;, and in
  2357. the datadir defined at configuration time (usually &lsquo;<tt>PREFIX/share/ffmpeg</tt>&rsquo;)
  2358. or in a &lsquo;<tt>ffpresets</tt>&rsquo; folder along the executable on win32,
  2359. in that order. For example, if the argument is <code>libvpx-1080p</code>, it will
  2360. search for the file &lsquo;<tt>libvpx-1080p.ffpreset</tt>&rsquo;.
  2361. </p>
  2362. <p>If no such file is found, then ffmpeg will search for a file named
  2363. <var>codec_name</var>-<var>arg</var>.ffpreset in the above-mentioned
  2364. directories, where <var>codec_name</var> is the name of the codec to which
  2365. the preset file options will be applied. For example, if you select
  2366. the video codec with <code>-vcodec libvpx</code> and use <code>-vpre 1080p</code>,
  2367. then it will search for the file &lsquo;<tt>libvpx-1080p.ffpreset</tt>&rsquo;.
  2368. </p>
  2369. <a name="avpreset-files"></a>
  2370. <h3 class="subsection"><a href="ffmpeg.html#toc-avpreset-files">5.12.2 avpreset files</a></h3>
  2371. <p>avpreset files are specified with the <code>pre</code> option. They work similar to
  2372. ffpreset files, but they only allow encoder- specific options. Therefore, an
  2373. <var>option</var>=<var>value</var> pair specifying an encoder cannot be used.
  2374. </p>
  2375. <p>When the <code>pre</code> option is specified, ffmpeg will look for files with the
  2376. suffix .avpreset in the directories &lsquo;<tt>$AVCONV_DATADIR</tt>&rsquo; (if set), and
  2377. &lsquo;<tt>$HOME/.avconv</tt>&rsquo;, and in the datadir defined at configuration time (usually
  2378. &lsquo;<tt>PREFIX/share/ffmpeg</tt>&rsquo;), in that order.
  2379. </p>
  2380. <p>First ffmpeg searches for a file named <var>codec_name</var>-<var>arg</var>.avpreset in
  2381. the above-mentioned directories, where <var>codec_name</var> is the name of the codec
  2382. to which the preset file options will be applied. For example, if you select the
  2383. video codec with <code>-vcodec libvpx</code> and use <code>-pre 1080p</code>, then it will
  2384. search for the file &lsquo;<tt>libvpx-1080p.avpreset</tt>&rsquo;.
  2385. </p>
  2386. <p>If no such file is found, then ffmpeg will search for a file named
  2387. <var>arg</var>.avpreset in the same directories.
  2388. </p>
  2389. <a name="Examples"></a>
  2390. <h1 class="chapter"><a href="ffmpeg.html#toc-Examples">6 Examples</a></h1>
  2391. <a name="Video-and-Audio-grabbing"></a>
  2392. <h2 class="section"><a href="ffmpeg.html#toc-Video-and-Audio-grabbing">6.1 Video and Audio grabbing</a></h2>
  2393. <p>If you specify the input format and device then ffmpeg can grab video
  2394. and audio directly.
  2395. </p>
  2396. <div class="example">
  2397. <pre class="example">ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  2398. </pre></div>
  2399. <p>Or with an ALSA audio source (mono input, card id 1) instead of OSS:
  2400. </p><div class="example">
  2401. <pre class="example">ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
  2402. </pre></div>
  2403. <p>Note that you must activate the right video source and channel before
  2404. launching ffmpeg with any TV viewer such as
  2405. <a href="http://linux.bytesex.org/xawtv/">xawtv</a> by Gerd Knorr. You also
  2406. have to set the audio recording levels correctly with a
  2407. standard mixer.
  2408. </p>
  2409. <a name="X11-grabbing"></a>
  2410. <h2 class="section"><a href="ffmpeg.html#toc-X11-grabbing">6.2 X11 grabbing</a></h2>
  2411. <p>Grab the X11 display with ffmpeg via
  2412. </p>
  2413. <div class="example">
  2414. <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
  2415. </pre></div>
  2416. <p>0.0 is display.screen number of your X11 server, same as
  2417. the DISPLAY environment variable.
  2418. </p>
  2419. <div class="example">
  2420. <pre class="example">ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
  2421. </pre></div>
  2422. <p>0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  2423. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  2424. </p>
  2425. <a name="Video-and-Audio-file-format-conversion"></a>
  2426. <h2 class="section"><a href="ffmpeg.html#toc-Video-and-Audio-file-format-conversion">6.3 Video and Audio file format conversion</a></h2>
  2427. <p>Any supported file format and protocol can serve as input to ffmpeg:
  2428. </p>
  2429. <p>Examples:
  2430. </p><ul>
  2431. <li>
  2432. You can use YUV files as input:
  2433. <div class="example">
  2434. <pre class="example">ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  2435. </pre></div>
  2436. <p>It will use the files:
  2437. </p><div class="example">
  2438. <pre class="example">/tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  2439. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  2440. </pre></div>
  2441. <p>The Y files use twice the resolution of the U and V files. They are
  2442. raw files, without header. They can be generated by all decent video
  2443. decoders. You must specify the size of the image with the &lsquo;<samp>-s</samp>&rsquo; option
  2444. if ffmpeg cannot guess it.
  2445. </p>
  2446. </li><li>
  2447. You can input from a raw YUV420P file:
  2448. <div class="example">
  2449. <pre class="example">ffmpeg -i /tmp/test.yuv /tmp/out.avi
  2450. </pre></div>
  2451. <p>test.yuv is a file containing raw YUV planar data. Each frame is composed
  2452. of the Y plane followed by the U and V planes at half vertical and
  2453. horizontal resolution.
  2454. </p>
  2455. </li><li>
  2456. You can output to a raw YUV420P file:
  2457. <div class="example">
  2458. <pre class="example">ffmpeg -i mydivx.avi hugefile.yuv
  2459. </pre></div>
  2460. </li><li>
  2461. You can set several input files and output files:
  2462. <div class="example">
  2463. <pre class="example">ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  2464. </pre></div>
  2465. <p>Converts the audio file a.wav and the raw YUV video file a.yuv
  2466. to MPEG file a.mpg.
  2467. </p>
  2468. </li><li>
  2469. You can also do audio and video conversions at the same time:
  2470. <div class="example">
  2471. <pre class="example">ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  2472. </pre></div>
  2473. <p>Converts a.wav to MPEG audio at 22050 Hz sample rate.
  2474. </p>
  2475. </li><li>
  2476. You can encode to several formats at the same time and define a
  2477. mapping from input stream to output streams:
  2478. <div class="example">
  2479. <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
  2480. </pre></div>
  2481. <p>Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. &rsquo;-map
  2482. file:index&rsquo; specifies which input stream is used for each output
  2483. stream, in the order of the definition of output streams.
  2484. </p>
  2485. </li><li>
  2486. You can transcode decrypted VOBs:
  2487. <div class="example">
  2488. <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
  2489. </pre></div>
  2490. <p>This is a typical DVD ripping example; the input is a VOB file, the
  2491. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  2492. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  2493. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  2494. input video. Furthermore, the audio stream is MP3-encoded so you need
  2495. to enable LAME support by passing <code>--enable-libmp3lame</code> to configure.
  2496. The mapping is particularly useful for DVD transcoding
  2497. to get the desired audio language.
  2498. </p>
  2499. <p>NOTE: To see the supported input formats, use <code>ffmpeg -demuxers</code>.
  2500. </p>
  2501. </li><li>
  2502. You can extract images from a video, or create a video from many images:
  2503. <p>For extracting images from a video:
  2504. </p><div class="example">
  2505. <pre class="example">ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  2506. </pre></div>
  2507. <p>This will extract one video frame per second from the video and will
  2508. output them in files named &lsquo;<tt>foo-001.jpeg</tt>&rsquo;, &lsquo;<tt>foo-002.jpeg</tt>&rsquo;,
  2509. etc. Images will be rescaled to fit the new WxH values.
  2510. </p>
  2511. <p>If you want to extract just a limited number of frames, you can use the
  2512. above command in combination with the <code>-frames:v</code> or <code>-t</code> option,
  2513. or in combination with -ss to start extracting from a certain point in time.
  2514. </p>
  2515. <p>For creating a video from many images:
  2516. </p><div class="example">
  2517. <pre class="example">ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
  2518. </pre></div>
  2519. <p>The syntax <code>foo-%03d.jpeg</code> specifies to use a decimal number
  2520. composed of three digits padded with zeroes to express the sequence
  2521. number. It is the same syntax supported by the C printf function, but
  2522. only formats accepting a normal integer are suitable.
  2523. </p>
  2524. <p>When importing an image sequence, -i also supports expanding
  2525. shell-like wildcard patterns (globbing) internally, by selecting the
  2526. image2-specific <code>-pattern_type glob</code> option.
  2527. </p>
  2528. <p>For example, for creating a video from filenames matching the glob pattern
  2529. <code>foo-*.jpeg</code>:
  2530. </p><div class="example">
  2531. <pre class="example">ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
  2532. </pre></div>
  2533. </li><li>
  2534. You can put many streams of the same type in the output:
  2535. <div class="example">
  2536. <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
  2537. </pre></div>
  2538. <p>The resulting output file &lsquo;<tt>test12.nut</tt>&rsquo; will contain the first four streams
  2539. from the input files in reverse order.
  2540. </p>
  2541. </li><li>
  2542. To force CBR video output:
  2543. <div class="example">
  2544. <pre class="example">ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
  2545. </pre></div>
  2546. </li><li>
  2547. The four options lmin, lmax, mblmin and mblmax use &rsquo;lambda&rsquo; units,
  2548. but you may use the QP2LAMBDA constant to easily convert from &rsquo;q&rsquo; units:
  2549. <div class="example">
  2550. <pre class="example">ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  2551. </pre></div>
  2552. </li></ul>
  2553. <a name="See-Also"></a>
  2554. <h1 class="chapter"><a href="ffmpeg.html#toc-See-Also">7 See Also</a></h1>
  2555. <p><a href="ffmpeg-all.html">ffmpeg-all</a>,
  2556. <a href="ffplay.html">ffplay</a>, <a href="ffprobe.html">ffprobe</a>,
  2557. <a href="ffmpeg-utils.html">ffmpeg-utils</a>,
  2558. <a href="ffmpeg-scaler.html">ffmpeg-scaler</a>,
  2559. <a href="ffmpeg-resampler.html">ffmpeg-resampler</a>,
  2560. <a href="ffmpeg-codecs.html">ffmpeg-codecs</a>,
  2561. <a href="ffmpeg-bitstream-filters.html">ffmpeg-bitstream-filters</a>,
  2562. <a href="ffmpeg-formats.html">ffmpeg-formats</a>,
  2563. <a href="ffmpeg-devices.html">ffmpeg-devices</a>,
  2564. <a href="ffmpeg-protocols.html">ffmpeg-protocols</a>,
  2565. <a href="ffmpeg-filters.html">ffmpeg-filters</a>
  2566. </p>
  2567. <a name="Authors"></a>
  2568. <h1 class="chapter"><a href="ffmpeg.html#toc-Authors">8 Authors</a></h1>
  2569. <p>The FFmpeg developers.
  2570. </p>
  2571. <p>For details about the authorship, see the Git history of the project
  2572. (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command
  2573. <code>git log</code> in the FFmpeg source directory, or browsing the
  2574. online repository at <a href="http://source.ffmpeg.org">http://source.ffmpeg.org</a>.
  2575. </p>
  2576. <p>Maintainers for the specific components are listed in the file
  2577. &lsquo;<tt>MAINTAINERS</tt>&rsquo; in the source code tree.
  2578. </p>
  2579. </div>
  2580. </body>
  2581. </html>