muxers.texi 132 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882
  1. @chapter Muxers
  2. @c man begin MUXERS
  3. Muxers are configured elements in FFmpeg which allow writing
  4. multimedia streams to a particular type of file.
  5. When you configure your FFmpeg build, all the supported muxers
  6. are enabled by default. You can list all available muxers using the
  7. configure option @code{--list-muxers}.
  8. You can disable all the muxers with the configure option
  9. @code{--disable-muxers} and selectively enable / disable single muxers
  10. with the options @code{--enable-muxer=@var{MUXER}} /
  11. @code{--disable-muxer=@var{MUXER}}.
  12. The option @code{-muxers} of the ff* tools will display the list of
  13. enabled muxers. Use @code{-formats} to view a combined list of
  14. enabled demuxers and muxers.
  15. A description of some of the currently available muxers follows.
  16. @anchor{raw muxers}
  17. @section Raw muxers
  18. This section covers raw muxers. They accept a single stream matching
  19. the designated codec. They do not store timestamps or metadata. The
  20. recognized extension is the same as the muxer name unless indicated
  21. otherwise.
  22. It comprises the following muxers. The media type and the eventual
  23. extensions used to automatically selects the muxer from the output
  24. extensions are also shown.
  25. @table @samp
  26. @item ac3 @emph{audio}
  27. Dolby Digital, also known as AC-3.
  28. @item adx @emph{audio}
  29. CRI Middleware ADX audio.
  30. This muxer will write out the total sample count near the start of the
  31. first packet when the output is seekable and the count can be stored
  32. in 32 bits.
  33. @item aptx @emph{audio}
  34. aptX (Audio Processing Technology for Bluetooth)
  35. @item aptx_hd @emph{audio} (aptxdh)
  36. aptX HD (Audio Processing Technology for Bluetooth) audio
  37. @item avs2 @emph{video} (avs, avs2)
  38. AVS2-P2 (Audio Video Standard - Second generation - Part 2) /
  39. IEEE 1857.4 video
  40. @item avs3 @emph{video} (avs3)
  41. AVS3-P2 (Audio Video Standard - Third generation - Part 2) /
  42. IEEE 1857.10 video
  43. @item cavsvideo @emph{video} (cavs)
  44. Chinese AVS (Audio Video Standard - First generation)
  45. @item codec2raw @emph{audio}
  46. Codec 2 audio.
  47. No extension is registered so format name has to be supplied e.g. with
  48. the ffmpeg CLI tool @code{-f codec2raw}.
  49. @item data @emph{any}
  50. Generic data muxer.
  51. This muxer accepts a single stream with any codec of any type. The
  52. input stream has to be selected using the @code{-map} option with the
  53. @command{ffmpeg} CLI tool.
  54. No extension is registered so format name has to be supplied e.g. with
  55. the @command{ffmpeg} CLI tool @code{-f data}.
  56. @item dfpwm @emph{audio} (dfpwm)
  57. Raw DFPWM1a (Dynamic Filter Pulse With Modulation) audio muxer.
  58. @item dirac @emph{video} (drc, vc2)
  59. BBC Dirac video.
  60. The Dirac Pro codec is a subset and is standardized as SMPTE VC-2.
  61. @item dnxhd @emph{video} (dnxhd, dnxhr)
  62. Avid DNxHD video.
  63. It is standardized as SMPTE VC-3. Accepts DNxHR streams.
  64. @item dts @emph{audio}
  65. DTS Coherent Acoustics (DCA) audio
  66. @item eac3 @emph{audio}
  67. Dolby Digital Plus, also known as Enhanced AC-3
  68. @item evc @emph{video} (evc)
  69. MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video
  70. @item g722 @emph{audio}
  71. ITU-T G.722 audio
  72. @item g723_1 @emph{audio} (tco, rco)
  73. ITU-T G.723.1 audio
  74. @item g726 @emph{audio}
  75. ITU-T G.726 big-endian ("left-justified") audio.
  76. No extension is registered so format name has to be supplied e.g. with
  77. the @command{ffmpeg} CLI tool @code{-f g726}.
  78. @item g726le @emph{audio}
  79. ITU-T G.726 little-endian ("right-justified") audio.
  80. No extension is registered so format name has to be supplied e.g. with
  81. the @command{ffmpeg} CLI tool @code{-f g726le}.
  82. @item gsm @emph{audio}
  83. Global System for Mobile Communications audio
  84. @item h261 @emph{video}
  85. ITU-T H.261 video
  86. @item h263 @emph{video}
  87. ITU-T H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 video
  88. @item h264 @emph{video} (h264, 264)
  89. ITU-T H.264 / MPEG-4 Part 10 AVC video. Bitstream shall be converted
  90. to Annex B syntax if it's in length-prefixed mode.
  91. @item hevc @emph{video} (hevc, h265, 265)
  92. ITU-T H.265 / MPEG-H Part 2 HEVC video. Bitstream shall be converted
  93. to Annex B syntax if it's in length-prefixed mode.
  94. @item m4v @emph{video}
  95. MPEG-4 Part 2 video
  96. @item mjpeg @emph{video} (mjpg, mjpeg)
  97. Motion JPEG video
  98. @item mlp @emph{audio}
  99. Meridian Lossless Packing, also known as Packed PCM
  100. @item mp2 @emph{audio} (mp2, m2a, mpa)
  101. MPEG-1 Audio Layer II audio
  102. @item mpeg1video @emph{video} (mpg, mpeg, m1v)
  103. MPEG-1 Part 2 video.
  104. @item mpeg2video @emph{video} (m2v)
  105. ITU-T H.262 / MPEG-2 Part 2 video
  106. @item obu @emph{video}
  107. AV1 low overhead Open Bitstream Units muxer.
  108. Temporal delimiter OBUs will be inserted in all temporal units of the
  109. stream.
  110. @item rawvideo @emph{video} (yuv, rgb)
  111. Raw uncompressed video.
  112. @item sbc @emph{audio} (sbc, msbc)
  113. Bluetooth SIG low-complexity subband codec audio
  114. @item truehd @emph{audio} (thd)
  115. Dolby TrueHD audio
  116. @item vc1 @emph{video}
  117. SMPTE 421M / VC-1 video
  118. @end table
  119. @subsection Examples
  120. @itemize
  121. @item
  122. Store raw video frames with the @samp{rawvideo} muxer using @command{ffmpeg}:
  123. @example
  124. ffmpeg -f lavfi -i testsrc -t 10 -s hd1080p testsrc.yuv
  125. @end example
  126. Since the rawvideo muxer do not store the information related to size
  127. and format, this information must be provided when demuxing the file:
  128. @example
  129. ffplay -video_size 1920x1080 -pixel_format rgb24 -f rawvideo testsrc.rgb
  130. @end example
  131. @end itemize
  132. @section Raw PCM muxers
  133. This section covers raw PCM (Pulse-Code Modulation) audio muxers.
  134. They accept a single stream matching the designated codec. They do not
  135. store timestamps or metadata. The recognized extension is the same as
  136. the muxer name.
  137. It comprises the following muxers. The optional additional extension
  138. used to automatically select the muxer from the output extension is
  139. also shown in parentheses.
  140. @table @samp
  141. @item alaw (al)
  142. PCM A-law
  143. @item f32be
  144. PCM 32-bit floating-point big-endian
  145. @item f32le
  146. PCM 32-bit floating-point little-endian
  147. @item f64be
  148. PCM 64-bit floating-point big-endian
  149. @item f64le
  150. PCM 64-bit floating-point little-endian
  151. @item mulaw (ul)
  152. PCM mu-law
  153. @item s16be
  154. PCM signed 16-bit big-endian
  155. @item s16le
  156. PCM signed 16-bit little-endian
  157. @item s24be
  158. PCM signed 24-bit big-endian
  159. @item s24le
  160. PCM signed 24-bit little-endian
  161. @item s32be
  162. PCM signed 32-bit big-endian
  163. @item s32le
  164. PCM signed 32-bit little-endian
  165. @item s8 (sb)
  166. PCM signed 8-bit
  167. @item u16be
  168. PCM unsigned 16-bit big-endian
  169. @item u16le
  170. PCM unsigned 16-bit little-endian
  171. @item u24be
  172. PCM unsigned 24-bit big-endian
  173. @item u24le
  174. PCM unsigned 24-bit little-endian
  175. @item u32be
  176. PCM unsigned 32-bit big-endian
  177. @item u32le
  178. PCM unsigned 32-bit little-endian
  179. @item u8 (ub)
  180. PCM unsigned 8-bit
  181. @item vidc
  182. PCM Archimedes VIDC
  183. @end table
  184. @section MPEG-1/MPEG-2 program stream muxers
  185. This section covers formats belonging to the MPEG-1 and MPEG-2 Systems
  186. family.
  187. The MPEG-1 Systems format (also known as ISO/IEEC 11172-1 or MPEG-1
  188. program stream) has been adopted for the format of media track stored
  189. in VCD (Video Compact Disc).
  190. The MPEG-2 Systems standard (also known as ISO/IEEC 13818-1) covers
  191. two containers formats, one known as transport stream and one known as
  192. program stream; only the latter is covered here.
  193. The MPEG-2 program stream format (also known as VOB due to the
  194. corresponding file extension) is an extension of MPEG-1 program
  195. stream: in addition to support different codecs for the audio and
  196. video streams, it also stores subtitles and navigation metadata.
  197. MPEG-2 program stream has been adopted for storing media streams in
  198. SVCD and DVD storage devices.
  199. This section comprises the following muxers.
  200. @table @samp
  201. @item mpeg (mpg,mpeg)
  202. MPEG-1 Systems / MPEG-1 program stream muxer.
  203. @item vcd
  204. MPEG-1 Systems / MPEG-1 program stream (VCD) muxer.
  205. This muxer can be used to generate tracks in the format accepted by
  206. the VCD (Video Compact Disc) storage devices.
  207. It is the same as the @samp{mpeg} muxer with a few differences.
  208. @item vob
  209. MPEG-2 program stream (VOB) muxer.
  210. @item dvd
  211. MPEG-2 program stream (DVD VOB) muxer.
  212. This muxer can be used to generate tracks in the format accepted by
  213. the DVD (Digital Versatile Disc) storage devices.
  214. This is the same as the @samp{vob} muxer with a few differences.
  215. @item svcd (vob)
  216. MPEG-2 program stream (SVCD VOB) muxer.
  217. This muxer can be used to generate tracks in the format accepted by
  218. the SVCD (Super Video Compact Disc) storage devices.
  219. This is the same as the @samp{vob} muxer with a few differences.
  220. @end table
  221. @subsection Options
  222. @table @option
  223. @item muxrate @var{rate}
  224. Set user-defined mux rate expressed as a number of bits/s. If not
  225. specied the automatically computed mux rate is employed. Default value
  226. is @code{0}.
  227. @item preload @var{delay}
  228. Set initial demux-decode delay in microseconds. Default value is
  229. @code{500000}.
  230. @end table
  231. @section MOV/MPEG-4/ISOMBFF muxers
  232. This section covers formats belonging to the QuickTime / MOV family,
  233. including the MPEG-4 Part 14 format and ISO base media file format
  234. (ISOBMFF). These formats share a common structure based on the ISO
  235. base media file format (ISOBMFF).
  236. The MOV format was originally developed for use with Apple QuickTime.
  237. It was later used as the basis for the MPEG-4 Part 1 (later Part 14)
  238. format, also known as ISO/IEC 14496-1. That format was then
  239. generalized into ISOBMFF, also named MPEG-4 Part 12 format, ISO/IEC
  240. 14496-12, or ISO/IEC 15444-12.
  241. It comprises the following muxers.
  242. @table @samp
  243. @item 3gp
  244. Third Generation Partnership Project (3GPP) format for 3G UMTS
  245. multimedia services
  246. @item 3g2
  247. Third Generation Partnership Project 2 (3GP2 or 3GPP2) format for 3G
  248. CDMA2000 multimedia services, similar to @samp{3gp} with extensions
  249. and limitations
  250. @item f4v
  251. Adobe Flash Video format
  252. @item ipod
  253. MPEG-4 audio file format, as MOV/MP4 but limited to contain only audio
  254. streams, typically played with the Apple ipod device
  255. @item ismv
  256. Microsoft IIS (Internet Information Services) Smooth Streaming
  257. Audio/Video (ISMV or ISMA) format. This is based on MPEG-4 Part 14
  258. format with a few incompatible variants, used to stream media files
  259. for the Microsoft IIS server.
  260. @item mov
  261. QuickTime player format identified by the @code{.mov} extension
  262. @item mp4
  263. MP4 or MPEG-4 Part 14 format
  264. @item psp
  265. PlayStation Portable MP4/MPEG-4 Part 14 format variant. This is based
  266. on MPEG-4 Part 14 format with a few incompatible variants, used to
  267. play files on PlayStation devices.
  268. @end table
  269. @subsection Fragmentation
  270. The @samp{mov}, @samp{mp4}, and @samp{ismv} muxers support
  271. fragmentation. Normally, a MOV/MP4 file has all the metadata about all
  272. packets stored in one location.
  273. This data is usually written at the end of the file, but it can be
  274. moved to the start for better playback by adding @code{+faststart} to
  275. the @code{-movflags}, or using the @command{qt-faststart} tool).
  276. A fragmented file consists of a number of fragments, where packets and
  277. metadata about these packets are stored together. Writing a fragmented
  278. file has the advantage that the file is decodable even if the writing
  279. is interrupted (while a normal MOV/MP4 is undecodable if it is not
  280. properly finished), and it requires less memory when writing very long
  281. files (since writing normal MOV/MP4 files stores info about every
  282. single packet in memory until the file is closed). The downside is
  283. that it is less compatible with other applications.
  284. Fragmentation is enabled by setting one of the options that define
  285. how to cut the file into fragments:
  286. @table @option
  287. @item frag_duration
  288. @item frag_size
  289. @item min_frag_duration
  290. @item movflags +frag_keyframe
  291. @item movflags +frag_custom
  292. @end table
  293. If more than one condition is specified, fragments are cut when one of
  294. the specified conditions is fulfilled. The exception to this is the
  295. option @option{min_frag_duration}, which has to be fulfilled for any
  296. of the other conditions to apply.
  297. @subsection Options
  298. @table @option
  299. @item brand @var{brand_string}
  300. Override major brand.
  301. @item empty_hdlr_name @var{bool}
  302. Enable to skip writing the name inside a @code{hdlr} box.
  303. Default is @code{false}.
  304. @item encryption_key @var{key}
  305. set the media encryption key in hexadecimal format
  306. @item encryption_kid @var{kid}
  307. set the media encryption key identifier in hexadecimal format
  308. @item encryption_scheme @var{scheme}
  309. configure the encryption scheme, allowed values are @samp{none}, and
  310. @samp{cenc-aes-ctr}
  311. @item frag_duration @var{duration}
  312. Create fragments that are @var{duration} microseconds long.
  313. @item frag_interleave @var{number}
  314. Interleave samples within fragments (max number of consecutive
  315. samples, lower is tighter interleaving, but with more overhead. It is
  316. set to @code{0} by default.
  317. @item frag_size @var{size}
  318. create fragments that contain up to @var{size} bytes of payload data
  319. @item iods_audio_profile @var{profile}
  320. specify iods number for the audio profile atom (from -1 to 255),
  321. default is @code{-1}
  322. @item iods_video_profile @var{profile}
  323. specify iods number for the video profile atom (from -1 to 255),
  324. default is @code{-1}
  325. @item ism_lookahead @var{num_entries}
  326. specify number of lookahead entries for ISM files (from 0 to 255),
  327. default is @code{0}
  328. @item min_frag_duration @var{duration}
  329. do not create fragments that are shorter than @var{duration} microseconds long
  330. @item moov_size @var{bytes}
  331. Reserves space for the moov atom at the beginning of the file instead of placing the
  332. moov atom at the end. If the space reserved is insufficient, muxing will fail.
  333. @item mov_gamma @var{gamma}
  334. specify gamma value for gama atom (as a decimal number from 0 to 10),
  335. default is @code{0.0}, must be set together with @code{+ movflags}
  336. @item movflags @var{flags}
  337. Set various muxing switches. The following flags can be used:
  338. @table @samp
  339. @item cmaf
  340. write CMAF (Common Media Application Format) compatible fragmented
  341. MP4 output
  342. @item dash
  343. write DASH (Dynamic Adaptive Streaming over HTTP) compatible fragmented
  344. MP4 output
  345. @item default_base_moof
  346. Similarly to the @samp{omit_tfhd_offset} flag, this flag avoids
  347. writing the absolute base_data_offset field in tfhd atoms, but does so
  348. by using the new default-base-is-moof flag instead. This flag is new
  349. from 14496-12:2012. This may make the fragments easier to parse in
  350. certain circumstances (avoiding basing track fragment location
  351. calculations on the implicit end of the previous track fragment).
  352. @item delay_moov
  353. delay writing the initial moov until the first fragment is cut, or
  354. until the first fragment flush
  355. @item disable_chpl
  356. Disable Nero chapter markers (chpl atom). Normally, both Nero chapters
  357. and a QuickTime chapter track are written to the file. With this
  358. option set, only the QuickTime chapter track will be written. Nero
  359. chapters can cause failures when the file is reprocessed with certain
  360. tagging programs, like mp3Tag 2.61a and iTunes 11.3, most likely other
  361. versions are affected as well.
  362. @item faststart
  363. Run a second pass moving the index (moov atom) to the beginning of the
  364. file. This operation can take a while, and will not work in various
  365. situations such as fragmented output, thus it is not enabled by
  366. default.
  367. @item frag_custom
  368. Allow the caller to manually choose when to cut fragments, by calling
  369. @code{av_write_frame(ctx, NULL)} to write a fragment with the packets
  370. written so far. (This is only useful with other applications
  371. integrating libavformat, not from @command{ffmpeg}.)
  372. @item frag_discont
  373. signal that the next fragment is discontinuous from earlier ones
  374. @item frag_every_frame
  375. fragment at every frame
  376. @item frag_keyframe
  377. start a new fragment at each video keyframe
  378. @item global_sidx
  379. write a global sidx index at the start of the file
  380. @item isml
  381. create a live smooth streaming feed (for pushing to a publishing point)
  382. @item negative_cts_offsets
  383. Enables utilization of version 1 of the CTTS box, in which the CTS offsets can
  384. be negative. This enables the initial sample to have DTS/CTS of zero, and
  385. reduces the need for edit lists for some cases such as video tracks with
  386. B-frames. Additionally, eases conformance with the DASH-IF interoperability
  387. guidelines.
  388. This option is implicitly set when writing @samp{ismv} (Smooth
  389. Streaming) files.
  390. @item omit_tfhd_offset
  391. Do not write any absolute base_data_offset in tfhd atoms. This avoids
  392. tying fragments to absolute byte positions in the file/streams.
  393. @item prefer_icc
  394. If writing colr atom prioritise usage of ICC profile if it exists in
  395. stream packet side data.
  396. @item rtphint
  397. add RTP hinting tracks to the output file
  398. @item separate_moof
  399. Write a separate moof (movie fragment) atom for each track. Normally,
  400. packets for all tracks are written in a moof atom (which is slightly
  401. more efficient), but with this option set, the muxer writes one
  402. moof/mdat pair for each track, making it easier to separate tracks.
  403. @item skip_sidx
  404. Skip writing of sidx atom. When bitrate overhead due to sidx atom is
  405. high, this option could be used for cases where sidx atom is not
  406. mandatory. When the @samp{global_sidx} flag is enabled, this option
  407. is ignored.
  408. @item skip_trailer
  409. skip writing the mfra/tfra/mfro trailer for fragmented files
  410. @item use_metadata_tags
  411. use mdta atom for metadata
  412. @item write_colr
  413. write colr atom even if the color info is unspecified. This flag is
  414. experimental, may be renamed or changed, do not use from scripts.
  415. @item write_gama
  416. write deprecated gama atom
  417. @item hybrid_fragmented
  418. For recoverability - write the output file as a fragmented file.
  419. This allows the intermediate file to be read while being written
  420. (in particular, if the writing process is aborted uncleanly). When
  421. writing is finished, the file is converted to a regular, non-fragmented
  422. file, which is more compatible and allows easier and quicker seeking.
  423. If writing is aborted, the intermediate file can manually be
  424. remuxed to get a regular, non-fragmented file of what had been
  425. written into the unfinished file.
  426. @end table
  427. @item movie_timescale @var{scale}
  428. Set the timescale written in the movie header box (@code{mvhd}).
  429. Range is 1 to INT_MAX. Default is @code{1000}.
  430. @item rtpflags @var{flags}
  431. Add RTP hinting tracks to the output file.
  432. The following flags can be used:
  433. @table @samp
  434. @item h264_mode0
  435. use mode 0 for H.264 in RTP
  436. @item latm
  437. use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC
  438. @item rfc2190
  439. use RFC 2190 packetization instead of RFC 4629 for H.263
  440. @item send_bye
  441. send RTCP BYE packets when finishing
  442. @item skip_rtcp
  443. do not send RTCP sender reports
  444. @end table
  445. @item skip_iods @var{bool}
  446. skip writing iods atom (default value is @code{true})
  447. @item use_editlist @var{bool}
  448. use edit list (default value is @code{auto})
  449. @item use_stream_ids_as_track_ids @var{bool}
  450. use stream ids as track ids (default value is @code{false})
  451. @item video_track_timescale @var{scale}
  452. Set the timescale used for video tracks. Range is @code{0} to INT_MAX. If
  453. set to @code{0}, the timescale is automatically set based on the
  454. native stream time base. Default is @code{0}.
  455. @item write_btrt @var{bool}
  456. Force or disable writing bitrate box inside stsd box of a track. The
  457. box contains decoding buffer size (in bytes), maximum bitrate and
  458. average bitrate for the track. The box will be skipped if none of
  459. these values can be computed. Default is @code{-1} or @code{auto},
  460. which will write the box only in MP4 mode.
  461. @item write_prft @var{option}
  462. Write producer time reference box (PRFT) with a specified time source for the
  463. NTP field in the PRFT box. Set value as @samp{wallclock} to specify timesource
  464. as wallclock time and @samp{pts} to specify timesource as input packets' PTS
  465. values.
  466. @item write_tmcd @var{bool}
  467. Specify @code{on} to force writing a timecode track, @code{off} to disable it
  468. and @code{auto} to write a timecode track only for mov and mp4 output (default).
  469. Setting value to @samp{pts} is applicable only for a live encoding use case,
  470. where PTS values are set as as wallclock time at the source. For example, an
  471. encoding use case with decklink capture source where @option{video_pts} and
  472. @option{audio_pts} are set to @samp{abs_wallclock}.
  473. @end table
  474. @subsection Examples
  475. @itemize
  476. @item
  477. Push Smooth Streaming content in real time to a publishing point on
  478. IIS with the @samp{ismv} muxer using @command{ffmpeg}:
  479. @example
  480. ffmpeg -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)
  481. @end example
  482. @end itemize
  483. @anchor{a64}
  484. @section a64
  485. A64 Commodore 64 video muxer.
  486. This muxer accepts a single @code{a64_multi} or @code{a64_multi5}
  487. codec video stream.
  488. @section ac4
  489. Raw AC-4 audio muxer.
  490. This muxer accepts a single @code{ac4} audio stream.
  491. @subsection Options
  492. @table @option
  493. @item write_crc @var{bool}
  494. when enabled, write a CRC checksum for each packet to the output,
  495. default is @code{false}
  496. @end table
  497. @anchor{adts}
  498. @section adts
  499. Audio Data Transport Stream muxer.
  500. It accepts a single AAC stream.
  501. @subsection Options
  502. @table @option
  503. @item write_id3v2 @var{bool}
  504. Enable to write ID3v2.4 tags at the start of the stream. Default is
  505. disabled.
  506. @item write_apetag @var{bool}
  507. Enable to write APE tags at the end of the stream. Default is
  508. disabled.
  509. @item write_mpeg2 @var{bool}
  510. Enable to set MPEG version bit in the ADTS frame header to 1 which
  511. indicates MPEG-2. Default is 0, which indicates MPEG-4.
  512. @end table
  513. @anchor{aea}
  514. @section aea
  515. MD STUDIO audio muxer.
  516. This muxer accepts a single ATRAC1 audio stream with either one or two channels
  517. and a sample rate of 44100Hz.
  518. As AEA supports storing the track title, this muxer will also write
  519. the title from stream's metadata to the container.
  520. @anchor{aiff}
  521. @section aiff
  522. Audio Interchange File Format muxer.
  523. @subsection Options
  524. @table @option
  525. @item write_id3v2 @var{bool}
  526. Enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
  527. @item id3v2_version @var{bool}
  528. Select ID3v2 version to write. Currently only version 3 and 4 (aka.
  529. ID3v2.3 and ID3v2.4) are supported. The default is version 4.
  530. @end table
  531. @anchor{alp}
  532. @section alp
  533. High Voltage Software's Lego Racers game audio muxer.
  534. It accepts a single ADPCM_IMA_ALP stream with no more than 2 channels
  535. and a sample rate not greater than 44100 Hz.
  536. Extensions: @code{tun}, @code{pcm}
  537. @subsection Options
  538. @table @option
  539. @item type @var{type}
  540. Set file type.
  541. @var{type} accepts the following values:
  542. @table @samp
  543. @item tun
  544. Set file type as music. Must have a sample rate of 22050 Hz.
  545. @item pcm
  546. Set file type as sfx.
  547. @item auto
  548. Set file type as per output file extension. @code{.pcm} results in
  549. type @code{pcm} else type @code{tun} is set. @var{(default)}
  550. @end table
  551. @end table
  552. @section amr
  553. 3GPP AMR (Adaptive Multi-Rate) audio muxer.
  554. It accepts a single audio stream containing an AMR NB stream.
  555. @section amv
  556. AMV (Actions Media Video) format muxer.
  557. @section apm
  558. Ubisoft Rayman 2 APM audio muxer.
  559. It accepts a single ADPCM IMA APM audio stream.
  560. @section apng
  561. Animated Portable Network Graphics muxer.
  562. It accepts a single APNG video stream.
  563. @subsection Options
  564. @table @option
  565. @item final_delay @var{delay}
  566. Force a delay expressed in seconds after the last frame of each
  567. repetition. Default value is @code{0.0}.
  568. @item plays @var{repetitions}
  569. specify how many times to play the content, @code{0} causes an infinte
  570. loop, with @code{1} there is no loop
  571. @end table
  572. @subsection Examples
  573. @itemize
  574. @item
  575. Use @command{ffmpeg} to generate an APNG output with 2 repetitions,
  576. and with a delay of half a second after the first repetition:
  577. @example
  578. ffmpeg -i INPUT -final_delay 0.5 -plays 2 out.apng
  579. @end example
  580. @end itemize
  581. @section argo_asf
  582. Argonaut Games ASF audio muxer.
  583. It accepts a single ADPCM audio stream.
  584. @subsection Options
  585. @table @option
  586. @item version_major @var{version}
  587. override file major version, specified as an integer, default value is
  588. @code{2}
  589. @item version_minor @var{version}
  590. override file minor version, specified as an integer, default value is
  591. @code{1}
  592. @item name @var{name}
  593. Embed file name into file, if not specified use the output file
  594. name. The name is truncated to 8 characters.
  595. @end table
  596. @section argo_cvg
  597. Argonaut Games CVG audio muxer.
  598. It accepts a single one-channel ADPCM 22050Hz audio stream.
  599. The @option{loop} and @option{reverb} options set the corresponding
  600. flags in the header which can be later retrieved to process the audio
  601. stream accordingly.
  602. @subsection Options
  603. @table @option
  604. @item skip_rate_check @var{bool}
  605. skip sample rate check (default is @code{false})
  606. @item loop @var{bool}
  607. set loop flag (default is @code{false})
  608. @item reverb @var{boolean}
  609. set reverb flag (default is @code{true})
  610. @end table
  611. @anchor{asf}
  612. @section asf, asf_stream
  613. Advanced / Active Systems (or Streaming) Format audio muxer.
  614. The @samp{asf_stream} variant should be selected for streaming.
  615. Note that Windows Media Audio (wma) and Windows Media Video (wmv) use this
  616. muxer too.
  617. @subsection Options
  618. @table @option
  619. @item packet_size @var{size}
  620. Set the muxer packet size as a number of bytes. By tuning this setting
  621. you may reduce data fragmentation or muxer overhead depending on your
  622. source. Default value is @code{3200}, minimum is @code{100}, maximum
  623. is @code{64Ki}.
  624. @end table
  625. @section ass
  626. ASS/SSA (SubStation Alpha) subtitles muxer.
  627. It accepts a single ASS subtitles stream.
  628. @subsection Options
  629. @table @option
  630. @item ignore_readorder @var{bool}
  631. Write dialogue events immediately, even if they are out-of-order,
  632. default is @code{false}, otherwise they are cached until the expected
  633. time event is found.
  634. @end table
  635. @section ast
  636. AST (Audio Stream) muxer.
  637. This format is used to play audio on some Nintendo Wii games.
  638. It accepts a single audio stream.
  639. The @option{loopstart} and @option{loopend} options can be used to
  640. define a section of the file to loop for players honoring such
  641. options.
  642. @subsection Options
  643. @table @option
  644. @item loopstart @var{start}
  645. Specify loop start position expressesd in milliseconds, from @code{-1}
  646. to @code{INT_MAX}, in case @code{-1} is set then no loop is specified
  647. (default -1) and the @option{loopend} value is ignored.
  648. @item loopend @var{end}
  649. Specify loop end position expressed in milliseconds, from @code{0} to
  650. @code{INT_MAX}, default is @code{0}, in case @code{0} is set it
  651. assumes the total stream duration.
  652. @end table
  653. @section au
  654. SUN AU audio muxer.
  655. It accepts a single audio stream.
  656. @anchor{avi}
  657. @section avi
  658. Audio Video Interleaved muxer.
  659. AVI is a proprietary format developed by Microsoft, and later formally specified
  660. through the Open DML specification.
  661. Because of differences in players implementations, it might be required to set
  662. some options to make sure that the generated output can be correctly played by
  663. the target player.
  664. @subsection Options
  665. @table @option
  666. @item flipped_raw_rgb @var{bool}
  667. If set to @code{true}, store positive height for raw RGB bitmaps, which
  668. indicates bitmap is stored bottom-up. Note that this option does not flip the
  669. bitmap which has to be done manually beforehand, e.g. by using the @samp{vflip}
  670. filter. Default is @code{false} and indicates bitmap is stored top down.
  671. @item reserve_index_space @var{size}
  672. Reserve the specified amount of bytes for the OpenDML master index of each
  673. stream within the file header. By default additional master indexes are
  674. embedded within the data packets if there is no space left in the first master
  675. index and are linked together as a chain of indexes. This index structure can
  676. cause problems for some use cases, e.g. third-party software strictly relying
  677. on the OpenDML index specification or when file seeking is slow. Reserving
  678. enough index space in the file header avoids these problems.
  679. The required index space depends on the output file size and should be about 16
  680. bytes per gigabyte. When this option is omitted or set to zero the necessary
  681. index space is guessed.
  682. Default value is @code{0}.
  683. @item write_channel_mask @var{bool}
  684. Write the channel layout mask into the audio stream header.
  685. This option is enabled by default. Disabling the channel mask can be useful in
  686. specific scenarios, e.g. when merging multiple audio streams into one for
  687. compatibility with software that only supports a single audio stream in AVI
  688. (see @ref{amerge,,the "amerge" section in the ffmpeg-filters manual,ffmpeg-filters}).
  689. @end table
  690. @section avif
  691. AV1 (Alliance for Open Media Video codec 1) image format muxer.
  692. This muxers stores images encoded using the AV1 codec.
  693. It accepts one or two video streams. In case two video streams are
  694. provided, the second one shall contain a single plane storing the
  695. alpha mask.
  696. In case more than one image is provided, the generated output is
  697. considered an animated AVIF and the number of loops can be specified
  698. with the @option{loop} option.
  699. This is based on the specification by Alliance for Open Media at url
  700. @url{https://aomediacodec.github.io/av1-avif}.
  701. @subsection Options
  702. @table @option
  703. @item loop @var{count}
  704. number of times to loop an animated AVIF, @code{0} specify an infinite
  705. loop, default is @code{0}
  706. @item movie_timescale @var{timescale}
  707. Set the timescale written in the movie header box (@code{mvhd}).
  708. Range is 1 to INT_MAX. Default is @code{1000}.
  709. @end table
  710. @section avm2
  711. ShockWave Flash (SWF) / ActionScript Virtual Machine 2 (AVM2) format muxer.
  712. It accepts one audio stream, one video stream, or both.
  713. @section bit
  714. G.729 (.bit) file format muxer.
  715. It accepts a single G.729 audio stream.
  716. @section caf
  717. Apple CAF (Core Audio Format) muxer.
  718. It accepts a single audio stream.
  719. @section codec2
  720. Codec2 audio audio muxer.
  721. It accepts a single codec2 audio stream.
  722. @anchor{chromaprint}
  723. @section chromaprint
  724. Chromaprint fingerprinter muxers.
  725. To enable compilation of this filter you need to configure FFmpeg with
  726. @code{--enable-chromaprint}.
  727. This muxer feeds audio data to the Chromaprint library, which
  728. generates a fingerprint for the provided audio data. See:
  729. @url{https://acoustid.org/chromaprint}
  730. It takes a single signed native-endian 16-bit raw audio stream of at
  731. most 2 channels.
  732. @subsection Options
  733. @table @option
  734. @item algorithm @var{version}
  735. Select version of algorithm to fingerprint with. Range is @code{0} to
  736. @code{4}. Version @code{3} enables silence detection. Default is @code{1}.
  737. @item fp_format @var{format}
  738. Format to output the fingerprint as. Accepts the following options:
  739. @table @samp
  740. @item base64
  741. Base64 compressed fingerprint @emph{(default)}
  742. @item compressed
  743. Binary compressed fingerprint
  744. @item raw
  745. Binary raw fingerprint
  746. @end table
  747. @item silence_threshold @var{threshold}
  748. Threshold for detecting silence. Range is from @code{-1} to
  749. @code{32767}, where @code{-1} disables silence detection. Silence
  750. detection can only be used with version @code{3} of the algorithm.
  751. Silence detection must be disabled for use with the AcoustID
  752. service. Default is @code{-1}.
  753. @end table
  754. @anchor{crc}
  755. @section crc
  756. CRC (Cyclic Redundancy Check) muxer.
  757. This muxer computes and prints the Adler-32 CRC of all the input audio
  758. and video frames. By default audio frames are converted to signed
  759. 16-bit raw audio and video frames to raw video before computing the
  760. CRC.
  761. The output of the muxer consists of a single line of the form:
  762. CRC=0x@var{CRC}, where @var{CRC} is a hexadecimal number 0-padded to
  763. 8 digits containing the CRC for all the decoded input frames.
  764. See also the @ref{framecrc} muxer.
  765. @subsection Examples
  766. @itemize
  767. @item
  768. Use @command{ffmpeg} to compute the CRC of the input, and store it in
  769. the file @file{out.crc}:
  770. @example
  771. ffmpeg -i INPUT -f crc out.crc
  772. @end example
  773. @item
  774. Use @command{ffmpeg} to print the CRC to stdout with the command:
  775. @example
  776. ffmpeg -i INPUT -f crc -
  777. @end example
  778. @item
  779. You can select the output format of each frame with @command{ffmpeg} by
  780. specifying the audio and video codec and format. For example, to
  781. compute the CRC of the input audio converted to PCM unsigned 8-bit
  782. and the input video converted to MPEG-2 video, use the command:
  783. @example
  784. ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
  785. @end example
  786. @end itemize
  787. @anchor{dash}
  788. @section dash
  789. Dynamic Adaptive Streaming over HTTP (DASH) muxer.
  790. This muxer creates segments and manifest files according to the
  791. MPEG-DASH standard ISO/IEC 23009-1:2014 and following standard
  792. updates.
  793. For more information see:
  794. @itemize @bullet
  795. @item
  796. ISO DASH Specification: @url{http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip}
  797. @item
  798. WebM DASH Specification: @url{https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification}
  799. @end itemize
  800. This muxer creates an MPD (Media Presentation Description) manifest
  801. file and segment files for each stream. Segment files are placed in
  802. the same directory of the MPD manifest file.
  803. The segment filename might contain pre-defined identifiers used in the
  804. manifest @code{SegmentTemplate} section as defined in section
  805. 5.3.9.4.4 of the standard.
  806. Available identifiers are @code{$RepresentationID$}, @code{$Number$},
  807. @code{$Bandwidth$}, and @code{$Time$}. In addition to the standard
  808. identifiers, an ffmpeg-specific @code{$ext$} identifier is also
  809. supported. When specified, @command{ffmpeg} will replace @code{$ext$}
  810. in the file name with muxing format's extensions such as @code{mp4},
  811. @code{webm} etc.
  812. @subsection Options
  813. @table @option
  814. @item adaptation_sets @var{adaptation_sets}
  815. Assign streams to adaptation sets, specified in the MPD manifest
  816. @code{AdaptationSets} section.
  817. An adaptation set contains a set of one or more streams accessed as a
  818. single subset, e.g. corresponding streams encoded at different size
  819. selectable by the user depending on the available bandwidth, or to
  820. different audio streams with a different language.
  821. Each adaptation set is specified with the syntax:
  822. @example
  823. id=@var{index},streams=@var{streams}
  824. @end example
  825. where @var{index} must be a numerical index, and @var{streams} is a
  826. sequence of @code{,}-separated stream indices. Multiple adaptation
  827. sets can be specified, separated by spaces.
  828. To map all video (or audio) streams to an adaptation set, @code{v} (or
  829. @code{a}) can be used as stream identifier instead of IDs.
  830. When no assignment is defined, this defaults to an adaptation set for
  831. each stream.
  832. The following optional fields can also be specified:
  833. @table @option
  834. @item descriptor
  835. Define the descriptor as defined by ISO/IEC 23009-1:2014/Amd.2:2015.
  836. For example:
  837. @example
  838. <SupplementalProperty schemeIdUri=\"urn:mpeg:dash:srd:2014\" value=\"0,0,0,1,1,2,2\"/>
  839. @end example
  840. The descriptor string should be a self-closing XML tag.
  841. @item frag_duration
  842. Override the global fragment duration specified with the
  843. @option{frag_duration} option.
  844. @item frag_type
  845. Override the global fragment type specified with the
  846. @option{frag_type} option.
  847. @item seg_duration
  848. Override the global segment duration specified with the
  849. @option{seg_duration} option.
  850. @item trick_id
  851. Mark an adaptation set as containing streams meant to be used for
  852. Trick Mode for the referenced adaptation set.
  853. @end table
  854. A few examples of possible values for the @option{adaptation_sets}
  855. option follow:
  856. @example
  857. id=0,seg_duration=2,frag_duration=1,frag_type=duration,streams=v id=1,seg_duration=2,frag_type=none,streams=a
  858. @end example
  859. @example
  860. id=0,seg_duration=2,frag_type=none,streams=0 id=1,seg_duration=10,frag_type=none,trick_id=0,streams=1
  861. @end example
  862. @item dash_segment_type @var{type}
  863. Set DASH segment files type.
  864. Possible values:
  865. @table @samp
  866. @item auto
  867. The dash segment files format will be selected based on the stream
  868. codec. This is the default mode.
  869. @item mp4
  870. the dash segment files will be in ISOBMFF/MP4 format
  871. @item webm
  872. the dash segment files will be in WebM format
  873. @end table
  874. @item extra_window_size @var{size}
  875. Set the maximum number of segments kept outside of the manifest before
  876. removing from disk.
  877. @item format_options @var{options_list}
  878. Set container format (mp4/webm) options using a @code{:}-separated list of
  879. key=value parameters. Values containing @code{:} special characters must be
  880. escaped.
  881. @item frag_duration @var{duration}
  882. Set the length in seconds of fragments within segments, fractional
  883. value can also be set.
  884. @item frag_type @var{type}
  885. Set the type of interval for fragmentation.
  886. Possible values:
  887. @table @samp
  888. @item auto
  889. set one fragment per segment
  890. @item every_frame
  891. fragment at every frame
  892. @item duration
  893. fragment at specific time intervals
  894. @item pframes
  895. fragment at keyframes and following P-Frame reordering (Video only,
  896. experimental)
  897. @end table
  898. @item global_sidx @var{bool}
  899. Write global @code{SIDX} atom. Applicable only for single file, mp4
  900. output, non-streaming mode.
  901. @item hls_master_name @var{file_name}
  902. HLS master playlist name. Default is @file{master.m3u8}.
  903. @item hls_playlist @var{bool}
  904. Generate HLS playlist files. The master playlist is generated with
  905. filename specified by the @option{hls_master_name} option. One media
  906. playlist file is generated for each stream with filenames
  907. @file{media_0.m3u8}, @file{media_1.m3u8}, etc.
  908. @item http_opts @var{http_opts}
  909. Specify a list of @code{:}-separated key=value options to pass to the
  910. underlying HTTP protocol. Applicable only for HTTP output.
  911. @item http_persistent @var{bool}
  912. Use persistent HTTP connections. Applicable only for HTTP output.
  913. @item http_user_agent @var{user_agent}
  914. Override User-Agent field in HTTP header. Applicable only for HTTP
  915. output.
  916. @item ignore_io_errors @var{bool}
  917. Ignore IO errors during open and write. Useful for long-duration runs
  918. with network output. This is disabled by default.
  919. @item index_correction @var{bool}
  920. Enable or disable segment index correction logic. Applicable only when
  921. @option{use_template} is enabled and @option{use_timeline} is
  922. disabled. This is disabled by default.
  923. When enabled, the logic monitors the flow of segment indexes. If a
  924. streams's segment index value is not at the expected real time
  925. position, then the logic corrects that index value.
  926. Typically this logic is needed in live streaming use cases. The
  927. network bandwidth fluctuations are common during long run
  928. streaming. Each fluctuation can cause the segment indexes fall behind
  929. the expected real time position.
  930. @item init_seg_name @var{init_name}
  931. DASH-templated name to use for the initialization segment. Default is
  932. @code{init-stream$RepresentationID$.$ext$}. @code{$ext$} is replaced
  933. with the file name extension specific for the segment format.
  934. @item ldash @var{bool}
  935. Enable Low-latency Dash by constraining the presence and values of
  936. some elements. This is disabled by default.
  937. @item lhls @var{bool}
  938. Enable Low-latency HLS (LHLS). Add @code{#EXT-X-PREFETCH} tag with
  939. current segment's URI. hls.js player folks are trying to standardize
  940. an open LHLS spec. The draft spec is available at
  941. @url{https://github.com/video-dev/hlsjs-rfcs/blob/lhls-spec/proposals/0001-lhls.md}.
  942. This option tries to comply with the above open spec. It enables
  943. @option{streaming} and @option{hls_playlist} options automatically.
  944. This is an experimental feature.
  945. Note: This is not Apple's version LHLS. See
  946. @url{https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis}
  947. @item master_m3u8_publish_rate @var{segment_intervals_count}
  948. Publish master playlist repeatedly every after specified number of
  949. segment intervals.
  950. @item max_playback_rate @var{rate}
  951. Set the maximum playback rate indicated as appropriate for the
  952. purposes of automatically adjusting playback latency and buffer
  953. occupancy during normal playback by clients.
  954. @item media_seg_name @var{segment_name}
  955. DASH-templated name to use for the media segments. Default is
  956. @code{chunk-stream$RepresentationID$-$Number%05d$.$ext$}. @code{$ext$}
  957. is replaced with the file name extension specific for the segment
  958. format.
  959. @item method @var{method}
  960. Use the given HTTP method to create output files. Generally set to @code{PUT}
  961. or @code{POST}.
  962. @item min_playback_rate @var{rate}
  963. Set the minimum playback rate indicated as appropriate for the
  964. purposes of automatically adjusting playback latency and buffer
  965. occupancy during normal playback by clients.
  966. @item mpd_profile @var{flags}
  967. Set one or more MPD manifest profiles.
  968. Possible values:
  969. @table @samp
  970. @item dash
  971. MPEG-DASH ISO Base media file format live profile
  972. @item dvb_dash
  973. DVB-DASH profile
  974. @end table
  975. Default value is @code{dash}.
  976. @item remove_at_exit @var{bool}
  977. Enable or disable removal of all segments when finished. This is
  978. disabled by default.
  979. @item seg_duration @var{duration}
  980. Set the segment length in seconds (fractional value can be set). The
  981. value is treated as average segment duration when the
  982. @option{use_template} option is enabled and the @option{use_timeline}
  983. option is disabled and as minimum segment duration for all the other
  984. use cases.
  985. Default value is @code{5}.
  986. @item single_file @var{bool}
  987. Enable or disable storing all segments in one file, accessed using
  988. byte ranges. This is disabled by default.
  989. The name of the single file can be specified with the
  990. @option{single_file_name} option, if not specified assume the basename
  991. of the manifest file with the output format extension.
  992. @item single_file_name @var{file_name}
  993. DASH-templated name to use for the manifest @code{baseURL}
  994. element. Imply that the @option{single_file} option is set to
  995. @var{true}. In the template, @code{$ext$} is replaced with the file
  996. name extension specific for the segment format.
  997. @item streaming @var{bool}
  998. Enable or disable chunk streaming mode of output. In chunk streaming
  999. mode, each frame will be a @code{moof} fragment which forms a
  1000. chunk. This is disabled by default.
  1001. @item target_latency @var{target_latency}
  1002. Set an intended target latency in seconds for serving (fractional
  1003. value can be set). Applicable only when the @option{streaming} and
  1004. @option{write_prft} options are enabled. This is an informative fields
  1005. clients can use to measure the latency of the service.
  1006. @item timeout @var{timeout}
  1007. Set timeout for socket I/O operations expressed in seconds (fractional
  1008. value can be set). Applicable only for HTTP output.
  1009. @item update_period @var{period}
  1010. Set the MPD update period, for dynamic content. The unit is
  1011. second. If set to @code{0}, the period is automatically computed.
  1012. Default value is @code{0}.
  1013. @item use_template @var{bool}
  1014. Enable or disable use of @code{SegmentTemplate} instead of
  1015. @code{SegmentList} in the manifest. This is enabled by default.
  1016. @item use_timeline @var{bool}
  1017. Enable or disable use of @code{SegmentTimeline} within the
  1018. @code{SegmentTemplate} manifest section. This is enabled by default.
  1019. @item utc_timing_url @var{url}
  1020. URL of the page that will return the UTC timestamp in ISO
  1021. format, for example @code{https://time.akamai.com/?iso}
  1022. @item window_size @var{size}
  1023. Set the maximum number of segments kept in the manifest, discard the
  1024. oldest one. This is useful for live streaming.
  1025. If the value is @code{0}, all segments are kept in the
  1026. manifest. Default value is @code{0}.
  1027. @item write_prft @var{write_prft}
  1028. Write Producer Reference Time elements on supported streams. This also
  1029. enables writing prft boxes in the underlying muxer. Applicable only
  1030. when the @var{utc_url} option is enabled. It is set to @var{auto} by
  1031. default, in which case the muxer will attempt to enable it only in
  1032. modes that require it.
  1033. @end table
  1034. @subsection Example
  1035. Generate a DASH output reading from an input source in realtime using
  1036. @command{ffmpeg}.
  1037. Two multimedia streams are generated from the input file, both
  1038. containing a video stream encoded through @samp{libx264}, and an audio
  1039. stream encoded with @samp{libfdk_aac}. The first multimedia stream
  1040. contains video with a bitrate of 800k and audio at the default rate,
  1041. the second with video scaled to 320x170 pixels at 300k and audio
  1042. resampled at 22005 Hz.
  1043. The @option{window_size} option keeps only the latest 5 segments with
  1044. the default duration of 5 seconds.
  1045. @example
  1046. ffmpeg -re -i <input> -map 0 -map 0 -c:a libfdk_aac -c:v libx264 \
  1047. -b:v:0 800k -profile:v:0 main \
  1048. -b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline -ar:a:1 22050 \
  1049. -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 \
  1050. -use_timeline 1 -use_template 1 -window_size 5 \
  1051. -adaptation_sets "id=0,streams=v id=1,streams=a" \
  1052. -f dash /path/to/out.mpd
  1053. @end example
  1054. @section daud
  1055. D-Cinema audio muxer.
  1056. It accepts a single 6-channels audio stream resampled at 96000 Hz
  1057. encoded with the @samp{pcm_24daud} codec.
  1058. @subsection Example
  1059. Use @command{ffmpeg} to mux input audio to a @samp{5.1} channel layout
  1060. resampled at 96000Hz:
  1061. @example
  1062. ffmpeg -i INPUT -af aresample=96000,pan=5.1 slow.302
  1063. @end example
  1064. For ffmpeg versions before 7.0 you might have to use the @samp{asetnsamples}
  1065. filter to limit the muxed packet size, because this format does not support
  1066. muxing packets larger than 65535 bytes (3640 samples). For newer ffmpeg
  1067. versions audio is automatically packetized to 36000 byte (2000 sample) packets.
  1068. @section dv
  1069. DV (Digital Video) muxer.
  1070. It accepts exactly one @samp{dvvideo} video stream and at most two
  1071. @samp{pcm_s16} audio streams. More constraints are defined by the
  1072. property of the video, which must correspond to a DV video supported
  1073. profile, and on the framerate.
  1074. @subsection Example
  1075. Use @command{ffmpeg} to convert the input:
  1076. @example
  1077. ffmpeg -i INPUT -s:v 720x480 -pix_fmt yuv411p -r 29.97 -ac 2 -ar 48000 -y out.dv
  1078. @end example
  1079. @section ffmetadata
  1080. FFmpeg metadata muxer.
  1081. This muxer writes the streams metadata in the @samp{ffmetadata}
  1082. format.
  1083. See @ref{metadata,,the Metadata chapter,ffmpeg-formats} for
  1084. information about the format.
  1085. @subsection Example
  1086. Use @command{ffmpeg} to extract metadata from an input file to a @file{metadata.ffmeta}
  1087. file in @samp{ffmetadata} format:
  1088. @example
  1089. ffmpeg -i INPUT -f ffmetadata metadata.ffmeta
  1090. @end example
  1091. @anchor{fifo}
  1092. @section fifo
  1093. FIFO (First-In First-Out) muxer.
  1094. The @samp{fifo} pseudo-muxer allows the separation of encoding and
  1095. muxing by using a first-in-first-out queue and running the actual muxer
  1096. in a separate thread.
  1097. This is especially useful in combination with
  1098. the @ref{tee} muxer and can be used to send data to several
  1099. destinations with different reliability/writing speed/latency.
  1100. The target muxer is either selected from the output name or specified
  1101. through the @option{fifo_format} option.
  1102. The behavior of the @samp{fifo} muxer if the queue fills up or if the
  1103. output fails (e.g. if a packet cannot be written to the output) is
  1104. selectable:
  1105. @itemize @bullet
  1106. @item
  1107. Output can be transparently restarted with configurable delay between
  1108. retries based on real time or time of the processed stream.
  1109. @item
  1110. Encoding can be blocked during temporary failure, or continue transparently
  1111. dropping packets in case the FIFO queue fills up.
  1112. @end itemize
  1113. API users should be aware that callback functions
  1114. (@code{interrupt_callback}, @code{io_open} and @code{io_close}) used
  1115. within its @code{AVFormatContext} must be thread-safe.
  1116. @subsection Options
  1117. @table @option
  1118. @item attempt_recovery @var{bool}
  1119. If failure occurs, attempt to recover the output. This is especially
  1120. useful when used with network output, since it makes it possible to
  1121. restart streaming transparently. By default this option is set to
  1122. @code{false}.
  1123. @item drop_pkts_on_overflow @var{bool}
  1124. If set to @code{true}, in case the fifo queue fills up, packets will
  1125. be dropped rather than blocking the encoder. This makes it possible to
  1126. continue streaming without delaying the input, at the cost of omitting
  1127. part of the stream. By default this option is set to @code{false}, so in
  1128. such cases the encoder will be blocked until the muxer processes some
  1129. of the packets and none of them is lost.
  1130. @item fifo_format @var{format_name}
  1131. Specify the format name. Useful if it cannot be guessed from the
  1132. output name suffix.
  1133. @item format_opts @var{options}
  1134. Specify format options for the underlying muxer. Muxer options can be
  1135. specified as a list of @var{key}=@var{value} pairs separated by ':'.
  1136. @item max_recovery_attempts @var{count}
  1137. Set maximum number of successive unsuccessful recovery attempts after
  1138. which the output fails permanently. By default this option is set to
  1139. @code{0} (unlimited).
  1140. @item queue_size @var{size}
  1141. Specify size of the queue as a number of packets. Default value is
  1142. @code{60}.
  1143. @item recover_any_error @var{bool}
  1144. If set to @code{true}, recovery will be attempted regardless of type
  1145. of the error causing the failure. By default this option is set to
  1146. @code{false} and in case of certain (usually permanent) errors the
  1147. recovery is not attempted even when the @option{attempt_recovery}
  1148. option is set to @code{true}.
  1149. @item recovery_wait_streamtime @var{bool}
  1150. If set to @code{false}, the real time is used when waiting for the
  1151. recovery attempt (i.e. the recovery will be attempted after the time
  1152. specified by the @option{recovery_wait_time} option).
  1153. If set to @code{true}, the time of the processed stream is taken into
  1154. account instead (i.e. the recovery will be attempted after discarding
  1155. the packets corresponding to the @option{recovery_wait_time} option).
  1156. By default this option is set to @code{false}.
  1157. @item recovery_wait_time @var{duration}
  1158. Specify waiting time in seconds before the next recovery attempt after
  1159. previous unsuccessful recovery attempt. Default value is @code{5}.
  1160. @item restart_with_keyframe @var{bool}
  1161. Specify whether to wait for the keyframe after recovering from
  1162. queue overflow or failure. This option is set to @code{false} by default.
  1163. @item timeshift @var{duration}
  1164. Buffer the specified amount of packets and delay writing the
  1165. output. Note that the value of the @option{queue_size} option must be
  1166. big enough to store the packets for timeshift. At the end of the input
  1167. the fifo buffer is flushed at realtime speed.
  1168. @end table
  1169. @subsection Example
  1170. Use @command{ffmpeg} to stream to an RTMP server, continue processing
  1171. the stream at real-time rate even in case of temporary failure
  1172. (network outage) and attempt to recover streaming every second
  1173. indefinitely:
  1174. @example
  1175. ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv \
  1176. -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 \
  1177. -map 0:v -map 0:a rtmp://example.com/live/stream_name
  1178. @end example
  1179. @section film_cpk
  1180. Sega film (.cpk) muxer.
  1181. This format was used as internal format for several Sega games.
  1182. For more information regarding the Sega film file format, visit
  1183. @url{http://wiki.multimedia.cx/index.php?title=Sega_FILM}.
  1184. It accepts at maximum one @samp{cinepak} or raw video stream, and at
  1185. maximum one audio stream.
  1186. @section filmstrip
  1187. Adobe Filmstrip muxer.
  1188. This format is used by several Adobe tools to store a generated filmstrip export. It
  1189. accepts a single raw video stream.
  1190. @section fits
  1191. Flexible Image Transport System (FITS) muxer.
  1192. This image format is used to store astronomical data.
  1193. For more information regarding the format, visit
  1194. @url{https://fits.gsfc.nasa.gov}.
  1195. @section flac
  1196. Raw FLAC audio muxer.
  1197. This muxer accepts exactly one FLAC audio stream. Additionally, it is possible to add
  1198. images with disposition @samp{attached_pic}.
  1199. @subsection Options
  1200. @table @option
  1201. @item write_header @var{bool}
  1202. write the file header if set to @code{true}, default is @code{true}
  1203. @end table
  1204. @subsection Example
  1205. Use @command{ffmpeg} to store the audio stream from an input file,
  1206. together with several pictures used with @samp{attached_pic}
  1207. disposition:
  1208. @example
  1209. ffmpeg -i INPUT -i pic1.png -i pic2.jpg -map 0:a -map 1 -map 2 -disposition:v attached_pic OUTPUT
  1210. @end example
  1211. @section flv
  1212. Adobe Flash Video Format muxer.
  1213. @subsection Options
  1214. @table @option
  1215. @item flvflags @var{flags}
  1216. Possible values:
  1217. @table @samp
  1218. @item aac_seq_header_detect
  1219. Place AAC sequence header based on audio stream data.
  1220. @item no_sequence_end
  1221. Disable sequence end tag.
  1222. @item no_metadata
  1223. Disable metadata tag.
  1224. @item no_duration_filesize
  1225. Disable duration and filesize in metadata when they are equal to zero
  1226. at the end of stream. (Be used to non-seekable living stream).
  1227. @item add_keyframe_index
  1228. Used to facilitate seeking; particularly for HTTP pseudo streaming.
  1229. @end table
  1230. @end table
  1231. @anchor{framecrc}
  1232. @section framecrc
  1233. Per-packet CRC (Cyclic Redundancy Check) testing format.
  1234. This muxer computes and prints the Adler-32 CRC for each audio
  1235. and video packet. By default audio frames are converted to signed
  1236. 16-bit raw audio and video frames to raw video before computing the
  1237. CRC.
  1238. The output of the muxer consists of a line for each audio and video
  1239. packet of the form:
  1240. @example
  1241. @var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, 0x@var{CRC}
  1242. @end example
  1243. @var{CRC} is a hexadecimal number 0-padded to 8 digits containing the
  1244. CRC of the packet.
  1245. @subsection Examples
  1246. For example to compute the CRC of the audio and video frames in
  1247. @file{INPUT}, converted to raw audio and video packets, and store it
  1248. in the file @file{out.crc}:
  1249. @example
  1250. ffmpeg -i INPUT -f framecrc out.crc
  1251. @end example
  1252. To print the information to stdout, use the command:
  1253. @example
  1254. ffmpeg -i INPUT -f framecrc -
  1255. @end example
  1256. With @command{ffmpeg}, you can select the output format to which the
  1257. audio and video frames are encoded before computing the CRC for each
  1258. packet by specifying the audio and video codec. For example, to
  1259. compute the CRC of each decoded input audio frame converted to PCM
  1260. unsigned 8-bit and of each decoded input video frame converted to
  1261. MPEG-2 video, use the command:
  1262. @example
  1263. ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
  1264. @end example
  1265. See also the @ref{crc} muxer.
  1266. @anchor{framehash}
  1267. @section framehash
  1268. Per-packet hash testing format.
  1269. This muxer computes and prints a cryptographic hash for each audio
  1270. and video packet. This can be used for packet-by-packet equality
  1271. checks without having to individually do a binary comparison on each.
  1272. By default audio frames are converted to signed 16-bit raw audio and
  1273. video frames to raw video before computing the hash, but the output
  1274. of explicit conversions to other codecs can also be used. It uses the
  1275. SHA-256 cryptographic hash function by default, but supports several
  1276. other algorithms.
  1277. The output of the muxer consists of a line for each audio and video
  1278. packet of the form:
  1279. @example
  1280. @var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{hash}
  1281. @end example
  1282. @var{hash} is a hexadecimal number representing the computed hash
  1283. for the packet.
  1284. @table @option
  1285. @item hash @var{algorithm}
  1286. Use the cryptographic hash function specified by the string @var{algorithm}.
  1287. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  1288. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  1289. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  1290. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  1291. @end table
  1292. @subsection Examples
  1293. To compute the SHA-256 hash of the audio and video frames in @file{INPUT},
  1294. converted to raw audio and video packets, and store it in the file
  1295. @file{out.sha256}:
  1296. @example
  1297. ffmpeg -i INPUT -f framehash out.sha256
  1298. @end example
  1299. To print the information to stdout, using the MD5 hash function, use
  1300. the command:
  1301. @example
  1302. ffmpeg -i INPUT -f framehash -hash md5 -
  1303. @end example
  1304. See also the @ref{hash} muxer.
  1305. @anchor{framemd5}
  1306. @section framemd5
  1307. Per-packet MD5 testing format.
  1308. This is a variant of the @ref{framehash} muxer. Unlike that muxer,
  1309. it defaults to using the MD5 hash function.
  1310. @subsection Examples
  1311. To compute the MD5 hash of the audio and video frames in @file{INPUT},
  1312. converted to raw audio and video packets, and store it in the file
  1313. @file{out.md5}:
  1314. @example
  1315. ffmpeg -i INPUT -f framemd5 out.md5
  1316. @end example
  1317. To print the information to stdout, use the command:
  1318. @example
  1319. ffmpeg -i INPUT -f framemd5 -
  1320. @end example
  1321. See also the @ref{framehash} and @ref{md5} muxers.
  1322. @anchor{gif}
  1323. @section gif
  1324. Animated GIF muxer.
  1325. Note that the GIF format has a very large time base: the delay between two frames can
  1326. therefore not be smaller than one centi second.
  1327. @subsection Options
  1328. @table @option
  1329. @item loop @var{bool}
  1330. Set the number of times to loop the output. Use @code{-1} for no loop, @code{0}
  1331. for looping indefinitely (default).
  1332. @item final_delay @var{delay}
  1333. Force the delay (expressed in centiseconds) after the last frame. Each frame
  1334. ends with a delay until the next frame. The default is @code{-1}, which is a
  1335. special value to tell the muxer to re-use the previous delay. In case of a
  1336. loop, you might want to customize this value to mark a pause for instance.
  1337. @end table
  1338. @subsection Example
  1339. Encode a gif looping 10 times, with a 5 seconds delay between
  1340. the loops:
  1341. @example
  1342. ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif
  1343. @end example
  1344. Note 1: if you wish to extract the frames into separate GIF files, you need to
  1345. force the @ref{image2} muxer:
  1346. @example
  1347. ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"
  1348. @end example
  1349. @section gxf
  1350. General eXchange Format (GXF) muxer.
  1351. GXF was developed by Grass Valley Group, then standardized by SMPTE as SMPTE
  1352. 360M and was extended in SMPTE RDD 14-2007 to include high-definition video
  1353. resolutions.
  1354. It accepts at most one video stream with codec @samp{mjpeg}, or
  1355. @samp{mpeg1video}, or @samp{mpeg2video}, or @samp{dvvideo} with resolution
  1356. @samp{512x480} or @samp{608x576}, and several audio streams with rate 48000Hz
  1357. and codec @samp{pcm16_le}.
  1358. @anchor{hash}
  1359. @section hash
  1360. Hash testing format.
  1361. This muxer computes and prints a cryptographic hash of all the input
  1362. audio and video frames. This can be used for equality checks without
  1363. having to do a complete binary comparison.
  1364. By default audio frames are converted to signed 16-bit raw audio and
  1365. video frames to raw video before computing the hash, but the output
  1366. of explicit conversions to other codecs can also be used. Timestamps
  1367. are ignored. It uses the SHA-256 cryptographic hash function by default,
  1368. but supports several other algorithms.
  1369. The output of the muxer consists of a single line of the form:
  1370. @var{algo}=@var{hash}, where @var{algo} is a short string representing
  1371. the hash function used, and @var{hash} is a hexadecimal number
  1372. representing the computed hash.
  1373. @table @option
  1374. @item hash @var{algorithm}
  1375. Use the cryptographic hash function specified by the string @var{algorithm}.
  1376. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  1377. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  1378. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  1379. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  1380. @end table
  1381. @subsection Examples
  1382. To compute the SHA-256 hash of the input converted to raw audio and
  1383. video, and store it in the file @file{out.sha256}:
  1384. @example
  1385. ffmpeg -i INPUT -f hash out.sha256
  1386. @end example
  1387. To print an MD5 hash to stdout use the command:
  1388. @example
  1389. ffmpeg -i INPUT -f hash -hash md5 -
  1390. @end example
  1391. See also the @ref{framehash} muxer.
  1392. @anchor{hds}
  1393. @section hds
  1394. HTTP Dynamic Streaming (HDS) muxer.
  1395. HTTP dynamic streaming, or HDS, is an adaptive bitrate streaming method
  1396. developed by Adobe. HDS delivers MP4 video content over HTTP connections. HDS
  1397. can be used for on-demand streaming or live streaming.
  1398. This muxer creates an .f4m (Adobe Flash Media Manifest File) manifest, an .abst
  1399. (Adobe Bootstrap File) for each stream, and segment files in a directory
  1400. specified as the output.
  1401. These needs to be accessed by an HDS player throuhg HTTPS for it to be able to
  1402. perform playback on the generated stream.
  1403. @subsection Options
  1404. @table @option
  1405. @item extra_window_size @var{int}
  1406. number of fragments kept outside of the manifest before removing from disk
  1407. @item min_frag_duration @var{microseconds}
  1408. minimum fragment duration (in microseconds), default value is 1 second
  1409. (@code{10000000})
  1410. @item remove_at_exit @var{bool}
  1411. remove all fragments when finished when set to @code{true}
  1412. @item window_size @var{int}
  1413. number of fragments kept in the manifest, if set to a value different from
  1414. @code{0}. By default all segments are kept in the output directory.
  1415. @end table
  1416. @subsection Example
  1417. Use @command{ffmpeg} to generate HDS files to the @file{output.hds} directory in
  1418. real-time rate:
  1419. @example
  1420. ffmpeg -re -i INPUT -f hds -b:v 200k output.hds
  1421. @end example
  1422. @anchor{hls}
  1423. @section hls
  1424. Apple HTTP Live Streaming muxer that segments MPEG-TS according to
  1425. the HTTP Live Streaming (HLS) specification.
  1426. It creates a playlist file, and one or more segment files. The output filename
  1427. specifies the playlist filename.
  1428. By default, the muxer creates a file for each segment produced. These files
  1429. have the same name as the playlist, followed by a sequential number and a
  1430. .ts extension.
  1431. Make sure to require a closed GOP when encoding and to set the GOP
  1432. size to fit your segment time constraint.
  1433. For example, to convert an input file with @command{ffmpeg}:
  1434. @example
  1435. ffmpeg -i in.mkv -c:v h264 -flags +cgop -g 30 -hls_time 1 out.m3u8
  1436. @end example
  1437. This example will produce the playlist, @file{out.m3u8}, and segment files:
  1438. @file{out0.ts}, @file{out1.ts}, @file{out2.ts}, etc.
  1439. See also the @ref{segment} muxer, which provides a more generic and
  1440. flexible implementation of a segmenter, and can be used to perform HLS
  1441. segmentation.
  1442. @subsection Options
  1443. @table @option
  1444. @item hls_init_time @var{duration}
  1445. Set the initial target segment length. Default value is @var{0}.
  1446. @var{duration} must be a time duration specification,
  1447. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  1448. Segment will be cut on the next key frame after this time has passed on the
  1449. first m3u8 list. After the initial playlist is filled, @command{ffmpeg} will cut
  1450. segments at duration equal to @option{hls_time}.
  1451. @item hls_time @var{duration}
  1452. Set the target segment length. Default value is 2.
  1453. @var{duration} must be a time duration specification,
  1454. see @ref{time duration syntax,,the Time duration section in the ffmpeg-utils(1) manual,ffmpeg-utils}.
  1455. Segment will be cut on the next key frame after this time has passed.
  1456. @item hls_list_size @var{size}
  1457. Set the maximum number of playlist entries. If set to 0 the list file
  1458. will contain all the segments. Default value is 5.
  1459. @item hls_delete_threshold @var{size}
  1460. Set the number of unreferenced segments to keep on disk before @code{hls_flags delete_segments}
  1461. deletes them. Increase this to allow continue clients to download segments which
  1462. were recently referenced in the playlist. Default value is 1, meaning segments older than
  1463. @option{hls_list_size+1} will be deleted.
  1464. @item hls_start_number_source @var{source}
  1465. Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) according to the specified source.
  1466. Unless @option{hls_flags single_file} is set, it also specifies source of starting sequence numbers of
  1467. segment and subtitle filenames. In any case, if @option{hls_flags append_list}
  1468. is set and read playlist sequence number is greater than the specified start sequence number,
  1469. then that value will be used as start value.
  1470. It accepts the following values:
  1471. @table @option
  1472. @item generic (default)
  1473. Set the start numbers according to the @option{start_number} option value.
  1474. @item epoch
  1475. Set the start number as the seconds since epoch (1970-01-01 00:00:00).
  1476. @item epoch_us
  1477. Set the start number as the microseconds since epoch (1970-01-01 00:00:00).
  1478. @item datetime
  1479. Set the start number based on the current date/time as YYYYmmddHHMMSS. e.g. 20161231235759.
  1480. @end table
  1481. @item start_number @var{number}
  1482. Start the playlist sequence number (@code{#EXT-X-MEDIA-SEQUENCE}) from the specified @var{number}
  1483. when @option{hls_start_number_source} value is @var{generic}. (This is the default case.)
  1484. Unless @option{hls_flags single_file} is set, it also specifies starting sequence numbers of segment and subtitle filenames.
  1485. Default value is 0.
  1486. @item hls_allow_cache @var{bool}
  1487. Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
  1488. @item hls_base_url @var{baseurl}
  1489. Append @var{baseurl} to every entry in the playlist.
  1490. Useful to generate playlists with absolute paths.
  1491. Note that the playlist sequence number must be unique for each segment
  1492. and it is not to be confused with the segment filename sequence number
  1493. which can be cyclic, for example if the @option{wrap} option is
  1494. specified.
  1495. @item hls_segment_filename @var{filename}
  1496. Set the segment filename. Unless the @option{hls_flags} option is set with
  1497. @samp{single_file}, @var{filename} is used as a string format with the
  1498. segment number appended.
  1499. For example:
  1500. @example
  1501. ffmpeg -i in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
  1502. @end example
  1503. will produce the playlist, @file{out.m3u8}, and segment files:
  1504. @file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc.
  1505. @var{filename} may contain a full path or relative path specification,
  1506. but only the file name part without any path will be contained in the m3u8 segment list.
  1507. Should a relative path be specified, the path of the created segment
  1508. files will be relative to the current working directory.
  1509. When @option{strftime_mkdir} is set, the whole expanded value of @var{filename} will be written into the m3u8 segment list.
  1510. When @option{var_stream_map} is set with two or more variant streams, the
  1511. @var{filename} pattern must contain the string "%v", and this string will be
  1512. expanded to the position of variant stream index in the generated segment file
  1513. names.
  1514. For example:
  1515. @example
  1516. ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1517. -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
  1518. -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8
  1519. @end example
  1520. will produce the playlists segment file sets:
  1521. @file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. and
  1522. @file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc.
  1523. The string "%v" may be present in the filename or in the last directory name
  1524. containing the file, but only in one of them. (Additionally, %v may appear multiple times in the last
  1525. sub-directory or filename.) If the string %v is present in the directory name, then
  1526. sub-directories are created after expanding the directory name pattern. This
  1527. enables creation of segments corresponding to different variant streams in
  1528. subdirectories.
  1529. For example:
  1530. @example
  1531. ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1532. -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
  1533. -hls_segment_filename 'vs%v/file_%03d.ts' vs%v/out.m3u8
  1534. @end example
  1535. will produce the playlists segment file sets:
  1536. @file{vs0/file_000.ts}, @file{vs0/file_001.ts}, @file{vs0/file_002.ts}, etc. and
  1537. @file{vs1/file_000.ts}, @file{vs1/file_001.ts}, @file{vs1/file_002.ts}, etc.
  1538. @item strftime @var{bool}
  1539. Use @code{strftime()} on @var{filename} to expand the segment filename with
  1540. localtime. The segment number is also available in this mode, but to use it,
  1541. you need to set @samp{second_level_segment_index} in the @option{hls_flag} and
  1542. %%d will be the specifier.
  1543. For example:
  1544. @example
  1545. ffmpeg -i in.nut -strftime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
  1546. @end example
  1547. will produce the playlist, @file{out.m3u8}, and segment files:
  1548. @file{file-20160215-1455569023.ts}, @file{file-20160215-1455569024.ts}, etc.
  1549. Note: On some systems/environments, the @code{%s} specifier is not
  1550. available. See @code{strftime()} documentation.
  1551. For example:
  1552. @example
  1553. ffmpeg -i in.nut -strftime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
  1554. @end example
  1555. will produce the playlist, @file{out.m3u8}, and segment files:
  1556. @file{file-20160215-0001.ts}, @file{file-20160215-0002.ts}, etc.
  1557. @item strftime_mkdir @var{bool}
  1558. Used together with @option{strftime}, it will create all subdirectories which
  1559. are present in the expanded values of option @option{hls_segment_filename}.
  1560. For example:
  1561. @example
  1562. ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
  1563. @end example
  1564. will create a directory @file{201560215} (if it does not exist), and then
  1565. produce the playlist, @file{out.m3u8}, and segment files:
  1566. @file{20160215/file-20160215-1455569023.ts},
  1567. @file{20160215/file-20160215-1455569024.ts}, etc.
  1568. For example:
  1569. @example
  1570. ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
  1571. @end example
  1572. will create a directory hierarchy @file{2016/02/15} (if any of them do not
  1573. exist), and then produce the playlist, @file{out.m3u8}, and segment files:
  1574. @file{2016/02/15/file-20160215-1455569023.ts},
  1575. @file{2016/02/15/file-20160215-1455569024.ts}, etc.
  1576. @item hls_segment_options @var{options_list}
  1577. Set output format options using a :-separated list of key=value
  1578. parameters. Values containing @code{:} special characters must be
  1579. escaped.
  1580. @item hls_key_info_file @var{key_info_file}
  1581. Use the information in @var{key_info_file} for segment encryption. The first
  1582. line of @var{key_info_file} specifies the key URI written to the playlist. The
  1583. key URL is used to access the encryption key during playback. The second line
  1584. specifies the path to the key file used to obtain the key during the encryption
  1585. process. The key file is read as a single packed array of 16 octets in binary
  1586. format. The optional third line specifies the initialization vector (IV) as a
  1587. hexadecimal string to be used instead of the segment sequence number (default)
  1588. for encryption. Changes to @var{key_info_file} will result in segment
  1589. encryption with the new key/IV and an entry in the playlist for the new key
  1590. URI/IV if @option{hls_flags periodic_rekey} is enabled.
  1591. Key info file format:
  1592. @example
  1593. @var{key URI}
  1594. @var{key file path}
  1595. @var{IV} (optional)
  1596. @end example
  1597. Example key URIs:
  1598. @example
  1599. http://server/file.key
  1600. /path/to/file.key
  1601. file.key
  1602. @end example
  1603. Example key file paths:
  1604. @example
  1605. file.key
  1606. /path/to/file.key
  1607. @end example
  1608. Example IV:
  1609. @example
  1610. 0123456789ABCDEF0123456789ABCDEF
  1611. @end example
  1612. Key info file example:
  1613. @example
  1614. http://server/file.key
  1615. /path/to/file.key
  1616. 0123456789ABCDEF0123456789ABCDEF
  1617. @end example
  1618. Example shell script:
  1619. @example
  1620. #!/bin/sh
  1621. BASE_URL=$@{1:-'.'@}
  1622. openssl rand 16 > file.key
  1623. echo $BASE_URL/file.key > file.keyinfo
  1624. echo file.key >> file.keyinfo
  1625. echo $(openssl rand -hex 16) >> file.keyinfo
  1626. ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
  1627. -hls_key_info_file file.keyinfo out.m3u8
  1628. @end example
  1629. @item hls_enc @var{bool}
  1630. Enable (1) or disable (0) the AES128 encryption.
  1631. When enabled every segment generated is encrypted and the encryption key
  1632. is saved as @var{playlist name}.key.
  1633. @item hls_enc_key @var{key}
  1634. Specify a 16-octet key to encrypt the segments, by default it is randomly
  1635. generated.
  1636. @item hls_enc_key_url @var{keyurl}
  1637. If set, @var{keyurl} is prepended instead of @var{baseurl} to the key filename
  1638. in the playlist.
  1639. @item hls_enc_iv @var{iv}
  1640. Specify the 16-octet initialization vector for every segment instead of the
  1641. autogenerated ones.
  1642. @item hls_segment_type @var{flags}
  1643. Possible values:
  1644. @table @samp
  1645. @item mpegts
  1646. Output segment files in MPEG-2 Transport Stream format. This is
  1647. compatible with all HLS versions.
  1648. @item fmp4
  1649. Output segment files in fragmented MP4 format, similar to MPEG-DASH.
  1650. fmp4 files may be used in HLS version 7 and above.
  1651. @end table
  1652. @item hls_fmp4_init_filename @var{filename}
  1653. Set filename for the fragment files header file, default filename is @file{init.mp4}.
  1654. When @option{strftime} is enabled, @var{filename} is expanded to the segment filename with localtime.
  1655. For example:
  1656. @example
  1657. ffmpeg -i in.nut -hls_segment_type fmp4 -strftime 1 -hls_fmp4_init_filename "%s_init.mp4" out.m3u8
  1658. @end example
  1659. will produce init like this @file{1602678741_init.mp4}.
  1660. @item hls_fmp4_init_resend @var{bool}
  1661. Resend init file after m3u8 file refresh every time, default is @var{0}.
  1662. When @option{var_stream_map} is set with two or more variant streams, the
  1663. @var{filename} pattern must contain the string "%v", this string specifies
  1664. the position of variant stream index in the generated init file names.
  1665. The string "%v" may be present in the filename or in the last directory name
  1666. containing the file. If the string is present in the directory name, then
  1667. sub-directories are created after expanding the directory name pattern. This
  1668. enables creation of init files corresponding to different variant streams in
  1669. subdirectories.
  1670. @item hls_flags @var{flags}
  1671. Possible values:
  1672. @table @samp
  1673. @item single_file
  1674. If this flag is set, the muxer will store all segments in a single MPEG-TS
  1675. file, and will use byte ranges in the playlist. HLS playlists generated with
  1676. this way will have the version number 4.
  1677. For example:
  1678. @example
  1679. ffmpeg -i in.nut -hls_flags single_file out.m3u8
  1680. @end example
  1681. will produce the playlist, @file{out.m3u8}, and a single segment file,
  1682. @file{out.ts}.
  1683. @item delete_segments
  1684. Segment files removed from the playlist are deleted after a period of time
  1685. equal to the duration of the segment plus the duration of the playlist.
  1686. @item append_list
  1687. Append new segments into the end of old segment list,
  1688. and remove the @code{#EXT-X-ENDLIST} from the old segment list.
  1689. @item round_durations
  1690. Round the duration info in the playlist file segment info to integer
  1691. values, instead of using floating point.
  1692. If there are no other features requiring higher HLS versions be used,
  1693. then this will allow @command{ffmpeg} to output a HLS version 2 m3u8.
  1694. @item discont_start
  1695. Add the @code{#EXT-X-DISCONTINUITY} tag to the playlist, before the
  1696. first segment's information.
  1697. @item omit_endlist
  1698. Do not append the @code{EXT-X-ENDLIST} tag at the end of the playlist.
  1699. @item periodic_rekey
  1700. The file specified by @code{hls_key_info_file} will be checked periodically and
  1701. detect updates to the encryption info. Be sure to replace this file atomically,
  1702. including the file containing the AES encryption key.
  1703. @item independent_segments
  1704. Add the @code{#EXT-X-INDEPENDENT-SEGMENTS} tag to playlists that has video segments
  1705. and when all the segments of that playlist are guaranteed to start with a key frame.
  1706. @item iframes_only
  1707. Add the @code{#EXT-X-I-FRAMES-ONLY} tag to playlists that has video segments
  1708. and can play only I-frames in the @code{#EXT-X-BYTERANGE} mode.
  1709. @item split_by_time
  1710. Allow segments to start on frames other than key frames. This improves
  1711. behavior on some players when the time between key frames is inconsistent,
  1712. but may make things worse on others, and can cause some oddities during
  1713. seeking. This flag should be used with the @option{hls_time} option.
  1714. @item program_date_time
  1715. Generate @code{EXT-X-PROGRAM-DATE-TIME} tags.
  1716. @item second_level_segment_index
  1717. Make it possible to use segment indexes as %%d in the
  1718. @option{hls_segment_filename} option expression besides date/time values when
  1719. @option{strftime} option is on. To get fixed width numbers with trailing zeroes, %%0xd format
  1720. is available where x is the required width.
  1721. @item second_level_segment_size
  1722. Make it possible to use segment sizes (counted in bytes) as %%s in
  1723. @option{hls_segment_filename} option expression besides date/time values when
  1724. strftime is on. To get fixed width numbers with trailing zeroes, %%0xs format
  1725. is available where x is the required width.
  1726. @item second_level_segment_duration
  1727. Make it possible to use segment duration (calculated in microseconds) as %%t in
  1728. @option{hls_segment_filename} option expression besides date/time values when
  1729. strftime is on. To get fixed width numbers with trailing zeroes, %%0xt format
  1730. is available where x is the required width.
  1731. For example:
  1732. @example
  1733. ffmpeg -i sample.mpeg \
  1734. -f hls -hls_time 3 -hls_list_size 5 \
  1735. -hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \
  1736. -strftime 1 -strftime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
  1737. @end example
  1738. will produce segments like this:
  1739. @file{segment_20170102194334_0003_00122200_0000003000000.ts}, @file{segment_20170102194334_0004_00120072_0000003000000.ts} etc.
  1740. @item temp_file
  1741. Write segment data to @file{filename.tmp} and rename to filename only once the
  1742. segment is complete.
  1743. A webserver serving up segments can be configured to reject requests to *.tmp to
  1744. prevent access to in-progress segments before they have been added to the m3u8
  1745. playlist.
  1746. This flag also affects how m3u8 playlist files are created. If this flag is set,
  1747. all playlist files will be written into a temporary file and renamed after they
  1748. are complete, similarly as segments are handled. But playlists with @code{file}
  1749. protocol and with @option{hls_playlist_type} type other than @samp{vod} are
  1750. always written into a temporary file regardless of this flag.
  1751. Master playlist files specified with @option{master_pl_name}, if any, with
  1752. @code{file} protocol, are always written into temporary file regardless of this
  1753. flag if @option{master_pl_publish_rate} value is other than zero.
  1754. @end table
  1755. @item hls_playlist_type @var{type}
  1756. If type is @samp{event}, emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8
  1757. header. This forces @option{hls_list_size} to 0; the playlist can only be
  1758. appended to.
  1759. If type is @samp{vod}, emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8
  1760. header. This forces @option{hls_list_size} to 0; the playlist must not change.
  1761. @item method @var{method}
  1762. Use the given HTTP method to create the hls files.
  1763. For example:
  1764. @example
  1765. ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8
  1766. @end example
  1767. will upload all the mpegts segment files to the HTTP server using the HTTP PUT
  1768. method, and update the m3u8 files every @code{refresh} times using the same
  1769. method. Note that the HTTP server must support the given method for uploading
  1770. files.
  1771. @item http_user_agent @var{agent}
  1772. Override User-Agent field in HTTP header. Applicable only for HTTP output.
  1773. @item var_stream_map @var{stream_map}
  1774. Specify a map string defining how to group the audio, video and subtitle streams
  1775. into different variant streams. The variant stream groups are separated by
  1776. space.
  1777. Expected string format is like this "a:0,v:0 a:1,v:1 ....". Here a:, v:, s: are
  1778. the keys to specify audio, video and subtitle streams respectively.
  1779. Allowed values are 0 to 9 (limited just based on practical usage).
  1780. When there are two or more variant streams, the output filename pattern must
  1781. contain the string "%v": this string specifies the position of variant stream
  1782. index in the output media playlist filenames. The string "%v" may be present in
  1783. the filename or in the last directory name containing the file. If the string is
  1784. present in the directory name, then sub-directories are created after expanding
  1785. the directory name pattern. This enables creation of variant streams in
  1786. subdirectories.
  1787. A few examples follow.
  1788. @itemize
  1789. @item
  1790. Create two hls variant streams. The first variant stream will contain video
  1791. stream of bitrate 1000k and audio stream of bitrate 64k and the second variant
  1792. stream will contain video stream of bitrate 256k and audio stream of bitrate
  1793. 32k. Here, two media playlist with file names @file{out_0.m3u8} and
  1794. @file{out_1.m3u8} will be created.
  1795. @example
  1796. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1797. -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
  1798. http://example.com/live/out_%v.m3u8
  1799. @end example
  1800. @item
  1801. If you want something meaningful text instead of indexes in result names, you
  1802. may specify names for each or some of the variants. The following example will
  1803. create two hls variant streams as in the previous one. But here, the two media
  1804. playlist with file names @file{out_my_hd.m3u8} and @file{out_my_sd.m3u8} will be
  1805. created.
  1806. @example
  1807. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1808. -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0,name:my_hd v:1,a:1,name:my_sd" \
  1809. http://example.com/live/out_%v.m3u8
  1810. @end example
  1811. @item
  1812. Create three hls variant streams. The first variant stream will be a video only
  1813. stream with video bitrate 1000k, the second variant stream will be an audio only
  1814. stream with bitrate 64k and the third variant stream will be a video only stream
  1815. with bitrate 256k. Here, three media playlist with file names @file{out_0.m3u8},
  1816. @file{out_1.m3u8} and @file{out_2.m3u8} will be created.
  1817. @example
  1818. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
  1819. -map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
  1820. http://example.com/live/out_%v.m3u8
  1821. @end example
  1822. @item
  1823. Create the variant streams in subdirectories. Here, the first media playlist is
  1824. created at @file{http://example.com/live/vs_0/out.m3u8} and the second one at
  1825. @file{http://example.com/live/vs_1/out.m3u8}.
  1826. @example
  1827. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1828. -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
  1829. http://example.com/live/vs_%v/out.m3u8
  1830. @end example
  1831. @item
  1832. Create two audio only and two video only variant streams. In addition to the
  1833. @code{#EXT-X-STREAM-INF} tag for each variant stream in the master playlist, the
  1834. @code{#EXT-X-MEDIA} tag is also added for the two audio only variant streams and
  1835. they are mapped to the two video only variant streams with audio group names
  1836. 'aud_low' and 'aud_high'.
  1837. By default, a single hls variant containing all the encoded streams is created.
  1838. @example
  1839. ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k \
  1840. -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
  1841. -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low v:1,agroup:aud_high" \
  1842. -master_pl_name master.m3u8 \
  1843. http://example.com/live/out_%v.m3u8
  1844. @end example
  1845. @item
  1846. Create two audio only and one video only variant streams. In addition to the
  1847. @code{#EXT-X-STREAM-INF} tag for each variant stream in the master playlist, the
  1848. @code{#EXT-X-MEDIA} tag is also added for the two audio only variant streams and
  1849. they are mapped to the one video only variant streams with audio group name
  1850. 'aud_low', and the audio group have default stat is NO or YES.
  1851. By default, a single hls variant containing all the encoded streams is created.
  1852. @example
  1853. ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
  1854. -map 0:a -map 0:a -map 0:v -f hls \
  1855. -var_stream_map "a:0,agroup:aud_low,default:yes a:1,agroup:aud_low v:0,agroup:aud_low" \
  1856. -master_pl_name master.m3u8 \
  1857. http://example.com/live/out_%v.m3u8
  1858. @end example
  1859. @item
  1860. Create two audio only and one video only variant streams. In addition to the
  1861. @code{#EXT-X-STREAM-INF} tag for each variant stream in the master playlist, the
  1862. @code{#EXT-X-MEDIA} tag is also added for the two audio only variant streams and
  1863. they are mapped to the one video only variant streams with audio group name
  1864. 'aud_low', and the audio group have default stat is NO or YES, and one audio
  1865. have and language is named ENG, the other audio language is named CHN. By
  1866. default, a single hls variant containing all the encoded streams is created.
  1867. @example
  1868. ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
  1869. -map 0:a -map 0:a -map 0:v -f hls \
  1870. -var_stream_map "a:0,agroup:aud_low,default:yes,language:ENG a:1,agroup:aud_low,language:CHN v:0,agroup:aud_low" \
  1871. -master_pl_name master.m3u8 \
  1872. http://example.com/live/out_%v.m3u8
  1873. @end example
  1874. @item
  1875. Create a single variant stream. Add the @code{#EXT-X-MEDIA} tag with
  1876. @code{TYPE=SUBTITLES} in the master playlist with webvtt subtitle group name
  1877. 'subtitle' and optional subtitle name, e.g. 'English'. Make sure the input
  1878. file has one text subtitle stream at least.
  1879. @example
  1880. ffmpeg -y -i input_with_subtitle.mkv \
  1881. -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
  1882. -b:a:0 256k \
  1883. -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
  1884. -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle,sname:English" \
  1885. -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \
  1886. 10 -master_pl_publish_rate 10 -hls_flags \
  1887. delete_segments+discont_start+split_by_time ./tmp/video.m3u8
  1888. @end example
  1889. @end itemize
  1890. @item cc_stream_map @var{cc_stream_map}
  1891. Map string which specifies different closed captions groups and their
  1892. attributes. The closed captions stream groups are separated by space.
  1893. Expected string format is like this
  1894. "ccgroup:<group name>,instreamid:<INSTREAM-ID>,language:<language code> ....".
  1895. 'ccgroup' and 'instreamid' are mandatory attributes. 'language' is an optional
  1896. attribute.
  1897. The closed captions groups configured using this option are mapped to different
  1898. variant streams by providing the same 'ccgroup' name in the
  1899. @option{var_stream_map} string.
  1900. For example:
  1901. @example
  1902. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1903. -a53cc:0 1 -a53cc:1 1 \
  1904. -map 0:v -map 0:a -map 0:v -map 0:a -f hls \
  1905. -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en ccgroup:cc,instreamid:CC2,language:sp" \
  1906. -var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
  1907. -master_pl_name master.m3u8 \
  1908. http://example.com/live/out_%v.m3u8
  1909. @end example
  1910. will add two @code{#EXT-X-MEDIA} tags with @code{TYPE=CLOSED-CAPTIONS} in the
  1911. master playlist for the INSTREAM-IDs 'CC1' and 'CC2'. Also, it will add
  1912. @code{CLOSED-CAPTIONS} attribute with group name 'cc' for the two output variant
  1913. streams.
  1914. If @option{var_stream_map} is not set, then the first available ccgroup in
  1915. @option{cc_stream_map} is mapped to the output variant stream.
  1916. For example:
  1917. @example
  1918. ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
  1919. -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
  1920. -master_pl_name master.m3u8 \
  1921. http://example.com/live/out.m3u8
  1922. @end example
  1923. this will add @code{#EXT-X-MEDIA} tag with @code{TYPE=CLOSED-CAPTIONS} in the
  1924. master playlist with group name 'cc', language 'en' (english) and INSTREAM-ID
  1925. 'CC1'. Also, it will add @code{CLOSED-CAPTIONS} attribute with group name 'cc'
  1926. for the output variant stream.
  1927. @item master_pl_name @var{name}
  1928. Create HLS master playlist with the given name.
  1929. For example:
  1930. @example
  1931. ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8
  1932. @end example
  1933. creates an HLS master playlist with name @file{master.m3u8} which is published
  1934. at @url{http://example.com/live/}.
  1935. @item master_pl_publish_rate @var{count}
  1936. Publish master play list repeatedly every after specified number of segment intervals.
  1937. For example:
  1938. @example
  1939. ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 \
  1940. -hls_time 2 -master_pl_publish_rate 30 http://example.com/live/out.m3u8
  1941. @end example
  1942. creates an HLS master playlist with name @file{master.m3u8} and keeps
  1943. publishing it repeatedly every after 30 segments i.e. every after 60s.
  1944. @item http_persistent @var{bool}
  1945. Use persistent HTTP connections. Applicable only for HTTP output.
  1946. @item timeout @var{timeout}
  1947. Set timeout for socket I/O operations. Applicable only for HTTP output.
  1948. @item ignore_io_errors @var{bool}
  1949. Ignore IO errors during open, write and delete. Useful for long-duration runs with network output.
  1950. @item headers @var{headers}
  1951. Set custom HTTP headers, can override built in default headers. Applicable only for HTTP output.
  1952. @end table
  1953. @section iamf
  1954. Immersive Audio Model and Formats (IAMF) muxer.
  1955. IAMF is used to provide immersive audio content for presentation on a wide range
  1956. of devices in both streaming and offline applications. These applications
  1957. include internet audio streaming, multicasting/broadcasting services, file
  1958. download, gaming, communication, virtual and augmented reality, and others. In
  1959. these applications, audio may be played back on a wide range of devices, e.g.,
  1960. headphones, mobile phones, tablets, TVs, sound bars, home theater systems, and
  1961. big screens.
  1962. This format was promoted and desgined by Alliance for Open Media.
  1963. For more information about this format, see @url{https://aomedia.org/iamf/}.
  1964. @anchor{ico}
  1965. @section ico
  1966. ICO file muxer.
  1967. Microsoft's icon file format (ICO) has some strict limitations that should be noted:
  1968. @itemize
  1969. @item
  1970. Size cannot exceed 256 pixels in any dimension
  1971. @item
  1972. Only BMP and PNG images can be stored
  1973. @item
  1974. If a BMP image is used, it must be one of the following pixel formats:
  1975. @example
  1976. BMP Bit Depth FFmpeg Pixel Format
  1977. 1bit pal8
  1978. 4bit pal8
  1979. 8bit pal8
  1980. 16bit rgb555le
  1981. 24bit bgr24
  1982. 32bit bgra
  1983. @end example
  1984. @item
  1985. If a BMP image is used, it must use the BITMAPINFOHEADER DIB header
  1986. @item
  1987. If a PNG image is used, it must use the rgba pixel format
  1988. @end itemize
  1989. @section ilbc
  1990. Internet Low Bitrate Codec (iLBC) raw muxer.
  1991. It accepts a single @samp{ilbc} audio stream.
  1992. @anchor{image2}
  1993. @section image2, image2pipe
  1994. Image file muxer.
  1995. The @samp{image2} muxer writes video frames to image files.
  1996. The output filenames are specified by a pattern, which can be used to
  1997. produce sequentially numbered series of files.
  1998. The pattern may contain the string "%d" or "%0@var{N}d", this string
  1999. specifies the position of the characters representing a numbering in
  2000. the filenames. If the form "%0@var{N}d" is used, the string
  2001. representing the number in each filename is 0-padded to @var{N}
  2002. digits. The literal character '%' can be specified in the pattern with
  2003. the string "%%".
  2004. If the pattern contains "%d" or "%0@var{N}d", the first filename of
  2005. the file list specified will contain the number 1, all the following
  2006. numbers will be sequential.
  2007. The pattern may contain a suffix which is used to automatically
  2008. determine the format of the image files to write.
  2009. For example the pattern "img-%03d.bmp" will specify a sequence of
  2010. filenames of the form @file{img-001.bmp}, @file{img-002.bmp}, ...,
  2011. @file{img-010.bmp}, etc.
  2012. The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
  2013. form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
  2014. etc.
  2015. The image muxer supports the .Y.U.V image file format. This format is
  2016. special in that each image frame consists of three files, for
  2017. each of the YUV420P components. To read or write this image file format,
  2018. specify the name of the '.Y' file. The muxer will automatically open the
  2019. '.U' and '.V' files as required.
  2020. The @samp{image2pipe} muxer accepts the same options as the @samp{image2} muxer,
  2021. but ignores the pattern verification and expansion, as it is supposed to write
  2022. to the command output rather than to an actual stored file.
  2023. @subsection Options
  2024. @table @option
  2025. @item frame_pts @var{bool}
  2026. If set to 1, expand the filename with the packet PTS (presentation time stamp).
  2027. Default value is 0.
  2028. @item start_number @var{count}
  2029. Start the sequence from the specified number. Default value is 1.
  2030. @item update @var{bool}
  2031. If set to 1, the filename will always be interpreted as just a
  2032. filename, not a pattern, and the corresponding file will be continuously
  2033. overwritten with new images. Default value is 0.
  2034. @item strftime @var{bool}
  2035. If set to 1, expand the filename with date and time information from
  2036. @code{strftime()}. Default value is 0.
  2037. @item atomic_writing @var{bool}
  2038. Write output to a temporary file, which is renamed to target filename once
  2039. writing is completed. Default is disabled.
  2040. @item protocol_opts @var{options_list}
  2041. Set protocol options as a :-separated list of key=value parameters. Values
  2042. containing the @code{:} special character must be escaped.
  2043. @end table
  2044. @subsection Examples
  2045. @itemize
  2046. @item
  2047. Use @command{ffmpeg} for creating a sequence of files @file{img-001.jpeg},
  2048. @file{img-002.jpeg}, ..., taking one image every second from the input video:
  2049. @example
  2050. ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'
  2051. @end example
  2052. Note that with @command{ffmpeg}, if the format is not specified with the
  2053. @code{-f} option and the output filename specifies an image file
  2054. format, the image2 muxer is automatically selected, so the previous
  2055. command can be written as:
  2056. @example
  2057. ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'
  2058. @end example
  2059. Note also that the pattern must not necessarily contain "%d" or
  2060. "%0@var{N}d", for example to create a single image file
  2061. @file{img.jpeg} from the start of the input video you can employ the command:
  2062. @example
  2063. ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
  2064. @end example
  2065. @item
  2066. The @option{strftime} option allows you to expand the filename with
  2067. date and time information. Check the documentation of
  2068. the @code{strftime()} function for the syntax.
  2069. To generate image files from the @code{strftime()} "%Y-%m-%d_%H-%M-%S" pattern,
  2070. the following @command{ffmpeg} command can be used:
  2071. @example
  2072. ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"
  2073. @end example
  2074. @item
  2075. Set the file name with current frame's PTS:
  2076. @example
  2077. ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg
  2078. @end example
  2079. @item
  2080. Publish contents of your desktop directly to a WebDAV server every second:
  2081. @example
  2082. ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg
  2083. @end example
  2084. @end itemize
  2085. @section ircam
  2086. Berkeley / IRCAM / CARL Sound Filesystem (BICSF) format muxer.
  2087. The Berkeley/IRCAM/CARL Sound Format, developed in the 1980s, is a result of the
  2088. merging of several different earlier sound file formats and systems including
  2089. the csound system developed by Dr Gareth Loy at the Computer Audio Research Lab
  2090. (CARL) at UC San Diego, the IRCAM sound file system developed by Rob Gross and
  2091. Dan Timis at the Institut de Recherche et Coordination Acoustique / Musique in
  2092. Paris and the Berkeley Fast Filesystem.
  2093. It was developed initially as part of the Berkeley/IRCAM/CARL Sound Filesystem,
  2094. a suite of programs designed to implement a filesystem for audio applications
  2095. running under Berkeley UNIX. It was particularly popular in academic music
  2096. research centres, and was used a number of times in the creation of early
  2097. computer-generated compositions.
  2098. This muxer accepts a single audio stream containing PCM data.
  2099. @section ivf
  2100. On2 IVF muxer.
  2101. IVF was developed by On2 Technologies (formerly known as Duck
  2102. Corporation), to store internally developed codecs.
  2103. This muxer accepts a single @samp{vp8}, @samp{vp9}, or @samp{av1}
  2104. video stream.
  2105. @section jacosub
  2106. JACOsub subtitle format muxer.
  2107. This muxer accepts a single @samp{jacosub} subtitles stream.
  2108. For more information about the format, see
  2109. @url{http://unicorn.us.com/jacosub/jscripts.html}.
  2110. @section kvag
  2111. Simon & Schuster Interactive VAG muxer.
  2112. This custom VAG container is used by some Simon & Schuster Interactive
  2113. games such as "Real War", and "Real War: Rogue States".
  2114. This muxer accepts a single @samp{adpcm_ima_ssi} audio stream.
  2115. @section lc3
  2116. Bluetooth SIG Low Complexity Communication Codec audio (LC3), or
  2117. ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus).
  2118. This muxer accepts a single @samp{lc3} audio stream.
  2119. @section lrc
  2120. LRC lyrics file format muxer.
  2121. LRC (short for LyRiCs) is a computer file format that synchronizes
  2122. song lyrics with an audio file, such as MP3, Vorbis, or MIDI.
  2123. This muxer accepts a single @samp{subrip} or @samp{text} subtitles stream.
  2124. @subsection Metadata
  2125. The following metadata tags are converted to the format corresponding
  2126. metadata:
  2127. @table @option
  2128. @item title
  2129. @item album
  2130. @item artist
  2131. @item author
  2132. @item creator
  2133. @item encoder
  2134. @item encoder_version
  2135. @end table
  2136. If @samp{encoder_version} is not explicitly set, it is automatically
  2137. set to the libavformat version.
  2138. @section matroska
  2139. Matroska container muxer.
  2140. This muxer implements the matroska and webm container specs.
  2141. @subsection Metadata
  2142. The recognized metadata settings in this muxer are:
  2143. @table @option
  2144. @item title
  2145. Set title name provided to a single track. This gets mapped to
  2146. the FileDescription element for a stream written as attachment.
  2147. @item language
  2148. Specify the language of the track in the Matroska languages form.
  2149. The language can be either the 3 letters bibliographic ISO-639-2 (ISO
  2150. 639-2/B) form (like "fre" for French), or a language code mixed with a
  2151. country code for specialities in languages (like "fre-ca" for Canadian
  2152. French).
  2153. @item stereo_mode
  2154. Set stereo 3D video layout of two views in a single video track.
  2155. The following values are recognized:
  2156. @table @samp
  2157. @item mono
  2158. video is not stereo
  2159. @item left_right
  2160. Both views are arranged side by side, Left-eye view is on the left
  2161. @item bottom_top
  2162. Both views are arranged in top-bottom orientation, Left-eye view is at bottom
  2163. @item top_bottom
  2164. Both views are arranged in top-bottom orientation, Left-eye view is on top
  2165. @item checkerboard_rl
  2166. Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
  2167. @item checkerboard_lr
  2168. Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
  2169. @item row_interleaved_rl
  2170. Each view is constituted by a row based interleaving, Right-eye view is first row
  2171. @item row_interleaved_lr
  2172. Each view is constituted by a row based interleaving, Left-eye view is first row
  2173. @item col_interleaved_rl
  2174. Both views are arranged in a column based interleaving manner, Right-eye view is first column
  2175. @item col_interleaved_lr
  2176. Both views are arranged in a column based interleaving manner, Left-eye view is first column
  2177. @item anaglyph_cyan_red
  2178. All frames are in anaglyph format viewable through red-cyan filters
  2179. @item right_left
  2180. Both views are arranged side by side, Right-eye view is on the left
  2181. @item anaglyph_green_magenta
  2182. All frames are in anaglyph format viewable through green-magenta filters
  2183. @item block_lr
  2184. Both eyes laced in one Block, Left-eye view is first
  2185. @item block_rl
  2186. Both eyes laced in one Block, Right-eye view is first
  2187. @end table
  2188. @end table
  2189. For example a 3D WebM clip can be created using the following command line:
  2190. @example
  2191. ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
  2192. @end example
  2193. @subsection Options
  2194. @table @option
  2195. @item reserve_index_space @var{size}
  2196. By default, this muxer writes the index for seeking (called cues in Matroska
  2197. terms) at the end of the file, because it cannot know in advance how much space
  2198. to leave for the index at the beginning of the file. However for some use cases
  2199. -- e.g. streaming where seeking is possible but slow -- it is useful to put the
  2200. index at the beginning of the file.
  2201. If this option is set to a non-zero value, the muxer will reserve @var{size} bytes
  2202. of space in the file header and then try to write the cues there when the muxing
  2203. finishes. If the reserved space does not suffice, no Cues will be written, the
  2204. file will be finalized and writing the trailer will return an error.
  2205. A safe size for most use cases should be about 50kB per hour of video.
  2206. Note that cues are only written if the output is seekable and this option will
  2207. have no effect if it is not.
  2208. @item cues_to_front @var{bool}
  2209. If set, the muxer will write the index at the beginning of the file
  2210. by shifting the main data if necessary. This can be combined with
  2211. reserve_index_space in which case the data is only shifted if
  2212. the initially reserved space turns out to be insufficient.
  2213. This option is ignored if the output is unseekable.
  2214. @item cluster_size_limit @var{size}
  2215. Store at most the provided amount of bytes in a cluster.
  2216. If not specified, the limit is set automatically to a sensible
  2217. hardcoded fixed value.
  2218. @item cluster_time_limit @var{duration}
  2219. Store at most the provided number of milliseconds in a cluster.
  2220. If not specified, the limit is set automatically to a sensible
  2221. hardcoded fixed value.
  2222. @item dash @var{bool}
  2223. Create a WebM file conforming to WebM DASH specification. By default
  2224. it is set to @code{false}.
  2225. @item dash_track_number @var{index}
  2226. Track number for the DASH stream. By default it is set to @code{1}.
  2227. @item live @var{bool}
  2228. Write files assuming it is a live stream. By default it is set to
  2229. @code{false}.
  2230. @item allow_raw_vfw @var{bool}
  2231. Allow raw VFW mode. By default it is set to @code{false}.
  2232. @item flipped_raw_rgb @var{bool}
  2233. If set to @code{true}, store positive height for raw RGB bitmaps, which indicates
  2234. bitmap is stored bottom-up. Note that this option does not flip the bitmap
  2235. which has to be done manually beforehand, e.g. by using the @samp{vflip} filter.
  2236. Default is @code{false} and indicates bitmap is stored top down.
  2237. @item write_crc32 @var{bool}
  2238. Write a CRC32 element inside every Level 1 element. By default it is
  2239. set to @code{true}. This option is ignored for WebM.
  2240. @item default_mode @var{mode}
  2241. Control how the FlagDefault of the output tracks will be set.
  2242. It influences which tracks players should play by default. The default mode
  2243. is @samp{passthrough}.
  2244. @table @samp
  2245. @item infer
  2246. Every track with disposition default will have the FlagDefault set.
  2247. Additionally, for each type of track (audio, video or subtitle), if no track
  2248. with disposition default of this type exists, then the first track of this type
  2249. will be marked as default (if existing). This ensures that the default flag
  2250. is set in a sensible way even if the input originated from containers that
  2251. lack the concept of default tracks.
  2252. @item infer_no_subs
  2253. This mode is the same as infer except that if no subtitle track with
  2254. disposition default exists, no subtitle track will be marked as default.
  2255. @item passthrough
  2256. In this mode the FlagDefault is set if and only if the AV_DISPOSITION_DEFAULT
  2257. flag is set in the disposition of the corresponding stream.
  2258. @end table
  2259. @end table
  2260. @anchor{md5}
  2261. @section md5
  2262. MD5 testing format.
  2263. This is a variant of the @ref{hash} muxer. Unlike that muxer, it
  2264. defaults to using the MD5 hash function.
  2265. See also the @ref{hash} and @ref{framemd5} muxers.
  2266. @subsection Examples
  2267. @itemize
  2268. @item
  2269. To compute the MD5 hash of the input converted to raw
  2270. audio and video, and store it in the file @file{out.md5}:
  2271. @example
  2272. ffmpeg -i INPUT -f md5 out.md5
  2273. @end example
  2274. @item
  2275. To print the MD5 hash to stdout:
  2276. @example
  2277. ffmpeg -i INPUT -f md5 -
  2278. @end example
  2279. @end itemize
  2280. @section microdvd
  2281. MicroDVD subtitle format muxer.
  2282. This muxer accepts a single @samp{microdvd} subtitles stream.
  2283. @section mmf
  2284. Synthetic music Mobile Application Format (SMAF) format muxer.
  2285. SMAF is a music data format specified by Yamaha for portable
  2286. electronic devices, such as mobile phones and personal digital
  2287. assistants.
  2288. This muxer accepts a single @samp{adpcm_yamaha} audio stream.
  2289. @section mp3
  2290. The MP3 muxer writes a raw MP3 stream with the following optional features:
  2291. @itemize @bullet
  2292. @item
  2293. An ID3v2 metadata header at the beginning (enabled by default). Versions 2.3 and
  2294. 2.4 are supported, the @code{id3v2_version} private option controls which one is
  2295. used (3 or 4). Setting @code{id3v2_version} to 0 disables the ID3v2 header
  2296. completely.
  2297. The muxer supports writing attached pictures (APIC frames) to the ID3v2 header.
  2298. The pictures are supplied to the muxer in form of a video stream with a single
  2299. packet. There can be any number of those streams, each will correspond to a
  2300. single APIC frame. The stream metadata tags @var{title} and @var{comment} map
  2301. to APIC @var{description} and @var{picture type} respectively. See
  2302. @url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
  2303. Note that the APIC frames must be written at the beginning, so the muxer will
  2304. buffer the audio frames until it gets all the pictures. It is therefore advised
  2305. to provide the pictures as soon as possible to avoid excessive buffering.
  2306. @item
  2307. A Xing/LAME frame right after the ID3v2 header (if present). It is enabled by
  2308. default, but will be written only if the output is seekable. The
  2309. @code{write_xing} private option can be used to disable it. The frame contains
  2310. various information that may be useful to the decoder, like the audio duration
  2311. or encoder delay.
  2312. @item
  2313. A legacy ID3v1 tag at the end of the file (disabled by default). It may be
  2314. enabled with the @code{write_id3v1} private option, but as its capabilities are
  2315. very limited, its usage is not recommended.
  2316. @end itemize
  2317. Examples:
  2318. Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
  2319. @example
  2320. ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
  2321. @end example
  2322. To attach a picture to an mp3 file select both the audio and the picture stream
  2323. with @code{map}:
  2324. @example
  2325. ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1
  2326. -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
  2327. @end example
  2328. Write a "clean" MP3 without any extra features:
  2329. @example
  2330. ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
  2331. @end example
  2332. @section mpegts
  2333. MPEG transport stream muxer.
  2334. This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
  2335. The recognized metadata settings in mpegts muxer are @code{service_provider}
  2336. and @code{service_name}. If they are not set the default for
  2337. @code{service_provider} is @samp{FFmpeg} and the default for
  2338. @code{service_name} is @samp{Service01}.
  2339. @subsection Options
  2340. The muxer options are:
  2341. @table @option
  2342. @item mpegts_transport_stream_id @var{integer}
  2343. Set the @samp{transport_stream_id}. This identifies a transponder in DVB.
  2344. Default is @code{0x0001}.
  2345. @item mpegts_original_network_id @var{integer}
  2346. Set the @samp{original_network_id}. This is unique identifier of a
  2347. network in DVB. Its main use is in the unique identification of a service
  2348. through the path @samp{Original_Network_ID, Transport_Stream_ID}. Default
  2349. is @code{0x0001}.
  2350. @item mpegts_service_id @var{integer}
  2351. Set the @samp{service_id}, also known as program in DVB. Default is
  2352. @code{0x0001}.
  2353. @item mpegts_service_type @var{integer}
  2354. Set the program @samp{service_type}. Default is @code{digital_tv}.
  2355. Accepts the following options:
  2356. @table @samp
  2357. @item hex_value
  2358. Any hexadecimal value between @code{0x01} and @code{0xff} as defined in
  2359. ETSI 300 468.
  2360. @item digital_tv
  2361. Digital TV service.
  2362. @item digital_radio
  2363. Digital Radio service.
  2364. @item teletext
  2365. Teletext service.
  2366. @item advanced_codec_digital_radio
  2367. Advanced Codec Digital Radio service.
  2368. @item mpeg2_digital_hdtv
  2369. MPEG2 Digital HDTV service.
  2370. @item advanced_codec_digital_sdtv
  2371. Advanced Codec Digital SDTV service.
  2372. @item advanced_codec_digital_hdtv
  2373. Advanced Codec Digital HDTV service.
  2374. @end table
  2375. @item mpegts_pmt_start_pid @var{integer}
  2376. Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
  2377. maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT
  2378. PID is fixed @code{0x0100}.
  2379. @item mpegts_start_pid @var{integer}
  2380. Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
  2381. @code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode
  2382. where the elementary stream PIDs are fixed.
  2383. @item mpegts_m2ts_mode @var{boolean}
  2384. Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
  2385. disables m2ts mode.
  2386. @item muxrate @var{integer}
  2387. Set a constant muxrate. Default is VBR.
  2388. @item pes_payload_size @var{integer}
  2389. Set minimum PES packet payload in bytes. Default is @code{2930}.
  2390. @item mpegts_flags @var{flags}
  2391. Set mpegts flags. Accepts the following options:
  2392. @table @samp
  2393. @item resend_headers
  2394. Reemit PAT/PMT before writing the next packet.
  2395. @item latm
  2396. Use LATM packetization for AAC.
  2397. @item pat_pmt_at_frames
  2398. Reemit PAT and PMT at each video frame.
  2399. @item system_b
  2400. Conform to System B (DVB) instead of System A (ATSC).
  2401. @item initial_discontinuity
  2402. Mark the initial packet of each stream as discontinuity.
  2403. @item nit
  2404. Emit NIT table.
  2405. @item omit_rai
  2406. Disable writing of random access indicator.
  2407. @end table
  2408. @item mpegts_copyts @var{boolean}
  2409. Preserve original timestamps, if value is set to @code{1}. Default value
  2410. is @code{-1}, which results in shifting timestamps so that they start from 0.
  2411. @item omit_video_pes_length @var{boolean}
  2412. Omit the PES packet length for video packets. Default is @code{1} (true).
  2413. @item pcr_period @var{integer}
  2414. Override the default PCR retransmission time in milliseconds. Default is
  2415. @code{-1} which means that the PCR interval will be determined automatically:
  2416. 20 ms is used for CBR streams, the highest multiple of the frame duration which
  2417. is less than 100 ms is used for VBR streams.
  2418. @item pat_period @var{duration}
  2419. Maximum time in seconds between PAT/PMT tables. Default is @code{0.1}.
  2420. @item sdt_period @var{duration}
  2421. Maximum time in seconds between SDT tables. Default is @code{0.5}.
  2422. @item nit_period @var{duration}
  2423. Maximum time in seconds between NIT tables. Default is @code{0.5}.
  2424. @item tables_version @var{integer}
  2425. Set PAT, PMT, SDT and NIT version (default @code{0}, valid values are from 0 to 31, inclusively).
  2426. This option allows updating stream structure so that standard consumer may
  2427. detect the change. To do so, reopen output @code{AVFormatContext} (in case of API
  2428. usage) or restart @command{ffmpeg} instance, cyclically changing
  2429. @option{tables_version} value:
  2430. @example
  2431. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  2432. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  2433. ...
  2434. ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
  2435. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  2436. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  2437. ...
  2438. @end example
  2439. @end table
  2440. @subsection Example
  2441. @example
  2442. ffmpeg -i file.mpg -c copy \
  2443. -mpegts_original_network_id 0x1122 \
  2444. -mpegts_transport_stream_id 0x3344 \
  2445. -mpegts_service_id 0x5566 \
  2446. -mpegts_pmt_start_pid 0x1500 \
  2447. -mpegts_start_pid 0x150 \
  2448. -metadata service_provider="Some provider" \
  2449. -metadata service_name="Some Channel" \
  2450. out.ts
  2451. @end example
  2452. @section mxf, mxf_d10, mxf_opatom
  2453. MXF muxer.
  2454. @subsection Options
  2455. The muxer options are:
  2456. @table @option
  2457. @item store_user_comments @var{bool}
  2458. Set if user comments should be stored if available or never.
  2459. IRT D-10 does not allow user comments. The default is thus to write them for
  2460. mxf and mxf_opatom but not for mxf_d10
  2461. @end table
  2462. @section null
  2463. Null muxer.
  2464. This muxer does not generate any output file, it is mainly useful for
  2465. testing or benchmarking purposes.
  2466. For example to benchmark decoding with @command{ffmpeg} you can use the
  2467. command:
  2468. @example
  2469. ffmpeg -benchmark -i INPUT -f null out.null
  2470. @end example
  2471. Note that the above command does not read or write the @file{out.null}
  2472. file, but specifying the output file is required by the @command{ffmpeg}
  2473. syntax.
  2474. Alternatively you can write the command as:
  2475. @example
  2476. ffmpeg -benchmark -i INPUT -f null -
  2477. @end example
  2478. @section nut
  2479. @table @option
  2480. @item -syncpoints @var{flags}
  2481. Change the syncpoint usage in nut:
  2482. @table @option
  2483. @item @var{default} use the normal low-overhead seeking aids.
  2484. @item @var{none} do not use the syncpoints at all, reducing the overhead but making the stream non-seekable;
  2485. Use of this option is not recommended, as the resulting files are very damage
  2486. sensitive and seeking is not possible. Also in general the overhead from
  2487. syncpoints is negligible. Note, -@code{write_index} 0 can be used to disable
  2488. all growing data tables, allowing to mux endless streams with limited memory
  2489. and without these disadvantages.
  2490. @item @var{timestamped} extend the syncpoint with a wallclock field.
  2491. @end table
  2492. The @var{none} and @var{timestamped} flags are experimental.
  2493. @item -write_index @var{bool}
  2494. Write index at the end, the default is to write an index.
  2495. @end table
  2496. @example
  2497. ffmpeg -i INPUT -f_strict experimental -syncpoints none - | processor
  2498. @end example
  2499. @section ogg
  2500. Ogg container muxer.
  2501. @table @option
  2502. @item -page_duration @var{duration}
  2503. Preferred page duration, in microseconds. The muxer will attempt to create
  2504. pages that are approximately @var{duration} microseconds long. This allows the
  2505. user to compromise between seek granularity and container overhead. The default
  2506. is 1 second. A value of 0 will fill all segments, making pages as large as
  2507. possible. A value of 1 will effectively use 1 packet-per-page in most
  2508. situations, giving a small seek granularity at the cost of additional container
  2509. overhead.
  2510. @item -serial_offset @var{value}
  2511. Serial value from which to set the streams serial number.
  2512. Setting it to different and sufficiently large values ensures that the produced
  2513. ogg files can be safely chained.
  2514. @end table
  2515. @anchor{rcwtenc}
  2516. @section rcwt
  2517. RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly
  2518. used open source tool for processing 608/708 Closed Captions (CC) sources.
  2519. It can be used to archive the original extracted CC bitstream and to produce
  2520. a source file for later processing or conversion. The format allows
  2521. for interoperability between ccextractor and FFmpeg, is simple to parse,
  2522. and can be used to create a backup of the CC presentation.
  2523. This muxer implements the specification as of March 2024, which has
  2524. been stable and unchanged since April 2014.
  2525. This muxer will have some nuances from the way that ccextractor muxes RCWT.
  2526. No compatibility issues when processing the output with ccextractor
  2527. have been observed as a result of this so far, but mileage may vary
  2528. and outputs will not be a bit-exact match.
  2529. A free specification of RCWT can be found here:
  2530. @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT}
  2531. @subsection Examples
  2532. @itemize
  2533. @item
  2534. Extract Closed Captions to RCWT using lavfi:
  2535. @example
  2536. ffmpeg -f lavfi -i "movie=INPUT.mkv[out+subcc]" -map 0:s:0 -c:s copy -f rcwt CC.rcwt.bin
  2537. @end example
  2538. @end itemize
  2539. @anchor{segment}
  2540. @section segment, stream_segment, ssegment
  2541. Basic stream segmenter.
  2542. This muxer outputs streams to a number of separate files of nearly
  2543. fixed duration. Output filename pattern can be set in a fashion
  2544. similar to @ref{image2}, or by using a @code{strftime} template if
  2545. the @option{strftime} option is enabled.
  2546. @code{stream_segment} is a variant of the muxer used to write to
  2547. streaming output formats, i.e. which do not require global headers,
  2548. and is recommended for outputting e.g. to MPEG transport stream segments.
  2549. @code{ssegment} is a shorter alias for @code{stream_segment}.
  2550. Every segment starts with a keyframe of the selected reference stream,
  2551. which is set through the @option{reference_stream} option.
  2552. Note that if you want accurate splitting for a video file, you need to
  2553. make the input key frames correspond to the exact splitting times
  2554. expected by the segmenter, or the segment muxer will start the new
  2555. segment with the key frame found next after the specified start
  2556. time.
  2557. The segment muxer works best with a single constant frame rate video.
  2558. Optionally it can generate a list of the created segments, by setting
  2559. the option @var{segment_list}. The list type is specified by the
  2560. @var{segment_list_type} option. The entry filenames in the segment
  2561. list are set by default to the basename of the corresponding segment
  2562. files.
  2563. See also the @ref{hls} muxer, which provides a more specific
  2564. implementation for HLS segmentation.
  2565. @subsection Options
  2566. The segment muxer supports the following options:
  2567. @table @option
  2568. @item increment_tc @var{1|0}
  2569. if set to @code{1}, increment timecode between each segment
  2570. If this is selected, the input need to have
  2571. a timecode in the first video stream. Default value is
  2572. @code{0}.
  2573. @item reference_stream @var{specifier}
  2574. Set the reference stream, as specified by the string @var{specifier}.
  2575. If @var{specifier} is set to @code{auto}, the reference is chosen
  2576. automatically. Otherwise it must be a stream specifier (see the ``Stream
  2577. specifiers'' chapter in the ffmpeg manual) which specifies the
  2578. reference stream. The default value is @code{auto}.
  2579. @item segment_format @var{format}
  2580. Override the inner container format, by default it is guessed by the filename
  2581. extension.
  2582. @item segment_format_options @var{options_list}
  2583. Set output format options using a :-separated list of key=value
  2584. parameters. Values containing the @code{:} special character must be
  2585. escaped.
  2586. @item segment_list @var{name}
  2587. Generate also a listfile named @var{name}. If not specified no
  2588. listfile is generated.
  2589. @item segment_list_flags @var{flags}
  2590. Set flags affecting the segment list generation.
  2591. It currently supports the following flags:
  2592. @table @samp
  2593. @item cache
  2594. Allow caching (only affects M3U8 list files).
  2595. @item live
  2596. Allow live-friendly file generation.
  2597. @end table
  2598. @item segment_list_size @var{size}
  2599. Update the list file so that it contains at most @var{size}
  2600. segments. If 0 the list file will contain all the segments. Default
  2601. value is 0.
  2602. @item segment_list_entry_prefix @var{prefix}
  2603. Prepend @var{prefix} to each entry. Useful to generate absolute paths.
  2604. By default no prefix is applied.
  2605. @item segment_list_type @var{type}
  2606. Select the listing format.
  2607. The following values are recognized:
  2608. @table @samp
  2609. @item flat
  2610. Generate a flat list for the created segments, one segment per line.
  2611. @item csv, ext
  2612. Generate a list for the created segments, one segment per line,
  2613. each line matching the format (comma-separated values):
  2614. @example
  2615. @var{segment_filename},@var{segment_start_time},@var{segment_end_time}
  2616. @end example
  2617. @var{segment_filename} is the name of the output file generated by the
  2618. muxer according to the provided pattern. CSV escaping (according to
  2619. RFC4180) is applied if required.
  2620. @var{segment_start_time} and @var{segment_end_time} specify
  2621. the segment start and end time expressed in seconds.
  2622. A list file with the suffix @code{".csv"} or @code{".ext"} will
  2623. auto-select this format.
  2624. @samp{ext} is deprecated in favor or @samp{csv}.
  2625. @item ffconcat
  2626. Generate an ffconcat file for the created segments. The resulting file
  2627. can be read using the FFmpeg @ref{concat} demuxer.
  2628. A list file with the suffix @code{".ffcat"} or @code{".ffconcat"} will
  2629. auto-select this format.
  2630. @item m3u8
  2631. Generate an extended M3U8 file, version 3, compliant with
  2632. @url{http://tools.ietf.org/id/draft-pantos-http-live-streaming}.
  2633. A list file with the suffix @code{".m3u8"} will auto-select this format.
  2634. @end table
  2635. If not specified the type is guessed from the list file name suffix.
  2636. @item segment_time @var{time}
  2637. Set segment duration to @var{time}, the value must be a duration
  2638. specification. Default value is "2". See also the
  2639. @option{segment_times} option.
  2640. Note that splitting may not be accurate, unless you force the
  2641. reference stream key-frames at the given time. See the introductory
  2642. notice and the examples below.
  2643. @item min_seg_duration @var{time}
  2644. Set minimum segment duration to @var{time}, the value must be a duration
  2645. specification. This prevents the muxer ending segments at a duration below
  2646. this value. Only effective with @code{segment_time}. Default value is "0".
  2647. @item segment_atclocktime @var{1|0}
  2648. If set to "1" split at regular clock time intervals starting from 00:00
  2649. o'clock. The @var{time} value specified in @option{segment_time} is
  2650. used for setting the length of the splitting interval.
  2651. For example with @option{segment_time} set to "900" this makes it possible
  2652. to create files at 12:00 o'clock, 12:15, 12:30, etc.
  2653. Default value is "0".
  2654. @item segment_clocktime_offset @var{duration}
  2655. Delay the segment splitting times with the specified duration when using
  2656. @option{segment_atclocktime}.
  2657. For example with @option{segment_time} set to "900" and
  2658. @option{segment_clocktime_offset} set to "300" this makes it possible to
  2659. create files at 12:05, 12:20, 12:35, etc.
  2660. Default value is "0".
  2661. @item segment_clocktime_wrap_duration @var{duration}
  2662. Force the segmenter to only start a new segment if a packet reaches the muxer
  2663. within the specified duration after the segmenting clock time. This way you
  2664. can make the segmenter more resilient to backward local time jumps, such as
  2665. leap seconds or transition to standard time from daylight savings time.
  2666. Default is the maximum possible duration which means starting a new segment
  2667. regardless of the elapsed time since the last clock time.
  2668. @item segment_time_delta @var{delta}
  2669. Specify the accuracy time when selecting the start time for a
  2670. segment, expressed as a duration specification. Default value is "0".
  2671. When delta is specified a key-frame will start a new segment if its
  2672. PTS satisfies the relation:
  2673. @example
  2674. PTS >= start_time - time_delta
  2675. @end example
  2676. This option is useful when splitting video content, which is always
  2677. split at GOP boundaries, in case a key frame is found just before the
  2678. specified split time.
  2679. In particular may be used in combination with the @file{ffmpeg} option
  2680. @var{force_key_frames}. The key frame times specified by
  2681. @var{force_key_frames} may not be set accurately because of rounding
  2682. issues, with the consequence that a key frame time may result set just
  2683. before the specified time. For constant frame rate videos a value of
  2684. 1/(2*@var{frame_rate}) should address the worst case mismatch between
  2685. the specified time and the time set by @var{force_key_frames}.
  2686. @item segment_times @var{times}
  2687. Specify a list of split points. @var{times} contains a list of comma
  2688. separated duration specifications, in increasing order. See also
  2689. the @option{segment_time} option.
  2690. @item segment_frames @var{frames}
  2691. Specify a list of split video frame numbers. @var{frames} contains a
  2692. list of comma separated integer numbers, in increasing order.
  2693. This option specifies to start a new segment whenever a reference
  2694. stream key frame is found and the sequential number (starting from 0)
  2695. of the frame is greater or equal to the next value in the list.
  2696. @item segment_wrap @var{limit}
  2697. Wrap around segment index once it reaches @var{limit}.
  2698. @item segment_start_number @var{number}
  2699. Set the sequence number of the first segment. Defaults to @code{0}.
  2700. @item strftime @var{1|0}
  2701. Use the @code{strftime} function to define the name of the new
  2702. segments to write. If this is selected, the output segment name must
  2703. contain a @code{strftime} function template. Default value is
  2704. @code{0}.
  2705. @item break_non_keyframes @var{1|0}
  2706. If enabled, allow segments to start on frames other than keyframes. This
  2707. improves behavior on some players when the time between keyframes is
  2708. inconsistent, but may make things worse on others, and can cause some oddities
  2709. during seeking. Defaults to @code{0}.
  2710. @item reset_timestamps @var{1|0}
  2711. Reset timestamps at the beginning of each segment, so that each segment
  2712. will start with near-zero timestamps. It is meant to ease the playback
  2713. of the generated segments. May not work with some combinations of
  2714. muxers/codecs. It is set to @code{0} by default.
  2715. @item initial_offset @var{offset}
  2716. Specify timestamp offset to apply to the output packet timestamps. The
  2717. argument must be a time duration specification, and defaults to 0.
  2718. @item write_empty_segments @var{1|0}
  2719. If enabled, write an empty segment if there are no packets during the period a
  2720. segment would usually span. Otherwise, the segment will be filled with the next
  2721. packet written. Defaults to @code{0}.
  2722. @end table
  2723. Make sure to require a closed GOP when encoding and to set the GOP
  2724. size to fit your segment time constraint.
  2725. @subsection Examples
  2726. @itemize
  2727. @item
  2728. Remux the content of file @file{in.mkv} to a list of segments
  2729. @file{out-000.nut}, @file{out-001.nut}, etc., and write the list of
  2730. generated segments to @file{out.list}:
  2731. @example
  2732. ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
  2733. @end example
  2734. @item
  2735. Segment input and set output format options for the output segments:
  2736. @example
  2737. ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
  2738. @end example
  2739. @item
  2740. Segment the input file according to the split points specified by the
  2741. @var{segment_times} option:
  2742. @example
  2743. ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 out%03d.nut
  2744. @end example
  2745. @item
  2746. Use the @command{ffmpeg} @option{force_key_frames}
  2747. option to force key frames in the input at the specified location, together
  2748. with the segment option @option{segment_time_delta} to account for
  2749. possible roundings operated when setting key frame times.
  2750. @example
  2751. ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
  2752. -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
  2753. @end example
  2754. In order to force key frames on the input file, transcoding is
  2755. required.
  2756. @item
  2757. Segment the input file by splitting the input file according to the
  2758. frame numbers sequence specified with the @option{segment_frames} option:
  2759. @example
  2760. ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
  2761. @end example
  2762. @item
  2763. Convert the @file{in.mkv} to TS segments using the @code{libx264}
  2764. and @code{aac} encoders:
  2765. @example
  2766. ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
  2767. @end example
  2768. @item
  2769. Segment the input file, and create an M3U8 live playlist (can be used
  2770. as live HLS source):
  2771. @example
  2772. ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
  2773. -segment_list_flags +live -segment_time 10 out%03d.mkv
  2774. @end example
  2775. @end itemize
  2776. @section smoothstreaming
  2777. Smooth Streaming muxer generates a set of files (Manifest, chunks) suitable for serving with conventional web server.
  2778. @table @option
  2779. @item window_size
  2780. Specify the number of fragments kept in the manifest. Default 0 (keep all).
  2781. @item extra_window_size
  2782. Specify the number of fragments kept outside of the manifest before removing from disk. Default 5.
  2783. @item lookahead_count
  2784. Specify the number of lookahead fragments. Default 2.
  2785. @item min_frag_duration
  2786. Specify the minimum fragment duration (in microseconds). Default 5000000.
  2787. @item remove_at_exit
  2788. Specify whether to remove all fragments when finished. Default 0 (do not remove).
  2789. @end table
  2790. @anchor{streamhash}
  2791. @section streamhash
  2792. Per stream hash testing format.
  2793. This muxer computes and prints a cryptographic hash of all the input frames,
  2794. on a per-stream basis. This can be used for equality checks without having
  2795. to do a complete binary comparison.
  2796. By default audio frames are converted to signed 16-bit raw audio and
  2797. video frames to raw video before computing the hash, but the output
  2798. of explicit conversions to other codecs can also be used. Timestamps
  2799. are ignored. It uses the SHA-256 cryptographic hash function by default,
  2800. but supports several other algorithms.
  2801. The output of the muxer consists of one line per stream of the form:
  2802. @var{streamindex},@var{streamtype},@var{algo}=@var{hash}, where
  2803. @var{streamindex} is the index of the mapped stream, @var{streamtype} is a
  2804. single character indicating the type of stream, @var{algo} is a short string
  2805. representing the hash function used, and @var{hash} is a hexadecimal number
  2806. representing the computed hash.
  2807. @table @option
  2808. @item hash @var{algorithm}
  2809. Use the cryptographic hash function specified by the string @var{algorithm}.
  2810. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  2811. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  2812. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  2813. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  2814. @end table
  2815. @subsection Examples
  2816. To compute the SHA-256 hash of the input converted to raw audio and
  2817. video, and store it in the file @file{out.sha256}:
  2818. @example
  2819. ffmpeg -i INPUT -f streamhash out.sha256
  2820. @end example
  2821. To print an MD5 hash to stdout use the command:
  2822. @example
  2823. ffmpeg -i INPUT -f streamhash -hash md5 -
  2824. @end example
  2825. See also the @ref{hash} and @ref{framehash} muxers.
  2826. @anchor{tee}
  2827. @section tee
  2828. The tee muxer can be used to write the same data to several outputs, such as files or streams.
  2829. It can be used, for example, to stream a video over a network and save it to disk at the same time.
  2830. It is different from specifying several outputs to the @command{ffmpeg}
  2831. command-line tool. With the tee muxer, the audio and video data will be encoded only once.
  2832. With conventional multiple outputs, multiple encoding operations in parallel are initiated,
  2833. which can be a very expensive process. The tee muxer is not useful when using the libavformat API
  2834. directly because it is then possible to feed the same packets to several muxers directly.
  2835. Since the tee muxer does not represent any particular output format, ffmpeg cannot auto-select
  2836. output streams. So all streams intended for output must be specified using @code{-map}. See
  2837. the examples below.
  2838. Some encoders may need different options depending on the output format;
  2839. the auto-detection of this can not work with the tee muxer, so they need to be explicitly specified.
  2840. The main example is the @option{global_header} flag.
  2841. The slave outputs are specified in the file name given to the muxer,
  2842. separated by '|'. If any of the slave name contains the '|' separator,
  2843. leading or trailing spaces or any special character, those must be
  2844. escaped (see @ref{quoting_and_escaping,,the "Quoting and escaping"
  2845. section in the ffmpeg-utils(1) manual,ffmpeg-utils}).
  2846. @subsection Options
  2847. @table @option
  2848. @item use_fifo @var{bool}
  2849. If set to 1, slave outputs will be processed in separate threads using the @ref{fifo}
  2850. muxer. This allows to compensate for different speed/latency/reliability of
  2851. outputs and setup transparent recovery. By default this feature is turned off.
  2852. @item fifo_options
  2853. Options to pass to fifo pseudo-muxer instances. See @ref{fifo}.
  2854. @end table
  2855. Muxer options can be specified for each slave by prepending them as a list of
  2856. @var{key}=@var{value} pairs separated by ':', between square brackets. If
  2857. the options values contain a special character or the ':' separator, they
  2858. must be escaped; note that this is a second level escaping.
  2859. The following special options are also recognized:
  2860. @table @option
  2861. @item f
  2862. Specify the format name. Required if it cannot be guessed from the
  2863. output URL.
  2864. @item bsfs[/@var{spec}]
  2865. Specify a list of bitstream filters to apply to the specified
  2866. output.
  2867. It is possible to specify to which streams a given bitstream filter
  2868. applies, by appending a stream specifier to the option separated by
  2869. @code{/}. @var{spec} must be a stream specifier (see @ref{Format
  2870. stream specifiers}).
  2871. If the stream specifier is not specified, the bitstream filters will be
  2872. applied to all streams in the output. This will cause that output operation
  2873. to fail if the output contains streams to which the bitstream filter cannot
  2874. be applied e.g. @code{h264_mp4toannexb} being applied to an output containing an audio stream.
  2875. Options for a bitstream filter must be specified in the form of @code{opt=value}.
  2876. Several bitstream filters can be specified, separated by ",".
  2877. @item use_fifo @var{bool}
  2878. This allows to override tee muxer use_fifo option for individual slave muxer.
  2879. @item fifo_options
  2880. This allows to override tee muxer fifo_options for individual slave muxer.
  2881. See @ref{fifo}.
  2882. @item select
  2883. Select the streams that should be mapped to the slave output,
  2884. specified by a stream specifier. If not specified, this defaults to
  2885. all the mapped streams. This will cause that output operation to fail
  2886. if the output format does not accept all mapped streams.
  2887. You may use multiple stream specifiers separated by commas (@code{,}) e.g.: @code{a:0,v}
  2888. @item onfail
  2889. Specify behaviour on output failure. This can be set to either @code{abort} (which is
  2890. default) or @code{ignore}. @code{abort} will cause whole process to fail in case of failure
  2891. on this slave output. @code{ignore} will ignore failure on this output, so other outputs
  2892. will continue without being affected.
  2893. @end table
  2894. @subsection Examples
  2895. @itemize
  2896. @item
  2897. Encode something and both archive it in a WebM file and stream it
  2898. as MPEG-TS over UDP:
  2899. @example
  2900. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  2901. "archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  2902. @end example
  2903. @item
  2904. As above, but continue streaming even if output to local file fails
  2905. (for example local drive fills up):
  2906. @example
  2907. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  2908. "[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  2909. @end example
  2910. @item
  2911. Use @command{ffmpeg} to encode the input, and send the output
  2912. to three different destinations. The @code{dump_extra} bitstream
  2913. filter is used to add extradata information to all the output video
  2914. keyframes packets, as requested by the MPEG-TS format. The select
  2915. option is applied to @file{out.aac} in order to make it contain only
  2916. audio packets.
  2917. @example
  2918. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
  2919. -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
  2920. @end example
  2921. @item
  2922. As above, but select only stream @code{a:1} for the audio output. Note
  2923. that a second level escaping must be performed, as ":" is a special
  2924. character used to separate options.
  2925. @example
  2926. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
  2927. -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"
  2928. @end example
  2929. @end itemize
  2930. @section webm_chunk
  2931. WebM Live Chunk Muxer.
  2932. This muxer writes out WebM headers and chunks as separate files which can be
  2933. consumed by clients that support WebM Live streams via DASH.
  2934. @subsection Options
  2935. This muxer supports the following options:
  2936. @table @option
  2937. @item chunk_start_index
  2938. Index of the first chunk (defaults to 0).
  2939. @item header
  2940. Filename of the header where the initialization data will be written.
  2941. @item audio_chunk_duration
  2942. Duration of each audio chunk in milliseconds (defaults to 5000).
  2943. @end table
  2944. @subsection Example
  2945. @example
  2946. ffmpeg -f v4l2 -i /dev/video0 \
  2947. -f alsa -i hw:0 \
  2948. -map 0:0 \
  2949. -c:v libvpx-vp9 \
  2950. -s 640x360 -keyint_min 30 -g 30 \
  2951. -f webm_chunk \
  2952. -header webm_live_video_360.hdr \
  2953. -chunk_start_index 1 \
  2954. webm_live_video_360_%d.chk \
  2955. -map 1:0 \
  2956. -c:a libvorbis \
  2957. -b:a 128k \
  2958. -f webm_chunk \
  2959. -header webm_live_audio_128.hdr \
  2960. -chunk_start_index 1 \
  2961. -audio_chunk_duration 1000 \
  2962. webm_live_audio_128_%d.chk
  2963. @end example
  2964. @section webm_dash_manifest
  2965. WebM DASH Manifest muxer.
  2966. This muxer implements the WebM DASH Manifest specification to generate the DASH
  2967. manifest XML. It also supports manifest generation for DASH live streams.
  2968. For more information see:
  2969. @itemize @bullet
  2970. @item
  2971. WebM DASH Specification: @url{https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification}
  2972. @item
  2973. ISO DASH Specification: @url{http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip}
  2974. @end itemize
  2975. @subsection Options
  2976. This muxer supports the following options:
  2977. @table @option
  2978. @item adaptation_sets
  2979. This option has the following syntax: "id=x,streams=a,b,c id=y,streams=d,e" where x and y are the
  2980. unique identifiers of the adaptation sets and a,b,c,d and e are the indices of the corresponding
  2981. audio and video streams. Any number of adaptation sets can be added using this option.
  2982. @item live
  2983. Set this to 1 to create a live stream DASH Manifest. Default: 0.
  2984. @item chunk_start_index
  2985. Start index of the first chunk. This will go in the @samp{startNumber} attribute
  2986. of the @samp{SegmentTemplate} element in the manifest. Default: 0.
  2987. @item chunk_duration_ms
  2988. Duration of each chunk in milliseconds. This will go in the @samp{duration}
  2989. attribute of the @samp{SegmentTemplate} element in the manifest. Default: 1000.
  2990. @item utc_timing_url
  2991. URL of the page that will return the UTC timestamp in ISO format. This will go
  2992. in the @samp{value} attribute of the @samp{UTCTiming} element in the manifest.
  2993. Default: None.
  2994. @item time_shift_buffer_depth
  2995. Smallest time (in seconds) shifting buffer for which any Representation is
  2996. guaranteed to be available. This will go in the @samp{timeShiftBufferDepth}
  2997. attribute of the @samp{MPD} element. Default: 60.
  2998. @item minimum_update_period
  2999. Minimum update period (in seconds) of the manifest. This will go in the
  3000. @samp{minimumUpdatePeriod} attribute of the @samp{MPD} element. Default: 0.
  3001. @end table
  3002. @subsection Example
  3003. @example
  3004. ffmpeg -f webm_dash_manifest -i video1.webm \
  3005. -f webm_dash_manifest -i video2.webm \
  3006. -f webm_dash_manifest -i audio1.webm \
  3007. -f webm_dash_manifest -i audio2.webm \
  3008. -map 0 -map 1 -map 2 -map 3 \
  3009. -c copy \
  3010. -f webm_dash_manifest \
  3011. -adaptation_sets "id=0,streams=0,1 id=1,streams=2,3" \
  3012. manifest.xml
  3013. @end example
  3014. @c man end MUXERS