muxers.texi 50 KB

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