ffmpeg.html 163 KB

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