ffmpeg.html 131 KB

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