muxers.texi 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619
  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{-formats} of the ff* tools will display the list of
  13. enabled muxers.
  14. A description of some of the currently available muxers follows.
  15. @anchor{aiff}
  16. @section aiff
  17. Audio Interchange File Format muxer.
  18. @subsection Options
  19. It accepts the following options:
  20. @table @option
  21. @item write_id3v2
  22. Enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
  23. @item id3v2_version
  24. Select ID3v2 version to write. Currently only version 3 and 4 (aka.
  25. ID3v2.3 and ID3v2.4) are supported. The default is version 4.
  26. @end table
  27. @anchor{asf}
  28. @section asf
  29. Advanced Systems Format muxer.
  30. Note that Windows Media Audio (wma) and Windows Media Video (wmv) use this
  31. muxer too.
  32. @subsection Options
  33. It accepts the following options:
  34. @table @option
  35. @item packet_size
  36. Set the muxer packet size. By tuning this setting you may reduce data
  37. fragmentation or muxer overhead depending on your source. Default value is
  38. 3200, minimum is 100, maximum is 64k.
  39. @end table
  40. @anchor{chromaprint}
  41. @section chromaprint
  42. Chromaprint fingerprinter
  43. This muxer feeds audio data to the Chromaprint library, which generates
  44. a fingerprint for the provided audio data. It takes a single signed
  45. native-endian 16-bit raw audio stream.
  46. @subsection Options
  47. @table @option
  48. @item silence_threshold
  49. Threshold for detecting silence, ranges from 0 to 32767. -1 for default
  50. (required for use with the AcoustID service).
  51. @item algorithm
  52. Algorithm index to fingerprint with.
  53. @item fp_format
  54. Format to output the fingerprint as. Accepts the following options:
  55. @table @samp
  56. @item raw
  57. Binary raw fingerprint
  58. @item compressed
  59. Binary compressed fingerprint
  60. @item base64
  61. Base64 compressed fingerprint
  62. @end table
  63. @end table
  64. @anchor{crc}
  65. @section crc
  66. CRC (Cyclic Redundancy Check) testing format.
  67. This muxer computes and prints the Adler-32 CRC of all the input audio
  68. and video frames. By default audio frames are converted to signed
  69. 16-bit raw audio and video frames to raw video before computing the
  70. CRC.
  71. The output of the muxer consists of a single line of the form:
  72. CRC=0x@var{CRC}, where @var{CRC} is a hexadecimal number 0-padded to
  73. 8 digits containing the CRC for all the decoded input frames.
  74. See also the @ref{framecrc} muxer.
  75. @subsection Examples
  76. For example to compute the CRC of the input, and store it in the file
  77. @file{out.crc}:
  78. @example
  79. ffmpeg -i INPUT -f crc out.crc
  80. @end example
  81. You can print the CRC to stdout with the command:
  82. @example
  83. ffmpeg -i INPUT -f crc -
  84. @end example
  85. You can select the output format of each frame with @command{ffmpeg} by
  86. specifying the audio and video codec and format. For example to
  87. compute the CRC of the input audio converted to PCM unsigned 8-bit
  88. and the input video converted to MPEG-2 video, use the command:
  89. @example
  90. ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
  91. @end example
  92. @anchor{framecrc}
  93. @section framecrc
  94. Per-packet CRC (Cyclic Redundancy Check) testing format.
  95. This muxer computes and prints the Adler-32 CRC for each audio
  96. and video packet. By default audio frames are converted to signed
  97. 16-bit raw audio and video frames to raw video before computing the
  98. CRC.
  99. The output of the muxer consists of a line for each audio and video
  100. packet of the form:
  101. @example
  102. @var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, 0x@var{CRC}
  103. @end example
  104. @var{CRC} is a hexadecimal number 0-padded to 8 digits containing the
  105. CRC of the packet.
  106. @subsection Examples
  107. For example to compute the CRC of the audio and video frames in
  108. @file{INPUT}, converted to raw audio and video packets, and store it
  109. in the file @file{out.crc}:
  110. @example
  111. ffmpeg -i INPUT -f framecrc out.crc
  112. @end example
  113. To print the information to stdout, use the command:
  114. @example
  115. ffmpeg -i INPUT -f framecrc -
  116. @end example
  117. With @command{ffmpeg}, you can select the output format to which the
  118. audio and video frames are encoded before computing the CRC for each
  119. packet by specifying the audio and video codec. For example, to
  120. compute the CRC of each decoded input audio frame converted to PCM
  121. unsigned 8-bit and of each decoded input video frame converted to
  122. MPEG-2 video, use the command:
  123. @example
  124. ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
  125. @end example
  126. See also the @ref{crc} muxer.
  127. @anchor{framehash}
  128. @section framehash
  129. Per-packet hash testing format.
  130. This muxer computes and prints a cryptographic hash for each audio
  131. and video packet. This can be used for packet-by-packet equality
  132. checks without having to individually do a binary comparison on each.
  133. By default audio frames are converted to signed 16-bit raw audio and
  134. video frames to raw video before computing the hash, but the output
  135. of explicit conversions to other codecs can also be used. It uses the
  136. SHA-256 cryptographic hash function by default, but supports several
  137. other algorithms.
  138. The output of the muxer consists of a line for each audio and video
  139. packet of the form:
  140. @example
  141. @var{stream_index}, @var{packet_dts}, @var{packet_pts}, @var{packet_duration}, @var{packet_size}, @var{hash}
  142. @end example
  143. @var{hash} is a hexadecimal number representing the computed hash
  144. for the packet.
  145. @table @option
  146. @item hash @var{algorithm}
  147. Use the cryptographic hash function specified by the string @var{algorithm}.
  148. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  149. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  150. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  151. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  152. @end table
  153. @subsection Examples
  154. To compute the SHA-256 hash of the audio and video frames in @file{INPUT},
  155. converted to raw audio and video packets, and store it in the file
  156. @file{out.sha256}:
  157. @example
  158. ffmpeg -i INPUT -f framehash out.sha256
  159. @end example
  160. To print the information to stdout, using the MD5 hash function, use
  161. the command:
  162. @example
  163. ffmpeg -i INPUT -f framehash -hash md5 -
  164. @end example
  165. See also the @ref{hash} muxer.
  166. @anchor{framemd5}
  167. @section framemd5
  168. Per-packet MD5 testing format.
  169. This is a variant of the @ref{framehash} muxer. Unlike that muxer,
  170. it defaults to using the MD5 hash function.
  171. @subsection Examples
  172. To compute the MD5 hash of the audio and video frames in @file{INPUT},
  173. converted to raw audio and video packets, and store it in the file
  174. @file{out.md5}:
  175. @example
  176. ffmpeg -i INPUT -f framemd5 out.md5
  177. @end example
  178. To print the information to stdout, use the command:
  179. @example
  180. ffmpeg -i INPUT -f framemd5 -
  181. @end example
  182. See also the @ref{framehash} and @ref{md5} muxers.
  183. @anchor{gif}
  184. @section gif
  185. Animated GIF muxer.
  186. It accepts the following options:
  187. @table @option
  188. @item loop
  189. Set the number of times to loop the output. Use @code{-1} for no loop, @code{0}
  190. for looping indefinitely (default).
  191. @item final_delay
  192. Force the delay (expressed in centiseconds) after the last frame. Each frame
  193. ends with a delay until the next frame. The default is @code{-1}, which is a
  194. special value to tell the muxer to re-use the previous delay. In case of a
  195. loop, you might want to customize this value to mark a pause for instance.
  196. @end table
  197. For example, to encode a gif looping 10 times, with a 5 seconds delay between
  198. the loops:
  199. @example
  200. ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif
  201. @end example
  202. Note 1: if you wish to extract the frames into separate GIF files, you need to
  203. force the @ref{image2} muxer:
  204. @example
  205. ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"
  206. @end example
  207. Note 2: the GIF format has a very large time base: the delay between two frames
  208. can therefore not be smaller than one centi second.
  209. @anchor{hash}
  210. @section hash
  211. Hash testing format.
  212. This muxer computes and prints a cryptographic hash of all the input
  213. audio and video frames. This can be used for equality checks without
  214. having to do a complete binary comparison.
  215. By default audio frames are converted to signed 16-bit raw audio and
  216. video frames to raw video before computing the hash, but the output
  217. of explicit conversions to other codecs can also be used. Timestamps
  218. are ignored. It uses the SHA-256 cryptographic hash function by default,
  219. but supports several other algorithms.
  220. The output of the muxer consists of a single line of the form:
  221. @var{algo}=@var{hash}, where @var{algo} is a short string representing
  222. the hash function used, and @var{hash} is a hexadecimal number
  223. representing the computed hash.
  224. @table @option
  225. @item hash @var{algorithm}
  226. Use the cryptographic hash function specified by the string @var{algorithm}.
  227. Supported values include @code{MD5}, @code{murmur3}, @code{RIPEMD128},
  228. @code{RIPEMD160}, @code{RIPEMD256}, @code{RIPEMD320}, @code{SHA160},
  229. @code{SHA224}, @code{SHA256} (default), @code{SHA512/224}, @code{SHA512/256},
  230. @code{SHA384}, @code{SHA512}, @code{CRC32} and @code{adler32}.
  231. @end table
  232. @subsection Examples
  233. To compute the SHA-256 hash of the input converted to raw audio and
  234. video, and store it in the file @file{out.sha256}:
  235. @example
  236. ffmpeg -i INPUT -f hash out.sha256
  237. @end example
  238. To print an MD5 hash to stdout use the command:
  239. @example
  240. ffmpeg -i INPUT -f hash -hash md5 -
  241. @end example
  242. See also the @ref{framehash} muxer.
  243. @anchor{hls}
  244. @section hls
  245. Apple HTTP Live Streaming muxer that segments MPEG-TS according to
  246. the HTTP Live Streaming (HLS) specification.
  247. It creates a playlist file, and one or more segment files. The output filename
  248. specifies the playlist filename.
  249. By default, the muxer creates a file for each segment produced. These files
  250. have the same name as the playlist, followed by a sequential number and a
  251. .ts extension.
  252. For example, to convert an input file with @command{ffmpeg}:
  253. @example
  254. ffmpeg -i in.nut out.m3u8
  255. @end example
  256. This example will produce the playlist, @file{out.m3u8}, and segment files:
  257. @file{out0.ts}, @file{out1.ts}, @file{out2.ts}, etc.
  258. See also the @ref{segment} muxer, which provides a more generic and
  259. flexible implementation of a segmenter, and can be used to perform HLS
  260. segmentation.
  261. @subsection Options
  262. This muxer supports the following options:
  263. @table @option
  264. @item hls_time @var{seconds}
  265. Set the target segment length in seconds. Default value is 2.
  266. Segment will be cut on the next key frame after this time has passed.
  267. @item hls_list_size @var{size}
  268. Set the maximum number of playlist entries. If set to 0 the list file
  269. will contain all the segments. Default value is 5.
  270. @item hls_ts_options @var{options_list}
  271. Set output format options using a :-separated list of key=value
  272. parameters. Values containing @code{:} special characters must be
  273. escaped.
  274. @item hls_wrap @var{wrap}
  275. Set the number after which the segment filename number (the number
  276. specified in each segment file) wraps. If set to 0 the number will be
  277. never wrapped. Default value is 0.
  278. This option is useful to avoid to fill the disk with many segment
  279. files, and limits the maximum number of segment files written to disk
  280. to @var{wrap}.
  281. @item start_number @var{number}
  282. Start the playlist sequence number from @var{number}. Default value is
  283. 0.
  284. @item hls_allow_cache @var{allowcache}
  285. Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
  286. @item hls_base_url @var{baseurl}
  287. Append @var{baseurl} to every entry in the playlist.
  288. Useful to generate playlists with absolute paths.
  289. Note that the playlist sequence number must be unique for each segment
  290. and it is not to be confused with the segment filename sequence number
  291. which can be cyclic, for example if the @option{wrap} option is
  292. specified.
  293. @item hls_segment_filename @var{filename}
  294. Set the segment filename. Unless hls_flags single_file is set @var{filename}
  295. is used as a string format with the segment number:
  296. @example
  297. ffmpeg in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
  298. @end example
  299. This example will produce the playlist, @file{out.m3u8}, and segment files:
  300. @file{file000.ts}, @file{file001.ts}, @file{file002.ts}, etc.
  301. @item use_localtime
  302. Use strftime on @var{filename} to expand the segment filename with localtime.
  303. The segment number (%d) is not available in this mode.
  304. @example
  305. ffmpeg in.nut -use_localtime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
  306. @end example
  307. This example will produce the playlist, @file{out.m3u8}, and segment files:
  308. @file{file-20160215-1455569023.ts}, @file{file-20160215-1455569024.ts}, etc.
  309. @item use_localtime_mkdir
  310. Used together with -use_localtime, it will create up to one subdirectory which
  311. is expanded in @var{filename}.
  312. @example
  313. ffmpeg in.nut -use_localtime 1 -use_localtime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
  314. @end example
  315. This example will create a directory 201560215 (if it does not exist), and then
  316. produce the playlist, @file{out.m3u8}, and segment files:
  317. @file{201560215/file-20160215-1455569023.ts}, @file{201560215/file-20160215-1455569024.ts}, etc.
  318. @item hls_key_info_file @var{key_info_file}
  319. Use the information in @var{key_info_file} for segment encryption. The first
  320. line of @var{key_info_file} specifies the key URI written to the playlist. The
  321. key URL is used to access the encryption key during playback. The second line
  322. specifies the path to the key file used to obtain the key during the encryption
  323. process. The key file is read as a single packed array of 16 octets in binary
  324. format. The optional third line specifies the initialization vector (IV) as a
  325. hexadecimal string to be used instead of the segment sequence number (default)
  326. for encryption. Changes to @var{key_info_file} will result in segment
  327. encryption with the new key/IV and an entry in the playlist for the new key
  328. URI/IV.
  329. Key info file format:
  330. @example
  331. @var{key URI}
  332. @var{key file path}
  333. @var{IV} (optional)
  334. @end example
  335. Example key URIs:
  336. @example
  337. http://server/file.key
  338. /path/to/file.key
  339. file.key
  340. @end example
  341. Example key file paths:
  342. @example
  343. file.key
  344. /path/to/file.key
  345. @end example
  346. Example IV:
  347. @example
  348. 0123456789ABCDEF0123456789ABCDEF
  349. @end example
  350. Key info file example:
  351. @example
  352. http://server/file.key
  353. /path/to/file.key
  354. 0123456789ABCDEF0123456789ABCDEF
  355. @end example
  356. Example shell script:
  357. @example
  358. #!/bin/sh
  359. BASE_URL=$@{1:-'.'@}
  360. openssl rand 16 > file.key
  361. echo $BASE_URL/file.key > file.keyinfo
  362. echo file.key >> file.keyinfo
  363. echo $(openssl rand -hex 16) >> file.keyinfo
  364. ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
  365. -hls_key_info_file file.keyinfo out.m3u8
  366. @end example
  367. @item hls_flags single_file
  368. If this flag is set, the muxer will store all segments in a single MPEG-TS
  369. file, and will use byte ranges in the playlist. HLS playlists generated with
  370. this way will have the version number 4.
  371. For example:
  372. @example
  373. ffmpeg -i in.nut -hls_flags single_file out.m3u8
  374. @end example
  375. Will produce the playlist, @file{out.m3u8}, and a single segment file,
  376. @file{out.ts}.
  377. @item hls_flags delete_segments
  378. Segment files removed from the playlist are deleted after a period of time
  379. equal to the duration of the segment plus the duration of the playlist.
  380. @item hls_playlist_type event
  381. Emit @code{#EXT-X-PLAYLIST-TYPE:EVENT} in the m3u8 header. Forces
  382. @option{hls_list_size} to 0; the playlist can only be appended to.
  383. @item hls_playlist_type vod
  384. Emit @code{#EXT-X-PLAYLIST-TYPE:VOD} in the m3u8 header. Forces
  385. @option{hls_list_size} to 0; the playlist must not change.
  386. @end table
  387. @anchor{ico}
  388. @section ico
  389. ICO file muxer.
  390. Microsoft's icon file format (ICO) has some strict limitations that should be noted:
  391. @itemize
  392. @item
  393. Size cannot exceed 256 pixels in any dimension
  394. @item
  395. Only BMP and PNG images can be stored
  396. @item
  397. If a BMP image is used, it must be one of the following pixel formats:
  398. @example
  399. BMP Bit Depth FFmpeg Pixel Format
  400. 1bit pal8
  401. 4bit pal8
  402. 8bit pal8
  403. 16bit rgb555le
  404. 24bit bgr24
  405. 32bit bgra
  406. @end example
  407. @item
  408. If a BMP image is used, it must use the BITMAPINFOHEADER DIB header
  409. @item
  410. If a PNG image is used, it must use the rgba pixel format
  411. @end itemize
  412. @anchor{image2}
  413. @section image2
  414. Image file muxer.
  415. The image file muxer writes video frames to image files.
  416. The output filenames are specified by a pattern, which can be used to
  417. produce sequentially numbered series of files.
  418. The pattern may contain the string "%d" or "%0@var{N}d", this string
  419. specifies the position of the characters representing a numbering in
  420. the filenames. If the form "%0@var{N}d" is used, the string
  421. representing the number in each filename is 0-padded to @var{N}
  422. digits. The literal character '%' can be specified in the pattern with
  423. the string "%%".
  424. If the pattern contains "%d" or "%0@var{N}d", the first filename of
  425. the file list specified will contain the number 1, all the following
  426. numbers will be sequential.
  427. The pattern may contain a suffix which is used to automatically
  428. determine the format of the image files to write.
  429. For example the pattern "img-%03d.bmp" will specify a sequence of
  430. filenames of the form @file{img-001.bmp}, @file{img-002.bmp}, ...,
  431. @file{img-010.bmp}, etc.
  432. The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
  433. form @file{img%-1.jpg}, @file{img%-2.jpg}, ..., @file{img%-10.jpg},
  434. etc.
  435. @subsection Examples
  436. The following example shows how to use @command{ffmpeg} for creating a
  437. sequence of files @file{img-001.jpeg}, @file{img-002.jpeg}, ...,
  438. taking one image every second from the input video:
  439. @example
  440. ffmpeg -i in.avi -vsync 1 -r 1 -f image2 'img-%03d.jpeg'
  441. @end example
  442. Note that with @command{ffmpeg}, if the format is not specified with the
  443. @code{-f} option and the output filename specifies an image file
  444. format, the image2 muxer is automatically selected, so the previous
  445. command can be written as:
  446. @example
  447. ffmpeg -i in.avi -vsync 1 -r 1 'img-%03d.jpeg'
  448. @end example
  449. Note also that the pattern must not necessarily contain "%d" or
  450. "%0@var{N}d", for example to create a single image file
  451. @file{img.jpeg} from the input video you can employ the command:
  452. @example
  453. ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
  454. @end example
  455. The @option{strftime} option allows you to expand the filename with
  456. date and time information. Check the documentation of
  457. the @code{strftime()} function for the syntax.
  458. For example to generate image files from the @code{strftime()}
  459. "%Y-%m-%d_%H-%M-%S" pattern, the following @command{ffmpeg} command
  460. can be used:
  461. @example
  462. ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"
  463. @end example
  464. @subsection Options
  465. @table @option
  466. @item start_number
  467. Start the sequence from the specified number. Default value is 0.
  468. @item update
  469. If set to 1, the filename will always be interpreted as just a
  470. filename, not a pattern, and the corresponding file will be continuously
  471. overwritten with new images. Default value is 0.
  472. @item strftime
  473. If set to 1, expand the filename with date and time information from
  474. @code{strftime()}. Default value is 0.
  475. @end table
  476. The image muxer supports the .Y.U.V image file format. This format is
  477. special in that that each image frame consists of three files, for
  478. each of the YUV420P components. To read or write this image file format,
  479. specify the name of the '.Y' file. The muxer will automatically open the
  480. '.U' and '.V' files as required.
  481. @section matroska
  482. Matroska container muxer.
  483. This muxer implements the matroska and webm container specs.
  484. @subsection Metadata
  485. The recognized metadata settings in this muxer are:
  486. @table @option
  487. @item title
  488. Set title name provided to a single track.
  489. @item language
  490. Specify the language of the track in the Matroska languages form.
  491. The language can be either the 3 letters bibliographic ISO-639-2 (ISO
  492. 639-2/B) form (like "fre" for French), or a language code mixed with a
  493. country code for specialities in languages (like "fre-ca" for Canadian
  494. French).
  495. @item stereo_mode
  496. Set stereo 3D video layout of two views in a single video track.
  497. The following values are recognized:
  498. @table @samp
  499. @item mono
  500. video is not stereo
  501. @item left_right
  502. Both views are arranged side by side, Left-eye view is on the left
  503. @item bottom_top
  504. Both views are arranged in top-bottom orientation, Left-eye view is at bottom
  505. @item top_bottom
  506. Both views are arranged in top-bottom orientation, Left-eye view is on top
  507. @item checkerboard_rl
  508. Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
  509. @item checkerboard_lr
  510. Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
  511. @item row_interleaved_rl
  512. Each view is constituted by a row based interleaving, Right-eye view is first row
  513. @item row_interleaved_lr
  514. Each view is constituted by a row based interleaving, Left-eye view is first row
  515. @item col_interleaved_rl
  516. Both views are arranged in a column based interleaving manner, Right-eye view is first column
  517. @item col_interleaved_lr
  518. Both views are arranged in a column based interleaving manner, Left-eye view is first column
  519. @item anaglyph_cyan_red
  520. All frames are in anaglyph format viewable through red-cyan filters
  521. @item right_left
  522. Both views are arranged side by side, Right-eye view is on the left
  523. @item anaglyph_green_magenta
  524. All frames are in anaglyph format viewable through green-magenta filters
  525. @item block_lr
  526. Both eyes laced in one Block, Left-eye view is first
  527. @item block_rl
  528. Both eyes laced in one Block, Right-eye view is first
  529. @end table
  530. @end table
  531. For example a 3D WebM clip can be created using the following command line:
  532. @example
  533. ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
  534. @end example
  535. @subsection Options
  536. This muxer supports the following options:
  537. @table @option
  538. @item reserve_index_space
  539. By default, this muxer writes the index for seeking (called cues in Matroska
  540. terms) at the end of the file, because it cannot know in advance how much space
  541. to leave for the index at the beginning of the file. However for some use cases
  542. -- e.g. streaming where seeking is possible but slow -- it is useful to put the
  543. index at the beginning of the file.
  544. If this option is set to a non-zero value, the muxer will reserve a given amount
  545. of space in the file header and then try to write the cues there when the muxing
  546. finishes. If the available space does not suffice, muxing will fail. A safe size
  547. for most use cases should be about 50kB per hour of video.
  548. Note that cues are only written if the output is seekable and this option will
  549. have no effect if it is not.
  550. @end table
  551. @anchor{md5}
  552. @section md5
  553. MD5 testing format.
  554. This is a variant of the @ref{hash} muxer. Unlike that muxer, it
  555. defaults to using the MD5 hash function.
  556. @subsection Examples
  557. To compute the MD5 hash of the input converted to raw
  558. audio and video, and store it in the file @file{out.md5}:
  559. @example
  560. ffmpeg -i INPUT -f md5 out.md5
  561. @end example
  562. You can print the MD5 to stdout with the command:
  563. @example
  564. ffmpeg -i INPUT -f md5 -
  565. @end example
  566. See also the @ref{hash} and @ref{framemd5} muxers.
  567. @section mov, mp4, ismv
  568. MOV/MP4/ISMV (Smooth Streaming) muxer.
  569. The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4
  570. file has all the metadata about all packets stored in one location
  571. (written at the end of the file, it can be moved to the start for
  572. better playback by adding @var{faststart} to the @var{movflags}, or
  573. using the @command{qt-faststart} tool). A fragmented
  574. file consists of a number of fragments, where packets and metadata
  575. about these packets are stored together. Writing a fragmented
  576. file has the advantage that the file is decodable even if the
  577. writing is interrupted (while a normal MOV/MP4 is undecodable if
  578. it is not properly finished), and it requires less memory when writing
  579. very long files (since writing normal MOV/MP4 files stores info about
  580. every single packet in memory until the file is closed). The downside
  581. is that it is less compatible with other applications.
  582. @subsection Options
  583. Fragmentation is enabled by setting one of the AVOptions that define
  584. how to cut the file into fragments:
  585. @table @option
  586. @item -moov_size @var{bytes}
  587. Reserves space for the moov atom at the beginning of the file instead of placing the
  588. moov atom at the end. If the space reserved is insufficient, muxing will fail.
  589. @item -movflags frag_keyframe
  590. Start a new fragment at each video keyframe.
  591. @item -frag_duration @var{duration}
  592. Create fragments that are @var{duration} microseconds long.
  593. @item -frag_size @var{size}
  594. Create fragments that contain up to @var{size} bytes of payload data.
  595. @item -movflags frag_custom
  596. Allow the caller to manually choose when to cut fragments, by
  597. calling @code{av_write_frame(ctx, NULL)} to write a fragment with
  598. the packets written so far. (This is only useful with other
  599. applications integrating libavformat, not from @command{ffmpeg}.)
  600. @item -min_frag_duration @var{duration}
  601. Don't create fragments that are shorter than @var{duration} microseconds long.
  602. @end table
  603. If more than one condition is specified, fragments are cut when
  604. one of the specified conditions is fulfilled. The exception to this is
  605. @code{-min_frag_duration}, which has to be fulfilled for any of the other
  606. conditions to apply.
  607. Additionally, the way the output file is written can be adjusted
  608. through a few other options:
  609. @table @option
  610. @item -movflags empty_moov
  611. Write an initial moov atom directly at the start of the file, without
  612. describing any samples in it. Generally, an mdat/moov pair is written
  613. at the start of the file, as a normal MOV/MP4 file, containing only
  614. a short portion of the file. With this option set, there is no initial
  615. mdat atom, and the moov atom only describes the tracks but has
  616. a zero duration.
  617. This option is implicitly set when writing ismv (Smooth Streaming) files.
  618. @item -movflags separate_moof
  619. Write a separate moof (movie fragment) atom for each track. Normally,
  620. packets for all tracks are written in a moof atom (which is slightly
  621. more efficient), but with this option set, the muxer writes one moof/mdat
  622. pair for each track, making it easier to separate tracks.
  623. This option is implicitly set when writing ismv (Smooth Streaming) files.
  624. @item -movflags faststart
  625. Run a second pass moving the index (moov atom) to the beginning of the file.
  626. This operation can take a while, and will not work in various situations such
  627. as fragmented output, thus it is not enabled by default.
  628. @item -movflags rtphint
  629. Add RTP hinting tracks to the output file.
  630. @item -movflags disable_chpl
  631. Disable Nero chapter markers (chpl atom). Normally, both Nero chapters
  632. and a QuickTime chapter track are written to the file. With this option
  633. set, only the QuickTime chapter track will be written. Nero chapters can
  634. cause failures when the file is reprocessed with certain tagging programs, like
  635. mp3Tag 2.61a and iTunes 11.3, most likely other versions are affected as well.
  636. @item -movflags omit_tfhd_offset
  637. Do not write any absolute base_data_offset in tfhd atoms. This avoids
  638. tying fragments to absolute byte positions in the file/streams.
  639. @item -movflags default_base_moof
  640. Similarly to the omit_tfhd_offset, this flag avoids writing the
  641. absolute base_data_offset field in tfhd atoms, but does so by using
  642. the new default-base-is-moof flag instead. This flag is new from
  643. 14496-12:2012. This may make the fragments easier to parse in certain
  644. circumstances (avoiding basing track fragment location calculations
  645. on the implicit end of the previous track fragment).
  646. @end table
  647. @subsection Example
  648. Smooth Streaming content can be pushed in real time to a publishing
  649. point on IIS with this muxer. Example:
  650. @example
  651. ffmpeg -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)
  652. @end example
  653. @subsection Audible AAX
  654. Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret.
  655. @example
  656. ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4
  657. @end example
  658. @section mp3
  659. The MP3 muxer writes a raw MP3 stream with the following optional features:
  660. @itemize @bullet
  661. @item
  662. An ID3v2 metadata header at the beginning (enabled by default). Versions 2.3 and
  663. 2.4 are supported, the @code{id3v2_version} private option controls which one is
  664. used (3 or 4). Setting @code{id3v2_version} to 0 disables the ID3v2 header
  665. completely.
  666. The muxer supports writing attached pictures (APIC frames) to the ID3v2 header.
  667. The pictures are supplied to the muxer in form of a video stream with a single
  668. packet. There can be any number of those streams, each will correspond to a
  669. single APIC frame. The stream metadata tags @var{title} and @var{comment} map
  670. to APIC @var{description} and @var{picture type} respectively. See
  671. @url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
  672. Note that the APIC frames must be written at the beginning, so the muxer will
  673. buffer the audio frames until it gets all the pictures. It is therefore advised
  674. to provide the pictures as soon as possible to avoid excessive buffering.
  675. @item
  676. A Xing/LAME frame right after the ID3v2 header (if present). It is enabled by
  677. default, but will be written only if the output is seekable. The
  678. @code{write_xing} private option can be used to disable it. The frame contains
  679. various information that may be useful to the decoder, like the audio duration
  680. or encoder delay.
  681. @item
  682. A legacy ID3v1 tag at the end of the file (disabled by default). It may be
  683. enabled with the @code{write_id3v1} private option, but as its capabilities are
  684. very limited, its usage is not recommended.
  685. @end itemize
  686. Examples:
  687. Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
  688. @example
  689. ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
  690. @end example
  691. To attach a picture to an mp3 file select both the audio and the picture stream
  692. with @code{map}:
  693. @example
  694. ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1
  695. -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
  696. @end example
  697. Write a "clean" MP3 without any extra features:
  698. @example
  699. ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
  700. @end example
  701. @section mpegts
  702. MPEG transport stream muxer.
  703. This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
  704. The recognized metadata settings in mpegts muxer are @code{service_provider}
  705. and @code{service_name}. If they are not set the default for
  706. @code{service_provider} is "FFmpeg" and the default for
  707. @code{service_name} is "Service01".
  708. @subsection Options
  709. The muxer options are:
  710. @table @option
  711. @item mpegts_original_network_id @var{number}
  712. Set the original_network_id (default 0x0001). This is unique identifier
  713. of a network in DVB. Its main use is in the unique identification of a
  714. service through the path Original_Network_ID, Transport_Stream_ID.
  715. @item mpegts_transport_stream_id @var{number}
  716. Set the transport_stream_id (default 0x0001). This identifies a
  717. transponder in DVB.
  718. @item mpegts_service_id @var{number}
  719. Set the service_id (default 0x0001) also known as program in DVB.
  720. @item mpegts_service_type @var{number}
  721. Set the program service_type (default @var{digital_tv}), see below
  722. a list of pre defined values.
  723. @item mpegts_pmt_start_pid @var{number}
  724. Set the first PID for PMT (default 0x1000, max 0x1f00).
  725. @item mpegts_start_pid @var{number}
  726. Set the first PID for data packets (default 0x0100, max 0x0f00).
  727. @item mpegts_m2ts_mode @var{number}
  728. Enable m2ts mode if set to 1. Default value is -1 which disables m2ts mode.
  729. @item muxrate @var{number}
  730. Set a constant muxrate (default VBR).
  731. @item pcr_period @var{numer}
  732. Override the default PCR retransmission time (default 20ms), ignored
  733. if variable muxrate is selected.
  734. @item pat_period @var{number}
  735. Maximal time in seconds between PAT/PMT tables.
  736. @item sdt_period @var{number}
  737. Maximal time in seconds between SDT tables.
  738. @item pes_payload_size @var{number}
  739. Set minimum PES packet payload in bytes.
  740. @item mpegts_flags @var{flags}
  741. Set flags (see below).
  742. @item mpegts_copyts @var{number}
  743. Preserve original timestamps, if value is set to 1. Default value is -1, which
  744. results in shifting timestamps so that they start from 0.
  745. @item tables_version @var{number}
  746. Set PAT, PMT and SDT version (default 0, valid values are from 0 to 31, inclusively).
  747. This option allows updating stream structure so that standard consumer may
  748. detect the change. To do so, reopen output AVFormatContext (in case of API
  749. usage) or restart ffmpeg instance, cyclically changing tables_version value:
  750. @example
  751. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  752. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  753. ...
  754. ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
  755. ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
  756. ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
  757. ...
  758. @end example
  759. @end table
  760. Option @option{mpegts_service_type} accepts the following values:
  761. @table @option
  762. @item hex_value
  763. Any hexdecimal value between 0x01 to 0xff as defined in ETSI 300 468.
  764. @item digital_tv
  765. Digital TV service.
  766. @item digital_radio
  767. Digital Radio service.
  768. @item teletext
  769. Teletext service.
  770. @item advanced_codec_digital_radio
  771. Advanced Codec Digital Radio service.
  772. @item mpeg2_digital_hdtv
  773. MPEG2 Digital HDTV service.
  774. @item advanced_codec_digital_sdtv
  775. Advanced Codec Digital SDTV service.
  776. @item advanced_codec_digital_hdtv
  777. Advanced Codec Digital HDTV service.
  778. @end table
  779. Option @option{mpegts_flags} may take a set of such flags:
  780. @table @option
  781. @item resend_headers
  782. Reemit PAT/PMT before writing the next packet.
  783. @item latm
  784. Use LATM packetization for AAC.
  785. @item pat_pmt_at_frames
  786. Reemit PAT and PMT at each video frame.
  787. @item system_b
  788. Conform to System B (DVB) instead of System A (ATSC).
  789. @end table
  790. @subsection Example
  791. @example
  792. ffmpeg -i file.mpg -c copy \
  793. -mpegts_original_network_id 0x1122 \
  794. -mpegts_transport_stream_id 0x3344 \
  795. -mpegts_service_id 0x5566 \
  796. -mpegts_pmt_start_pid 0x1500 \
  797. -mpegts_start_pid 0x150 \
  798. -metadata service_provider="Some provider" \
  799. -metadata service_name="Some Channel" \
  800. -y out.ts
  801. @end example
  802. @section mxf, mxf_d10
  803. MXF muxer.
  804. @subsection Options
  805. The muxer options are:
  806. @table @option
  807. @item store_user_comments @var{bool}
  808. Set if user comments should be stored if available or never.
  809. IRT D-10 does not allow user comments. The default is thus to write them for
  810. mxf but not for mxf_d10
  811. @end table
  812. @section null
  813. Null muxer.
  814. This muxer does not generate any output file, it is mainly useful for
  815. testing or benchmarking purposes.
  816. For example to benchmark decoding with @command{ffmpeg} you can use the
  817. command:
  818. @example
  819. ffmpeg -benchmark -i INPUT -f null out.null
  820. @end example
  821. Note that the above command does not read or write the @file{out.null}
  822. file, but specifying the output file is required by the @command{ffmpeg}
  823. syntax.
  824. Alternatively you can write the command as:
  825. @example
  826. ffmpeg -benchmark -i INPUT -f null -
  827. @end example
  828. @section nut
  829. @table @option
  830. @item -syncpoints @var{flags}
  831. Change the syncpoint usage in nut:
  832. @table @option
  833. @item @var{default} use the normal low-overhead seeking aids.
  834. @item @var{none} do not use the syncpoints at all, reducing the overhead but making the stream non-seekable;
  835. Use of this option is not recommended, as the resulting files are very damage
  836. sensitive and seeking is not possible. Also in general the overhead from
  837. syncpoints is negligible. Note, -@code{write_index} 0 can be used to disable
  838. all growing data tables, allowing to mux endless streams with limited memory
  839. and without these disadvantages.
  840. @item @var{timestamped} extend the syncpoint with a wallclock field.
  841. @end table
  842. The @var{none} and @var{timestamped} flags are experimental.
  843. @item -write_index @var{bool}
  844. Write index at the end, the default is to write an index.
  845. @end table
  846. @example
  847. ffmpeg -i INPUT -f_strict experimental -syncpoints none - | processor
  848. @end example
  849. @section ogg
  850. Ogg container muxer.
  851. @table @option
  852. @item -page_duration @var{duration}
  853. Preferred page duration, in microseconds. The muxer will attempt to create
  854. pages that are approximately @var{duration} microseconds long. This allows the
  855. user to compromise between seek granularity and container overhead. The default
  856. is 1 second. A value of 0 will fill all segments, making pages as large as
  857. possible. A value of 1 will effectively use 1 packet-per-page in most
  858. situations, giving a small seek granularity at the cost of additional container
  859. overhead.
  860. @item -serial_offset @var{value}
  861. Serial value from which to set the streams serial number.
  862. Setting it to different and sufficiently large values ensures that the produced
  863. ogg files can be safely chained.
  864. @end table
  865. @anchor{segment}
  866. @section segment, stream_segment, ssegment
  867. Basic stream segmenter.
  868. This muxer outputs streams to a number of separate files of nearly
  869. fixed duration. Output filename pattern can be set in a fashion
  870. similar to @ref{image2}, or by using a @code{strftime} template if
  871. the @option{strftime} option is enabled.
  872. @code{stream_segment} is a variant of the muxer used to write to
  873. streaming output formats, i.e. which do not require global headers,
  874. and is recommended for outputting e.g. to MPEG transport stream segments.
  875. @code{ssegment} is a shorter alias for @code{stream_segment}.
  876. Every segment starts with a keyframe of the selected reference stream,
  877. which is set through the @option{reference_stream} option.
  878. Note that if you want accurate splitting for a video file, you need to
  879. make the input key frames correspond to the exact splitting times
  880. expected by the segmenter, or the segment muxer will start the new
  881. segment with the key frame found next after the specified start
  882. time.
  883. The segment muxer works best with a single constant frame rate video.
  884. Optionally it can generate a list of the created segments, by setting
  885. the option @var{segment_list}. The list type is specified by the
  886. @var{segment_list_type} option. The entry filenames in the segment
  887. list are set by default to the basename of the corresponding segment
  888. files.
  889. See also the @ref{hls} muxer, which provides a more specific
  890. implementation for HLS segmentation.
  891. @subsection Options
  892. The segment muxer supports the following options:
  893. @table @option
  894. @item increment_tc @var{1|0}
  895. if set to @code{1}, increment timecode between each segment
  896. If this is selected, the input need to have
  897. a timecode in the first video stream. Default value is
  898. @code{0}.
  899. @item reference_stream @var{specifier}
  900. Set the reference stream, as specified by the string @var{specifier}.
  901. If @var{specifier} is set to @code{auto}, the reference is chosen
  902. automatically. Otherwise it must be a stream specifier (see the ``Stream
  903. specifiers'' chapter in the ffmpeg manual) which specifies the
  904. reference stream. The default value is @code{auto}.
  905. @item segment_format @var{format}
  906. Override the inner container format, by default it is guessed by the filename
  907. extension.
  908. @item segment_format_options @var{options_list}
  909. Set output format options using a :-separated list of key=value
  910. parameters. Values containing the @code{:} special character must be
  911. escaped.
  912. @item segment_list @var{name}
  913. Generate also a listfile named @var{name}. If not specified no
  914. listfile is generated.
  915. @item segment_list_flags @var{flags}
  916. Set flags affecting the segment list generation.
  917. It currently supports the following flags:
  918. @table @samp
  919. @item cache
  920. Allow caching (only affects M3U8 list files).
  921. @item live
  922. Allow live-friendly file generation.
  923. @end table
  924. @item segment_list_size @var{size}
  925. Update the list file so that it contains at most @var{size}
  926. segments. If 0 the list file will contain all the segments. Default
  927. value is 0.
  928. @item segment_list_entry_prefix @var{prefix}
  929. Prepend @var{prefix} to each entry. Useful to generate absolute paths.
  930. By default no prefix is applied.
  931. @item segment_list_type @var{type}
  932. Select the listing format.
  933. The following values are recognized:
  934. @table @samp
  935. @item flat
  936. Generate a flat list for the created segments, one segment per line.
  937. @item csv, ext
  938. Generate a list for the created segments, one segment per line,
  939. each line matching the format (comma-separated values):
  940. @example
  941. @var{segment_filename},@var{segment_start_time},@var{segment_end_time}
  942. @end example
  943. @var{segment_filename} is the name of the output file generated by the
  944. muxer according to the provided pattern. CSV escaping (according to
  945. RFC4180) is applied if required.
  946. @var{segment_start_time} and @var{segment_end_time} specify
  947. the segment start and end time expressed in seconds.
  948. A list file with the suffix @code{".csv"} or @code{".ext"} will
  949. auto-select this format.
  950. @samp{ext} is deprecated in favor or @samp{csv}.
  951. @item ffconcat
  952. Generate an ffconcat file for the created segments. The resulting file
  953. can be read using the FFmpeg @ref{concat} demuxer.
  954. A list file with the suffix @code{".ffcat"} or @code{".ffconcat"} will
  955. auto-select this format.
  956. @item m3u8
  957. Generate an extended M3U8 file, version 3, compliant with
  958. @url{http://tools.ietf.org/id/draft-pantos-http-live-streaming}.
  959. A list file with the suffix @code{".m3u8"} will auto-select this format.
  960. @end table
  961. If not specified the type is guessed from the list file name suffix.
  962. @item segment_time @var{time}
  963. Set segment duration to @var{time}, the value must be a duration
  964. specification. Default value is "2". See also the
  965. @option{segment_times} option.
  966. Note that splitting may not be accurate, unless you force the
  967. reference stream key-frames at the given time. See the introductory
  968. notice and the examples below.
  969. @item segment_atclocktime @var{1|0}
  970. If set to "1" split at regular clock time intervals starting from 00:00
  971. o'clock. The @var{time} value specified in @option{segment_time} is
  972. used for setting the length of the splitting interval.
  973. For example with @option{segment_time} set to "900" this makes it possible
  974. to create files at 12:00 o'clock, 12:15, 12:30, etc.
  975. Default value is "0".
  976. @item segment_clocktime_offset @var{duration}
  977. Delay the segment splitting times with the specified duration when using
  978. @option{segment_atclocktime}.
  979. For example with @option{segment_time} set to "900" and
  980. @option{segment_clocktime_offset} set to "300" this makes it possible to
  981. create files at 12:05, 12:20, 12:35, etc.
  982. Default value is "0".
  983. @item segment_clocktime_wrap_duration @var{duration}
  984. Force the segmenter to only start a new segment if a packet reaches the muxer
  985. within the specified duration after the segmenting clock time. This way you
  986. can make the segmenter more resilient to backward local time jumps, such as
  987. leap seconds or transition to standard time from daylight savings time.
  988. Assuming that the delay between the packets of your source is less than 0.5
  989. second you can detect a leap second by specifying 0.5 as the duration.
  990. Default is the maximum possible duration which means starting a new segment
  991. regardless of the elapsed time since the last clock time.
  992. @item segment_time_delta @var{delta}
  993. Specify the accuracy time when selecting the start time for a
  994. segment, expressed as a duration specification. Default value is "0".
  995. When delta is specified a key-frame will start a new segment if its
  996. PTS satisfies the relation:
  997. @example
  998. PTS >= start_time - time_delta
  999. @end example
  1000. This option is useful when splitting video content, which is always
  1001. split at GOP boundaries, in case a key frame is found just before the
  1002. specified split time.
  1003. In particular may be used in combination with the @file{ffmpeg} option
  1004. @var{force_key_frames}. The key frame times specified by
  1005. @var{force_key_frames} may not be set accurately because of rounding
  1006. issues, with the consequence that a key frame time may result set just
  1007. before the specified time. For constant frame rate videos a value of
  1008. 1/(2*@var{frame_rate}) should address the worst case mismatch between
  1009. the specified time and the time set by @var{force_key_frames}.
  1010. @item segment_times @var{times}
  1011. Specify a list of split points. @var{times} contains a list of comma
  1012. separated duration specifications, in increasing order. See also
  1013. the @option{segment_time} option.
  1014. @item segment_frames @var{frames}
  1015. Specify a list of split video frame numbers. @var{frames} contains a
  1016. list of comma separated integer numbers, in increasing order.
  1017. This option specifies to start a new segment whenever a reference
  1018. stream key frame is found and the sequential number (starting from 0)
  1019. of the frame is greater or equal to the next value in the list.
  1020. @item segment_wrap @var{limit}
  1021. Wrap around segment index once it reaches @var{limit}.
  1022. @item segment_start_number @var{number}
  1023. Set the sequence number of the first segment. Defaults to @code{0}.
  1024. @item strftime @var{1|0}
  1025. Use the @code{strftime} function to define the name of the new
  1026. segments to write. If this is selected, the output segment name must
  1027. contain a @code{strftime} function template. Default value is
  1028. @code{0}.
  1029. @item break_non_keyframes @var{1|0}
  1030. If enabled, allow segments to start on frames other than keyframes. This
  1031. improves behavior on some players when the time between keyframes is
  1032. inconsistent, but may make things worse on others, and can cause some oddities
  1033. during seeking. Defaults to @code{0}.
  1034. @item reset_timestamps @var{1|0}
  1035. Reset timestamps at the begin of each segment, so that each segment
  1036. will start with near-zero timestamps. It is meant to ease the playback
  1037. of the generated segments. May not work with some combinations of
  1038. muxers/codecs. It is set to @code{0} by default.
  1039. @item initial_offset @var{offset}
  1040. Specify timestamp offset to apply to the output packet timestamps. The
  1041. argument must be a time duration specification, and defaults to 0.
  1042. @item write_empty_segments @var{1|0}
  1043. If enabled, write an empty segment if there are no packets during the period a
  1044. segment would usually span. Otherwise, the segment will be filled with the next
  1045. packet written. Defaults to @code{0}.
  1046. @end table
  1047. @subsection Examples
  1048. @itemize
  1049. @item
  1050. Remux the content of file @file{in.mkv} to a list of segments
  1051. @file{out-000.nut}, @file{out-001.nut}, etc., and write the list of
  1052. generated segments to @file{out.list}:
  1053. @example
  1054. ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.list out%03d.nut
  1055. @end example
  1056. @item
  1057. Segment input and set output format options for the output segments:
  1058. @example
  1059. ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
  1060. @end example
  1061. @item
  1062. Segment the input file according to the split points specified by the
  1063. @var{segment_times} option:
  1064. @example
  1065. 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
  1066. @end example
  1067. @item
  1068. Use the @command{ffmpeg} @option{force_key_frames}
  1069. option to force key frames in the input at the specified location, together
  1070. with the segment option @option{segment_time_delta} to account for
  1071. possible roundings operated when setting key frame times.
  1072. @example
  1073. ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
  1074. -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
  1075. @end example
  1076. In order to force key frames on the input file, transcoding is
  1077. required.
  1078. @item
  1079. Segment the input file by splitting the input file according to the
  1080. frame numbers sequence specified with the @option{segment_frames} option:
  1081. @example
  1082. ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
  1083. @end example
  1084. @item
  1085. Convert the @file{in.mkv} to TS segments using the @code{libx264}
  1086. and @code{libfaac} encoders:
  1087. @example
  1088. ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a libfaac -f ssegment -segment_list out.list out%03d.ts
  1089. @end example
  1090. @item
  1091. Segment the input file, and create an M3U8 live playlist (can be used
  1092. as live HLS source):
  1093. @example
  1094. ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
  1095. -segment_list_flags +live -segment_time 10 out%03d.mkv
  1096. @end example
  1097. @end itemize
  1098. @section smoothstreaming
  1099. Smooth Streaming muxer generates a set of files (Manifest, chunks) suitable for serving with conventional web server.
  1100. @table @option
  1101. @item window_size
  1102. Specify the number of fragments kept in the manifest. Default 0 (keep all).
  1103. @item extra_window_size
  1104. Specify the number of fragments kept outside of the manifest before removing from disk. Default 5.
  1105. @item lookahead_count
  1106. Specify the number of lookahead fragments. Default 2.
  1107. @item min_frag_duration
  1108. Specify the minimum fragment duration (in microseconds). Default 5000000.
  1109. @item remove_at_exit
  1110. Specify whether to remove all fragments when finished. Default 0 (do not remove).
  1111. @end table
  1112. @section tee
  1113. The tee muxer can be used to write the same data to several files or any
  1114. other kind of muxer. It can be used, for example, to both stream a video to
  1115. the network and save it to disk at the same time.
  1116. It is different from specifying several outputs to the @command{ffmpeg}
  1117. command-line tool because the audio and video data will be encoded only once
  1118. with the tee muxer; encoding can be a very expensive process. It is not
  1119. useful when using the libavformat API directly because it is then possible
  1120. to feed the same packets to several muxers directly.
  1121. The slave outputs are specified in the file name given to the muxer,
  1122. separated by '|'. If any of the slave name contains the '|' separator,
  1123. leading or trailing spaces or any special character, it must be
  1124. escaped (see @ref{quoting_and_escaping,,the "Quoting and escaping"
  1125. section in the ffmpeg-utils(1) manual,ffmpeg-utils}).
  1126. Muxer options can be specified for each slave by prepending them as a list of
  1127. @var{key}=@var{value} pairs separated by ':', between square brackets. If
  1128. the options values contain a special character or the ':' separator, they
  1129. must be escaped; note that this is a second level escaping.
  1130. The following special options are also recognized:
  1131. @table @option
  1132. @item f
  1133. Specify the format name. Useful if it cannot be guessed from the
  1134. output name suffix.
  1135. @item bsfs[/@var{spec}]
  1136. Specify a list of bitstream filters to apply to the specified
  1137. output.
  1138. It is possible to specify to which streams a given bitstream filter
  1139. applies, by appending a stream specifier to the option separated by
  1140. @code{/}. @var{spec} must be a stream specifier (see @ref{Format
  1141. stream specifiers}). If the stream specifier is not specified, the
  1142. bitstream filters will be applied to all streams in the output.
  1143. Several bitstream filters can be specified, separated by ",".
  1144. @item select
  1145. Select the streams that should be mapped to the slave output,
  1146. specified by a stream specifier. If not specified, this defaults to
  1147. all the input streams. You may use multiple stream specifiers
  1148. separated by commas (@code{,}) e.g.: @code{a:0,v}
  1149. @item onfail
  1150. Specify behaviour on output failure. This can be set to either @code{abort} (which is
  1151. default) or @code{ignore}. @code{abort} will cause whole process to fail in case of failure
  1152. on this slave output. @code{ignore} will ignore failure on this output, so other outputs
  1153. will continue without being affected.
  1154. @end table
  1155. @subsection Examples
  1156. @itemize
  1157. @item
  1158. Encode something and both archive it in a WebM file and stream it
  1159. as MPEG-TS over UDP (the streams need to be explicitly mapped):
  1160. @example
  1161. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  1162. "archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  1163. @end example
  1164. @item
  1165. As above, but continue streaming even if output to local file fails
  1166. (for example local drive fills up):
  1167. @example
  1168. ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  1169. "[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  1170. @end example
  1171. @item
  1172. Use @command{ffmpeg} to encode the input, and send the output
  1173. to three different destinations. The @code{dump_extra} bitstream
  1174. filter is used to add extradata information to all the output video
  1175. keyframes packets, as requested by the MPEG-TS format. The select
  1176. option is applied to @file{out.aac} in order to make it contain only
  1177. audio packets.
  1178. @example
  1179. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental
  1180. -f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
  1181. @end example
  1182. @item
  1183. As below, but select only stream @code{a:1} for the audio output. Note
  1184. that a second level escaping must be performed, as ":" is a special
  1185. character used to separate options.
  1186. @example
  1187. ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental
  1188. -f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"
  1189. @end example
  1190. @end itemize
  1191. Note: some codecs may need different options depending on the output format;
  1192. the auto-detection of this can not work with the tee muxer. The main example
  1193. is the @option{global_header} flag.
  1194. @section webm_dash_manifest
  1195. WebM DASH Manifest muxer.
  1196. This muxer implements the WebM DASH Manifest specification to generate the DASH
  1197. manifest XML. It also supports manifest generation for DASH live streams.
  1198. For more information see:
  1199. @itemize @bullet
  1200. @item
  1201. WebM DASH Specification: @url{https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification}
  1202. @item
  1203. ISO DASH Specification: @url{http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip}
  1204. @end itemize
  1205. @subsection Options
  1206. This muxer supports the following options:
  1207. @table @option
  1208. @item adaptation_sets
  1209. This option has the following syntax: "id=x,streams=a,b,c id=y,streams=d,e" where x and y are the
  1210. unique identifiers of the adaptation sets and a,b,c,d and e are the indices of the corresponding
  1211. audio and video streams. Any number of adaptation sets can be added using this option.
  1212. @item live
  1213. Set this to 1 to create a live stream DASH Manifest. Default: 0.
  1214. @item chunk_start_index
  1215. Start index of the first chunk. This will go in the @samp{startNumber} attribute
  1216. of the @samp{SegmentTemplate} element in the manifest. Default: 0.
  1217. @item chunk_duration_ms
  1218. Duration of each chunk in milliseconds. This will go in the @samp{duration}
  1219. attribute of the @samp{SegmentTemplate} element in the manifest. Default: 1000.
  1220. @item utc_timing_url
  1221. URL of the page that will return the UTC timestamp in ISO format. This will go
  1222. in the @samp{value} attribute of the @samp{UTCTiming} element in the manifest.
  1223. Default: None.
  1224. @item time_shift_buffer_depth
  1225. Smallest time (in seconds) shifting buffer for which any Representation is
  1226. guaranteed to be available. This will go in the @samp{timeShiftBufferDepth}
  1227. attribute of the @samp{MPD} element. Default: 60.
  1228. @item minimum_update_period
  1229. Minimum update period (in seconds) of the manifest. This will go in the
  1230. @samp{minimumUpdatePeriod} attribute of the @samp{MPD} element. Default: 0.
  1231. @end table
  1232. @subsection Example
  1233. @example
  1234. ffmpeg -f webm_dash_manifest -i video1.webm \
  1235. -f webm_dash_manifest -i video2.webm \
  1236. -f webm_dash_manifest -i audio1.webm \
  1237. -f webm_dash_manifest -i audio2.webm \
  1238. -map 0 -map 1 -map 2 -map 3 \
  1239. -c copy \
  1240. -f webm_dash_manifest \
  1241. -adaptation_sets "id=0,streams=0,1 id=1,streams=2,3" \
  1242. manifest.xml
  1243. @end example
  1244. @section webm_chunk
  1245. WebM Live Chunk Muxer.
  1246. This muxer writes out WebM headers and chunks as separate files which can be
  1247. consumed by clients that support WebM Live streams via DASH.
  1248. @subsection Options
  1249. This muxer supports the following options:
  1250. @table @option
  1251. @item chunk_start_index
  1252. Index of the first chunk (defaults to 0).
  1253. @item header
  1254. Filename of the header where the initialization data will be written.
  1255. @item audio_chunk_duration
  1256. Duration of each audio chunk in milliseconds (defaults to 5000).
  1257. @end table
  1258. @subsection Example
  1259. @example
  1260. ffmpeg -f v4l2 -i /dev/video0 \
  1261. -f alsa -i hw:0 \
  1262. -map 0:0 \
  1263. -c:v libvpx-vp9 \
  1264. -s 640x360 -keyint_min 30 -g 30 \
  1265. -f webm_chunk \
  1266. -header webm_live_video_360.hdr \
  1267. -chunk_start_index 1 \
  1268. webm_live_video_360_%d.chk \
  1269. -map 1:0 \
  1270. -c:a libvorbis \
  1271. -b:a 128k \
  1272. -f webm_chunk \
  1273. -header webm_live_audio_128.hdr \
  1274. -chunk_start_index 1 \
  1275. -audio_chunk_duration 1000 \
  1276. webm_live_audio_128_%d.chk
  1277. @end example
  1278. @c man end MUXERS