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

ffmpeg.html 149KB

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