muxers.texi 132 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881
  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'. Make sure the input file has one text subtitle stream at least.
  1878. @example
  1879. ffmpeg -y -i input_with_subtitle.mkv \
  1880. -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
  1881. -b:a:0 256k \
  1882. -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
  1883. -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \
  1884. -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \
  1885. 10 -master_pl_publish_rate 10 -hls_flags \
  1886. delete_segments+discont_start+split_by_time ./tmp/video.m3u8
  1887. @end example
  1888. @end itemize
  1889. @item cc_stream_map @var{cc_stream_map}
  1890. Map string which specifies different closed captions groups and their
  1891. attributes. The closed captions stream groups are separated by space.
  1892. Expected string format is like this
  1893. "ccgroup:<group name>,instreamid:<INSTREAM-ID>,language:<language code> ....".
  1894. 'ccgroup' and 'instreamid' are mandatory attributes. 'language' is an optional
  1895. attribute.
  1896. The closed captions groups configured using this option are mapped to different
  1897. variant streams by providing the same 'ccgroup' name in the
  1898. @option{var_stream_map} string.
  1899. For example:
  1900. @example
  1901. ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  1902. -a53cc:0 1 -a53cc:1 1 \
  1903. -map 0:v -map 0:a -map 0:v -map 0:a -f hls \
  1904. -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en ccgroup:cc,instreamid:CC2,language:sp" \
  1905. -var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
  1906. -master_pl_name master.m3u8 \
  1907. http://example.com/live/out_%v.m3u8
  1908. @end example
  1909. will add two @code{#EXT-X-MEDIA} tags with @code{TYPE=CLOSED-CAPTIONS} in the
  1910. master playlist for the INSTREAM-IDs 'CC1' and 'CC2'. Also, it will add
  1911. @code{CLOSED-CAPTIONS} attribute with group name 'cc' for the two output variant
  1912. streams.
  1913. If @option{var_stream_map} is not set, then the first available ccgroup in
  1914. @option{cc_stream_map} is mapped to the output variant stream.
  1915. For example:
  1916. @example
  1917. ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
  1918. -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
  1919. -master_pl_name master.m3u8 \
  1920. http://example.com/live/out.m3u8
  1921. @end example
  1922. this will add @code{#EXT-X-MEDIA} tag with @code{TYPE=CLOSED-CAPTIONS} in the
  1923. master playlist with group name 'cc', language 'en' (english) and INSTREAM-ID
  1924. 'CC1'. Also, it will add @code{CLOSED-CAPTIONS} attribute with group name 'cc'
  1925. for the output variant stream.
  1926. @item master_pl_name @var{name}
  1927. Create HLS master playlist with the given name.
  1928. For example:
  1929. @example
  1930. ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8
  1931. @end example
  1932. creates an HLS master playlist with name @file{master.m3u8} which is published
  1933. at @url{http://example.com/live/}.
  1934. @item master_pl_publish_rate @var{count}
  1935. Publish master play list repeatedly every after specified number of segment intervals.
  1936. For example:
  1937. @example
  1938. ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 \
  1939. -hls_time 2 -master_pl_publish_rate 30 http://example.com/live/out.m3u8
  1940. @end example
  1941. creates an HLS master playlist with name @file{master.m3u8} and keeps
  1942. publishing it repeatedly every after 30 segments i.e. every after 60s.
  1943. @item http_persistent @var{bool}
  1944. Use persistent HTTP connections. Applicable only for HTTP output.
  1945. @item timeout @var{timeout}
  1946. Set timeout for socket I/O operations. Applicable only for HTTP output.
  1947. @item ignore_io_errors @var{bool}
  1948. Ignore IO errors during open, write and delete. Useful for long-duration runs with network output.
  1949. @item headers @var{headers}
  1950. Set custom HTTP headers, can override built in default headers. Applicable only for HTTP output.
  1951. @end table
  1952. @section iamf
  1953. Immersive Audio Model and Formats (IAMF) muxer.
  1954. IAMF is used to provide immersive audio content for presentation on a wide range
  1955. of devices in both streaming and offline applications. These applications
  1956. include internet audio streaming, multicasting/broadcasting services, file
  1957. download, gaming, communication, virtual and augmented reality, and others. In
  1958. these applications, audio may be played back on a wide range of devices, e.g.,
  1959. headphones, mobile phones, tablets, TVs, sound bars, home theater systems, and
  1960. big screens.
  1961. This format was promoted and desgined by Alliance for Open Media.
  1962. For more information about this format, see @url{https://aomedia.org/iamf/}.
  1963. @anchor{ico}
  1964. @section ico
  1965. ICO file muxer.
  1966. Microsoft's icon file format (ICO) has some strict limitations that should be noted:
  1967. @itemize
  1968. @item
  1969. Size cannot exceed 256 pixels in any dimension
  1970. @item
  1971. Only BMP and PNG images can be stored
  1972. @item
  1973. If a BMP image is used, it must be one of the following pixel formats:
  1974. @example
  1975. BMP Bit Depth FFmpeg Pixel Format
  1976. 1bit pal8
  1977. 4bit pal8
  1978. 8bit pal8
  1979. 16bit rgb555le
  1980. 24bit bgr24
  1981. 32bit bgra
  1982. @end example
  1983. @item
  1984. If a BMP image is used, it must use the BITMAPINFOHEADER DIB header
  1985. @item
  1986. If a PNG image is used, it must use the rgba pixel format
  1987. @end itemize
  1988. @section ilbc
  1989. Internet Low Bitrate Codec (iLBC) raw muxer.
  1990. It accepts a single @samp{ilbc} audio stream.
  1991. @anchor{image2}
  1992. @section image2, image2pipe
  1993. Image file muxer.
  1994. The @samp{image2} muxer writes video frames to image files.
  1995. The output filenames are specified by a pattern, which can be used to
  1996. produce sequentially numbered series of files.
  1997. The pattern may contain the string "%d" or "%0@var{N}d", this string
  1998. specifies the position of the characters representing a numbering in
  1999. the filenames. If the form "%0@var{N}d" is used, the string
  2000. representing the number in each filename is 0-padded to @var{N}
  2001. digits. The literal character '%' can be specified in the pattern with
  2002. the string "%%".
  2003. If the pattern contains "%d" or "%0@var{N}d", the first filename of
  2004. the file list specified will contain the number 1, all the following
  2005. numbers will be sequential.
  2006. The pattern may contain a suffix which is used to automatically
  2007. determine the format of the image files to write.
  2008. For example the pattern "img-%03d.bmp" will specify a sequence of
  2009. filenames of the form @file{img-001.bmp}, @file{img-002.bmp}, ...,
  2010. @file{img-010.bmp}, etc.
  2011. The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
  2012. form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
  2013. etc.
  2014. The image muxer supports the .Y.U.V image file format. This format is
  2015. special in that each image frame consists of three files, for
  2016. each of the YUV420P components. To read or write this image file format,
  2017. specify the name of the '.Y' file. The muxer will automatically open the
  2018. '.U' and '.V' files as required.
  2019. The @samp{image2pipe} muxer accepts the same options as the @samp{image2} muxer,
  2020. but ignores the pattern verification and expansion, as it is supposed to write
  2021. to the command output rather than to an actual stored file.
  2022. @subsection Options
  2023. @table @option
  2024. @item frame_pts @var{bool}
  2025. If set to 1, expand the filename with the packet PTS (presentation time stamp).
  2026. Default value is 0.
  2027. @item start_number @var{count}
  2028. Start the sequence from the specified number. Default value is 1.
  2029. @item update @var{bool}
  2030. If set to 1, the filename will always be interpreted as just a
  2031. filename, not a pattern, and the corresponding file will be continuously
  2032. overwritten with new images. Default value is 0.
  2033. @item strftime @var{bool}
  2034. If set to 1, expand the filename with date and time information from
  2035. @code{strftime()}. Default value is 0.
  2036. @item atomic_writing @var{bool}
  2037. Write output to a temporary file, which is renamed to target filename once
  2038. writing is completed. Default is disabled.
  2039. @item protocol_opts @var{options_list}
  2040. Set protocol options as a :-separated list of key=value parameters. Values
  2041. containing the @code{:} special character must be escaped.
  2042. @end table
  2043. @subsection Examples
  2044. @itemize
  2045. @item
  2046. Use @command{ffmpeg} for creating a sequence of files @file{img-001.jpeg},
  2047. @file{img-002.jpeg}, ..., taking one image every second from the input video:
  2048. @example
  2049. ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'
  2050. @end example
  2051. Note that with @command{ffmpeg}, if the format is not specified with the
  2052. @code{-f} option and the output filename specifies an image file
  2053. format, the image2 muxer is automatically selected, so the previous
  2054. command can be written as:
  2055. @example
  2056. ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'
  2057. @end example
  2058. Note also that the pattern must not necessarily contain "%d" or
  2059. "%0@var{N}d", for example to create a single image file
  2060. @file{img.jpeg} from the start of the input video you can employ the command:
  2061. @example
  2062. ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
  2063. @end example
  2064. @item
  2065. The @option{strftime} option allows you to expand the filename with
  2066. date and time information. Check the documentation of
  2067. the @code{strftime()} function for the syntax.
  2068. To generate image files from the @code{strftime()} "%Y-%m-%d_%H-%M-%S" pattern,
  2069. the following @command{ffmpeg} command can be used:
  2070. @example
  2071. ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"
  2072. @end example
  2073. @item
  2074. Set the file name with current frame's PTS:
  2075. @example
  2076. ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg
  2077. @end example
  2078. @item
  2079. Publish contents of your desktop directly to a WebDAV server every second:
  2080. @example
  2081. ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg
  2082. @end example
  2083. @end itemize
  2084. @section ircam
  2085. Berkeley / IRCAM / CARL Sound Filesystem (BICSF) format muxer.
  2086. The Berkeley/IRCAM/CARL Sound Format, developed in the 1980s, is a result of the
  2087. merging of several different earlier sound file formats and systems including
  2088. the csound system developed by Dr Gareth Loy at the Computer Audio Research Lab
  2089. (CARL) at UC San Diego, the IRCAM sound file system developed by Rob Gross and
  2090. Dan Timis at the Institut de Recherche et Coordination Acoustique / Musique in
  2091. Paris and the Berkeley Fast Filesystem.
  2092. It was developed initially as part of the Berkeley/IRCAM/CARL Sound Filesystem,
  2093. a suite of programs designed to implement a filesystem for audio applications
  2094. running under Berkeley UNIX. It was particularly popular in academic music
  2095. research centres, and was used a number of times in the creation of early
  2096. computer-generated compositions.
  2097. This muxer accepts a single audio stream containing PCM data.
  2098. @section ivf
  2099. On2 IVF muxer.
  2100. IVF was developed by On2 Technologies (formerly known as Duck
  2101. Corporation), to store internally developed codecs.
  2102. This muxer accepts a single @samp{vp8}, @samp{vp9}, or @samp{av1}
  2103. video stream.
  2104. @section jacosub
  2105. JACOsub subtitle format muxer.
  2106. This muxer accepts a single @samp{jacosub} subtitles stream.
  2107. For more information about the format, see
  2108. @url{http://unicorn.us.com/jacosub/jscripts.html}.
  2109. @section kvag
  2110. Simon & Schuster Interactive VAG muxer.
  2111. This custom VAG container is used by some Simon & Schuster Interactive
  2112. games such as "Real War", and "Real War: Rogue States".
  2113. This muxer accepts a single @samp{adpcm_ima_ssi} audio stream.
  2114. @section lc3
  2115. Bluetooth SIG Low Complexity Communication Codec audio (LC3), or
  2116. ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus).
  2117. This muxer accepts a single @samp{lc3} audio stream.
  2118. @section lrc
  2119. LRC lyrics file format muxer.
  2120. LRC (short for LyRiCs) is a computer file format that synchronizes
  2121. song lyrics with an audio file, such as MP3, Vorbis, or MIDI.
  2122. This muxer accepts a single @samp{subrip} or @samp{text} subtitles stream.
  2123. @subsection Metadata
  2124. The following metadata tags are converted to the format corresponding
  2125. metadata:
  2126. @table @option
  2127. @item title
  2128. @item album
  2129. @item artist
  2130. @item author
  2131. @item creator
  2132. @item encoder
  2133. @item encoder_version
  2134. @end table
  2135. If @samp{encoder_version} is not explicitly set, it is automatically
  2136. set to the libavformat version.
  2137. @section matroska
  2138. Matroska container muxer.
  2139. This muxer implements the matroska and webm container specs.
  2140. @subsection Metadata
  2141. The recognized metadata settings in this muxer are:
  2142. @table @option
  2143. @item title
  2144. Set title name provided to a single track. This gets mapped to
  2145. the FileDescription element for a stream written as attachment.
  2146. @item language
  2147. Specify the language of the track in the Matroska languages form.
  2148. The language can be either the 3 letters bibliographic ISO-639-2 (ISO
  2149. 639-2/B) form (like "fre" for French), or a language code mixed with a
  2150. country code for specialities in languages (like "fre-ca" for Canadian
  2151. French).
  2152. @item stereo_mode
  2153. Set stereo 3D video layout of two views in a single video track.
  2154. The following values are recognized:
  2155. @table @samp
  2156. @item mono
  2157. video is not stereo
  2158. @item left_right
  2159. Both views are arranged side by side, Left-eye view is on the left
  2160. @item bottom_top
  2161. Both views are arranged in top-bottom orientation, Left-eye view is at bottom
  2162. @item top_bottom
  2163. Both views are arranged in top-bottom orientation, Left-eye view is on top
  2164. @item checkerboard_rl
  2165. Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
  2166. @item checkerboard_lr
  2167. Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
  2168. @item row_interleaved_rl
  2169. Each view is constituted by a row based interleaving, Right-eye view is first row
  2170. @item row_interleaved_lr
  2171. Each view is constituted by a row based interleaving, Left-eye view is first row
  2172. @item col_interleaved_rl
  2173. Both views are arranged in a column based interleaving manner, Right-eye view is first column
  2174. @item col_interleaved_lr
  2175. Both views are arranged in a column based interleaving manner, Left-eye view is first column
  2176. @item anaglyph_cyan_red
  2177. All frames are in anaglyph format viewable through red-cyan filters
  2178. @item right_left
  2179. Both views are arranged side by side, Right-eye view is on the left
  2180. @item anaglyph_green_magenta
  2181. All frames are in anaglyph format viewable through green-magenta filters
  2182. @item block_lr
  2183. Both eyes laced in one Block, Left-eye view is first
  2184. @item block_rl
  2185. Both eyes laced in one Block, Right-eye view is first
  2186. @end table
  2187. @end table
  2188. For example a 3D WebM clip can be created using the following command line:
  2189. @example
  2190. ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
  2191. @end example
  2192. @subsection Options
  2193. @table @option
  2194. @item reserve_index_space @var{size}
  2195. By default, this muxer writes the index for seeking (called cues in Matroska
  2196. terms) at the end of the file, because it cannot know in advance how much space
  2197. to leave for the index at the beginning of the file. However for some use cases
  2198. -- e.g. streaming where seeking is possible but slow -- it is useful to put the
  2199. index at the beginning of the file.
  2200. If this option is set to a non-zero value, the muxer will reserve @var{size} bytes
  2201. of space in the file header and then try to write the cues there when the muxing
  2202. finishes. If the reserved space does not suffice, no Cues will be written, the
  2203. file will be finalized and writing the trailer will return an error.
  2204. A safe size for most use cases should be about 50kB per hour of video.
  2205. Note that cues are only written if the output is seekable and this option will
  2206. have no effect if it is not.
  2207. @item cues_to_front @var{bool}
  2208. If set, the muxer will write the index at the beginning of the file
  2209. by shifting the main data if necessary. This can be combined with
  2210. reserve_index_space in which case the data is only shifted if
  2211. the initially reserved space turns out to be insufficient.
  2212. This option is ignored if the output is unseekable.
  2213. @item cluster_size_limit @var{size}
  2214. Store at most the provided amount of bytes in a cluster.
  2215. If not specified, the limit is set automatically to a sensible
  2216. hardcoded fixed value.
  2217. @item cluster_time_limit @var{duration}
  2218. Store at most the provided number of milliseconds in a cluster.
  2219. If not specified, the limit is set automatically to a sensible
  2220. hardcoded fixed value.
  2221. @item dash @var{bool}
  2222. Create a WebM file conforming to WebM DASH specification. By default
  2223. it is set to @code{false}.
  2224. @item dash_track_number @var{index}
  2225. Track number for the DASH stream. By default it is set to @code{1}.
  2226. @item live @var{bool}
  2227. Write files assuming it is a live stream. By default it is set to
  2228. @code{false}.
  2229. @item allow_raw_vfw @var{bool}
  2230. Allow raw VFW mode. By default it is set to @code{false}.
  2231. @item flipped_raw_rgb @var{bool}
  2232. If set to @code{true}, store positive height for raw RGB bitmaps, which indicates
  2233. bitmap is stored bottom-up. Note that this option does not flip the bitmap
  2234. which has to be done manually beforehand, e.g. by using the @samp{vflip} filter.
  2235. Default is @code{false} and indicates bitmap is stored top down.
  2236. @item write_crc32 @var{bool}
  2237. Write a CRC32 element inside every Level 1 element. By default it is
  2238. set to @code{true}. This option is ignored for WebM.
  2239. @item default_mode @var{mode}
  2240. Control how the FlagDefault of the output tracks will be set.
  2241. It influences which tracks players should play by default. The default mode
  2242. is @samp{passthrough}.
  2243. @table @samp
  2244. @item infer
  2245. Every track with disposition default will have the FlagDefault set.
  2246. Additionally, for each type of track (audio, video or subtitle), if no track
  2247. with disposition default of this type exists, then the first track of this type
  2248. will be marked as default (if existing). This ensures that the default flag
  2249. is set in a sensible way even if the input originated from containers that
  2250. lack the concept of default tracks.
  2251. @item infer_no_subs
  2252. This mode is the same as infer except that if no subtitle track with
  2253. disposition default exists, no subtitle track will be marked as default.
  2254. @item passthrough
  2255. In this mode the FlagDefault is set if and only if the AV_DISPOSITION_DEFAULT
  2256. flag is set in the disposition of the corresponding stream.
  2257. @end table
  2258. @end table
  2259. @anchor{md5}
  2260. @section md5
  2261. MD5 testing format.
  2262. This is a variant of the @ref{hash} muxer. Unlike that muxer, it
  2263. defaults to using the MD5 hash function.
  2264. See also the @ref{hash} and @ref{framemd5} muxers.
  2265. @subsection Examples
  2266. @itemize
  2267. @item
  2268. To compute the MD5 hash of the input converted to raw
  2269. audio and video, and store it in the file @file{out.md5}:
  2270. @example
  2271. ffmpeg -i INPUT -f md5 out.md5
  2272. @end example
  2273. @item
  2274. To print the MD5 hash to stdout:
  2275. @example
  2276. ffmpeg -i INPUT -f md5 -
  2277. @end example
  2278. @end itemize
  2279. @section microdvd
  2280. MicroDVD subtitle format muxer.
  2281. This muxer accepts a single @samp{microdvd} subtitles stream.
  2282. @section mmf
  2283. Synthetic music Mobile Application Format (SMAF) format muxer.
  2284. SMAF is a music data format specified by Yamaha for portable
  2285. electronic devices, such as mobile phones and personal digital
  2286. assistants.
  2287. This muxer accepts a single @samp{adpcm_yamaha} audio stream.
  2288. @section mp3
  2289. The MP3 muxer writes a raw MP3 stream with the following optional features:
  2290. @itemize @bullet
  2291. @item
  2292. An ID3v2 metadata header at the beginning (enabled by default). Versions 2.3 and
  2293. 2.4 are supported, the @code{id3v2_version} private option controls which one is
  2294. used (3 or 4). Setting @code{id3v2_version} to 0 disables the ID3v2 header
  2295. completely.
  2296. The muxer supports writing attached pictures (APIC frames) to the ID3v2 header.
  2297. The pictures are supplied to the muxer in form of a video stream with a single
  2298. packet. There can be any number of those streams, each will correspond to a
  2299. single APIC frame. The stream metadata tags @var{title} and @var{comment} map
  2300. to APIC @var{description} and @var{picture type} respectively. See
  2301. @url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
  2302. Note that the APIC frames must be written at the beginning, so the muxer will
  2303. buffer the audio frames until it gets all the pictures. It is therefore advised
  2304. to provide the pictures as soon as possible to avoid excessive buffering.
  2305. @item
  2306. A Xing/LAME frame right after the ID3v2 header (if present). It is enabled by
  2307. default, but will be written only if the output is seekable. The
  2308. @code{write_xing} private option can be used to disable it. The frame contains
  2309. various information that may be useful to the decoder, like the audio duration
  2310. or encoder delay.
  2311. @item
  2312. A legacy ID3v1 tag at the end of the file (disabled by default). It may be
  2313. enabled with the @code{write_id3v1} private option, but as its capabilities are
  2314. very limited, its usage is not recommended.
  2315. @end itemize
  2316. Examples:
  2317. Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
  2318. @example
  2319. ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
  2320. @end example
  2321. To attach a picture to an mp3 file select both the audio and the picture stream
  2322. with @code{map}:
  2323. @example
  2324. ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1
  2325. -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
  2326. @end example
  2327. Write a "clean" MP3 without any extra features:
  2328. @example
  2329. ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
  2330. @end example
  2331. @section mpegts
  2332. MPEG transport stream muxer.
  2333. This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
  2334. The recognized metadata settings in mpegts muxer are @code{service_provider}
  2335. and @code{service_name}. If they are not set the default for
  2336. @code{service_provider} is @samp{FFmpeg} and the default for
  2337. @code{service_name} is @samp{Service01}.
  2338. @subsection Options
  2339. The muxer options are:
  2340. @table @option
  2341. @item mpegts_transport_stream_id @var{integer}
  2342. Set the @samp{transport_stream_id}. This identifies a transponder in DVB.
  2343. Default is @code{0x0001}.
  2344. @item mpegts_original_network_id @var{integer}
  2345. Set the @samp{original_network_id}. This is unique identifier of a
  2346. network in DVB. Its main use is in the unique identification of a service
  2347. through the path @samp{Original_Network_ID, Transport_Stream_ID}. Default
  2348. is @code{0x0001}.
  2349. @item mpegts_service_id @var{integer}
  2350. Set the @samp{service_id}, also known as program in DVB. Default is
  2351. @code{0x0001}.
  2352. @item mpegts_service_type @var{integer}
  2353. Set the program @samp{service_type}. Default is @code{digital_tv}.
  2354. Accepts the following options:
  2355. @table @samp
  2356. @item hex_value
  2357. Any hexadecimal value between @code{0x01} and @code{0xff} as defined in
  2358. ETSI 300 468.
  2359. @item digital_tv
  2360. Digital TV service.
  2361. @item digital_radio
  2362. Digital Radio service.
  2363. @item teletext
  2364. Teletext service.
  2365. @item advanced_codec_digital_radio
  2366. Advanced Codec Digital Radio service.
  2367. @item mpeg2_digital_hdtv
  2368. MPEG2 Digital HDTV service.
  2369. @item advanced_codec_digital_sdtv
  2370. Advanced Codec Digital SDTV service.
  2371. @item advanced_codec_digital_hdtv
  2372. Advanced Codec Digital HDTV service.
  2373. @end table
  2374. @item mpegts_pmt_start_pid @var{integer}
  2375. Set the first PID for PMTs. Default is @code{0x1000}, minimum is @code{0x0020},
  2376. maximum is @code{0x1ffa}. This option has no effect in m2ts mode where the PMT
  2377. PID is fixed @code{0x0100}.
  2378. @item mpegts_start_pid @var{integer}
  2379. Set the first PID for elementary streams. Default is @code{0x0100}, minimum is
  2380. @code{0x0020}, maximum is @code{0x1ffa}. This option has no effect in m2ts mode
  2381. where the elementary stream PIDs are fixed.
  2382. @item mpegts_m2ts_mode @var{boolean}
  2383. Enable m2ts mode if set to @code{1}. Default value is @code{-1} which
  2384. disables m2ts mode.
  2385. @item muxrate @var{integer}
  2386. Set a constant muxrate. Default is VBR.
  2387. @item pes_payload_size @var{integer}
  2388. Set minimum PES packet payload in bytes. Default is @code{2930}.
  2389. @item mpegts_flags @var{flags}
  2390. Set mpegts flags. Accepts the following options:
  2391. @table @samp
  2392. @item resend_headers
  2393. Reemit PAT/PMT before writing the next packet.
  2394. @item latm
  2395. Use LATM packetization for AAC.
  2396. @item pat_pmt_at_frames
  2397. Reemit PAT and PMT at each video frame.
  2398. @item system_b
  2399. Conform to System B (DVB) instead of System A (ATSC).
  2400. @item initial_discontinuity
  2401. Mark the initial packet of each stream as discontinuity.
  2402. @item nit
  2403. Emit NIT table.
  2404. @item omit_rai
  2405. Disable writing of random access indicator.
  2406. @end table
  2407. @item mpegts_copyts @var{boolean}
  2408. Preserve original timestamps, if value is set to @code{1}. Default value
  2409. is @code{-1}, which results in shifting timestamps so that they start from 0.
  2410. @item omit_video_pes_length @var{boolean}
  2411. Omit the PES packet length for video packets. Default is @code{1} (true).
  2412. @item pcr_period @var{integer}
  2413. Override the default PCR retransmission time in milliseconds. Default is
  2414. @code{-1} which means that the PCR interval will be determined automatically:
  2415. 20 ms is used for CBR streams, the highest multiple of the frame duration which
  2416. is less than 100 ms is used for VBR streams.
  2417. @item pat_period @var{duration}
  2418. Maximum time in seconds between PAT/PMT tables. Default is @code{0.1}.
  2419. @item sdt_period @var{duration}
  2420. Maximum time in seconds between SDT tables. Default is @code{0.5}.
  2421. @item nit_period @var{duration}
  2422. Maximum time in seconds between NIT tables. Default is @code{0.5}.
  2423. @item tables_version @var{integer}
  2424. Set PAT, PMT, SDT and NIT version (default @code{0}, valid values are from 0 to 31, inclusively).
  2425. This option allows updating stream structure so that standard consumer may
  2426. detect the change. To do so, reopen output @code{AVFormatContext} (in case of API
  2427. usage) or restart @command{ffmpeg} instance, cyclically changing
  2428. @option{tables_version} value:
  2429. @example
  2430. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  2431. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  2432. ...
  2433. ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
  2434. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  2435. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  2436. ...
  2437. @end example
  2438. @end table
  2439. @subsection Example
  2440. @example
  2441. ffmpeg -i file.mpg -c copy \
  2442. -mpegts_original_network_id 0x1122 \
  2443. -mpegts_transport_stream_id 0x3344 \
  2444. -mpegts_service_id 0x5566 \
  2445. -mpegts_pmt_start_pid 0x1500 \
  2446. -mpegts_start_pid 0x150 \
  2447. -metadata service_provider="Some provider" \
  2448. -metadata service_name="Some Channel" \
  2449. out.ts
  2450. @end example
  2451. @section mxf, mxf_d10, mxf_opatom
  2452. MXF muxer.
  2453. @subsection Options
  2454. The muxer options are:
  2455. @table @option
  2456. @item store_user_comments @var{bool}
  2457. Set if user comments should be stored if available or never.
  2458. IRT D-10 does not allow user comments. The default is thus to write them for
  2459. mxf and mxf_opatom but not for mxf_d10
  2460. @end table
  2461. @section null
  2462. Null muxer.
  2463. This muxer does not generate any output file, it is mainly useful for
  2464. testing or benchmarking purposes.
  2465. For example to benchmark decoding with @command{ffmpeg} you can use the
  2466. command:
  2467. @example
  2468. ffmpeg -benchmark -i INPUT -f null out.null
  2469. @end example
  2470. Note that the above command does not read or write the @file{out.null}
  2471. file, but specifying the output file is required by the @command{ffmpeg}
  2472. syntax.
  2473. Alternatively you can write the command as:
  2474. @example
  2475. ffmpeg -benchmark -i INPUT -f null -
  2476. @end example
  2477. @section nut
  2478. @table @option
  2479. @item -syncpoints @var{flags}
  2480. Change the syncpoint usage in nut:
  2481. @table @option
  2482. @item @var{default} use the normal low-overhead seeking aids.
  2483. @item @var{none} do not use the syncpoints at all, reducing the overhead but making the stream non-seekable;
  2484. Use of this option is not recommended, as the resulting files are very damage
  2485. sensitive and seeking is not possible. Also in general the overhead from
  2486. syncpoints is negligible. Note, -@code{write_index} 0 can be used to disable
  2487. all growing data tables, allowing to mux endless streams with limited memory
  2488. and without these disadvantages.
  2489. @item @var{timestamped} extend the syncpoint with a wallclock field.
  2490. @end table
  2491. The @var{none} and @var{timestamped} flags are experimental.
  2492. @item -write_index @var{bool}
  2493. Write index at the end, the default is to write an index.
  2494. @end table
  2495. @example
  2496. ffmpeg -i INPUT -f_strict experimental -syncpoints none - | processor
  2497. @end example
  2498. @section ogg
  2499. Ogg container muxer.
  2500. @table @option
  2501. @item -page_duration @var{duration}
  2502. Preferred page duration, in microseconds. The muxer will attempt to create
  2503. pages that are approximately @var{duration} microseconds long. This allows the
  2504. user to compromise between seek granularity and container overhead. The default
  2505. is 1 second. A value of 0 will fill all segments, making pages as large as
  2506. possible. A value of 1 will effectively use 1 packet-per-page in most
  2507. situations, giving a small seek granularity at the cost of additional container
  2508. overhead.
  2509. @item -serial_offset @var{value}
  2510. Serial value from which to set the streams serial number.
  2511. Setting it to different and sufficiently large values ensures that the produced
  2512. ogg files can be safely chained.
  2513. @end table
  2514. @anchor{rcwtenc}
  2515. @section rcwt
  2516. RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly
  2517. used open source tool for processing 608/708 Closed Captions (CC) sources.
  2518. It can be used to archive the original extracted CC bitstream and to produce
  2519. a source file for later processing or conversion. The format allows
  2520. for interoperability between ccextractor and FFmpeg, is simple to parse,
  2521. and can be used to create a backup of the CC presentation.
  2522. This muxer implements the specification as of March 2024, which has
  2523. been stable and unchanged since April 2014.
  2524. This muxer will have some nuances from the way that ccextractor muxes RCWT.
  2525. No compatibility issues when processing the output with ccextractor
  2526. have been observed as a result of this so far, but mileage may vary
  2527. and outputs will not be a bit-exact match.
  2528. A free specification of RCWT can be found here:
  2529. @url{https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT}
  2530. @subsection Examples
  2531. @itemize
  2532. @item
  2533. Extract Closed Captions to RCWT using lavfi:
  2534. @example
  2535. ffmpeg -f lavfi -i "movie=INPUT.mkv[out+subcc]" -map 0:s:0 -c:s copy -f rcwt CC.rcwt.bin
  2536. @end example
  2537. @end itemize
  2538. @anchor{segment}
  2539. @section segment, stream_segment, ssegment
  2540. Basic stream segmenter.
  2541. This muxer outputs streams to a number of separate files of nearly
  2542. fixed duration. Output filename pattern can be set in a fashion
  2543. similar to @ref{image2}, or by using a @code{strftime} template if
  2544. the @option{strftime} option is enabled.
  2545. @code{stream_segment} is a variant of the muxer used to write to
  2546. streaming output formats, i.e. which do not require global headers,
  2547. and is recommended for outputting e.g. to MPEG transport stream segments.
  2548. @code{ssegment} is a shorter alias for @code{stream_segment}.
  2549. Every segment starts with a keyframe of the selected reference stream,
  2550. which is set through the @option{reference_stream} option.
  2551. Note that if you want accurate splitting for a video file, you need to
  2552. make the input key frames correspond to the exact splitting times
  2553. expected by the segmenter, or the segment muxer will start the new
  2554. segment with the key frame found next after the specified start
  2555. time.
  2556. The segment muxer works best with a single constant frame rate video.
  2557. Optionally it can generate a list of the created segments, by setting
  2558. the option @var{segment_list}. The list type is specified by the
  2559. @var{segment_list_type} option. The entry filenames in the segment
  2560. list are set by default to the basename of the corresponding segment
  2561. files.
  2562. See also the @ref{hls} muxer, which provides a more specific
  2563. implementation for HLS segmentation.
  2564. @subsection Options
  2565. The segment muxer supports the following options:
  2566. @table @option
  2567. @item increment_tc @var{1|0}
  2568. if set to @code{1}, increment timecode between each segment
  2569. If this is selected, the input need to have
  2570. a timecode in the first video stream. Default value is
  2571. @code{0}.
  2572. @item reference_stream @var{specifier}
  2573. Set the reference stream, as specified by the string @var{specifier}.
  2574. If @var{specifier} is set to @code{auto}, the reference is chosen
  2575. automatically. Otherwise it must be a stream specifier (see the ``Stream
  2576. specifiers'' chapter in the ffmpeg manual) which specifies the
  2577. reference stream. The default value is @code{auto}.
  2578. @item segment_format @var{format}
  2579. Override the inner container format, by default it is guessed by the filename
  2580. extension.
  2581. @item segment_format_options @var{options_list}
  2582. Set output format options using a :-separated list of key=value
  2583. parameters. Values containing the @code{:} special character must be
  2584. escaped.
  2585. @item segment_list @var{name}
  2586. Generate also a listfile named @var{name}. If not specified no
  2587. listfile is generated.
  2588. @item segment_list_flags @var{flags}
  2589. Set flags affecting the segment list generation.
  2590. It currently supports the following flags:
  2591. @table @samp
  2592. @item cache
  2593. Allow caching (only affects M3U8 list files).
  2594. @item live
  2595. Allow live-friendly file generation.
  2596. @end table
  2597. @item segment_list_size @var{size}
  2598. Update the list file so that it contains at most @var{size}
  2599. segments. If 0 the list file will contain all the segments. Default
  2600. value is 0.
  2601. @item segment_list_entry_prefix @var{prefix}
  2602. Prepend @var{prefix} to each entry. Useful to generate absolute paths.
  2603. By default no prefix is applied.
  2604. @item segment_list_type @var{type}
  2605. Select the listing format.
  2606. The following values are recognized:
  2607. @table @samp
  2608. @item flat
  2609. Generate a flat list for the created segments, one segment per line.
  2610. @item csv, ext
  2611. Generate a list for the created segments, one segment per line,
  2612. each line matching the format (comma-separated values):
  2613. @example
  2614. @var{segment_filename},@var{segment_start_time},@var{segment_end_time}
  2615. @end example
  2616. @var{segment_filename} is the name of the output file generated by the
  2617. muxer according to the provided pattern. CSV escaping (according to
  2618. RFC4180) is applied if required.
  2619. @var{segment_start_time} and @var{segment_end_time} specify
  2620. the segment start and end time expressed in seconds.
  2621. A list file with the suffix @code{".csv"} or @code{".ext"} will
  2622. auto-select this format.
  2623. @samp{ext} is deprecated in favor or @samp{csv}.
  2624. @item ffconcat
  2625. Generate an ffconcat file for the created segments. The resulting file
  2626. can be read using the FFmpeg @ref{concat} demuxer.
  2627. A list file with the suffix @code{".ffcat"} or @code{".ffconcat"} will
  2628. auto-select this format.
  2629. @item m3u8
  2630. Generate an extended M3U8 file, version 3, compliant with
  2631. @url{http://tools.ietf.org/id/draft-pantos-http-live-streaming}.
  2632. A list file with the suffix @code{".m3u8"} will auto-select this format.
  2633. @end table
  2634. If not specified the type is guessed from the list file name suffix.
  2635. @item segment_time @var{time}
  2636. Set segment duration to @var{time}, the value must be a duration
  2637. specification. Default value is "2". See also the
  2638. @option{segment_times} option.
  2639. Note that splitting may not be accurate, unless you force the
  2640. reference stream key-frames at the given time. See the introductory
  2641. notice and the examples below.
  2642. @item min_seg_duration @var{time}
  2643. Set minimum segment duration to @var{time}, the value must be a duration
  2644. specification. This prevents the muxer ending segments at a duration below
  2645. this value. Only effective with @code{segment_time}. Default value is "0".
  2646. @item segment_atclocktime @var{1|0}
  2647. If set to "1" split at regular clock time intervals starting from 00:00
  2648. o'clock. The @var{time} value specified in @option{segment_time} is
  2649. used for setting the length of the splitting interval.
  2650. For example with @option{segment_time} set to "900" this makes it possible
  2651. to create files at 12:00 o'clock, 12:15, 12:30, etc.
  2652. Default value is "0".
  2653. @item segment_clocktime_offset @var{duration}
  2654. Delay the segment splitting times with the specified duration when using
  2655. @option{segment_atclocktime}.
  2656. For example with @option{segment_time} set to "900" and
  2657. @option{segment_clocktime_offset} set to "300" this makes it possible to
  2658. create files at 12:05, 12:20, 12:35, etc.
  2659. Default value is "0".
  2660. @item segment_clocktime_wrap_duration @var{duration}
  2661. Force the segmenter to only start a new segment if a packet reaches the muxer
  2662. within the specified duration after the segmenting clock time. This way you
  2663. can make the segmenter more resilient to backward local time jumps, such as
  2664. leap seconds or transition to standard time from daylight savings time.
  2665. Default is the maximum possible duration which means starting a new segment
  2666. regardless of the elapsed time since the last clock time.
  2667. @item segment_time_delta @var{delta}
  2668. Specify the accuracy time when selecting the start time for a
  2669. segment, expressed as a duration specification. Default value is "0".
  2670. When delta is specified a key-frame will start a new segment if its
  2671. PTS satisfies the relation:
  2672. @example
  2673. PTS >= start_time - time_delta
  2674. @end example
  2675. This option is useful when splitting video content, which is always
  2676. split at GOP boundaries, in case a key frame is found just before the
  2677. specified split time.
  2678. In particular may be used in combination with the @file{ffmpeg} option
  2679. @var{force_key_frames}. The key frame times specified by
  2680. @var{force_key_frames} may not be set accurately because of rounding
  2681. issues, with the consequence that a key frame time may result set just
  2682. before the specified time. For constant frame rate videos a value of
  2683. 1/(2*@var{frame_rate}) should address the worst case mismatch between
  2684. the specified time and the time set by @var{force_key_frames}.
  2685. @item segment_times @var{times}
  2686. Specify a list of split points. @var{times} contains a list of comma
  2687. separated duration specifications, in increasing order. See also
  2688. the @option{segment_time} option.
  2689. @item segment_frames @var{frames}
  2690. Specify a list of split video frame numbers. @var{frames} contains a
  2691. list of comma separated integer numbers, in increasing order.
  2692. This option specifies to start a new segment whenever a reference
  2693. stream key frame is found and the sequential number (starting from 0)
  2694. of the frame is greater or equal to the next value in the list.
  2695. @item segment_wrap @var{limit}
  2696. Wrap around segment index once it reaches @var{limit}.
  2697. @item segment_start_number @var{number}
  2698. Set the sequence number of the first segment. Defaults to @code{0}.
  2699. @item strftime @var{1|0}
  2700. Use the @code{strftime} function to define the name of the new
  2701. segments to write. If this is selected, the output segment name must
  2702. contain a @code{strftime} function template. Default value is
  2703. @code{0}.
  2704. @item break_non_keyframes @var{1|0}
  2705. If enabled, allow segments to start on frames other than keyframes. This
  2706. improves behavior on some players when the time between keyframes is
  2707. inconsistent, but may make things worse on others, and can cause some oddities
  2708. during seeking. Defaults to @code{0}.
  2709. @item reset_timestamps @var{1|0}
  2710. Reset timestamps at the beginning of each segment, so that each segment
  2711. will start with near-zero timestamps. It is meant to ease the playback
  2712. of the generated segments. May not work with some combinations of
  2713. muxers/codecs. It is set to @code{0} by default.
  2714. @item initial_offset @var{offset}
  2715. Specify timestamp offset to apply to the output packet timestamps. The
  2716. argument must be a time duration specification, and defaults to 0.
  2717. @item write_empty_segments @var{1|0}
  2718. If enabled, write an empty segment if there are no packets during the period a
  2719. segment would usually span. Otherwise, the segment will be filled with the next
  2720. packet written. Defaults to @code{0}.
  2721. @end table
  2722. Make sure to require a closed GOP when encoding and to set the GOP
  2723. size to fit your segment time constraint.
  2724. @subsection Examples
  2725. @itemize
  2726. @item
  2727. Remux the content of file @file{in.mkv} to a list of segments
  2728. @file{out-000.nut}, @file{out-001.nut}, etc., and write the list of
  2729. generated segments to @file{out.list}:
  2730. @example
  2731. ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
  2732. @end example
  2733. @item
  2734. Segment input and set output format options for the output segments:
  2735. @example
  2736. ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
  2737. @end example
  2738. @item
  2739. Segment the input file according to the split points specified by the
  2740. @var{segment_times} option:
  2741. @example
  2742. 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
  2743. @end example
  2744. @item
  2745. Use the @command{ffmpeg} @option{force_key_frames}
  2746. option to force key frames in the input at the specified location, together
  2747. with the segment option @option{segment_time_delta} to account for
  2748. possible roundings operated when setting key frame times.
  2749. @example
  2750. ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
  2751. -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
  2752. @end example
  2753. In order to force key frames on the input file, transcoding is
  2754. required.
  2755. @item
  2756. Segment the input file by splitting the input file according to the
  2757. frame numbers sequence specified with the @option{segment_frames} option:
  2758. @example
  2759. ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
  2760. @end example
  2761. @item
  2762. Convert the @file{in.mkv} to TS segments using the @code{libx264}
  2763. and @code{aac} encoders:
  2764. @example
  2765. ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
  2766. @end example
  2767. @item
  2768. Segment the input file, and create an M3U8 live playlist (can be used
  2769. as live HLS source):
  2770. @example
  2771. ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
  2772. -segment_list_flags +live -segment_time 10 out%03d.mkv
  2773. @end example
  2774. @end itemize
  2775. @section smoothstreaming
  2776. Smooth Streaming muxer generates a set of files (Manifest, chunks) suitable for serving with conventional web server.
  2777. @table @option
  2778. @item window_size
  2779. Specify the number of fragments kept in the manifest. Default 0 (keep all).
  2780. @item extra_window_size
  2781. Specify the number of fragments kept outside of the manifest before removing from disk. Default 5.
  2782. @item lookahead_count
  2783. Specify the number of lookahead fragments. Default 2.
  2784. @item min_frag_duration
  2785. Specify the minimum fragment duration (in microseconds). Default 5000000.
  2786. @item remove_at_exit
  2787. Specify whether to remove all fragments when finished. Default 0 (do not remove).
  2788. @end table
  2789. @anchor{streamhash}
  2790. @section streamhash
  2791. Per stream hash testing format.
  2792. This muxer computes and prints a cryptographic hash of all the input frames,
  2793. on a per-stream basis. This can be used for equality checks without having
  2794. to do a complete binary comparison.
  2795. By default audio frames are converted to signed 16-bit raw audio and
  2796. video frames to raw video before computing the hash, but the output
  2797. of explicit conversions to other codecs can also be used. Timestamps
  2798. are ignored. It uses the SHA-256 cryptographic hash function by default,
  2799. but supports several other algorithms.
  2800. The output of the muxer consists of one line per stream of the form:
  2801. @var{streamindex},@var{streamtype},@var{algo}=@var{hash}, where
  2802. @var{streamindex} is the index of the mapped stream, @var{streamtype} is a
  2803. single character indicating the type of stream, @var{algo} is a short string
  2804. representing the hash function used, and @var{hash} is a hexadecimal number
  2805. representing the computed hash.
  2806. @table @option
  2807. @item hash @var{algorithm}
  2808. Use the cryptographic hash function specified by the string @var{algorithm}.
  2809. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  2810. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  2811. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  2812. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  2813. @end table
  2814. @subsection Examples
  2815. To compute the SHA-256 hash of the input converted to raw audio and
  2816. video, and store it in the file @file{out.sha256}:
  2817. @example
  2818. ffmpeg -i INPUT -f streamhash out.sha256
  2819. @end example
  2820. To print an MD5 hash to stdout use the command:
  2821. @example
  2822. ffmpeg -i INPUT -f streamhash -hash md5 -
  2823. @end example
  2824. See also the @ref{hash} and @ref{framehash} muxers.
  2825. @anchor{tee}
  2826. @section tee
  2827. The tee muxer can be used to write the same data to several outputs, such as files or streams.
  2828. It can be used, for example, to stream a video over a network and save it to disk at the same time.
  2829. It is different from specifying several outputs to the @command{ffmpeg}
  2830. command-line tool. With the tee muxer, the audio and video data will be encoded only once.
  2831. With conventional multiple outputs, multiple encoding operations in parallel are initiated,
  2832. which can be a very expensive process. The tee muxer is not useful when using the libavformat API
  2833. directly because it is then possible to feed the same packets to several muxers directly.
  2834. Since the tee muxer does not represent any particular output format, ffmpeg cannot auto-select
  2835. output streams. So all streams intended for output must be specified using @code{-map}. See
  2836. the examples below.
  2837. Some encoders may need different options depending on the output format;
  2838. the auto-detection of this can not work with the tee muxer, so they need to be explicitly specified.
  2839. The main example is the @option{global_header} flag.
  2840. The slave outputs are specified in the file name given to the muxer,
  2841. separated by '|'. If any of the slave name contains the '|' separator,
  2842. leading or trailing spaces or any special character, those must be
  2843. escaped (see @ref{quoting_and_escaping,,the "Quoting and escaping"
  2844. section in the ffmpeg-utils(1) manual,ffmpeg-utils}).
  2845. @subsection Options
  2846. @table @option
  2847. @item use_fifo @var{bool}
  2848. If set to 1, slave outputs will be processed in separate threads using the @ref{fifo}
  2849. muxer. This allows to compensate for different speed/latency/reliability of
  2850. outputs and setup transparent recovery. By default this feature is turned off.
  2851. @item fifo_options
  2852. Options to pass to fifo pseudo-muxer instances. See @ref{fifo}.
  2853. @end table
  2854. Muxer options can be specified for each slave by prepending them as a list of
  2855. @var{key}=@var{value} pairs separated by ':', between square brackets. If
  2856. the options values contain a special character or the ':' separator, they
  2857. must be escaped; note that this is a second level escaping.
  2858. The following special options are also recognized:
  2859. @table @option
  2860. @item f
  2861. Specify the format name. Required if it cannot be guessed from the
  2862. output URL.
  2863. @item bsfs[/@var{spec}]
  2864. Specify a list of bitstream filters to apply to the specified
  2865. output.
  2866. It is possible to specify to which streams a given bitstream filter
  2867. applies, by appending a stream specifier to the option separated by
  2868. @code{/}. @var{spec} must be a stream specifier (see @ref{Format
  2869. stream specifiers}).
  2870. If the stream specifier is not specified, the bitstream filters will be
  2871. applied to all streams in the output. This will cause that output operation
  2872. to fail if the output contains streams to which the bitstream filter cannot
  2873. be applied e.g. @code{h264_mp4toannexb} being applied to an output containing an audio stream.
  2874. Options for a bitstream filter must be specified in the form of @code{opt=value}.
  2875. Several bitstream filters can be specified, separated by ",".
  2876. @item use_fifo @var{bool}
  2877. This allows to override tee muxer use_fifo option for individual slave muxer.
  2878. @item fifo_options
  2879. This allows to override tee muxer fifo_options for individual slave muxer.
  2880. See @ref{fifo}.
  2881. @item select
  2882. Select the streams that should be mapped to the slave output,
  2883. specified by a stream specifier. If not specified, this defaults to
  2884. all the mapped streams. This will cause that output operation to fail
  2885. if the output format does not accept all mapped streams.
  2886. You may use multiple stream specifiers separated by commas (@code{,}) e.g.: @code{a:0,v}
  2887. @item onfail
  2888. Specify behaviour on output failure. This can be set to either @code{abort} (which is
  2889. default) or @code{ignore}. @code{abort} will cause whole process to fail in case of failure
  2890. on this slave output. @code{ignore} will ignore failure on this output, so other outputs
  2891. will continue without being affected.
  2892. @end table
  2893. @subsection Examples
  2894. @itemize
  2895. @item
  2896. Encode something and both archive it in a WebM file and stream it
  2897. as MPEG-TS over UDP:
  2898. @example
  2899. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  2900. "archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  2901. @end example
  2902. @item
  2903. As above, but continue streaming even if output to local file fails
  2904. (for example local drive fills up):
  2905. @example
  2906. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  2907. "[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  2908. @end example
  2909. @item
  2910. Use @command{ffmpeg} to encode the input, and send the output
  2911. to three different destinations. The @code{dump_extra} bitstream
  2912. filter is used to add extradata information to all the output video
  2913. keyframes packets, as requested by the MPEG-TS format. The select
  2914. option is applied to @file{out.aac} in order to make it contain only
  2915. audio packets.
  2916. @example
  2917. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
  2918. -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
  2919. @end example
  2920. @item
  2921. As above, but select only stream @code{a:1} for the audio output. Note
  2922. that a second level escaping must be performed, as ":" is a special
  2923. character used to separate options.
  2924. @example
  2925. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
  2926. -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"
  2927. @end example
  2928. @end itemize
  2929. @section webm_chunk
  2930. WebM Live Chunk Muxer.
  2931. This muxer writes out WebM headers and chunks as separate files which can be
  2932. consumed by clients that support WebM Live streams via DASH.
  2933. @subsection Options
  2934. This muxer supports the following options:
  2935. @table @option
  2936. @item chunk_start_index
  2937. Index of the first chunk (defaults to 0).
  2938. @item header
  2939. Filename of the header where the initialization data will be written.
  2940. @item audio_chunk_duration
  2941. Duration of each audio chunk in milliseconds (defaults to 5000).
  2942. @end table
  2943. @subsection Example
  2944. @example
  2945. ffmpeg -f v4l2 -i /dev/video0 \
  2946. -f alsa -i hw:0 \
  2947. -map 0:0 \
  2948. -c:v libvpx-vp9 \
  2949. -s 640x360 -keyint_min 30 -g 30 \
  2950. -f webm_chunk \
  2951. -header webm_live_video_360.hdr \
  2952. -chunk_start_index 1 \
  2953. webm_live_video_360_%d.chk \
  2954. -map 1:0 \
  2955. -c:a libvorbis \
  2956. -b:a 128k \
  2957. -f webm_chunk \
  2958. -header webm_live_audio_128.hdr \
  2959. -chunk_start_index 1 \
  2960. -audio_chunk_duration 1000 \
  2961. webm_live_audio_128_%d.chk
  2962. @end example
  2963. @section webm_dash_manifest
  2964. WebM DASH Manifest muxer.
  2965. This muxer implements the WebM DASH Manifest specification to generate the DASH
  2966. manifest XML. It also supports manifest generation for DASH live streams.
  2967. For more information see:
  2968. @itemize @bullet
  2969. @item
  2970. WebM DASH Specification: @url{https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification}
  2971. @item
  2972. ISO DASH Specification: @url{http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip}
  2973. @end itemize
  2974. @subsection Options
  2975. This muxer supports the following options:
  2976. @table @option
  2977. @item adaptation_sets
  2978. This option has the following syntax: "id=x,streams=a,b,c id=y,streams=d,e" where x and y are the
  2979. unique identifiers of the adaptation sets and a,b,c,d and e are the indices of the corresponding
  2980. audio and video streams. Any number of adaptation sets can be added using this option.
  2981. @item live
  2982. Set this to 1 to create a live stream DASH Manifest. Default: 0.
  2983. @item chunk_start_index
  2984. Start index of the first chunk. This will go in the @samp{startNumber} attribute
  2985. of the @samp{SegmentTemplate} element in the manifest. Default: 0.
  2986. @item chunk_duration_ms
  2987. Duration of each chunk in milliseconds. This will go in the @samp{duration}
  2988. attribute of the @samp{SegmentTemplate} element in the manifest. Default: 1000.
  2989. @item utc_timing_url
  2990. URL of the page that will return the UTC timestamp in ISO format. This will go
  2991. in the @samp{value} attribute of the @samp{UTCTiming} element in the manifest.
  2992. Default: None.
  2993. @item time_shift_buffer_depth
  2994. Smallest time (in seconds) shifting buffer for which any Representation is
  2995. guaranteed to be available. This will go in the @samp{timeShiftBufferDepth}
  2996. attribute of the @samp{MPD} element. Default: 60.
  2997. @item minimum_update_period
  2998. Minimum update period (in seconds) of the manifest. This will go in the
  2999. @samp{minimumUpdatePeriod} attribute of the @samp{MPD} element. Default: 0.
  3000. @end table
  3001. @subsection Example
  3002. @example
  3003. ffmpeg -f webm_dash_manifest -i video1.webm \
  3004. -f webm_dash_manifest -i video2.webm \
  3005. -f webm_dash_manifest -i audio1.webm \
  3006. -f webm_dash_manifest -i audio2.webm \
  3007. -map 0 -map 1 -map 2 -map 3 \
  3008. -c copy \
  3009. -f webm_dash_manifest \
  3010. -adaptation_sets "id=0,streams=0,1 id=1,streams=2,3" \
  3011. manifest.xml
  3012. @end example
  3013. @c man end MUXERS