ffmpeg.html 151 KB

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