ffmpeg.html 211 KB

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