OSDN Git Service

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