ffmpeg.texi 97 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498
  1. \input texinfo @c -*- texinfo -*-
  2. @documentencoding UTF-8
  3. @settitle ffmpeg Documentation
  4. @titlepage
  5. @center @titlefont{ffmpeg Documentation}
  6. @end titlepage
  7. @top
  8. @contents
  9. @chapter Synopsis
  10. ffmpeg [@var{global_options}] @{[@var{input_file_options}] -i @file{input_url}@} ... @{[@var{output_file_options}] @file{output_url}@} ...
  11. @chapter Description
  12. @c man begin DESCRIPTION
  13. @command{ffmpeg} is a very fast video and audio converter that can also grab from
  14. a live audio/video source. It can also convert between arbitrary sample
  15. rates and resize video on the fly with a high quality polyphase filter.
  16. @command{ffmpeg} reads from an arbitrary number of input "files" (which can be regular
  17. files, pipes, network streams, grabbing devices, etc.), specified by the
  18. @code{-i} option, and writes to an arbitrary number of output "files", which are
  19. specified by a plain output url. Anything found on the command line which
  20. cannot be interpreted as an option is considered to be an output url.
  21. Each input or output url can, in principle, contain any number of streams of
  22. different types (video/audio/subtitle/attachment/data). The allowed number and/or
  23. types of streams may be limited by the container format. Selecting which
  24. streams from which inputs will go into which output is either done automatically
  25. or with the @code{-map} option (see the Stream selection chapter).
  26. To refer to input files in options, you must use their indices (0-based). E.g.
  27. the first input file is @code{0}, the second is @code{1}, etc. Similarly, streams
  28. within a file are referred to by their indices. E.g. @code{2:3} refers to the
  29. fourth stream in the third input file. Also see the Stream specifiers chapter.
  30. As a general rule, options are applied to the next specified
  31. file. Therefore, order is important, and you can have the same
  32. option on the command line multiple times. Each occurrence is
  33. then applied to the next input or output file.
  34. Exceptions from this rule are the global options (e.g. verbosity level),
  35. which should be specified first.
  36. Do not mix input and output files -- first specify all input files, then all
  37. output files. Also do not mix options which belong to different files. All
  38. options apply ONLY to the next input or output file and are reset between files.
  39. @itemize
  40. @item
  41. To set the video bitrate of the output file to 64 kbit/s:
  42. @example
  43. ffmpeg -i input.avi -b:v 64k -bufsize 64k output.avi
  44. @end example
  45. @item
  46. To force the frame rate of the output file to 24 fps:
  47. @example
  48. ffmpeg -i input.avi -r 24 output.avi
  49. @end example
  50. @item
  51. To force the frame rate of the input file (valid for raw formats only)
  52. to 1 fps and the frame rate of the output file to 24 fps:
  53. @example
  54. ffmpeg -r 1 -i input.m2v -r 24 output.avi
  55. @end example
  56. @end itemize
  57. The format option may be needed for raw input files.
  58. @c man end DESCRIPTION
  59. @chapter Detailed description
  60. @c man begin DETAILED DESCRIPTION
  61. The transcoding process in @command{ffmpeg} for each output can be described by
  62. the following diagram:
  63. @verbatim
  64. _______ ______________
  65. | | | |
  66. | input | demuxer | encoded data | decoder
  67. | file | ---------> | packets | -----+
  68. |_______| |______________| |
  69. v
  70. _________
  71. | |
  72. | decoded |
  73. | frames |
  74. |_________|
  75. ________ ______________ |
  76. | | | | |
  77. | output | <-------- | encoded data | <----+
  78. | file | muxer | packets | encoder
  79. |________| |______________|
  80. @end verbatim
  81. @command{ffmpeg} calls the libavformat library (containing demuxers) to read
  82. input files and get packets containing encoded data from them. When there are
  83. multiple input files, @command{ffmpeg} tries to keep them synchronized by
  84. tracking lowest timestamp on any active input stream.
  85. Encoded packets are then passed to the decoder (unless streamcopy is selected
  86. for the stream, see further for a description). The decoder produces
  87. uncompressed frames (raw video/PCM audio/...) which can be processed further by
  88. filtering (see next section). After filtering, the frames are passed to the
  89. encoder, which encodes them and outputs encoded packets. Finally those are
  90. passed to the muxer, which writes the encoded packets to the output file.
  91. @section Filtering
  92. Before encoding, @command{ffmpeg} can process raw audio and video frames using
  93. filters from the libavfilter library. Several chained filters form a filter
  94. graph. @command{ffmpeg} distinguishes between two types of filtergraphs:
  95. simple and complex.
  96. @subsection Simple filtergraphs
  97. Simple filtergraphs are those that have exactly one input and output, both of
  98. the same type. In the above diagram they can be represented by simply inserting
  99. an additional step between decoding and encoding:
  100. @verbatim
  101. _________ ______________
  102. | | | |
  103. | decoded | | encoded data |
  104. | frames |\ _ | packets |
  105. |_________| \ /||______________|
  106. \ __________ /
  107. simple _\|| | / encoder
  108. filtergraph | filtered |/
  109. | frames |
  110. |__________|
  111. @end verbatim
  112. Simple filtergraphs are configured with the per-stream @option{-filter} option
  113. (with @option{-vf} and @option{-af} aliases for video and audio respectively).
  114. A simple filtergraph for video can look for example like this:
  115. @verbatim
  116. _______ _____________ _______ ________
  117. | | | | | | | |
  118. | input | ---> | deinterlace | ---> | scale | ---> | output |
  119. |_______| |_____________| |_______| |________|
  120. @end verbatim
  121. Note that some filters change frame properties but not frame contents. E.g. the
  122. @code{fps} filter in the example above changes number of frames, but does not
  123. touch the frame contents. Another example is the @code{setpts} filter, which
  124. only sets timestamps and otherwise passes the frames unchanged.
  125. @subsection Complex filtergraphs
  126. Complex filtergraphs are those which cannot be described as simply a linear
  127. processing chain applied to one stream. This is the case, for example, when the graph has
  128. more than one input and/or output, or when output stream type is different from
  129. input. They can be represented with the following diagram:
  130. @verbatim
  131. _________
  132. | |
  133. | input 0 |\ __________
  134. |_________| \ | |
  135. \ _________ /| output 0 |
  136. \ | | / |__________|
  137. _________ \| complex | /
  138. | | | |/
  139. | input 1 |---->| filter |\
  140. |_________| | | \ __________
  141. /| graph | \ | |
  142. / | | \| output 1 |
  143. _________ / |_________| |__________|
  144. | | /
  145. | input 2 |/
  146. |_________|
  147. @end verbatim
  148. Complex filtergraphs are configured with the @option{-filter_complex} option.
  149. Note that this option is global, since a complex filtergraph, by its nature,
  150. cannot be unambiguously associated with a single stream or file.
  151. The @option{-lavfi} option is equivalent to @option{-filter_complex}.
  152. A trivial example of a complex filtergraph is the @code{overlay} filter, which
  153. has two video inputs and one video output, containing one video overlaid on top
  154. of the other. Its audio counterpart is the @code{amix} filter.
  155. @section Stream copy
  156. Stream copy is a mode selected by supplying the @code{copy} parameter to the
  157. @option{-codec} option. It makes @command{ffmpeg} omit the decoding and encoding
  158. step for the specified stream, so it does only demuxing and muxing. It is useful
  159. for changing the container format or modifying container-level metadata. The
  160. diagram above will, in this case, simplify to this:
  161. @verbatim
  162. _______ ______________ ________
  163. | | | | | |
  164. | input | demuxer | encoded data | muxer | output |
  165. | file | ---------> | packets | -------> | file |
  166. |_______| |______________| |________|
  167. @end verbatim
  168. Since there is no decoding or encoding, it is very fast and there is no quality
  169. loss. However, it might not work in some cases because of many factors. Applying
  170. filters is obviously also impossible, since filters work on uncompressed data.
  171. @c man end DETAILED DESCRIPTION
  172. @chapter Stream selection
  173. @c man begin STREAM SELECTION
  174. @command{ffmpeg} provides the @code{-map} option for manual control of stream selection in each
  175. output file. Users can skip @code{-map} and let ffmpeg perform automatic stream selection as
  176. described below. The @code{-vn / -an / -sn / -dn} options can be used to skip inclusion of
  177. video, audio, subtitle and data streams respectively, whether manually mapped or automatically
  178. selected, except for those streams which are outputs of complex filtergraphs.
  179. @section Description
  180. The sub-sections that follow describe the various rules that are involved in stream selection.
  181. The examples that follow next show how these rules are applied in practice.
  182. While every effort is made to accurately reflect the behavior of the program, FFmpeg is under
  183. continuous development and the code may have changed since the time of this writing.
  184. @subsection Automatic stream selection
  185. In the absence of any map options for a particular output file, ffmpeg inspects the output
  186. format to check which type of streams can be included in it, viz. video, audio and/or
  187. subtitles. For each acceptable stream type, ffmpeg will pick one stream, when available,
  188. from among all the inputs.
  189. It will select that stream based upon the following criteria:
  190. @itemize
  191. @item
  192. for video, it is the stream with the highest resolution,
  193. @item
  194. for audio, it is the stream with the most channels,
  195. @item
  196. for subtitles, it is the first subtitle stream found but there's a caveat.
  197. The output format's default subtitle encoder can be either text-based or image-based,
  198. and only a subtitle stream of the same type will be chosen.
  199. @end itemize
  200. In the case where several streams of the same type rate equally, the stream with the lowest
  201. index is chosen.
  202. Data or attachment streams are not automatically selected and can only be included
  203. using @code{-map}.
  204. @subsection Manual stream selection
  205. When @code{-map} is used, only user-mapped streams are included in that output file,
  206. with one possible exception for filtergraph outputs described below.
  207. @subsection Complex filtergraphs
  208. If there are any complex filtergraph output streams with unlabeled pads, they will be added
  209. to the first output file. This will lead to a fatal error if the stream type is not supported
  210. by the output format. In the absence of the map option, the inclusion of these streams leads
  211. to the automatic stream selection of their types being skipped. If map options are present,
  212. these filtergraph streams are included in addition to the mapped streams.
  213. Complex filtergraph output streams with labeled pads must be mapped once and exactly once.
  214. @subsection Stream handling
  215. Stream handling is independent of stream selection, with an exception for subtitles described
  216. below. Stream handling is set via the @code{-codec} option addressed to streams within a
  217. specific @emph{output} file. In particular, codec options are applied by ffmpeg after the
  218. stream selection process and thus do not influence the latter. If no @code{-codec} option is
  219. specified for a stream type, ffmpeg will select the default encoder registered by the output
  220. file muxer.
  221. An exception exists for subtitles. If a subtitle encoder is specified for an output file, the
  222. first subtitle stream found of any type, text or image, will be included. ffmpeg does not validate
  223. if the specified encoder can convert the selected stream or if the converted stream is acceptable
  224. within the output format. This applies generally as well: when the user sets an encoder manually,
  225. the stream selection process cannot check if the encoded stream can be muxed into the output file.
  226. If it cannot, ffmpeg will abort and @emph{all} output files will fail to be processed.
  227. @section Examples
  228. The following examples illustrate the behavior, quirks and limitations of ffmpeg's stream
  229. selection methods.
  230. They assume the following three input files.
  231. @verbatim
  232. input file 'A.avi'
  233. stream 0: video 640x360
  234. stream 1: audio 2 channels
  235. input file 'B.mp4'
  236. stream 0: video 1920x1080
  237. stream 1: audio 2 channels
  238. stream 2: subtitles (text)
  239. stream 3: audio 5.1 channels
  240. stream 4: subtitles (text)
  241. input file 'C.mkv'
  242. stream 0: video 1280x720
  243. stream 1: audio 2 channels
  244. stream 2: subtitles (image)
  245. @end verbatim
  246. @subsubheading Example: automatic stream selection
  247. @example
  248. ffmpeg -i A.avi -i B.mp4 out1.mkv out2.wav -map 1:a -c:a copy out3.mov
  249. @end example
  250. There are three output files specified, and for the first two, no @code{-map} options
  251. are set, so ffmpeg will select streams for these two files automatically.
  252. @file{out1.mkv} is a Matroska container file and accepts video, audio and subtitle streams,
  253. so ffmpeg will try to select one of each type.@*
  254. For video, it will select @code{stream 0} from @file{B.mp4}, which has the highest
  255. resolution among all the input video streams.@*
  256. For audio, it will select @code{stream 3} from @file{B.mp4}, since it has the greatest
  257. number of channels.@*
  258. For subtitles, it will select @code{stream 2} from @file{B.mp4}, which is the first subtitle
  259. stream from among @file{A.avi} and @file{B.mp4}.
  260. @file{out2.wav} accepts only audio streams, so only @code{stream 3} from @file{B.mp4} is
  261. selected.
  262. For @file{out3.mov}, since a @code{-map} option is set, no automatic stream selection will
  263. occur. The @code{-map 1:a} option will select all audio streams from the second input
  264. @file{B.mp4}. No other streams will be included in this output file.
  265. For the first two outputs, all included streams will be transcoded. The encoders chosen will
  266. be the default ones registered by each output format, which may not match the codec of the
  267. selected input streams.
  268. For the third output, codec option for audio streams has been set
  269. to @code{copy}, so no decoding-filtering-encoding operations will occur, or @emph{can} occur.
  270. Packets of selected streams shall be conveyed from the input file and muxed within the output
  271. file.
  272. @subsubheading Example: automatic subtitles selection
  273. @example
  274. ffmpeg -i C.mkv out1.mkv -c:s dvdsub -an out2.mkv
  275. @end example
  276. Although @file{out1.mkv} is a Matroska container file which accepts subtitle streams, only a
  277. video and audio stream shall be selected. The subtitle stream of @file{C.mkv} is image-based
  278. and the default subtitle encoder of the Matroska muxer is text-based, so a transcode operation
  279. for the subtitles is expected to fail and hence the stream isn't selected. However, in
  280. @file{out2.mkv}, a subtitle encoder is specified in the command and so, the subtitle stream is
  281. selected, in addition to the video stream. The presence of @code{-an} disables audio stream
  282. selection for @file{out2.mkv}.
  283. @subsubheading Example: unlabeled filtergraph outputs
  284. @example
  285. ffmpeg -i A.avi -i C.mkv -i B.mp4 -filter_complex "overlay" out1.mp4 out2.srt
  286. @end example
  287. A filtergraph is setup here using the @code{-filter_complex} option and consists of a single
  288. video filter. The @code{overlay} filter requires exactly two video inputs, but none are
  289. specified, so the first two available video streams are used, those of @file{A.avi} and
  290. @file{C.mkv}. The output pad of the filter has no label and so is sent to the first output file
  291. @file{out1.mp4}. Due to this, automatic selection of the video stream is skipped, which would
  292. have selected the stream in @file{B.mp4}. The audio stream with most channels viz. @code{stream 3}
  293. in @file{B.mp4}, is chosen automatically. No subtitle stream is chosen however, since the MP4
  294. format has no default subtitle encoder registered, and the user hasn't specified a subtitle encoder.
  295. The 2nd output file, @file{out2.srt}, only accepts text-based subtitle streams. So, even though
  296. the first subtitle stream available belongs to @file{C.mkv}, it is image-based and hence skipped.
  297. The selected stream, @code{stream 2} in @file{B.mp4}, is the first text-based subtitle stream.
  298. @subsubheading Example: labeled filtergraph outputs
  299. @example
  300. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
  301. -map '[outv]' -an out1.mp4 \
  302. out2.mkv \
  303. -map '[outv]' -map 1:a:0 out3.mkv
  304. @end example
  305. The above command will fail, as the output pad labelled @code{[outv]} has been mapped twice.
  306. None of the output files shall be processed.
  307. @example
  308. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0[outv];overlay;aresample" \
  309. -an out1.mp4 \
  310. out2.mkv \
  311. -map 1:a:0 out3.mkv
  312. @end example
  313. This command above will also fail as the hue filter output has a label, @code{[outv]},
  314. and hasn't been mapped anywhere.
  315. The command should be modified as follows,
  316. @example
  317. ffmpeg -i A.avi -i B.mp4 -i C.mkv -filter_complex "[1:v]hue=s=0,split=2[outv1][outv2];overlay;aresample" \
  318. -map '[outv1]' -an out1.mp4 \
  319. out2.mkv \
  320. -map '[outv2]' -map 1:a:0 out3.mkv
  321. @end example
  322. The video stream from @file{B.mp4} is sent to the hue filter, whose output is cloned once using
  323. the split filter, and both outputs labelled. Then a copy each is mapped to the first and third
  324. output files.
  325. The overlay filter, requiring two video inputs, uses the first two unused video streams. Those
  326. are the streams from @file{A.avi} and @file{C.mkv}. The overlay output isn't labelled, so it is
  327. sent to the first output file @file{out1.mp4}, regardless of the presence of the @code{-map} option.
  328. The aresample filter is sent the first unused audio stream, that of @file{A.avi}. Since this filter
  329. output is also unlabelled, it too is mapped to the first output file. The presence of @code{-an}
  330. only suppresses automatic or manual stream selection of audio streams, not outputs sent from
  331. filtergraphs. Both these mapped streams shall be ordered before the mapped stream in @file{out1.mp4}.
  332. The video, audio and subtitle streams mapped to @code{out2.mkv} are entirely determined by
  333. automatic stream selection.
  334. @file{out3.mkv} consists of the cloned video output from the hue filter and the first audio
  335. stream from @file{B.mp4}.
  336. @*
  337. @c man end STREAM SELECTION
  338. @chapter Options
  339. @c man begin OPTIONS
  340. @include fftools-common-opts.texi
  341. @section Main options
  342. @table @option
  343. @item -f @var{fmt} (@emph{input/output})
  344. Force input or output file format. The format is normally auto detected for input
  345. files and guessed from the file extension for output files, so this option is not
  346. needed in most cases.
  347. @item -i @var{url} (@emph{input})
  348. input file url
  349. @item -y (@emph{global})
  350. Overwrite output files without asking.
  351. @item -n (@emph{global})
  352. Do not overwrite output files, and exit immediately if a specified
  353. output file already exists.
  354. @item -stream_loop @var{number} (@emph{input})
  355. Set number of times input stream shall be looped. Loop 0 means no loop,
  356. loop -1 means infinite loop.
  357. @item -recast_media (@emph{global})
  358. Allow forcing a decoder of a different media type than the one
  359. detected or designated by the demuxer. Useful for decoding media
  360. data muxed as data streams.
  361. @item -c[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
  362. @itemx -codec[:@var{stream_specifier}] @var{codec} (@emph{input/output,per-stream})
  363. Select an encoder (when used before an output file) or a decoder (when used
  364. before an input file) for one or more streams. @var{codec} is the name of a
  365. decoder/encoder or a special value @code{copy} (output only) to indicate that
  366. the stream is not to be re-encoded.
  367. For example
  368. @example
  369. ffmpeg -i INPUT -map 0 -c:v libx264 -c:a copy OUTPUT
  370. @end example
  371. encodes all video streams with libx264 and copies all audio streams.
  372. For each stream, the last matching @code{c} option is applied, so
  373. @example
  374. ffmpeg -i INPUT -map 0 -c copy -c:v:1 libx264 -c:a:137 libvorbis OUTPUT
  375. @end example
  376. will copy all the streams except the second video, which will be encoded with
  377. libx264, and the 138th audio, which will be encoded with libvorbis.
  378. @item -t @var{duration} (@emph{input/output})
  379. When used as an input option (before @code{-i}), limit the @var{duration} of
  380. data read from the input file.
  381. When used as an output option (before an output url), stop writing the
  382. output after its duration reaches @var{duration}.
  383. @var{duration} must be a time duration specification,
  384. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  385. -to and -t are mutually exclusive and -t has priority.
  386. @item -to @var{position} (@emph{input/output})
  387. Stop writing the output or reading the input at @var{position}.
  388. @var{position} must be a time duration specification,
  389. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  390. -to and -t are mutually exclusive and -t has priority.
  391. @item -fs @var{limit_size} (@emph{output})
  392. Set the file size limit, expressed in bytes. No further chunk of bytes is written
  393. after the limit is exceeded. The size of the output file is slightly more than the
  394. requested file size.
  395. @item -ss @var{position} (@emph{input/output})
  396. When used as an input option (before @code{-i}), seeks in this input file to
  397. @var{position}. Note that in most formats it is not possible to seek exactly,
  398. so @command{ffmpeg} will seek to the closest seek point before @var{position}.
  399. When transcoding and @option{-accurate_seek} is enabled (the default), this
  400. extra segment between the seek point and @var{position} will be decoded and
  401. discarded. When doing stream copy or when @option{-noaccurate_seek} is used, it
  402. will be preserved.
  403. When used as an output option (before an output url), decodes but discards
  404. input until the timestamps reach @var{position}.
  405. @var{position} must be a time duration specification,
  406. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  407. @item -sseof @var{position} (@emph{input})
  408. Like the @code{-ss} option but relative to the "end of file". That is negative
  409. values are earlier in the file, 0 is at EOF.
  410. @item -isync @var{input_index} (@emph{input})
  411. Assign an input as a sync source.
  412. This will take the difference between the start times of the target and reference inputs and
  413. offset the timestamps of the target file by that difference. The source timestamps of the two
  414. inputs should derive from the same clock source for expected results. If @code{copyts} is set
  415. then @code{start_at_zero} must also be set. If either of the inputs has no starting timestamp
  416. then no sync adjustment is made.
  417. Acceptable values are those that refer to a valid ffmpeg input index. If the sync reference is
  418. the target index itself or @var{-1}, then no adjustment is made to target timestamps. A sync
  419. reference may not itself be synced to any other input.
  420. Default value is @var{-1}.
  421. @item -itsoffset @var{offset} (@emph{input})
  422. Set the input time offset.
  423. @var{offset} must be a time duration specification,
  424. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  425. The offset is added to the timestamps of the input files. Specifying
  426. a positive offset means that the corresponding streams are delayed by
  427. the time duration specified in @var{offset}.
  428. @item -itsscale @var{scale} (@emph{input,per-stream})
  429. Rescale input timestamps. @var{scale} should be a floating point number.
  430. @item -timestamp @var{date} (@emph{output})
  431. Set the recording timestamp in the container.
  432. @var{date} must be a date specification,
  433. see @ref{date syntax,,the Date section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  434. @item -metadata[:metadata_specifier] @var{key}=@var{value} (@emph{output,per-metadata})
  435. Set a metadata key/value pair.
  436. An optional @var{metadata_specifier} may be given to set metadata
  437. on streams, chapters or programs. See @code{-map_metadata}
  438. documentation for details.
  439. This option overrides metadata set with @code{-map_metadata}. It is
  440. also possible to delete metadata by using an empty value.
  441. For example, for setting the title in the output file:
  442. @example
  443. ffmpeg -i in.avi -metadata title="my title" out.flv
  444. @end example
  445. To set the language of the first audio stream:
  446. @example
  447. ffmpeg -i INPUT -metadata:s:a:0 language=eng OUTPUT
  448. @end example
  449. @item -disposition[:stream_specifier] @var{value} (@emph{output,per-stream})
  450. Sets the disposition for a stream.
  451. By default, the disposition is copied from the input stream, unless the output
  452. stream this option applies to is fed by a complex filtergraph - in that case the
  453. disposition is unset by default.
  454. @var{value} is a sequence of items separated by '+' or '-'. The first item may
  455. also be prefixed with '+' or '-', in which case this option modifies the default
  456. value. Otherwise (the first item is not prefixed) this options overrides the
  457. default value. A '+' prefix adds the given disposition, '-' removes it. It is
  458. also possible to clear the disposition by setting it to 0.
  459. If no @code{-disposition} options were specified for an output file, ffmpeg will
  460. automatically set the 'default' disposition on the first stream of each type,
  461. when there are multiple streams of this type in the output file and no stream of
  462. that type is already marked as default.
  463. The @code{-dispositions} option lists the known dispositions.
  464. For example, to make the second audio stream the default stream:
  465. @example
  466. ffmpeg -i in.mkv -c copy -disposition:a:1 default out.mkv
  467. @end example
  468. To make the second subtitle stream the default stream and remove the default
  469. disposition from the first subtitle stream:
  470. @example
  471. ffmpeg -i in.mkv -c copy -disposition:s:0 0 -disposition:s:1 default out.mkv
  472. @end example
  473. To add an embedded cover/thumbnail:
  474. @example
  475. ffmpeg -i in.mp4 -i IMAGE -map 0 -map 1 -c copy -c:v:1 png -disposition:v:1 attached_pic out.mp4
  476. @end example
  477. Not all muxers support embedded thumbnails, and those who do, only support a few formats, like JPEG or PNG.
  478. @item -program [title=@var{title}:][program_num=@var{program_num}:]st=@var{stream}[:st=@var{stream}...] (@emph{output})
  479. Creates a program with the specified @var{title}, @var{program_num} and adds the specified
  480. @var{stream}(s) to it.
  481. @item -target @var{type} (@emph{output})
  482. Specify target file type (@code{vcd}, @code{svcd}, @code{dvd}, @code{dv},
  483. @code{dv50}). @var{type} may be prefixed with @code{pal-}, @code{ntsc-} or
  484. @code{film-} to use the corresponding standard. All the format options
  485. (bitrate, codecs, buffer sizes) are then set automatically. You can just type:
  486. @example
  487. ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
  488. @end example
  489. Nevertheless you can specify additional options as long as you know
  490. they do not conflict with the standard, as in:
  491. @example
  492. ffmpeg -i myfile.avi -target vcd -bf 2 /tmp/vcd.mpg
  493. @end example
  494. The parameters set for each target are as follows.
  495. @strong{VCD}
  496. @example
  497. @var{pal}:
  498. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  499. -s 352x288 -r 25
  500. -codec:v mpeg1video -g 15 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  501. -ar 44100 -ac 2
  502. -codec:a mp2 -b:a 224k
  503. @var{ntsc}:
  504. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  505. -s 352x240 -r 30000/1001
  506. -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  507. -ar 44100 -ac 2
  508. -codec:a mp2 -b:a 224k
  509. @var{film}:
  510. -f vcd -muxrate 1411200 -muxpreload 0.44 -packetsize 2324
  511. -s 352x240 -r 24000/1001
  512. -codec:v mpeg1video -g 18 -b:v 1150k -maxrate:v 1150k -minrate:v 1150k -bufsize:v 327680
  513. -ar 44100 -ac 2
  514. -codec:a mp2 -b:a 224k
  515. @end example
  516. @strong{SVCD}
  517. @example
  518. @var{pal}:
  519. -f svcd -packetsize 2324
  520. -s 480x576 -pix_fmt yuv420p -r 25
  521. -codec:v mpeg2video -g 15 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  522. -ar 44100
  523. -codec:a mp2 -b:a 224k
  524. @var{ntsc}:
  525. -f svcd -packetsize 2324
  526. -s 480x480 -pix_fmt yuv420p -r 30000/1001
  527. -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  528. -ar 44100
  529. -codec:a mp2 -b:a 224k
  530. @var{film}:
  531. -f svcd -packetsize 2324
  532. -s 480x480 -pix_fmt yuv420p -r 24000/1001
  533. -codec:v mpeg2video -g 18 -b:v 2040k -maxrate:v 2516k -minrate:v 0 -bufsize:v 1835008 -scan_offset 1
  534. -ar 44100
  535. -codec:a mp2 -b:a 224k
  536. @end example
  537. @strong{DVD}
  538. @example
  539. @var{pal}:
  540. -f dvd -muxrate 10080k -packetsize 2048
  541. -s 720x576 -pix_fmt yuv420p -r 25
  542. -codec:v mpeg2video -g 15 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  543. -ar 48000
  544. -codec:a ac3 -b:a 448k
  545. @var{ntsc}:
  546. -f dvd -muxrate 10080k -packetsize 2048
  547. -s 720x480 -pix_fmt yuv420p -r 30000/1001
  548. -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  549. -ar 48000
  550. -codec:a ac3 -b:a 448k
  551. @var{film}:
  552. -f dvd -muxrate 10080k -packetsize 2048
  553. -s 720x480 -pix_fmt yuv420p -r 24000/1001
  554. -codec:v mpeg2video -g 18 -b:v 6000k -maxrate:v 9000k -minrate:v 0 -bufsize:v 1835008
  555. -ar 48000
  556. -codec:a ac3 -b:a 448k
  557. @end example
  558. @strong{DV}
  559. @example
  560. @var{pal}:
  561. -f dv
  562. -s 720x576 -pix_fmt yuv420p -r 25
  563. -ar 48000 -ac 2
  564. @var{ntsc}:
  565. -f dv
  566. -s 720x480 -pix_fmt yuv411p -r 30000/1001
  567. -ar 48000 -ac 2
  568. @var{film}:
  569. -f dv
  570. -s 720x480 -pix_fmt yuv411p -r 24000/1001
  571. -ar 48000 -ac 2
  572. @end example
  573. The @code{dv50} target is identical to the @code{dv} target except that the pixel format set is @code{yuv422p} for all three standards.
  574. Any user-set value for a parameter above will override the target preset value. In that case, the output may
  575. not comply with the target standard.
  576. @item -dn (@emph{input/output})
  577. As an input option, blocks all data streams of a file from being filtered or
  578. being automatically selected or mapped for any output. See @code{-discard}
  579. option to disable streams individually.
  580. As an output option, disables data recording i.e. automatic selection or
  581. mapping of any data stream. For full manual control see the @code{-map}
  582. option.
  583. @item -dframes @var{number} (@emph{output})
  584. Set the number of data frames to output. This is an obsolete alias for
  585. @code{-frames:d}, which you should use instead.
  586. @item -frames[:@var{stream_specifier}] @var{framecount} (@emph{output,per-stream})
  587. Stop writing to the stream after @var{framecount} frames.
  588. @item -q[:@var{stream_specifier}] @var{q} (@emph{output,per-stream})
  589. @itemx -qscale[:@var{stream_specifier}] @var{q} (@emph{output,per-stream})
  590. Use fixed quality scale (VBR). The meaning of @var{q}/@var{qscale} is
  591. codec-dependent.
  592. If @var{qscale} is used without a @var{stream_specifier} then it applies only
  593. to the video stream, this is to maintain compatibility with previous behavior
  594. and as specifying the same codec specific value to 2 different codecs that is
  595. audio and video generally is not what is intended when no stream_specifier is
  596. used.
  597. @anchor{filter_option}
  598. @item -filter[:@var{stream_specifier}] @var{filtergraph} (@emph{output,per-stream})
  599. Create the filtergraph specified by @var{filtergraph} and use it to
  600. filter the stream.
  601. @var{filtergraph} is a description of the filtergraph to apply to
  602. the stream, and must have a single input and a single output of the
  603. same type of the stream. In the filtergraph, the input is associated
  604. to the label @code{in}, and the output to the label @code{out}. See
  605. the ffmpeg-filters manual for more information about the filtergraph
  606. syntax.
  607. See the @ref{filter_complex_option,,-filter_complex option} if you
  608. want to create filtergraphs with multiple inputs and/or outputs.
  609. @item -filter_script[:@var{stream_specifier}] @var{filename} (@emph{output,per-stream})
  610. This option is similar to @option{-filter}, the only difference is that its
  611. argument is the name of the file from which a filtergraph description is to be
  612. read.
  613. @item -reinit_filter[:@var{stream_specifier}] @var{integer} (@emph{input,per-stream})
  614. This boolean option determines if the filtergraph(s) to which this stream is fed gets
  615. reinitialized when input frame parameters change mid-stream. This option is enabled by
  616. default as most video and all audio filters cannot handle deviation in input frame properties.
  617. Upon reinitialization, existing filter state is lost, like e.g. the frame count @code{n}
  618. reference available in some filters. Any frames buffered at time of reinitialization are lost.
  619. The properties where a change triggers reinitialization are,
  620. for video, frame resolution or pixel format;
  621. for audio, sample format, sample rate, channel count or channel layout.
  622. @item -filter_threads @var{nb_threads} (@emph{global})
  623. Defines how many threads are used to process a filter pipeline. Each pipeline
  624. will produce a thread pool with this many threads available for parallel processing.
  625. The default is the number of available CPUs.
  626. @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream})
  627. Specify the preset for matching stream(s).
  628. @item -stats (@emph{global})
  629. Print encoding progress/statistics. It is on by default, to explicitly
  630. disable it you need to specify @code{-nostats}.
  631. @item -stats_period @var{time} (@emph{global})
  632. Set period at which encoding progress/statistics are updated. Default is 0.5 seconds.
  633. @item -progress @var{url} (@emph{global})
  634. Send program-friendly progress information to @var{url}.
  635. Progress information is written periodically and at the end of
  636. the encoding process. It is made of "@var{key}=@var{value}" lines. @var{key}
  637. consists of only alphanumeric characters. The last key of a sequence of
  638. progress information is always "progress".
  639. The update period is set using @code{-stats_period}.
  640. @anchor{stdin option}
  641. @item -stdin
  642. Enable interaction on standard input. On by default unless standard input is
  643. used as an input. To explicitly disable interaction you need to specify
  644. @code{-nostdin}.
  645. Disabling interaction on standard input is useful, for example, if
  646. ffmpeg is in the background process group. Roughly the same result can
  647. be achieved with @code{ffmpeg ... < /dev/null} but it requires a
  648. shell.
  649. @item -debug_ts (@emph{global})
  650. Print timestamp information. It is off by default. This option is
  651. mostly useful for testing and debugging purposes, and the output
  652. format may change from one version to another, so it should not be
  653. employed by portable scripts.
  654. See also the option @code{-fdebug ts}.
  655. @item -attach @var{filename} (@emph{output})
  656. Add an attachment to the output file. This is supported by a few formats
  657. like Matroska for e.g. fonts used in rendering subtitles. Attachments
  658. are implemented as a specific type of stream, so this option will add
  659. a new stream to the file. It is then possible to use per-stream options
  660. on this stream in the usual way. Attachment streams created with this
  661. option will be created after all the other streams (i.e. those created
  662. with @code{-map} or automatic mappings).
  663. Note that for Matroska you also have to set the mimetype metadata tag:
  664. @example
  665. ffmpeg -i INPUT -attach DejaVuSans.ttf -metadata:s:2 mimetype=application/x-truetype-font out.mkv
  666. @end example
  667. (assuming that the attachment stream will be third in the output file).
  668. @item -dump_attachment[:@var{stream_specifier}] @var{filename} (@emph{input,per-stream})
  669. Extract the matching attachment stream into a file named @var{filename}. If
  670. @var{filename} is empty, then the value of the @code{filename} metadata tag
  671. will be used.
  672. E.g. to extract the first attachment to a file named 'out.ttf':
  673. @example
  674. ffmpeg -dump_attachment:t:0 out.ttf -i INPUT
  675. @end example
  676. To extract all attachments to files determined by the @code{filename} tag:
  677. @example
  678. ffmpeg -dump_attachment:t "" -i INPUT
  679. @end example
  680. Technical note -- attachments are implemented as codec extradata, so this
  681. option can actually be used to extract extradata from any stream, not just
  682. attachments.
  683. @end table
  684. @section Video Options
  685. @table @option
  686. @item -vframes @var{number} (@emph{output})
  687. Set the number of video frames to output. This is an obsolete alias for
  688. @code{-frames:v}, which you should use instead.
  689. @item -r[:@var{stream_specifier}] @var{fps} (@emph{input/output,per-stream})
  690. Set frame rate (Hz value, fraction or abbreviation).
  691. As an input option, ignore any timestamps stored in the file and instead
  692. generate timestamps assuming constant frame rate @var{fps}.
  693. This is not the same as the @option{-framerate} option used for some input formats
  694. like image2 or v4l2 (it used to be the same in older versions of FFmpeg).
  695. If in doubt use @option{-framerate} instead of the input option @option{-r}.
  696. As an output option:
  697. @table @option
  698. @item video encoding
  699. Duplicate or drop frames right before encoding them to achieve constant output
  700. frame rate @var{fps}.
  701. @item video streamcopy
  702. Indicate to the muxer that @var{fps} is the stream frame rate. No data is
  703. dropped or duplicated in this case. This may produce invalid files if @var{fps}
  704. does not match the actual stream frame rate as determined by packet timestamps.
  705. See also the @code{setts} bitstream filter.
  706. @end table
  707. @item -fpsmax[:@var{stream_specifier}] @var{fps} (@emph{output,per-stream})
  708. Set maximum frame rate (Hz value, fraction or abbreviation).
  709. Clamps output frame rate when output framerate is auto-set and is higher than this value.
  710. Useful in batch processing or when input framerate is wrongly detected as very high.
  711. It cannot be set together with @code{-r}. It is ignored during streamcopy.
  712. @item -s[:@var{stream_specifier}] @var{size} (@emph{input/output,per-stream})
  713. Set frame size.
  714. As an input option, this is a shortcut for the @option{video_size} private
  715. option, recognized by some demuxers for which the frame size is either not
  716. stored in the file or is configurable -- e.g. raw video or video grabbers.
  717. As an output option, this inserts the @code{scale} video filter to the
  718. @emph{end} of the corresponding filtergraph. Please use the @code{scale} filter
  719. directly to insert it at the beginning or some other place.
  720. The format is @samp{wxh} (default - same as source).
  721. @item -aspect[:@var{stream_specifier}] @var{aspect} (@emph{output,per-stream})
  722. Set the video display aspect ratio specified by @var{aspect}.
  723. @var{aspect} can be a floating point number string, or a string of the
  724. form @var{num}:@var{den}, where @var{num} and @var{den} are the
  725. numerator and denominator of the aspect ratio. For example "4:3",
  726. "16:9", "1.3333", and "1.7777" are valid argument values.
  727. If used together with @option{-vcodec copy}, it will affect the aspect ratio
  728. stored at container level, but not the aspect ratio stored in encoded
  729. frames, if it exists.
  730. @item -display_rotation[:@var{stream_specifier}] @var{rotation} (@emph{input,per-stream})
  731. Set video rotation metadata.
  732. @var{rotation} is a decimal number specifying the amount in degree by
  733. which the video should be rotated counter-clockwise before being
  734. displayed.
  735. This option overrides the rotation/display transform metadata stored in
  736. the file, if any. When the video is being transcoded (rather than
  737. copied) and @code{-autorotate} is enabled, the video will be rotated at
  738. the filtering stage. Otherwise, the metadata will be written into the
  739. output file if the muxer supports it.
  740. If the @code{-display_hflip} and/or @code{-display_vflip} options are
  741. given, they are applied after the rotation specified by this option.
  742. @item -display_hflip[:@var{stream_specifier}] (@emph{input,per-stream})
  743. Set whether on display the image should be horizontally flipped.
  744. See the @code{-display_rotation} option for more details.
  745. @item -display_vflip[:@var{stream_specifier}] (@emph{input,per-stream})
  746. Set whether on display the image should be vertically flipped.
  747. See the @code{-display_rotation} option for more details.
  748. @item -vn (@emph{input/output})
  749. As an input option, blocks all video streams of a file from being filtered or
  750. being automatically selected or mapped for any output. See @code{-discard}
  751. option to disable streams individually.
  752. As an output option, disables video recording i.e. automatic selection or
  753. mapping of any video stream. For full manual control see the @code{-map}
  754. option.
  755. @item -vcodec @var{codec} (@emph{output})
  756. Set the video codec. This is an alias for @code{-codec:v}.
  757. @item -pass[:@var{stream_specifier}] @var{n} (@emph{output,per-stream})
  758. Select the pass number (1 or 2). It is used to do two-pass
  759. video encoding. The statistics of the video are recorded in the first
  760. pass into a log file (see also the option -passlogfile),
  761. and in the second pass that log file is used to generate the video
  762. at the exact requested bitrate.
  763. On pass 1, you may just deactivate audio and set output to null,
  764. examples for Windows and Unix:
  765. @example
  766. ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y NUL
  767. ffmpeg -i foo.mov -c:v libxvid -pass 1 -an -f rawvideo -y /dev/null
  768. @end example
  769. @item -passlogfile[:@var{stream_specifier}] @var{prefix} (@emph{output,per-stream})
  770. Set two-pass log file name prefix to @var{prefix}, the default file name
  771. prefix is ``ffmpeg2pass''. The complete file name will be
  772. @file{PREFIX-N.log}, where N is a number specific to the output
  773. stream
  774. @item -vf @var{filtergraph} (@emph{output})
  775. Create the filtergraph specified by @var{filtergraph} and use it to
  776. filter the stream.
  777. This is an alias for @code{-filter:v}, see the @ref{filter_option,,-filter option}.
  778. @item -autorotate
  779. Automatically rotate the video according to file metadata. Enabled by
  780. default, use @option{-noautorotate} to disable it.
  781. @item -autoscale
  782. Automatically scale the video according to the resolution of first frame.
  783. Enabled by default, use @option{-noautoscale} to disable it. When autoscale is
  784. disabled, all output frames of filter graph might not be in the same resolution
  785. and may be inadequate for some encoder/muxer. Therefore, it is not recommended
  786. to disable it unless you really know what you are doing.
  787. Disable autoscale at your own risk.
  788. @end table
  789. @section Advanced Video options
  790. @table @option
  791. @item -pix_fmt[:@var{stream_specifier}] @var{format} (@emph{input/output,per-stream})
  792. Set pixel format. Use @code{-pix_fmts} to show all the supported
  793. pixel formats.
  794. If the selected pixel format can not be selected, ffmpeg will print a
  795. warning and select the best pixel format supported by the encoder.
  796. If @var{pix_fmt} is prefixed by a @code{+}, ffmpeg will exit with an error
  797. if the requested pixel format can not be selected, and automatic conversions
  798. inside filtergraphs are disabled.
  799. If @var{pix_fmt} is a single @code{+}, ffmpeg selects the same pixel format
  800. as the input (or graph output) and automatic conversions are disabled.
  801. @item -sws_flags @var{flags} (@emph{input/output})
  802. Set SwScaler flags.
  803. @item -rc_override[:@var{stream_specifier}] @var{override} (@emph{output,per-stream})
  804. Rate control override for specific intervals, formatted as "int,int,int"
  805. list separated with slashes. Two first values are the beginning and
  806. end frame numbers, last one is quantizer to use if positive, or quality
  807. factor if negative.
  808. @item -psnr
  809. Calculate PSNR of compressed frames. This option is deprecated, pass the
  810. PSNR flag to the encoder instead, using @code{-flags +psnr}.
  811. @item -vstats
  812. Dump video coding statistics to @file{vstats_HHMMSS.log}.
  813. @item -vstats_file @var{file}
  814. Dump video coding statistics to @var{file}.
  815. @item -vstats_version @var{file}
  816. Specifies which version of the vstats format to use. Default is 2.
  817. version = 1 :
  818. @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}
  819. version > 1:
  820. @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}
  821. @item -top[:@var{stream_specifier}] @var{n} (@emph{output,per-stream})
  822. top=1/bottom=0/auto=-1 field first
  823. @item -vtag @var{fourcc/tag} (@emph{output})
  824. Force video tag/fourcc. This is an alias for @code{-tag:v}.
  825. @item -qphist (@emph{global})
  826. Show QP histogram
  827. @item -vbsf @var{bitstream_filter}
  828. Deprecated see -bsf
  829. @item -force_key_frames[:@var{stream_specifier}] @var{time}[,@var{time}...] (@emph{output,per-stream})
  830. @item -force_key_frames[:@var{stream_specifier}] expr:@var{expr} (@emph{output,per-stream})
  831. @item -force_key_frames[:@var{stream_specifier}] source (@emph{output,per-stream})
  832. @item -force_key_frames[:@var{stream_specifier}] source_no_drop (@emph{output,per-stream})
  833. @var{force_key_frames} can take arguments of the following form:
  834. @table @option
  835. @item @var{time}[,@var{time}...]
  836. If the argument consists of timestamps, ffmpeg will round the specified times to the nearest
  837. output timestamp as per the encoder time base and force a keyframe at the first frame having
  838. timestamp equal or greater than the computed timestamp. Note that if the encoder time base is too
  839. coarse, then the keyframes may be forced on frames with timestamps lower than the specified time.
  840. The default encoder time base is the inverse of the output framerate but may be set otherwise
  841. via @code{-enc_time_base}.
  842. If one of the times is "@code{chapters}[@var{delta}]", it is expanded into
  843. the time of the beginning of all chapters in the file, shifted by
  844. @var{delta}, expressed as a time in seconds.
  845. This option can be useful to ensure that a seek point is present at a
  846. chapter mark or any other designated place in the output file.
  847. For example, to insert a key frame at 5 minutes, plus key frames 0.1 second
  848. before the beginning of every chapter:
  849. @example
  850. -force_key_frames 0:05:00,chapters-0.1
  851. @end example
  852. @item expr:@var{expr}
  853. If the argument is prefixed with @code{expr:}, the string @var{expr}
  854. is interpreted like an expression and is evaluated for each frame. A
  855. key frame is forced in case the evaluation is non-zero.
  856. The expression in @var{expr} can contain the following constants:
  857. @table @option
  858. @item n
  859. the number of current processed frame, starting from 0
  860. @item n_forced
  861. the number of forced frames
  862. @item prev_forced_n
  863. the number of the previous forced frame, it is @code{NAN} when no
  864. keyframe was forced yet
  865. @item prev_forced_t
  866. the time of the previous forced frame, it is @code{NAN} when no
  867. keyframe was forced yet
  868. @item t
  869. the time of the current processed frame
  870. @end table
  871. For example to force a key frame every 5 seconds, you can specify:
  872. @example
  873. -force_key_frames expr:gte(t,n_forced*5)
  874. @end example
  875. To force a key frame 5 seconds after the time of the last forced one,
  876. starting from second 13:
  877. @example
  878. -force_key_frames expr:if(isnan(prev_forced_t),gte(t,13),gte(t,prev_forced_t+5))
  879. @end example
  880. @item source
  881. If the argument is @code{source}, ffmpeg will force a key frame if
  882. the current frame being encoded is marked as a key frame in its source.
  883. @item source_no_drop
  884. If the argument is @code{source_no_drop}, ffmpeg will force a key frame if
  885. the current frame being encoded is marked as a key frame in its source.
  886. In cases where this particular source frame has to be dropped,
  887. enforce the next available frame to become a key frame instead.
  888. @end table
  889. Note that forcing too many keyframes is very harmful for the lookahead
  890. algorithms of certain encoders: using fixed-GOP options or similar
  891. would be more efficient.
  892. @item -copyinkf[:@var{stream_specifier}] (@emph{output,per-stream})
  893. When doing stream copy, copy also non-key frames found at the
  894. beginning.
  895. @item -init_hw_device @var{type}[=@var{name}][:@var{device}[,@var{key=value}...]]
  896. Initialise a new hardware device of type @var{type} called @var{name}, using the
  897. given device parameters.
  898. If no name is specified it will receive a default name of the form "@var{type}%d".
  899. The meaning of @var{device} and the following arguments depends on the
  900. device type:
  901. @table @option
  902. @item cuda
  903. @var{device} is the number of the CUDA device.
  904. The following options are recognized:
  905. @table @option
  906. @item primary_ctx
  907. If set to 1, uses the primary device context instead of creating a new one.
  908. @end table
  909. Examples:
  910. @table @emph
  911. @item -init_hw_device cuda:1
  912. Choose the second device on the system.
  913. @item -init_hw_device cuda:0,primary_ctx=1
  914. Choose the first device and use the primary device context.
  915. @end table
  916. @item dxva2
  917. @var{device} is the number of the Direct3D 9 display adapter.
  918. @item d3d11va
  919. @var{device} is the number of the Direct3D 11 display adapter.
  920. @item vaapi
  921. @var{device} is either an X11 display name or a DRM render node.
  922. If not specified, it will attempt to open the default X11 display (@emph{$DISPLAY})
  923. and then the first DRM render node (@emph{/dev/dri/renderD128}).
  924. @item vdpau
  925. @var{device} is an X11 display name.
  926. If not specified, it will attempt to open the default X11 display (@emph{$DISPLAY}).
  927. @item qsv
  928. @var{device} selects a value in @samp{MFX_IMPL_*}. Allowed values are:
  929. @table @option
  930. @item auto
  931. @item sw
  932. @item hw
  933. @item auto_any
  934. @item hw_any
  935. @item hw2
  936. @item hw3
  937. @item hw4
  938. @end table
  939. If not specified, @samp{auto_any} is used.
  940. (Note that it may be easier to achieve the desired result for QSV by creating the
  941. platform-appropriate subdevice (@samp{dxva2} or @samp{d3d11va} or @samp{vaapi}) and then deriving a
  942. QSV device from that.)
  943. Alternatively, @samp{child_device_type} helps to choose platform-appropriate subdevice type.
  944. On Windows @samp{d3d11va} is used as default subdevice type.
  945. Examples:
  946. @table @emph
  947. @item -init_hw_device qsv:hw,child_device_type=d3d11va
  948. Choose the GPU subdevice with type @samp{d3d11va} and create QSV device with @samp{MFX_IMPL_HARDWARE}.
  949. @item -init_hw_device qsv:hw,child_device_type=dxva2
  950. Choose the GPU subdevice with type @samp{dxva2} and create QSV device with @samp{MFX_IMPL_HARDWARE}.
  951. @end table
  952. @item opencl
  953. @var{device} selects the platform and device as @emph{platform_index.device_index}.
  954. The set of devices can also be filtered using the key-value pairs to find only
  955. devices matching particular platform or device strings.
  956. The strings usable as filters are:
  957. @table @option
  958. @item platform_profile
  959. @item platform_version
  960. @item platform_name
  961. @item platform_vendor
  962. @item platform_extensions
  963. @item device_name
  964. @item device_vendor
  965. @item driver_version
  966. @item device_version
  967. @item device_profile
  968. @item device_extensions
  969. @item device_type
  970. @end table
  971. The indices and filters must together uniquely select a device.
  972. Examples:
  973. @table @emph
  974. @item -init_hw_device opencl:0.1
  975. Choose the second device on the first platform.
  976. @item -init_hw_device opencl:,device_name=Foo9000
  977. Choose the device with a name containing the string @emph{Foo9000}.
  978. @item -init_hw_device opencl:1,device_type=gpu,device_extensions=cl_khr_fp16
  979. Choose the GPU device on the second platform supporting the @emph{cl_khr_fp16}
  980. extension.
  981. @end table
  982. @item vulkan
  983. If @var{device} is an integer, it selects the device by its index in a
  984. system-dependent list of devices. If @var{device} is any other string, it
  985. selects the first device with a name containing that string as a substring.
  986. The following options are recognized:
  987. @table @option
  988. @item debug
  989. If set to 1, enables the validation layer, if installed.
  990. @item linear_images
  991. If set to 1, images allocated by the hwcontext will be linear and locally mappable.
  992. @item instance_extensions
  993. A plus separated list of additional instance extensions to enable.
  994. @item device_extensions
  995. A plus separated list of additional device extensions to enable.
  996. @end table
  997. Examples:
  998. @table @emph
  999. @item -init_hw_device vulkan:1
  1000. Choose the second device on the system.
  1001. @item -init_hw_device vulkan:RADV
  1002. Choose the first device with a name containing the string @emph{RADV}.
  1003. @item -init_hw_device vulkan:0,instance_extensions=VK_KHR_wayland_surface+VK_KHR_xcb_surface
  1004. Choose the first device and enable the Wayland and XCB instance extensions.
  1005. @end table
  1006. @end table
  1007. @item -init_hw_device @var{type}[=@var{name}]@@@var{source}
  1008. Initialise a new hardware device of type @var{type} called @var{name},
  1009. deriving it from the existing device with the name @var{source}.
  1010. @item -init_hw_device list
  1011. List all hardware device types supported in this build of ffmpeg.
  1012. @item -filter_hw_device @var{name}
  1013. Pass the hardware device called @var{name} to all filters in any filter graph.
  1014. This can be used to set the device to upload to with the @code{hwupload} filter,
  1015. or the device to map to with the @code{hwmap} filter. Other filters may also
  1016. make use of this parameter when they require a hardware device. Note that this
  1017. is typically only required when the input is not already in hardware frames -
  1018. when it is, filters will derive the device they require from the context of the
  1019. frames they receive as input.
  1020. This is a global setting, so all filters will receive the same device.
  1021. @item -hwaccel[:@var{stream_specifier}] @var{hwaccel} (@emph{input,per-stream})
  1022. Use hardware acceleration to decode the matching stream(s). The allowed values
  1023. of @var{hwaccel} are:
  1024. @table @option
  1025. @item none
  1026. Do not use any hardware acceleration (the default).
  1027. @item auto
  1028. Automatically select the hardware acceleration method.
  1029. @item vdpau
  1030. Use VDPAU (Video Decode and Presentation API for Unix) hardware acceleration.
  1031. @item dxva2
  1032. Use DXVA2 (DirectX Video Acceleration) hardware acceleration.
  1033. @item d3d11va
  1034. Use D3D11VA (DirectX Video Acceleration) hardware acceleration.
  1035. @item vaapi
  1036. Use VAAPI (Video Acceleration API) hardware acceleration.
  1037. @item qsv
  1038. Use the Intel QuickSync Video acceleration for video transcoding.
  1039. Unlike most other values, this option does not enable accelerated decoding (that
  1040. is used automatically whenever a qsv decoder is selected), but accelerated
  1041. transcoding, without copying the frames into the system memory.
  1042. For it to work, both the decoder and the encoder must support QSV acceleration
  1043. and no filters must be used.
  1044. @end table
  1045. This option has no effect if the selected hwaccel is not available or not
  1046. supported by the chosen decoder.
  1047. Note that most acceleration methods are intended for playback and will not be
  1048. faster than software decoding on modern CPUs. Additionally, @command{ffmpeg}
  1049. will usually need to copy the decoded frames from the GPU memory into the system
  1050. memory, resulting in further performance loss. This option is thus mainly
  1051. useful for testing.
  1052. @item -hwaccel_device[:@var{stream_specifier}] @var{hwaccel_device} (@emph{input,per-stream})
  1053. Select a device to use for hardware acceleration.
  1054. This option only makes sense when the @option{-hwaccel} option is also specified.
  1055. It can either refer to an existing device created with @option{-init_hw_device}
  1056. by name, or it can create a new device as if
  1057. @samp{-init_hw_device} @var{type}:@var{hwaccel_device}
  1058. were called immediately before.
  1059. @item -hwaccels
  1060. List all hardware acceleration components enabled in this build of ffmpeg.
  1061. Actual runtime availability depends on the hardware and its suitable driver
  1062. being installed.
  1063. @item -fix_sub_duration_heartbeat[:@var{stream_specifier}]
  1064. Set a specific output video stream as the heartbeat stream according to which
  1065. to split and push through currently in-progress subtitle upon receipt of a
  1066. random access packet.
  1067. This lowers the latency of subtitles for which the end packet or the following
  1068. subtitle has not yet been received. As a drawback, this will most likely lead
  1069. to duplication of subtitle events in order to cover the full duration, so
  1070. when dealing with use cases where latency of when the subtitle event is passed
  1071. on to output is not relevant this option should not be utilized.
  1072. Requires @option{-fix_sub_duration} to be set for the relevant input subtitle
  1073. stream for this to have any effect, as well as for the input subtitle stream
  1074. having to be directly mapped to the same output in which the heartbeat stream
  1075. resides.
  1076. @end table
  1077. @section Audio Options
  1078. @table @option
  1079. @item -aframes @var{number} (@emph{output})
  1080. Set the number of audio frames to output. This is an obsolete alias for
  1081. @code{-frames:a}, which you should use instead.
  1082. @item -ar[:@var{stream_specifier}] @var{freq} (@emph{input/output,per-stream})
  1083. Set the audio sampling frequency. For output streams it is set by
  1084. default to the frequency of the corresponding input stream. For input
  1085. streams this option only makes sense for audio grabbing devices and raw
  1086. demuxers and is mapped to the corresponding demuxer options.
  1087. @item -aq @var{q} (@emph{output})
  1088. Set the audio quality (codec-specific, VBR). This is an alias for -q:a.
  1089. @item -ac[:@var{stream_specifier}] @var{channels} (@emph{input/output,per-stream})
  1090. Set the number of audio channels. For output streams it is set by
  1091. default to the number of input audio channels. For input streams
  1092. this option only makes sense for audio grabbing devices and raw demuxers
  1093. and is mapped to the corresponding demuxer options.
  1094. @item -an (@emph{input/output})
  1095. As an input option, blocks all audio streams of a file from being filtered or
  1096. being automatically selected or mapped for any output. See @code{-discard}
  1097. option to disable streams individually.
  1098. As an output option, disables audio recording i.e. automatic selection or
  1099. mapping of any audio stream. For full manual control see the @code{-map}
  1100. option.
  1101. @item -acodec @var{codec} (@emph{input/output})
  1102. Set the audio codec. This is an alias for @code{-codec:a}.
  1103. @item -sample_fmt[:@var{stream_specifier}] @var{sample_fmt} (@emph{output,per-stream})
  1104. Set the audio sample format. Use @code{-sample_fmts} to get a list
  1105. of supported sample formats.
  1106. @item -af @var{filtergraph} (@emph{output})
  1107. Create the filtergraph specified by @var{filtergraph} and use it to
  1108. filter the stream.
  1109. This is an alias for @code{-filter:a}, see the @ref{filter_option,,-filter option}.
  1110. @end table
  1111. @section Advanced Audio options
  1112. @table @option
  1113. @item -atag @var{fourcc/tag} (@emph{output})
  1114. Force audio tag/fourcc. This is an alias for @code{-tag:a}.
  1115. @item -absf @var{bitstream_filter}
  1116. Deprecated, see -bsf
  1117. @item -guess_layout_max @var{channels} (@emph{input,per-stream})
  1118. If some input channel layout is not known, try to guess only if it
  1119. corresponds to at most the specified number of channels. For example, 2
  1120. tells to @command{ffmpeg} to recognize 1 channel as mono and 2 channels as
  1121. stereo but not 6 channels as 5.1. The default is to always try to guess. Use
  1122. 0 to disable all guessing.
  1123. @end table
  1124. @section Subtitle options
  1125. @table @option
  1126. @item -scodec @var{codec} (@emph{input/output})
  1127. Set the subtitle codec. This is an alias for @code{-codec:s}.
  1128. @item -sn (@emph{input/output})
  1129. As an input option, blocks all subtitle streams of a file from being filtered or
  1130. being automatically selected or mapped for any output. See @code{-discard}
  1131. option to disable streams individually.
  1132. As an output option, disables subtitle recording i.e. automatic selection or
  1133. mapping of any subtitle stream. For full manual control see the @code{-map}
  1134. option.
  1135. @item -sbsf @var{bitstream_filter}
  1136. Deprecated, see -bsf
  1137. @end table
  1138. @section Advanced Subtitle options
  1139. @table @option
  1140. @item -fix_sub_duration
  1141. Fix subtitles durations. For each subtitle, wait for the next packet in the
  1142. same stream and adjust the duration of the first to avoid overlap. This is
  1143. necessary with some subtitles codecs, especially DVB subtitles, because the
  1144. duration in the original packet is only a rough estimate and the end is
  1145. actually marked by an empty subtitle frame. Failing to use this option when
  1146. necessary can result in exaggerated durations or muxing failures due to
  1147. non-monotonic timestamps.
  1148. Note that this option will delay the output of all data until the next
  1149. subtitle packet is decoded: it may increase memory consumption and latency a
  1150. lot.
  1151. @item -canvas_size @var{size}
  1152. Set the size of the canvas used to render subtitles.
  1153. @end table
  1154. @section Advanced options
  1155. @table @option
  1156. @item -map [-]@var{input_file_id}[:@var{stream_specifier}][?] | @var{[linklabel]} (@emph{output})
  1157. Create one or more streams in the output file. This option has two forms for
  1158. specifying the data source(s): the first selects one or more streams from some
  1159. input file (specified with @code{-i}), the second takes an output from some
  1160. complex filtergraph (specified with @code{-filter_complex} or
  1161. @code{-filter_complex_script}).
  1162. In the first form, an output stream is created for every stream from the input
  1163. file with the index @var{input_file_id}. If @var{stream_specifier} is given,
  1164. only those streams that match the specifier are used (see the
  1165. @ref{Stream specifiers} section for the @var{stream_specifier} syntax).
  1166. A @code{-} character before the stream identifier creates a "negative" mapping.
  1167. It disables matching streams from already created mappings.
  1168. A trailing @code{?} after the stream index will allow the map to be
  1169. optional: if the map matches no streams the map will be ignored instead
  1170. of failing. Note the map will still fail if an invalid input file index
  1171. is used; such as if the map refers to a non-existent input.
  1172. An alternative @var{[linklabel]} form will map outputs from complex filter
  1173. graphs (see the @option{-filter_complex} option) to the output file.
  1174. @var{linklabel} must correspond to a defined output link label in the graph.
  1175. This option may be specified multiple times, each adding more streams to the
  1176. output file. Any given input stream may also be mapped any number of times as a
  1177. source for different output streams, e.g. in order to use different encoding
  1178. options and/or filters. The streams are created in the output in the same order
  1179. in which the @code{-map} options are given on the commandline.
  1180. Using this option disables the default mappings for this output file.
  1181. Examples:
  1182. @table @emph
  1183. @item map everything
  1184. To map ALL streams from the first input file to output
  1185. @example
  1186. ffmpeg -i INPUT -map 0 output
  1187. @end example
  1188. @item select specific stream
  1189. If you have two audio streams in the first input file, these streams are
  1190. identified by @var{0:0} and @var{0:1}. You can use @code{-map} to select which
  1191. streams to place in an output file. For example:
  1192. @example
  1193. ffmpeg -i INPUT -map 0:1 out.wav
  1194. @end example
  1195. will map the second input stream in @file{INPUT} to the (single) output stream
  1196. in @file{out.wav}.
  1197. @item create multiple streams
  1198. To select the stream with index 2 from input file @file{a.mov} (specified by the
  1199. identifier @var{0:2}), and stream with index 6 from input @file{b.mov}
  1200. (specified by the identifier @var{1:6}), and copy them to the output file
  1201. @file{out.mov}:
  1202. @example
  1203. ffmpeg -i a.mov -i b.mov -c copy -map 0:2 -map 1:6 out.mov
  1204. @end example
  1205. @item create multiple streams 2
  1206. To select all video and the third audio stream from an input file:
  1207. @example
  1208. ffmpeg -i INPUT -map 0:v -map 0:a:2 OUTPUT
  1209. @end example
  1210. @item negative map
  1211. To map all the streams except the second audio, use negative mappings
  1212. @example
  1213. ffmpeg -i INPUT -map 0 -map -0:a:1 OUTPUT
  1214. @end example
  1215. @item optional map
  1216. To map the video and audio streams from the first input, and using the
  1217. trailing @code{?}, ignore the audio mapping if no audio streams exist in
  1218. the first input:
  1219. @example
  1220. ffmpeg -i INPUT -map 0:v -map 0:a? OUTPUT
  1221. @end example
  1222. @item map by language
  1223. To pick the English audio stream:
  1224. @example
  1225. ffmpeg -i INPUT -map 0:m:language:eng OUTPUT
  1226. @end example
  1227. @end table
  1228. @item -ignore_unknown
  1229. Ignore input streams with unknown type instead of failing if copying
  1230. such streams is attempted.
  1231. @item -copy_unknown
  1232. Allow input streams with unknown type to be copied instead of failing if copying
  1233. such streams is attempted.
  1234. @item -map_channel [@var{input_file_id}.@var{stream_specifier}.@var{channel_id}|-1][?][:@var{output_file_id}.@var{stream_specifier}]
  1235. This option is deprecated and will be removed. It can be replaced by the
  1236. @var{pan} filter. In some cases it may be easier to use some combination of the
  1237. @var{channelsplit}, @var{channelmap}, or @var{amerge} filters.
  1238. Map an audio channel from a given input to an output. If
  1239. @var{output_file_id}.@var{stream_specifier} is not set, the audio channel will
  1240. be mapped on all the audio streams.
  1241. Using "-1" instead of
  1242. @var{input_file_id}.@var{stream_specifier}.@var{channel_id} will map a muted
  1243. channel.
  1244. A trailing @code{?} will allow the map_channel to be
  1245. optional: if the map_channel matches no channel the map_channel will be ignored instead
  1246. of failing.
  1247. For example, assuming @var{INPUT} is a stereo audio file, you can switch the
  1248. two audio channels with the following command:
  1249. @example
  1250. ffmpeg -i INPUT -map_channel 0.0.1 -map_channel 0.0.0 OUTPUT
  1251. @end example
  1252. If you want to mute the first channel and keep the second:
  1253. @example
  1254. ffmpeg -i INPUT -map_channel -1 -map_channel 0.0.1 OUTPUT
  1255. @end example
  1256. The order of the "-map_channel" option specifies the order of the channels in
  1257. the output stream. The output channel layout is guessed from the number of
  1258. channels mapped (mono if one "-map_channel", stereo if two, etc.). Using "-ac"
  1259. in combination of "-map_channel" makes the channel gain levels to be updated if
  1260. input and output channel layouts don't match (for instance two "-map_channel"
  1261. options and "-ac 6").
  1262. You can also extract each channel of an input to specific outputs; the following
  1263. command extracts two channels of the @var{INPUT} audio stream (file 0, stream 0)
  1264. to the respective @var{OUTPUT_CH0} and @var{OUTPUT_CH1} outputs:
  1265. @example
  1266. ffmpeg -i INPUT -map_channel 0.0.0 OUTPUT_CH0 -map_channel 0.0.1 OUTPUT_CH1
  1267. @end example
  1268. The following example splits the channels of a stereo input into two separate
  1269. streams, which are put into the same output file:
  1270. @example
  1271. 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
  1272. @end example
  1273. Note that currently each output stream can only contain channels from a single
  1274. input stream; you can't for example use "-map_channel" to pick multiple input
  1275. audio channels contained in different streams (from the same or different files)
  1276. and merge them into a single output stream. It is therefore not currently
  1277. possible, for example, to turn two separate mono streams into a single stereo
  1278. stream. However splitting a stereo stream into two single channel mono streams
  1279. is possible.
  1280. If you need this feature, a possible workaround is to use the @emph{amerge}
  1281. filter. For example, if you need to merge a media (here @file{input.mkv}) with 2
  1282. mono audio streams into one single stereo channel audio stream (and keep the
  1283. video stream), you can use the following command:
  1284. @example
  1285. ffmpeg -i input.mkv -filter_complex "[0:1] [0:2] amerge" -c:a pcm_s16le -c:v copy output.mkv
  1286. @end example
  1287. To map the first two audio channels from the first input, and using the
  1288. trailing @code{?}, ignore the audio channel mapping if the first input is
  1289. mono instead of stereo:
  1290. @example
  1291. ffmpeg -i INPUT -map_channel 0.0.0 -map_channel 0.0.1? OUTPUT
  1292. @end example
  1293. @item -map_metadata[:@var{metadata_spec_out}] @var{infile}[:@var{metadata_spec_in}] (@emph{output,per-metadata})
  1294. Set metadata information of the next output file from @var{infile}. Note that
  1295. those are file indices (zero-based), not filenames.
  1296. Optional @var{metadata_spec_in/out} parameters specify, which metadata to copy.
  1297. A metadata specifier can have the following forms:
  1298. @table @option
  1299. @item @var{g}
  1300. global metadata, i.e. metadata that applies to the whole file
  1301. @item @var{s}[:@var{stream_spec}]
  1302. per-stream metadata. @var{stream_spec} is a stream specifier as described
  1303. in the @ref{Stream specifiers} chapter. In an input metadata specifier, the first
  1304. matching stream is copied from. In an output metadata specifier, all matching
  1305. streams are copied to.
  1306. @item @var{c}:@var{chapter_index}
  1307. per-chapter metadata. @var{chapter_index} is the zero-based chapter index.
  1308. @item @var{p}:@var{program_index}
  1309. per-program metadata. @var{program_index} is the zero-based program index.
  1310. @end table
  1311. If metadata specifier is omitted, it defaults to global.
  1312. By default, global metadata is copied from the first input file,
  1313. per-stream and per-chapter metadata is copied along with streams/chapters. These
  1314. default mappings are disabled by creating any mapping of the relevant type. A negative
  1315. file index can be used to create a dummy mapping that just disables automatic copying.
  1316. For example to copy metadata from the first stream of the input file to global metadata
  1317. of the output file:
  1318. @example
  1319. ffmpeg -i in.ogg -map_metadata 0:s:0 out.mp3
  1320. @end example
  1321. To do the reverse, i.e. copy global metadata to all audio streams:
  1322. @example
  1323. ffmpeg -i in.mkv -map_metadata:s:a 0:g out.mkv
  1324. @end example
  1325. Note that simple @code{0} would work as well in this example, since global
  1326. metadata is assumed by default.
  1327. @item -map_chapters @var{input_file_index} (@emph{output})
  1328. Copy chapters from input file with index @var{input_file_index} to the next
  1329. output file. If no chapter mapping is specified, then chapters are copied from
  1330. the first input file with at least one chapter. Use a negative file index to
  1331. disable any chapter copying.
  1332. @item -benchmark (@emph{global})
  1333. Show benchmarking information at the end of an encode.
  1334. Shows real, system and user time used and maximum memory consumption.
  1335. Maximum memory consumption is not supported on all systems,
  1336. it will usually display as 0 if not supported.
  1337. @item -benchmark_all (@emph{global})
  1338. Show benchmarking information during the encode.
  1339. Shows real, system and user time used in various steps (audio/video encode/decode).
  1340. @item -timelimit @var{duration} (@emph{global})
  1341. Exit after ffmpeg has been running for @var{duration} seconds in CPU user time.
  1342. @item -dump (@emph{global})
  1343. Dump each input packet to stderr.
  1344. @item -hex (@emph{global})
  1345. When dumping packets, also dump the payload.
  1346. @item -readrate @var{speed} (@emph{input})
  1347. Limit input read speed.
  1348. Its value is a floating-point positive number which represents the maximum duration of
  1349. media, in seconds, that should be ingested in one second of wallclock time.
  1350. Default value is zero and represents no imposed limitation on speed of ingestion.
  1351. Value @code{1} represents real-time speed and is equivalent to @code{-re}.
  1352. Mainly used to simulate a capture device or live input stream (e.g. when reading from a file).
  1353. Should not be used with a low value when input is an actual capture device or live stream as
  1354. it may cause packet loss.
  1355. It is useful for when flow speed of output packets is important, such as live streaming.
  1356. @item -re (@emph{input})
  1357. Read input at native frame rate. This is equivalent to setting @code{-readrate 1}.
  1358. @item -vsync @var{parameter} (@emph{global})
  1359. @itemx -fps_mode[:@var{stream_specifier}] @var{parameter} (@emph{output,per-stream})
  1360. Set video sync method / framerate mode. vsync is applied to all output video streams
  1361. but can be overridden for a stream by setting fps_mode. vsync is deprecated and will be
  1362. removed in the future.
  1363. For compatibility reasons some of the values for vsync can be specified as numbers (shown
  1364. in parentheses in the following table).
  1365. @table @option
  1366. @item passthrough (0)
  1367. Each frame is passed with its timestamp from the demuxer to the muxer.
  1368. @item cfr (1)
  1369. Frames will be duplicated and dropped to achieve exactly the requested
  1370. constant frame rate.
  1371. @item vfr (2)
  1372. Frames are passed through with their timestamp or dropped so as to
  1373. prevent 2 frames from having the same timestamp.
  1374. @item drop
  1375. As passthrough but destroys all timestamps, making the muxer generate
  1376. fresh timestamps based on frame-rate.
  1377. @item auto (-1)
  1378. Chooses between cfr and vfr depending on muxer capabilities. This is the
  1379. default method.
  1380. @end table
  1381. Note that the timestamps may be further modified by the muxer, after this.
  1382. For example, in the case that the format option @option{avoid_negative_ts}
  1383. is enabled.
  1384. With -map you can select from which stream the timestamps should be
  1385. taken. You can leave either video or audio unchanged and sync the
  1386. remaining stream(s) to the unchanged one.
  1387. @item -frame_drop_threshold @var{parameter}
  1388. Frame drop threshold, which specifies how much behind video frames can
  1389. be before they are dropped. In frame rate units, so 1.0 is one frame.
  1390. The default is -1.1. One possible usecase is to avoid framedrops in case
  1391. of noisy timestamps or to increase frame drop precision in case of exact
  1392. timestamps.
  1393. @item -adrift_threshold @var{time}
  1394. Set the minimum difference between timestamps and audio data (in seconds) to trigger
  1395. adding/dropping samples to make it match the timestamps. This option effectively is
  1396. a threshold to select between hard (add/drop) and soft (squeeze/stretch) compensation.
  1397. @code{-async} must be set to a positive value.
  1398. @item -apad @var{parameters} (@emph{output,per-stream})
  1399. Pad the output audio stream(s). This is the same as applying @code{-af apad}.
  1400. Argument is a string of filter parameters composed the same as with the @code{apad} filter.
  1401. @code{-shortest} must be set for this output for the option to take effect.
  1402. @item -copyts
  1403. Do not process input timestamps, but keep their values without trying
  1404. to sanitize them. In particular, do not remove the initial start time
  1405. offset value.
  1406. Note that, depending on the @option{vsync} option or on specific muxer
  1407. processing (e.g. in case the format option @option{avoid_negative_ts}
  1408. is enabled) the output timestamps may mismatch with the input
  1409. timestamps even when this option is selected.
  1410. @item -start_at_zero
  1411. When used with @option{copyts}, shift input timestamps so they start at zero.
  1412. This means that using e.g. @code{-ss 50} will make output timestamps start at
  1413. 50 seconds, regardless of what timestamp the input file started at.
  1414. @item -copytb @var{mode}
  1415. Specify how to set the encoder timebase when stream copying. @var{mode} is an
  1416. integer numeric value, and can assume one of the following values:
  1417. @table @option
  1418. @item 1
  1419. Use the demuxer timebase.
  1420. The time base is copied to the output encoder from the corresponding input
  1421. demuxer. This is sometimes required to avoid non monotonically increasing
  1422. timestamps when copying video streams with variable frame rate.
  1423. @item 0
  1424. Use the decoder timebase.
  1425. The time base is copied to the output encoder from the corresponding input
  1426. decoder.
  1427. @item -1
  1428. Try to make the choice automatically, in order to generate a sane output.
  1429. @end table
  1430. Default value is -1.
  1431. @item -enc_time_base[:@var{stream_specifier}] @var{timebase} (@emph{output,per-stream})
  1432. Set the encoder timebase. @var{timebase} is a floating point number,
  1433. and can assume one of the following values:
  1434. @table @option
  1435. @item 0
  1436. Assign a default value according to the media type.
  1437. For video - use 1/framerate, for audio - use 1/samplerate.
  1438. @item -1
  1439. Use the input stream timebase when possible.
  1440. If an input stream is not available, the default timebase will be used.
  1441. @item >0
  1442. Use the provided number as the timebase.
  1443. This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000)
  1444. or as a floating point number (e.g. 0.04166, 2.0833e-5)
  1445. @end table
  1446. Default value is 0.
  1447. @item -bitexact (@emph{input/output})
  1448. Enable bitexact mode for (de)muxer and (de/en)coder
  1449. @item -shortest (@emph{output})
  1450. Finish encoding when the shortest output stream ends.
  1451. Note that this option may require buffering frames, which introduces extra
  1452. latency. The maximum amount of this latency may be controlled with the
  1453. @code{-shortest_buf_duration} option.
  1454. @item -shortest_buf_duration @var{duration} (@emph{output})
  1455. The @code{-shortest} option may require buffering potentially large amounts
  1456. of data when at least one of the streams is "sparse" (i.e. has large gaps
  1457. between frames – this is typically the case for subtitles).
  1458. This option controls the maximum duration of buffered frames in seconds.
  1459. Larger values may allow the @code{-shortest} option to produce more accurate
  1460. results, but increase memory use and latency.
  1461. The default value is 10 seconds.
  1462. @item -dts_delta_threshold
  1463. Timestamp discontinuity delta threshold.
  1464. @item -dts_error_threshold @var{seconds}
  1465. Timestamp error delta threshold. This threshold use to discard crazy/damaged
  1466. timestamps and the default is 30 hours which is arbitrarily picked and quite
  1467. conservative.
  1468. @item -muxdelay @var{seconds} (@emph{output})
  1469. Set the maximum demux-decode delay.
  1470. @item -muxpreload @var{seconds} (@emph{output})
  1471. Set the initial demux-decode delay.
  1472. @item -streamid @var{output-stream-index}:@var{new-value} (@emph{output})
  1473. Assign a new stream-id value to an output stream. This option should be
  1474. specified prior to the output filename to which it applies.
  1475. For the situation where multiple output files exist, a streamid
  1476. may be reassigned to a different value.
  1477. For example, to set the stream 0 PID to 33 and the stream 1 PID to 36 for
  1478. an output mpegts file:
  1479. @example
  1480. ffmpeg -i inurl -streamid 0:33 -streamid 1:36 out.ts
  1481. @end example
  1482. @item -bsf[:@var{stream_specifier}] @var{bitstream_filters} (@emph{output,per-stream})
  1483. Set bitstream filters for matching streams. @var{bitstream_filters} is
  1484. a comma-separated list of bitstream filters. Use the @code{-bsfs} option
  1485. to get the list of bitstream filters.
  1486. @example
  1487. ffmpeg -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
  1488. @end example
  1489. @example
  1490. ffmpeg -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
  1491. @end example
  1492. @item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{input/output,per-stream})
  1493. Force a tag/fourcc for matching streams.
  1494. @item -timecode @var{hh}:@var{mm}:@var{ss}SEP@var{ff}
  1495. Specify Timecode for writing. @var{SEP} is ':' for non drop timecode and ';'
  1496. (or '.') for drop.
  1497. @example
  1498. ffmpeg -i input.mpg -timecode 01:02:03.04 -r 30000/1001 -s ntsc output.mpg
  1499. @end example
  1500. @anchor{filter_complex_option}
  1501. @item -filter_complex @var{filtergraph} (@emph{global})
  1502. Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  1503. outputs. For simple graphs -- those with one input and one output of the same
  1504. type -- see the @option{-filter} options. @var{filtergraph} is a description of
  1505. the filtergraph, as described in the ``Filtergraph syntax'' section of the
  1506. ffmpeg-filters manual.
  1507. Input link labels must refer to input streams using the
  1508. @code{[file_index:stream_specifier]} syntax (i.e. the same as @option{-map}
  1509. uses). If @var{stream_specifier} matches multiple streams, the first one will be
  1510. used. An unlabeled input will be connected to the first unused input stream of
  1511. the matching type.
  1512. Output link labels are referred to with @option{-map}. Unlabeled outputs are
  1513. added to the first output file.
  1514. Note that with this option it is possible to use only lavfi sources without
  1515. normal input files.
  1516. For example, to overlay an image over video
  1517. @example
  1518. ffmpeg -i video.mkv -i image.png -filter_complex '[0:v][1:v]overlay[out]' -map
  1519. '[out]' out.mkv
  1520. @end example
  1521. Here @code{[0:v]} refers to the first video stream in the first input file,
  1522. which is linked to the first (main) input of the overlay filter. Similarly the
  1523. first video stream in the second input is linked to the second (overlay) input
  1524. of overlay.
  1525. Assuming there is only one video stream in each input file, we can omit input
  1526. labels, so the above is equivalent to
  1527. @example
  1528. ffmpeg -i video.mkv -i image.png -filter_complex 'overlay[out]' -map
  1529. '[out]' out.mkv
  1530. @end example
  1531. Furthermore we can omit the output label and the single output from the filter
  1532. graph will be added to the output file automatically, so we can simply write
  1533. @example
  1534. ffmpeg -i video.mkv -i image.png -filter_complex 'overlay' out.mkv
  1535. @end example
  1536. As a special exception, you can use a bitmap subtitle stream as input: it
  1537. will be converted into a video with the same size as the largest video in
  1538. the file, or 720x576 if no video is present. Note that this is an
  1539. experimental and temporary solution. It will be removed once libavfilter has
  1540. proper support for subtitles.
  1541. For example, to hardcode subtitles on top of a DVB-T recording stored in
  1542. MPEG-TS format, delaying the subtitles by 1 second:
  1543. @example
  1544. ffmpeg -i input.ts -filter_complex \
  1545. '[#0x2ef] setpts=PTS+1/TB [sub] ; [#0x2d0] [sub] overlay' \
  1546. -sn -map '#0x2dc' output.mkv
  1547. @end example
  1548. (0x2d0, 0x2dc and 0x2ef are the MPEG-TS PIDs of respectively the video,
  1549. audio and subtitles streams; 0:0, 0:3 and 0:7 would have worked too)
  1550. To generate 5 seconds of pure red video using lavfi @code{color} source:
  1551. @example
  1552. ffmpeg -filter_complex 'color=c=red' -t 5 out.mkv
  1553. @end example
  1554. @item -filter_complex_threads @var{nb_threads} (@emph{global})
  1555. Defines how many threads are used to process a filter_complex graph.
  1556. Similar to filter_threads but used for @code{-filter_complex} graphs only.
  1557. The default is the number of available CPUs.
  1558. @item -lavfi @var{filtergraph} (@emph{global})
  1559. Define a complex filtergraph, i.e. one with arbitrary number of inputs and/or
  1560. outputs. Equivalent to @option{-filter_complex}.
  1561. @item -filter_complex_script @var{filename} (@emph{global})
  1562. This option is similar to @option{-filter_complex}, the only difference is that
  1563. its argument is the name of the file from which a complex filtergraph
  1564. description is to be read.
  1565. @item -accurate_seek (@emph{input})
  1566. This option enables or disables accurate seeking in input files with the
  1567. @option{-ss} option. It is enabled by default, so seeking is accurate when
  1568. transcoding. Use @option{-noaccurate_seek} to disable it, which may be useful
  1569. e.g. when copying some streams and transcoding the others.
  1570. @item -seek_timestamp (@emph{input})
  1571. This option enables or disables seeking by timestamp in input files with the
  1572. @option{-ss} option. It is disabled by default. If enabled, the argument
  1573. to the @option{-ss} option is considered an actual timestamp, and is not
  1574. offset by the start time of the file. This matters only for files which do
  1575. not start from timestamp 0, such as transport streams.
  1576. @item -thread_queue_size @var{size} (@emph{input/output})
  1577. For input, this option sets the maximum number of queued packets when reading
  1578. from the file or device. With low latency / high rate live streams, packets may
  1579. be discarded if they are not read in a timely manner; setting this value can
  1580. force ffmpeg to use a separate input thread and read packets as soon as they
  1581. arrive. By default ffmpeg only does this if multiple inputs are specified.
  1582. For output, this option specified the maximum number of packets that may be
  1583. queued to each muxing thread.
  1584. @item -sdp_file @var{file} (@emph{global})
  1585. Print sdp information for an output stream to @var{file}.
  1586. This allows dumping sdp information when at least one output isn't an
  1587. rtp stream. (Requires at least one of the output formats to be rtp).
  1588. @item -discard (@emph{input})
  1589. Allows discarding specific streams or frames from streams.
  1590. Any input stream can be fully discarded, using value @code{all} whereas
  1591. selective discarding of frames from a stream occurs at the demuxer
  1592. and is not supported by all demuxers.
  1593. @table @option
  1594. @item none
  1595. Discard no frame.
  1596. @item default
  1597. Default, which discards no frames.
  1598. @item noref
  1599. Discard all non-reference frames.
  1600. @item bidir
  1601. Discard all bidirectional frames.
  1602. @item nokey
  1603. Discard all frames excepts keyframes.
  1604. @item all
  1605. Discard all frames.
  1606. @end table
  1607. @item -abort_on @var{flags} (@emph{global})
  1608. Stop and abort on various conditions. The following flags are available:
  1609. @table @option
  1610. @item empty_output
  1611. No packets were passed to the muxer, the output is empty.
  1612. @item empty_output_stream
  1613. No packets were passed to the muxer in some of the output streams.
  1614. @end table
  1615. @item -max_error_rate (@emph{global})
  1616. Set fraction of decoding frame failures across all inputs which when crossed
  1617. ffmpeg will return exit code 69. Crossing this threshold does not terminate
  1618. processing. Range is a floating-point number between 0 to 1. Default is 2/3.
  1619. @item -xerror (@emph{global})
  1620. Stop and exit on error
  1621. @item -max_muxing_queue_size @var{packets} (@emph{output,per-stream})
  1622. When transcoding audio and/or video streams, ffmpeg will not begin writing into
  1623. the output until it has one packet for each such stream. While waiting for that
  1624. to happen, packets for other streams are buffered. This option sets the size of
  1625. this buffer, in packets, for the matching output stream.
  1626. The default value of this option should be high enough for most uses, so only
  1627. touch this option if you are sure that you need it.
  1628. @item -muxing_queue_data_threshold @var{bytes} (@emph{output,per-stream})
  1629. This is a minimum threshold until which the muxing queue size is not taken into
  1630. account. Defaults to 50 megabytes per stream, and is based on the overall size
  1631. of packets passed to the muxer.
  1632. @item -auto_conversion_filters (@emph{global})
  1633. Enable automatically inserting format conversion filters in all filter
  1634. graphs, including those defined by @option{-vf}, @option{-af},
  1635. @option{-filter_complex} and @option{-lavfi}. If filter format negotiation
  1636. requires a conversion, the initialization of the filters will fail.
  1637. Conversions can still be performed by inserting the relevant conversion
  1638. filter (scale, aresample) in the graph.
  1639. On by default, to explicitly disable it you need to specify
  1640. @code{-noauto_conversion_filters}.
  1641. @item -bits_per_raw_sample[:@var{stream_specifier}] @var{value} (@emph{output,per-stream})
  1642. Declare the number of bits per raw sample in the given output stream to be
  1643. @var{value}. Note that this option sets the information provided to the
  1644. encoder/muxer, it does not change the stream to conform to this value. Setting
  1645. values that do not match the stream properties may result in encoding failures
  1646. or invalid output files.
  1647. @item -stats_enc_pre[:@var{stream_specifier}] @var{path} (@emph{output,per-stream})
  1648. @item -stats_enc_post[:@var{stream_specifier}] @var{path} (@emph{output,per-stream})
  1649. @item -stats_mux_pre[:@var{stream_specifier}] @var{path} (@emph{output,per-stream})
  1650. Write per-frame encoding information about the matching streams into the file
  1651. given by @var{path}.
  1652. @option{-stats_enc_pre} writes information about raw video or audio frames right
  1653. before they are sent for encoding, while @option{-stats_enc_post} writes
  1654. information about encoded packets as they are received from the encoder.
  1655. @option{-stats_mux_pre} writes information about packets just as they are about to
  1656. be sent to the muxer. Every frame or packet produces one line in the specified
  1657. file. The format of this line is controlled by @option{-stats_enc_pre_fmt} /
  1658. @option{-stats_enc_post_fmt} / @option{-stats_mux_pre_fmt}.
  1659. When stats for multiple streams are written into a single file, the lines
  1660. corresponding to different streams will be interleaved. The precise order of
  1661. this interleaving is not specified and not guaranteed to remain stable between
  1662. different invocations of the program, even with the same options.
  1663. @item -stats_enc_pre_fmt[:@var{stream_specifier}] @var{format_spec} (@emph{output,per-stream})
  1664. @item -stats_enc_post_fmt[:@var{stream_specifier}] @var{format_spec} (@emph{output,per-stream})
  1665. @item -stats_mux_pre_fmt[:@var{stream_specifier}] @var{format_spec} (@emph{output,per-stream})
  1666. Specify the format for the lines written with @option{-stats_enc_pre} /
  1667. @option{-stats_enc_post} / @option{-stats_mux_pre}.
  1668. @var{format_spec} is a string that may contain directives of the form
  1669. @var{@{fmt@}}. @var{format_spec} is backslash-escaped --- use \@{, \@}, and \\
  1670. to write a literal @{, @}, or \, respectively, into the output.
  1671. The directives given with @var{fmt} may be one of the following:
  1672. @table @option
  1673. @item fidx
  1674. Index of the output file.
  1675. @item sidx
  1676. Index of the output stream in the file.
  1677. @item n
  1678. Frame number. Pre-encoding: number of frames sent to the encoder so far.
  1679. Post-encoding: number of packets received from the encoder so far.
  1680. Muxing: number of packets submitted to the muxer for this stream so far.
  1681. @item ni
  1682. Input frame number. Index of the input frame (i.e. output by a decoder) that
  1683. corresponds to this output frame or packet. -1 if unavailable.
  1684. @item tb
  1685. Encoder timebase, as a rational number @var{num/den}. Note that this may be
  1686. different from the timebase used by the muxer.
  1687. @item tbi
  1688. Timebase for @var{ptsi}, as a rational number @var{num/den}. Available when
  1689. @var{ptsi} is available, @var{0/1} otherwise.
  1690. @item pts
  1691. Presentation timestamp of the frame or packet, as an integer. Should be
  1692. multiplied by the timebase to compute presentation time.
  1693. @item ptsi
  1694. Presentation timestamp of the input frame (see @var{ni}), as an integer. Should
  1695. be multiplied by @var{tbi} to compute presentation time. Printed as
  1696. (2^63 - 1 = 9223372036854775807) when not available.
  1697. @item t
  1698. Presentation time of the frame or packet, as a decimal number. Equal to
  1699. @var{pts} multiplied by @var{tb}.
  1700. @item ti
  1701. Presentation time of the input frame (see @var{ni}), as a decimal number. Equal
  1702. to @var{ptsi} multiplied by @var{tbi}. Printed as inf when not available.
  1703. @item dts
  1704. Decoding timestamp of the packet, as an integer. Should be multiplied by the
  1705. timebase to compute presentation time. Post-encoding only.
  1706. @item dt
  1707. Decoding time of the frame or packet, as a decimal number. Equal to
  1708. @var{dts} multiplied by @var{tb}.
  1709. @item sn
  1710. Number of audio samples sent to the encoder so far. Audio and pre-encoding only.
  1711. @item samp
  1712. Number of audio samples in the frame. Audio and pre-encoding only.
  1713. @item size
  1714. Size of the encoded packet in bytes. Post-encoding only.
  1715. @item br
  1716. Current bitrate in bits per second. Post-encoding only.
  1717. @item abr
  1718. Average bitrate for the whole stream so far, in bits per second, -1 if it cannot
  1719. be determined at this point. Post-encoding only.
  1720. @end table
  1721. The default format strings are:
  1722. @table @option
  1723. @item pre-encoding
  1724. @{fidx@} @{sidx@} @{n@} @{t@}
  1725. @item post-encoding
  1726. @{fidx@} @{sidx@} @{n@} @{t@}
  1727. @end table
  1728. In the future, new items may be added to the end of the default formatting
  1729. strings. Users who depend on the format staying exactly the same, should
  1730. prescribe it manually.
  1731. Note that stats for different streams written into the same file may have
  1732. different formats.
  1733. @end table
  1734. @section Preset files
  1735. A preset file contains a sequence of @var{option}=@var{value} pairs,
  1736. one for each line, specifying a sequence of options which would be
  1737. awkward to specify on the command line. Lines starting with the hash
  1738. ('#') character are ignored and are used to provide comments. Check
  1739. the @file{presets} directory in the FFmpeg source tree for examples.
  1740. There are two types of preset files: ffpreset and avpreset files.
  1741. @subsection ffpreset files
  1742. ffpreset files are specified with the @code{vpre}, @code{apre},
  1743. @code{spre}, and @code{fpre} options. The @code{fpre} option takes the
  1744. filename of the preset instead of a preset name as input and can be
  1745. used for any kind of codec. For the @code{vpre}, @code{apre}, and
  1746. @code{spre} options, the options specified in a preset file are
  1747. applied to the currently selected codec of the same type as the preset
  1748. option.
  1749. The argument passed to the @code{vpre}, @code{apre}, and @code{spre}
  1750. preset options identifies the preset file to use according to the
  1751. following rules:
  1752. First ffmpeg searches for a file named @var{arg}.ffpreset in the
  1753. directories @file{$FFMPEG_DATADIR} (if set), and @file{$HOME/.ffmpeg}, and in
  1754. the datadir defined at configuration time (usually @file{PREFIX/share/ffmpeg})
  1755. or in a @file{ffpresets} folder along the executable on win32,
  1756. in that order. For example, if the argument is @code{libvpx-1080p}, it will
  1757. search for the file @file{libvpx-1080p.ffpreset}.
  1758. If no such file is found, then ffmpeg will search for a file named
  1759. @var{codec_name}-@var{arg}.ffpreset in the above-mentioned
  1760. directories, where @var{codec_name} is the name of the codec to which
  1761. the preset file options will be applied. For example, if you select
  1762. the video codec with @code{-vcodec libvpx} and use @code{-vpre 1080p},
  1763. then it will search for the file @file{libvpx-1080p.ffpreset}.
  1764. @subsection avpreset files
  1765. avpreset files are specified with the @code{pre} option. They work similar to
  1766. ffpreset files, but they only allow encoder- specific options. Therefore, an
  1767. @var{option}=@var{value} pair specifying an encoder cannot be used.
  1768. When the @code{pre} option is specified, ffmpeg will look for files with the
  1769. suffix .avpreset in the directories @file{$AVCONV_DATADIR} (if set), and
  1770. @file{$HOME/.avconv}, and in the datadir defined at configuration time (usually
  1771. @file{PREFIX/share/ffmpeg}), in that order.
  1772. First ffmpeg searches for a file named @var{codec_name}-@var{arg}.avpreset in
  1773. the above-mentioned directories, where @var{codec_name} is the name of the codec
  1774. to which the preset file options will be applied. For example, if you select the
  1775. video codec with @code{-vcodec libvpx} and use @code{-pre 1080p}, then it will
  1776. search for the file @file{libvpx-1080p.avpreset}.
  1777. If no such file is found, then ffmpeg will search for a file named
  1778. @var{arg}.avpreset in the same directories.
  1779. @c man end OPTIONS
  1780. @chapter Examples
  1781. @c man begin EXAMPLES
  1782. @section Video and Audio grabbing
  1783. If you specify the input format and device then ffmpeg can grab video
  1784. and audio directly.
  1785. @example
  1786. ffmpeg -f oss -i /dev/dsp -f video4linux2 -i /dev/video0 /tmp/out.mpg
  1787. @end example
  1788. Or with an ALSA audio source (mono input, card id 1) instead of OSS:
  1789. @example
  1790. ffmpeg -f alsa -ac 1 -i hw:1 -f video4linux2 -i /dev/video0 /tmp/out.mpg
  1791. @end example
  1792. Note that you must activate the right video source and channel before
  1793. launching ffmpeg with any TV viewer such as
  1794. @uref{http://linux.bytesex.org/xawtv/, xawtv} by Gerd Knorr. You also
  1795. have to set the audio recording levels correctly with a
  1796. standard mixer.
  1797. @section X11 grabbing
  1798. Grab the X11 display with ffmpeg via
  1799. @example
  1800. ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0 /tmp/out.mpg
  1801. @end example
  1802. 0.0 is display.screen number of your X11 server, same as
  1803. the DISPLAY environment variable.
  1804. @example
  1805. ffmpeg -f x11grab -video_size cif -framerate 25 -i :0.0+10,20 /tmp/out.mpg
  1806. @end example
  1807. 0.0 is display.screen number of your X11 server, same as the DISPLAY environment
  1808. variable. 10 is the x-offset and 20 the y-offset for the grabbing.
  1809. @section Video and Audio file format conversion
  1810. Any supported file format and protocol can serve as input to ffmpeg:
  1811. Examples:
  1812. @itemize
  1813. @item
  1814. You can use YUV files as input:
  1815. @example
  1816. ffmpeg -i /tmp/test%d.Y /tmp/out.mpg
  1817. @end example
  1818. It will use the files:
  1819. @example
  1820. /tmp/test0.Y, /tmp/test0.U, /tmp/test0.V,
  1821. /tmp/test1.Y, /tmp/test1.U, /tmp/test1.V, etc...
  1822. @end example
  1823. The Y files use twice the resolution of the U and V files. They are
  1824. raw files, without header. They can be generated by all decent video
  1825. decoders. You must specify the size of the image with the @option{-s} option
  1826. if ffmpeg cannot guess it.
  1827. @item
  1828. You can input from a raw YUV420P file:
  1829. @example
  1830. ffmpeg -i /tmp/test.yuv /tmp/out.avi
  1831. @end example
  1832. test.yuv is a file containing raw YUV planar data. Each frame is composed
  1833. of the Y plane followed by the U and V planes at half vertical and
  1834. horizontal resolution.
  1835. @item
  1836. You can output to a raw YUV420P file:
  1837. @example
  1838. ffmpeg -i mydivx.avi hugefile.yuv
  1839. @end example
  1840. @item
  1841. You can set several input files and output files:
  1842. @example
  1843. ffmpeg -i /tmp/a.wav -s 640x480 -i /tmp/a.yuv /tmp/a.mpg
  1844. @end example
  1845. Converts the audio file a.wav and the raw YUV video file a.yuv
  1846. to MPEG file a.mpg.
  1847. @item
  1848. You can also do audio and video conversions at the same time:
  1849. @example
  1850. ffmpeg -i /tmp/a.wav -ar 22050 /tmp/a.mp2
  1851. @end example
  1852. Converts a.wav to MPEG audio at 22050 Hz sample rate.
  1853. @item
  1854. You can encode to several formats at the same time and define a
  1855. mapping from input stream to output streams:
  1856. @example
  1857. ffmpeg -i /tmp/a.wav -map 0:a -b:a 64k /tmp/a.mp2 -map 0:a -b:a 128k /tmp/b.mp2
  1858. @end example
  1859. Converts a.wav to a.mp2 at 64 kbits and to b.mp2 at 128 kbits. '-map
  1860. file:index' specifies which input stream is used for each output
  1861. stream, in the order of the definition of output streams.
  1862. @item
  1863. You can transcode decrypted VOBs:
  1864. @example
  1865. 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
  1866. @end example
  1867. This is a typical DVD ripping example; the input is a VOB file, the
  1868. output an AVI file with MPEG-4 video and MP3 audio. Note that in this
  1869. command we use B-frames so the MPEG-4 stream is DivX5 compatible, and
  1870. GOP size is 300 which means one intra frame every 10 seconds for 29.97fps
  1871. input video. Furthermore, the audio stream is MP3-encoded so you need
  1872. to enable LAME support by passing @code{--enable-libmp3lame} to configure.
  1873. The mapping is particularly useful for DVD transcoding
  1874. to get the desired audio language.
  1875. NOTE: To see the supported input formats, use @code{ffmpeg -demuxers}.
  1876. @item
  1877. You can extract images from a video, or create a video from many images:
  1878. For extracting images from a video:
  1879. @example
  1880. ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
  1881. @end example
  1882. This will extract one video frame per second from the video and will
  1883. output them in files named @file{foo-001.jpeg}, @file{foo-002.jpeg},
  1884. etc. Images will be rescaled to fit the new WxH values.
  1885. If you want to extract just a limited number of frames, you can use the
  1886. above command in combination with the @code{-frames:v} or @code{-t} option,
  1887. or in combination with -ss to start extracting from a certain point in time.
  1888. For creating a video from many images:
  1889. @example
  1890. ffmpeg -f image2 -framerate 12 -i foo-%03d.jpeg -s WxH foo.avi
  1891. @end example
  1892. The syntax @code{foo-%03d.jpeg} specifies to use a decimal number
  1893. composed of three digits padded with zeroes to express the sequence
  1894. number. It is the same syntax supported by the C printf function, but
  1895. only formats accepting a normal integer are suitable.
  1896. When importing an image sequence, -i also supports expanding
  1897. shell-like wildcard patterns (globbing) internally, by selecting the
  1898. image2-specific @code{-pattern_type glob} option.
  1899. For example, for creating a video from filenames matching the glob pattern
  1900. @code{foo-*.jpeg}:
  1901. @example
  1902. ffmpeg -f image2 -pattern_type glob -framerate 12 -i 'foo-*.jpeg' -s WxH foo.avi
  1903. @end example
  1904. @item
  1905. You can put many streams of the same type in the output:
  1906. @example
  1907. ffmpeg -i test1.avi -i test2.avi -map 1:1 -map 1:0 -map 0:1 -map 0:0 -c copy -y test12.nut
  1908. @end example
  1909. The resulting output file @file{test12.nut} will contain the first four streams
  1910. from the input files in reverse order.
  1911. @item
  1912. To force CBR video output:
  1913. @example
  1914. ffmpeg -i myfile.avi -b 4000k -minrate 4000k -maxrate 4000k -bufsize 1835k out.m2v
  1915. @end example
  1916. @item
  1917. The four options lmin, lmax, mblmin and mblmax use 'lambda' units,
  1918. but you may use the QP2LAMBDA constant to easily convert from 'q' units:
  1919. @example
  1920. ffmpeg -i src.ext -lmax 21*QP2LAMBDA dst.ext
  1921. @end example
  1922. @end itemize
  1923. @c man end EXAMPLES
  1924. @include config.texi
  1925. @ifset config-all
  1926. @ifset config-avutil
  1927. @include utils.texi
  1928. @end ifset
  1929. @ifset config-avcodec
  1930. @include codecs.texi
  1931. @include bitstream_filters.texi
  1932. @end ifset
  1933. @ifset config-avformat
  1934. @include formats.texi
  1935. @include protocols.texi
  1936. @end ifset
  1937. @ifset config-avdevice
  1938. @include devices.texi
  1939. @end ifset
  1940. @ifset config-swresample
  1941. @include resampler.texi
  1942. @end ifset
  1943. @ifset config-swscale
  1944. @include scaler.texi
  1945. @end ifset
  1946. @ifset config-avfilter
  1947. @include filters.texi
  1948. @end ifset
  1949. @include general_contents.texi
  1950. @end ifset
  1951. @chapter See Also
  1952. @ifhtml
  1953. @ifset config-all
  1954. @url{ffmpeg.html,ffmpeg}
  1955. @end ifset
  1956. @ifset config-not-all
  1957. @url{ffmpeg-all.html,ffmpeg-all},
  1958. @end ifset
  1959. @url{ffplay.html,ffplay}, @url{ffprobe.html,ffprobe},
  1960. @url{ffmpeg-utils.html,ffmpeg-utils},
  1961. @url{ffmpeg-scaler.html,ffmpeg-scaler},
  1962. @url{ffmpeg-resampler.html,ffmpeg-resampler},
  1963. @url{ffmpeg-codecs.html,ffmpeg-codecs},
  1964. @url{ffmpeg-bitstream-filters.html,ffmpeg-bitstream-filters},
  1965. @url{ffmpeg-formats.html,ffmpeg-formats},
  1966. @url{ffmpeg-devices.html,ffmpeg-devices},
  1967. @url{ffmpeg-protocols.html,ffmpeg-protocols},
  1968. @url{ffmpeg-filters.html,ffmpeg-filters}
  1969. @end ifhtml
  1970. @ifnothtml
  1971. @ifset config-all
  1972. ffmpeg(1),
  1973. @end ifset
  1974. @ifset config-not-all
  1975. ffmpeg-all(1),
  1976. @end ifset
  1977. ffplay(1), ffprobe(1),
  1978. ffmpeg-utils(1), ffmpeg-scaler(1), ffmpeg-resampler(1),
  1979. ffmpeg-codecs(1), ffmpeg-bitstream-filters(1), ffmpeg-formats(1),
  1980. ffmpeg-devices(1), ffmpeg-protocols(1), ffmpeg-filters(1)
  1981. @end ifnothtml
  1982. @include authors.texi
  1983. @ignore
  1984. @setfilename ffmpeg
  1985. @settitle ffmpeg video converter
  1986. @end ignore
  1987. @bye