1FFMPEG-FORMATS(1) FFMPEG-FORMATS(1)
2
3
4
6 ffmpeg-formats - FFmpeg formats
7
9 This document describes the supported formats (muxers and demuxers)
10 provided by the libavformat library.
11
13 The libavformat library provides some generic global options, which can
14 be set on all the muxers and demuxers. In addition each muxer or
15 demuxer may support so-called private options, which are specific for
16 that component.
17
18 Options may be set by specifying -option value in the FFmpeg tools, or
19 by setting the value explicitly in the "AVFormatContext" options or
20 using the libavutil/opt.h API for programmatic use.
21
22 The list of supported options follows:
23
24 avioflags flags (input/output)
25 Possible values:
26
27 direct
28 Reduce buffering.
29
30 probesize integer (input)
31 Set probing size in bytes, i.e. the size of the data to analyze to
32 get stream information. A higher value will enable detecting more
33 information in case it is dispersed into the stream, but will
34 increase latency. Must be an integer not lesser than 32. It is
35 5000000 by default.
36
37 max_probe_packets integer (input)
38 Set the maximum number of buffered packets when probing a codec.
39 Default is 2500 packets.
40
41 packetsize integer (output)
42 Set packet size.
43
44 fflags flags
45 Set format flags. Some are implemented for a limited number of
46 formats.
47
48 Possible values for input files:
49
50 discardcorrupt
51 Discard corrupted packets.
52
53 fastseek
54 Enable fast, but inaccurate seeks for some formats.
55
56 genpts
57 Generate missing PTS if DTS is present.
58
59 igndts
60 Ignore DTS if PTS is set. Inert when nofillin is set.
61
62 ignidx
63 Ignore index.
64
65 nobuffer
66 Reduce the latency introduced by buffering during initial input
67 streams analysis.
68
69 nofillin
70 Do not fill in missing values in packet fields that can be
71 exactly calculated.
72
73 noparse
74 Disable AVParsers, this needs "+nofillin" too.
75
76 sortdts
77 Try to interleave output packets by DTS. At present, available
78 only for AVIs with an index.
79
80 Possible values for output files:
81
82 autobsf
83 Automatically apply bitstream filters as required by the output
84 format. Enabled by default.
85
86 bitexact
87 Only write platform-, build- and time-independent data. This
88 ensures that file and data checksums are reproducible and match
89 between platforms. Its primary use is for regression testing.
90
91 flush_packets
92 Write out packets immediately.
93
94 shortest
95 Stop muxing at the end of the shortest stream. It may be
96 needed to increase max_interleave_delta to avoid flushing the
97 longer streams before EOF.
98
99 seek2any integer (input)
100 Allow seeking to non-keyframes on demuxer level when supported if
101 set to 1. Default is 0.
102
103 analyzeduration integer (input)
104 Specify how many microseconds are analyzed to probe the input. A
105 higher value will enable detecting more accurate information, but
106 will increase latency. It defaults to 5,000,000 microseconds = 5
107 seconds.
108
109 cryptokey hexadecimal string (input)
110 Set decryption key.
111
112 indexmem integer (input)
113 Set max memory used for timestamp index (per stream).
114
115 rtbufsize integer (input)
116 Set max memory used for buffering real-time frames.
117
118 fdebug flags (input/output)
119 Print specific debug info.
120
121 Possible values:
122
123 ts
124 max_delay integer (input/output)
125 Set maximum muxing or demuxing delay in microseconds.
126
127 fpsprobesize integer (input)
128 Set number of frames used to probe fps.
129
130 audio_preload integer (output)
131 Set microseconds by which audio packets should be interleaved
132 earlier.
133
134 chunk_duration integer (output)
135 Set microseconds for each chunk.
136
137 chunk_size integer (output)
138 Set size in bytes for each chunk.
139
140 err_detect, f_err_detect flags (input)
141 Set error detection flags. "f_err_detect" is deprecated and should
142 be used only via the ffmpeg tool.
143
144 Possible values:
145
146 crccheck
147 Verify embedded CRCs.
148
149 bitstream
150 Detect bitstream specification deviations.
151
152 buffer
153 Detect improper bitstream length.
154
155 explode
156 Abort decoding on minor error detection.
157
158 careful
159 Consider things that violate the spec and have not been seen in
160 the wild as errors.
161
162 compliant
163 Consider all spec non compliancies as errors.
164
165 aggressive
166 Consider things that a sane encoder should not do as an error.
167
168 max_interleave_delta integer (output)
169 Set maximum buffering duration for interleaving. The duration is
170 expressed in microseconds, and defaults to 10000000 (10 seconds).
171
172 To ensure all the streams are interleaved correctly, libavformat
173 will wait until it has at least one packet for each stream before
174 actually writing any packets to the output file. When some streams
175 are "sparse" (i.e. there are large gaps between successive
176 packets), this can result in excessive buffering.
177
178 This field specifies the maximum difference between the timestamps
179 of the first and the last packet in the muxing queue, above which
180 libavformat will output a packet regardless of whether it has
181 queued a packet for all the streams.
182
183 If set to 0, libavformat will continue buffering packets until it
184 has a packet for each stream, regardless of the maximum timestamp
185 difference between the buffered packets.
186
187 use_wallclock_as_timestamps integer (input)
188 Use wallclock as timestamps if set to 1. Default is 0.
189
190 avoid_negative_ts integer (output)
191 Possible values:
192
193 make_non_negative
194 Shift timestamps to make them non-negative. Also note that
195 this affects only leading negative timestamps, and not non-
196 monotonic negative timestamps.
197
198 make_zero
199 Shift timestamps so that the first timestamp is 0.
200
201 auto (default)
202 Enables shifting when required by the target format.
203
204 disabled
205 Disables shifting of timestamp.
206
207 When shifting is enabled, all output timestamps are shifted by the
208 same amount. Audio, video, and subtitles desynching and relative
209 timestamp differences are preserved compared to how they would have
210 been without shifting.
211
212 skip_initial_bytes integer (input)
213 Set number of bytes to skip before reading header and frames if set
214 to 1. Default is 0.
215
216 correct_ts_overflow integer (input)
217 Correct single timestamp overflows if set to 1. Default is 1.
218
219 flush_packets integer (output)
220 Flush the underlying I/O stream after each packet. Default is -1
221 (auto), which means that the underlying protocol will decide, 1
222 enables it, and has the effect of reducing the latency, 0 disables
223 it and may increase IO throughput in some cases.
224
225 output_ts_offset offset (output)
226 Set the output time offset.
227
228 offset must be a time duration specification, see the Time duration
229 section in the ffmpeg-utils(1) manual.
230
231 The offset is added by the muxer to the output timestamps.
232
233 Specifying a positive offset means that the corresponding streams
234 are delayed bt the time duration specified in offset. Default value
235 is 0 (meaning that no offset is applied).
236
237 format_whitelist list (input)
238 "," separated list of allowed demuxers. By default all are allowed.
239
240 dump_separator string (input)
241 Separator used to separate the fields printed on the command line
242 about the Stream parameters. For example, to separate the fields
243 with newlines and indentation:
244
245 ffprobe -dump_separator "
246 " -i ~/videos/matrixbench_mpeg2.mpg
247
248 max_streams integer (input)
249 Specifies the maximum number of streams. This can be used to reject
250 files that would require too many resources due to a large number
251 of streams.
252
253 skip_estimate_duration_from_pts bool (input)
254 Skip estimation of input duration when calculated using PTS. At
255 present, applicable for MPEG-PS and MPEG-TS.
256
257 strict, f_strict integer (input/output)
258 Specify how strictly to follow the standards. "f_strict" is
259 deprecated and should be used only via the ffmpeg tool.
260
261 Possible values:
262
263 very
264 strictly conform to an older more strict version of the spec or
265 reference software
266
267 strict
268 strictly conform to all the things in the spec no matter what
269 consequences
270
271 normal
272 unofficial
273 allow unofficial extensions
274
275 experimental
276 allow non standardized experimental things, experimental
277 (unfinished/work in progress/not well tested) decoders and
278 encoders. Note: experimental decoders can pose a security
279 risk, do not use this for decoding untrusted input.
280
281 Format stream specifiers
282 Format stream specifiers allow selection of one or more streams that
283 match specific properties.
284
285 The exact semantics of stream specifiers is defined by the
286 "avformat_match_stream_specifier()" function declared in the
287 libavformat/avformat.h header and documented in the Stream specifiers
288 section in the ffmpeg(1) manual.
289
291 Demuxers are configured elements in FFmpeg that can read the multimedia
292 streams from a particular type of file.
293
294 When you configure your FFmpeg build, all the supported demuxers are
295 enabled by default. You can list all available ones using the configure
296 option "--list-demuxers".
297
298 You can disable all the demuxers using the configure option
299 "--disable-demuxers", and selectively enable a single demuxer with the
300 option "--enable-demuxer=DEMUXER", or disable it with the option
301 "--disable-demuxer=DEMUXER".
302
303 The option "-demuxers" of the ff* tools will display the list of
304 enabled demuxers. Use "-formats" to view a combined list of enabled
305 demuxers and muxers.
306
307 The description of some of the currently available demuxers follows.
308
309 aa
310 Audible Format 2, 3, and 4 demuxer.
311
312 This demuxer is used to demux Audible Format 2, 3, and 4 (.aa) files.
313
314 aac
315 Raw Audio Data Transport Stream AAC demuxer.
316
317 This demuxer is used to demux an ADTS input containing a single AAC
318 stream alongwith any ID3v1/2 or APE tags in it.
319
320 apng
321 Animated Portable Network Graphics demuxer.
322
323 This demuxer is used to demux APNG files. All headers, but the PNG
324 signature, up to (but not including) the first fcTL chunk are
325 transmitted as extradata. Frames are then split as being all the
326 chunks between two fcTL ones, or between the last fcTL and IEND chunks.
327
328 -ignore_loop bool
329 Ignore the loop variable in the file if set. Default is enabled.
330
331 -max_fps int
332 Maximum framerate in frames per second. Default of 0 imposes no
333 limit.
334
335 -default_fps int
336 Default framerate in frames per second when none is specified in
337 the file (0 meaning as fast as possible). Default is 15.
338
339 asf
340 Advanced Systems Format demuxer.
341
342 This demuxer is used to demux ASF files and MMS network streams.
343
344 -no_resync_search bool
345 Do not try to resynchronize by looking for a certain optional start
346 code.
347
348 concat
349 Virtual concatenation script demuxer.
350
351 This demuxer reads a list of files and other directives from a text
352 file and demuxes them one after the other, as if all their packets had
353 been muxed together.
354
355 The timestamps in the files are adjusted so that the first file starts
356 at 0 and each next file starts where the previous one finishes. Note
357 that it is done globally and may cause gaps if all streams do not have
358 exactly the same length.
359
360 All files must have the same streams (same codecs, same time base,
361 etc.).
362
363 The duration of each file is used to adjust the timestamps of the next
364 file: if the duration is incorrect (because it was computed using the
365 bit-rate or because the file is truncated, for example), it can cause
366 artifacts. The "duration" directive can be used to override the
367 duration stored in each file.
368
369 Syntax
370
371 The script is a text file in extended-ASCII, with one directive per
372 line. Empty lines, leading spaces and lines starting with '#' are
373 ignored. The following directive is recognized:
374
375 "file path"
376 Path to a file to read; special characters and spaces must be
377 escaped with backslash or single quotes.
378
379 All subsequent file-related directives apply to that file.
380
381 "ffconcat version 1.0"
382 Identify the script type and version.
383
384 To make FFmpeg recognize the format automatically, this directive
385 must appear exactly as is (no extra space or byte-order-mark) on
386 the very first line of the script.
387
388 "duration dur"
389 Duration of the file. This information can be specified from the
390 file; specifying it here may be more efficient or help if the
391 information from the file is not available or accurate.
392
393 If the duration is set for all files, then it is possible to seek
394 in the whole concatenated video.
395
396 "inpoint timestamp"
397 In point of the file. When the demuxer opens the file it instantly
398 seeks to the specified timestamp. Seeking is done so that all
399 streams can be presented successfully at In point.
400
401 This directive works best with intra frame codecs, because for non-
402 intra frame ones you will usually get extra packets before the
403 actual In point and the decoded content will most likely contain
404 frames before In point too.
405
406 For each file, packets before the file In point will have
407 timestamps less than the calculated start timestamp of the file
408 (negative in case of the first file), and the duration of the files
409 (if not specified by the "duration" directive) will be reduced
410 based on their specified In point.
411
412 Because of potential packets before the specified In point, packet
413 timestamps may overlap between two concatenated files.
414
415 "outpoint timestamp"
416 Out point of the file. When the demuxer reaches the specified
417 decoding timestamp in any of the streams, it handles it as an end
418 of file condition and skips the current and all the remaining
419 packets from all streams.
420
421 Out point is exclusive, which means that the demuxer will not
422 output packets with a decoding timestamp greater or equal to Out
423 point.
424
425 This directive works best with intra frame codecs and formats where
426 all streams are tightly interleaved. For non-intra frame codecs you
427 will usually get additional packets with presentation timestamp
428 after Out point therefore the decoded content will most likely
429 contain frames after Out point too. If your streams are not tightly
430 interleaved you may not get all the packets from all streams before
431 Out point and you may only will be able to decode the earliest
432 stream until Out point.
433
434 The duration of the files (if not specified by the "duration"
435 directive) will be reduced based on their specified Out point.
436
437 "file_packet_metadata key=value"
438 Metadata of the packets of the file. The specified metadata will be
439 set for each file packet. You can specify this directive multiple
440 times to add multiple metadata entries. This directive is
441 deprecated, use "file_packet_meta" instead.
442
443 "file_packet_meta key value"
444 Metadata of the packets of the file. The specified metadata will be
445 set for each file packet. You can specify this directive multiple
446 times to add multiple metadata entries.
447
448 "option key value"
449 Option to access, open and probe the file. Can be present multiple
450 times.
451
452 "stream"
453 Introduce a stream in the virtual file. All subsequent stream-
454 related directives apply to the last introduced stream. Some
455 streams properties must be set in order to allow identifying the
456 matching streams in the subfiles. If no streams are defined in the
457 script, the streams from the first file are copied.
458
459 "exact_stream_id id"
460 Set the id of the stream. If this directive is given, the string
461 with the corresponding id in the subfiles will be used. This is
462 especially useful for MPEG-PS (VOB) files, where the order of the
463 streams is not reliable.
464
465 "stream_meta key value"
466 Metadata for the stream. Can be present multiple times.
467
468 "stream_codec value"
469 Codec for the stream.
470
471 "stream_extradata hex_string"
472 Extradata for the string, encoded in hexadecimal.
473
474 "chapter id start end"
475 Add a chapter. id is an unique identifier, possibly small and
476 consecutive.
477
478 Options
479
480 This demuxer accepts the following option:
481
482 safe
483 If set to 1, reject unsafe file paths and directives. A file path
484 is considered safe if it does not contain a protocol specification
485 and is relative and all components only contain characters from the
486 portable character set (letters, digits, period, underscore and
487 hyphen) and have no period at the beginning of a component.
488
489 If set to 0, any file name is accepted.
490
491 The default is 1.
492
493 auto_convert
494 If set to 1, try to perform automatic conversions on packet data to
495 make the streams concatenable. The default is 1.
496
497 Currently, the only conversion is adding the h264_mp4toannexb
498 bitstream filter to H.264 streams in MP4 format. This is necessary
499 in particular if there are resolution changes.
500
501 segment_time_metadata
502 If set to 1, every packet will contain the lavf.concat.start_time
503 and the lavf.concat.duration packet metadata values which are the
504 start_time and the duration of the respective file segments in the
505 concatenated output expressed in microseconds. The duration
506 metadata is only set if it is known based on the concat file. The
507 default is 0.
508
509 Examples
510
511 • Use absolute filenames and include some comments:
512
513 # my first filename
514 file /mnt/share/file-1.wav
515 # my second filename including whitespace
516 file '/mnt/share/file 2.wav'
517 # my third filename including whitespace plus single quote
518 file '/mnt/share/file 3'\''.wav'
519
520 • Allow for input format auto-probing, use safe filenames and set the
521 duration of the first file:
522
523 ffconcat version 1.0
524
525 file file-1.wav
526 duration 20.0
527
528 file subdir/file-2.wav
529
530 dash
531 Dynamic Adaptive Streaming over HTTP demuxer.
532
533 This demuxer presents all AVStreams found in the manifest. By setting
534 the discard flags on AVStreams the caller can decide which streams to
535 actually receive. Each stream mirrors the "id" and "bandwidth"
536 properties from the "<Representation>" as metadata keys named "id" and
537 "variant_bitrate" respectively.
538
539 imf
540 Interoperable Master Format demuxer.
541
542 This demuxer presents audio and video streams found in an IMF
543 Composition.
544
545 flv, live_flv, kux
546 Adobe Flash Video Format demuxer.
547
548 This demuxer is used to demux FLV files and RTMP network streams. In
549 case of live network streams, if you force format, you may use live_flv
550 option instead of flv to survive timestamp discontinuities. KUX is a
551 flv variant used on the Youku platform.
552
553 ffmpeg -f flv -i myfile.flv ...
554 ffmpeg -f live_flv -i rtmp://<any.server>/anything/key ....
555
556 -flv_metadata bool
557 Allocate the streams according to the onMetaData array content.
558
559 -flv_ignore_prevtag bool
560 Ignore the size of previous tag value.
561
562 -flv_full_metadata bool
563 Output all context of the onMetadata.
564
565 gif
566 Animated GIF demuxer.
567
568 It accepts the following options:
569
570 min_delay
571 Set the minimum valid delay between frames in hundredths of
572 seconds. Range is 0 to 6000. Default value is 2.
573
574 max_gif_delay
575 Set the maximum valid delay between frames in hundredth of seconds.
576 Range is 0 to 65535. Default value is 65535 (nearly eleven
577 minutes), the maximum value allowed by the specification.
578
579 default_delay
580 Set the default delay between frames in hundredths of seconds.
581 Range is 0 to 6000. Default value is 10.
582
583 ignore_loop
584 GIF files can contain information to loop a certain number of times
585 (or infinitely). If ignore_loop is set to 1, then the loop setting
586 from the input will be ignored and looping will not occur. If set
587 to 0, then looping will occur and will cycle the number of times
588 according to the GIF. Default value is 1.
589
590 For example, with the overlay filter, place an infinitely looping GIF
591 over another video:
592
593 ffmpeg -i input.mp4 -ignore_loop 0 -i input.gif -filter_complex overlay=shortest=1 out.mkv
594
595 Note that in the above example the shortest option for overlay filter
596 is used to end the output video at the length of the shortest input
597 file, which in this case is input.mp4 as the GIF in this example loops
598 infinitely.
599
600 hls
601 HLS demuxer
602
603 Apple HTTP Live Streaming demuxer.
604
605 This demuxer presents all AVStreams from all variant streams. The id
606 field is set to the bitrate variant index number. By setting the
607 discard flags on AVStreams (by pressing 'a' or 'v' in ffplay), the
608 caller can decide which variant streams to actually receive. The total
609 bitrate of the variant that the stream belongs to is available in a
610 metadata key named "variant_bitrate".
611
612 It accepts the following options:
613
614 live_start_index
615 segment index to start live streams at (negative values are from
616 the end).
617
618 allowed_extensions
619 ',' separated list of file extensions that hls is allowed to
620 access.
621
622 max_reload
623 Maximum number of times a insufficient list is attempted to be
624 reloaded. Default value is 1000.
625
626 m3u8_hold_counters
627 The maximum number of times to load m3u8 when it refreshes without
628 new segments. Default value is 1000.
629
630 http_persistent
631 Use persistent HTTP connections. Applicable only for HTTP streams.
632 Enabled by default.
633
634 http_multiple
635 Use multiple HTTP connections for downloading HTTP segments.
636 Enabled by default for HTTP/1.1 servers.
637
638 http_seekable
639 Use HTTP partial requests for downloading HTTP segments. 0 =
640 disable, 1 = enable, -1 = auto, Default is auto.
641
642 seg_format_options
643 Set options for the demuxer of media segments using a list of
644 key=value pairs separated by ":".
645
646 image2
647 Image file demuxer.
648
649 This demuxer reads from a list of image files specified by a pattern.
650 The syntax and meaning of the pattern is specified by the option
651 pattern_type.
652
653 The pattern may contain a suffix which is used to automatically
654 determine the format of the images contained in the files.
655
656 The size, the pixel format, and the format of each image must be the
657 same for all the files in the sequence.
658
659 This demuxer accepts the following options:
660
661 framerate
662 Set the frame rate for the video stream. It defaults to 25.
663
664 loop
665 If set to 1, loop over the input. Default value is 0.
666
667 pattern_type
668 Select the pattern type used to interpret the provided filename.
669
670 pattern_type accepts one of the following values.
671
672 none
673 Disable pattern matching, therefore the video will only contain
674 the specified image. You should use this option if you do not
675 want to create sequences from multiple images and your
676 filenames may contain special pattern characters.
677
678 sequence
679 Select a sequence pattern type, used to specify a sequence of
680 files indexed by sequential numbers.
681
682 A sequence pattern may contain the string "%d" or "%0Nd", which
683 specifies the position of the characters representing a
684 sequential number in each filename matched by the pattern. If
685 the form "%d0Nd" is used, the string representing the number in
686 each filename is 0-padded and N is the total number of 0-padded
687 digits representing the number. The literal character '%' can
688 be specified in the pattern with the string "%%".
689
690 If the sequence pattern contains "%d" or "%0Nd", the first
691 filename of the file list specified by the pattern must contain
692 a number inclusively contained between start_number and
693 start_number+start_number_range-1, and all the following
694 numbers must be sequential.
695
696 For example the pattern "img-%03d.bmp" will match a sequence of
697 filenames of the form img-001.bmp, img-002.bmp, ...,
698 img-010.bmp, etc.; the pattern "i%%m%%g-%d.jpg" will match a
699 sequence of filenames of the form i%m%g-1.jpg, i%m%g-2.jpg,
700 ..., i%m%g-10.jpg, etc.
701
702 Note that the pattern must not necessarily contain "%d" or
703 "%0Nd", for example to convert a single image file img.jpeg you
704 can employ the command:
705
706 ffmpeg -i img.jpeg img.png
707
708 glob
709 Select a glob wildcard pattern type.
710
711 The pattern is interpreted like a "glob()" pattern. This is
712 only selectable if libavformat was compiled with globbing
713 support.
714
715 glob_sequence (deprecated, will be removed)
716 Select a mixed glob wildcard/sequence pattern.
717
718 If your version of libavformat was compiled with globbing
719 support, and the provided pattern contains at least one glob
720 meta character among "%*?[]{}" that is preceded by an unescaped
721 "%", the pattern is interpreted like a "glob()" pattern,
722 otherwise it is interpreted like a sequence pattern.
723
724 All glob special characters "%*?[]{}" must be prefixed with
725 "%". To escape a literal "%" you shall use "%%".
726
727 For example the pattern "foo-%*.jpeg" will match all the
728 filenames prefixed by "foo-" and terminating with ".jpeg", and
729 "foo-%?%?%?.jpeg" will match all the filenames prefixed with
730 "foo-", followed by a sequence of three characters, and
731 terminating with ".jpeg".
732
733 This pattern type is deprecated in favor of glob and sequence.
734
735 Default value is glob_sequence.
736
737 pixel_format
738 Set the pixel format of the images to read. If not specified the
739 pixel format is guessed from the first image file in the sequence.
740
741 start_number
742 Set the index of the file matched by the image file pattern to
743 start to read from. Default value is 0.
744
745 start_number_range
746 Set the index interval range to check when looking for the first
747 image file in the sequence, starting from start_number. Default
748 value is 5.
749
750 ts_from_file
751 If set to 1, will set frame timestamp to modification time of image
752 file. Note that monotonity of timestamps is not provided: images go
753 in the same order as without this option. Default value is 0. If
754 set to 2, will set frame timestamp to the modification time of the
755 image file in nanosecond precision.
756
757 video_size
758 Set the video size of the images to read. If not specified the
759 video size is guessed from the first image file in the sequence.
760
761 export_path_metadata
762 If set to 1, will add two extra fields to the metadata found in
763 input, making them also available for other filters (see drawtext
764 filter for examples). Default value is 0. The extra fields are
765 described below:
766
767 lavf.image2dec.source_path
768 Corresponds to the full path to the input file being read.
769
770 lavf.image2dec.source_basename
771 Corresponds to the name of the file being read.
772
773 Examples
774
775 • Use ffmpeg for creating a video from the images in the file
776 sequence img-001.jpeg, img-002.jpeg, ..., assuming an input frame
777 rate of 10 frames per second:
778
779 ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv
780
781 • As above, but start by reading from a file with index 100 in the
782 sequence:
783
784 ffmpeg -framerate 10 -start_number 100 -i 'img-%03d.jpeg' out.mkv
785
786 • Read images matching the "*.png" glob pattern , that is all the
787 files terminating with the ".png" suffix:
788
789 ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv
790
791 libgme
792 The Game Music Emu library is a collection of video game music file
793 emulators.
794
795 See <https://bitbucket.org/mpyne/game-music-emu/overview> for more
796 information.
797
798 It accepts the following options:
799
800 track_index
801 Set the index of which track to demux. The demuxer can only export
802 one track. Track indexes start at 0. Default is to pick the first
803 track. Number of tracks is exported as tracks metadata entry.
804
805 sample_rate
806 Set the sampling rate of the exported track. Range is 1000 to
807 999999. Default is 44100.
808
809 max_size (bytes)
810 The demuxer buffers the entire file into memory. Adjust this value
811 to set the maximum buffer size, which in turn, acts as a ceiling
812 for the size of files that can be read. Default is 50 MiB.
813
814 libmodplug
815 ModPlug based module demuxer
816
817 See <https://github.com/Konstanty/libmodplug>
818
819 It will export one 2-channel 16-bit 44.1 kHz audio stream. Optionally,
820 a "pal8" 16-color video stream can be exported with or without printed
821 metadata.
822
823 It accepts the following options:
824
825 noise_reduction
826 Apply a simple low-pass filter. Can be 1 (on) or 0 (off). Default
827 is 0.
828
829 reverb_depth
830 Set amount of reverb. Range 0-100. Default is 0.
831
832 reverb_delay
833 Set delay in ms, clamped to 40-250 ms. Default is 0.
834
835 bass_amount
836 Apply bass expansion a.k.a. XBass or megabass. Range is 0 (quiet)
837 to 100 (loud). Default is 0.
838
839 bass_range
840 Set cutoff i.e. upper-bound for bass frequencies. Range is 10-100
841 Hz. Default is 0.
842
843 surround_depth
844 Apply a Dolby Pro-Logic surround effect. Range is 0 (quiet) to 100
845 (heavy). Default is 0.
846
847 surround_delay
848 Set surround delay in ms, clamped to 5-40 ms. Default is 0.
849
850 max_size
851 The demuxer buffers the entire file into memory. Adjust this value
852 to set the maximum buffer size, which in turn, acts as a ceiling
853 for the size of files that can be read. Range is 0 to 100 MiB. 0
854 removes buffer size limit (not recommended). Default is 5 MiB.
855
856 video_stream_expr
857 String which is evaluated using the eval API to assign colors to
858 the generated video stream. Variables which can be used are "x",
859 "y", "w", "h", "t", "speed", "tempo", "order", "pattern" and "row".
860
861 video_stream
862 Generate video stream. Can be 1 (on) or 0 (off). Default is 0.
863
864 video_stream_w
865 Set video frame width in 'chars' where one char indicates 8 pixels.
866 Range is 20-512. Default is 30.
867
868 video_stream_h
869 Set video frame height in 'chars' where one char indicates 8
870 pixels. Range is 20-512. Default is 30.
871
872 video_stream_ptxt
873 Print metadata on video stream. Includes "speed", "tempo", "order",
874 "pattern", "row" and "ts" (time in ms). Can be 1 (on) or 0 (off).
875 Default is 1.
876
877 libopenmpt
878 libopenmpt based module demuxer
879
880 See <https://lib.openmpt.org/libopenmpt/> for more information.
881
882 Some files have multiple subsongs (tracks) this can be set with the
883 subsong option.
884
885 It accepts the following options:
886
887 subsong
888 Set the subsong index. This can be either 'all', 'auto', or the
889 index of the subsong. Subsong indexes start at 0. The default is
890 'auto'.
891
892 The default value is to let libopenmpt choose.
893
894 layout
895 Set the channel layout. Valid values are 1, 2, and 4 channel
896 layouts. The default value is STEREO.
897
898 sample_rate
899 Set the sample rate for libopenmpt to output. Range is from 1000
900 to INT_MAX. The value default is 48000.
901
902 mov/mp4/3gp
903 Demuxer for Quicktime File Format & ISO/IEC Base Media File Format
904 (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part
905 12).
906
907 Registered extensions: mov, mp4, m4a, 3gp, 3g2, mj2, psp, m4b, ism,
908 ismv, isma, f4v
909
910 Options
911
912 This demuxer accepts the following options:
913
914 enable_drefs
915 Enable loading of external tracks, disabled by default. Enabling
916 this can theoretically leak information in some use cases.
917
918 use_absolute_path
919 Allows loading of external tracks via absolute paths, disabled by
920 default. Enabling this poses a security risk. It should only be
921 enabled if the source is known to be non-malicious.
922
923 seek_streams_individually
924 When seeking, identify the closest point in each stream
925 individually and demux packets in that stream from identified
926 point. This can lead to a different sequence of packets compared to
927 demuxing linearly from the beginning. Default is true.
928
929 ignore_editlist
930 Ignore any edit list atoms. The demuxer, by default, modifies the
931 stream index to reflect the timeline described by the edit list.
932 Default is false.
933
934 advanced_editlist
935 Modify the stream index to reflect the timeline described by the
936 edit list. "ignore_editlist" must be set to false for this option
937 to be effective. If both "ignore_editlist" and this option are set
938 to false, then only the start of the stream index is modified to
939 reflect initial dwell time or starting timestamp described by the
940 edit list. Default is true.
941
942 ignore_chapters
943 Don't parse chapters. This includes GoPro 'HiLight' tags/moments.
944 Note that chapters are only parsed when input is seekable. Default
945 is false.
946
947 use_mfra_for
948 For seekable fragmented input, set fragment's starting timestamp
949 from media fragment random access box, if present.
950
951 Following options are available:
952
953 auto
954 Auto-detect whether to set mfra timestamps as PTS or DTS
955 (default)
956
957 dts Set mfra timestamps as DTS
958
959 pts Set mfra timestamps as PTS
960
961 0 Don't use mfra box to set timestamps
962
963 use_tfdt
964 For fragmented input, set fragment's starting timestamp to
965 "baseMediaDecodeTime" from the "tfdt" box. Default is enabled,
966 which will prefer to use the "tfdt" box to set DTS. Disable to use
967 the "earliest_presentation_time" from the "sidx" box. In either
968 case, the timestamp from the "mfra" box will be used if it's
969 available and "use_mfra_for" is set to pts or dts.
970
971 export_all
972 Export unrecognized boxes within the udta box as metadata entries.
973 The first four characters of the box type are set as the key.
974 Default is false.
975
976 export_xmp
977 Export entire contents of XMP_ box and uuid box as a string with
978 key "xmp". Note that if "export_all" is set and this option isn't,
979 the contents of XMP_ box are still exported but with key "XMP_".
980 Default is false.
981
982 activation_bytes
983 4-byte key required to decrypt Audible AAX and AAX+ files. See
984 Audible AAX subsection below.
985
986 audible_fixed_key
987 Fixed key used for handling Audible AAX/AAX+ files. It has been
988 pre-set so should not be necessary to specify.
989
990 decryption_key
991 16-byte key, in hex, to decrypt files encrypted using ISO Common
992 Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
993
994 max_stts_delta
995 Very high sample deltas written in a trak's stts box may
996 occasionally be intended but usually they are written in error or
997 used to store a negative value for dts correction when treated as
998 signed 32-bit integers. This option lets the user set an upper
999 limit, beyond which the delta is clamped to 1. Values greater than
1000 the limit if negative when cast to int32 are used to adjust onward
1001 dts.
1002
1003 Unit is the track time scale. Range is 0 to UINT_MAX. Default is
1004 "UINT_MAX - 48000*10" which allows upto a 10 second dts correction
1005 for 48 kHz audio streams while accommodating 99.9% of "uint32"
1006 range.
1007
1008 Audible AAX
1009
1010 Audible AAX files are encrypted M4B files, and they can be decrypted by
1011 specifying a 4 byte activation secret.
1012
1013 ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4
1014
1015 mpegts
1016 MPEG-2 transport stream demuxer.
1017
1018 This demuxer accepts the following options:
1019
1020 resync_size
1021 Set size limit for looking up a new synchronization. Default value
1022 is 65536.
1023
1024 skip_unknown_pmt
1025 Skip PMTs for programs not defined in the PAT. Default value is 0.
1026
1027 fix_teletext_pts
1028 Override teletext packet PTS and DTS values with the timestamps
1029 calculated from the PCR of the first program which the teletext
1030 stream is part of and is not discarded. Default value is 1, set
1031 this option to 0 if you want your teletext packet PTS and DTS
1032 values untouched.
1033
1034 ts_packetsize
1035 Output option carrying the raw packet size in bytes. Show the
1036 detected raw packet size, cannot be set by the user.
1037
1038 scan_all_pmts
1039 Scan and combine all PMTs. The value is an integer with value from
1040 -1 to 1 (-1 means automatic setting, 1 means enabled, 0 means
1041 disabled). Default value is -1.
1042
1043 merge_pmt_versions
1044 Re-use existing streams when a PMT's version is updated and
1045 elementary streams move to different PIDs. Default value is 0.
1046
1047 mpjpeg
1048 MJPEG encapsulated in multi-part MIME demuxer.
1049
1050 This demuxer allows reading of MJPEG, where each frame is represented
1051 as a part of multipart/x-mixed-replace stream.
1052
1053 strict_mime_boundary
1054 Default implementation applies a relaxed standard to multi-part
1055 MIME boundary detection, to prevent regression with numerous
1056 existing endpoints not generating a proper MIME MJPEG stream.
1057 Turning this option on by setting it to 1 will result in a stricter
1058 check of the boundary value.
1059
1060 rawvideo
1061 Raw video demuxer.
1062
1063 This demuxer allows one to read raw video data. Since there is no
1064 header specifying the assumed video parameters, the user must specify
1065 them in order to be able to decode the data correctly.
1066
1067 This demuxer accepts the following options:
1068
1069 framerate
1070 Set input video frame rate. Default value is 25.
1071
1072 pixel_format
1073 Set the input video pixel format. Default value is "yuv420p".
1074
1075 video_size
1076 Set the input video size. This value must be specified explicitly.
1077
1078 For example to read a rawvideo file input.raw with ffplay, assuming a
1079 pixel format of "rgb24", a video size of "320x240", and a frame rate of
1080 10 images per second, use the command:
1081
1082 ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw
1083
1084 sbg
1085 SBaGen script demuxer.
1086
1087 This demuxer reads the script language used by SBaGen
1088 <http://uazu.net/sbagen/> to generate binaural beats sessions. A SBG
1089 script looks like that:
1090
1091 -SE
1092 a: 300-2.5/3 440+4.5/0
1093 b: 300-2.5/0 440+4.5/3
1094 off: -
1095 NOW == a
1096 +0:07:00 == b
1097 +0:14:00 == a
1098 +0:21:00 == b
1099 +0:30:00 off
1100
1101 A SBG script can mix absolute and relative timestamps. If the script
1102 uses either only absolute timestamps (including the script start time)
1103 or only relative ones, then its layout is fixed, and the conversion is
1104 straightforward. On the other hand, if the script mixes both kind of
1105 timestamps, then the NOW reference for relative timestamps will be
1106 taken from the current time of day at the time the script is read, and
1107 the script layout will be frozen according to that reference. That
1108 means that if the script is directly played, the actual times will
1109 match the absolute timestamps up to the sound controller's clock
1110 accuracy, but if the user somehow pauses the playback or seeks, all
1111 times will be shifted accordingly.
1112
1113 tedcaptions
1114 JSON captions used for <http://www.ted.com/>.
1115
1116 TED does not provide links to the captions, but they can be guessed
1117 from the page. The file tools/bookmarklets.html from the FFmpeg source
1118 tree contains a bookmarklet to expose them.
1119
1120 This demuxer accepts the following option:
1121
1122 start_time
1123 Set the start time of the TED talk, in milliseconds. The default is
1124 15000 (15s). It is used to sync the captions with the downloadable
1125 videos, because they include a 15s intro.
1126
1127 Example: convert the captions to a format most players understand:
1128
1129 ffmpeg -i http://www.ted.com/talks/subtitles/id/1/lang/en talk1-en.srt
1130
1131 vapoursynth
1132 Vapoursynth wrapper.
1133
1134 Due to security concerns, Vapoursynth scripts will not be autodetected
1135 so the input format has to be forced. For ff* CLI tools, add "-f
1136 vapoursynth" before the input "-i yourscript.vpy".
1137
1138 This demuxer accepts the following option:
1139
1140 max_script_size
1141 The demuxer buffers the entire script into memory. Adjust this
1142 value to set the maximum buffer size, which in turn, acts as a
1143 ceiling for the size of scripts that can be read. Default is 1
1144 MiB.
1145
1147 Muxers are configured elements in FFmpeg which allow writing multimedia
1148 streams to a particular type of file.
1149
1150 When you configure your FFmpeg build, all the supported muxers are
1151 enabled by default. You can list all available muxers using the
1152 configure option "--list-muxers".
1153
1154 You can disable all the muxers with the configure option
1155 "--disable-muxers" and selectively enable / disable single muxers with
1156 the options "--enable-muxer=MUXER" / "--disable-muxer=MUXER".
1157
1158 The option "-muxers" of the ff* tools will display the list of enabled
1159 muxers. Use "-formats" to view a combined list of enabled demuxers and
1160 muxers.
1161
1162 A description of some of the currently available muxers follows.
1163
1164 a64
1165 A64 muxer for Commodore 64 video. Accepts a single "a64_multi" or
1166 "a64_multi5" codec video stream.
1167
1168 adts
1169 Audio Data Transport Stream muxer. It accepts a single AAC stream.
1170
1171 Options
1172
1173 It accepts the following options:
1174
1175 write_id3v2 bool
1176 Enable to write ID3v2.4 tags at the start of the stream. Default is
1177 disabled.
1178
1179 write_apetag bool
1180 Enable to write APE tags at the end of the stream. Default is
1181 disabled.
1182
1183 write_mpeg2 bool
1184 Enable to set MPEG version bit in the ADTS frame header to 1 which
1185 indicates MPEG-2. Default is 0, which indicates MPEG-4.
1186
1187 aiff
1188 Audio Interchange File Format muxer.
1189
1190 Options
1191
1192 It accepts the following options:
1193
1194 write_id3v2
1195 Enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
1196
1197 id3v2_version
1198 Select ID3v2 version to write. Currently only version 3 and 4 (aka.
1199 ID3v2.3 and ID3v2.4) are supported. The default is version 4.
1200
1201 alp
1202 Muxer for audio of High Voltage Software's Lego Racers game. It accepts
1203 a single ADPCM_IMA_ALP stream with no more than 2 channels nor a sample
1204 rate greater than 44100 Hz.
1205
1206 Extensions: tun, pcm
1207
1208 Options
1209
1210 It accepts the following options:
1211
1212 type type
1213 Set file type.
1214
1215 tun Set file type as music. Must have a sample rate of 22050 Hz.
1216
1217 pcm Set file type as sfx.
1218
1219 auto
1220 Set file type as per output file extension. ".pcm" results in
1221 type "pcm" else type "tun" is set. (default)
1222
1223 asf
1224 Advanced Systems Format muxer.
1225
1226 Note that Windows Media Audio (wma) and Windows Media Video (wmv) use
1227 this muxer too.
1228
1229 Options
1230
1231 It accepts the following options:
1232
1233 packet_size
1234 Set the muxer packet size. By tuning this setting you may reduce
1235 data fragmentation or muxer overhead depending on your source.
1236 Default value is 3200, minimum is 100, maximum is 64k.
1237
1238 avi
1239 Audio Video Interleaved muxer.
1240
1241 Options
1242
1243 It accepts the following options:
1244
1245 reserve_index_space
1246 Reserve the specified amount of bytes for the OpenDML master index
1247 of each stream within the file header. By default additional master
1248 indexes are embedded within the data packets if there is no space
1249 left in the first master index and are linked together as a chain
1250 of indexes. This index structure can cause problems for some use
1251 cases, e.g. third-party software strictly relying on the OpenDML
1252 index specification or when file seeking is slow. Reserving enough
1253 index space in the file header avoids these problems.
1254
1255 The required index space depends on the output file size and should
1256 be about 16 bytes per gigabyte. When this option is omitted or set
1257 to zero the necessary index space is guessed.
1258
1259 write_channel_mask
1260 Write the channel layout mask into the audio stream header.
1261
1262 This option is enabled by default. Disabling the channel mask can
1263 be useful in specific scenarios, e.g. when merging multiple audio
1264 streams into one for compatibility with software that only supports
1265 a single audio stream in AVI (see the "amerge" section in the
1266 ffmpeg-filters manual).
1267
1268 flipped_raw_rgb
1269 If set to true, store positive height for raw RGB bitmaps, which
1270 indicates bitmap is stored bottom-up. Note that this option does
1271 not flip the bitmap which has to be done manually beforehand, e.g.
1272 by using the vflip filter. Default is false and indicates bitmap
1273 is stored top down.
1274
1275 chromaprint
1276 Chromaprint fingerprinter.
1277
1278 This muxer feeds audio data to the Chromaprint library, which generates
1279 a fingerprint for the provided audio data. See
1280 <https://acoustid.org/chromaprint>
1281
1282 It takes a single signed native-endian 16-bit raw audio stream of at
1283 most 2 channels.
1284
1285 Options
1286
1287 silence_threshold
1288 Threshold for detecting silence. Range is from -1 to 32767, where
1289 -1 disables silence detection. Silence detection can only be used
1290 with version 3 of the algorithm. Silence detection must be
1291 disabled for use with the AcoustID service. Default is -1.
1292
1293 algorithm
1294 Version of algorithm to fingerprint with. Range is 0 to 4. Version
1295 3 enables silence detection. Default is 1.
1296
1297 fp_format
1298 Format to output the fingerprint as. Accepts the following options:
1299
1300 raw Binary raw fingerprint
1301
1302 compressed
1303 Binary compressed fingerprint
1304
1305 base64
1306 Base64 compressed fingerprint (default)
1307
1308 crc
1309 CRC (Cyclic Redundancy Check) testing format.
1310
1311 This muxer computes and prints the Adler-32 CRC of all the input audio
1312 and video frames. By default audio frames are converted to signed
1313 16-bit raw audio and video frames to raw video before computing the
1314 CRC.
1315
1316 The output of the muxer consists of a single line of the form:
1317 CRC=0xCRC, where CRC is a hexadecimal number 0-padded to 8 digits
1318 containing the CRC for all the decoded input frames.
1319
1320 See also the framecrc muxer.
1321
1322 Examples
1323
1324 For example to compute the CRC of the input, and store it in the file
1325 out.crc:
1326
1327 ffmpeg -i INPUT -f crc out.crc
1328
1329 You can print the CRC to stdout with the command:
1330
1331 ffmpeg -i INPUT -f crc -
1332
1333 You can select the output format of each frame with ffmpeg by
1334 specifying the audio and video codec and format. For example to compute
1335 the CRC of the input audio converted to PCM unsigned 8-bit and the
1336 input video converted to MPEG-2 video, use the command:
1337
1338 ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -
1339
1340 dash
1341 Dynamic Adaptive Streaming over HTTP (DASH) muxer that creates segments
1342 and manifest files according to the MPEG-DASH standard ISO/IEC
1343 23009-1:2014.
1344
1345 For more information see:
1346
1347 • ISO DASH Specification:
1348 <http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip>
1349
1350 • WebM DASH Specification:
1351 <https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification>
1352
1353 It creates a MPD manifest file and segment files for each stream.
1354
1355 The segment filename might contain pre-defined identifiers used with
1356 SegmentTemplate as defined in section 5.3.9.4.4 of the standard.
1357 Available identifiers are "$RepresentationID$", "$Number$",
1358 "$Bandwidth$" and "$Time$". In addition to the standard identifiers,
1359 an ffmpeg-specific "$ext$" identifier is also supported. When
1360 specified ffmpeg will replace $ext$ in the file name with muxing
1361 format's extensions such as mp4, webm etc.,
1362
1363 ffmpeg -re -i <input> -map 0 -map 0 -c:a libfdk_aac -c:v libx264 \
1364 -b:v:0 800k -b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline \
1365 -profile:v:0 main -bf 1 -keyint_min 120 -g 120 -sc_threshold 0 \
1366 -b_strategy 0 -ar:a:1 22050 -use_timeline 1 -use_template 1 \
1367 -window_size 5 -adaptation_sets "id=0,streams=v id=1,streams=a" \
1368 -f dash /path/to/out.mpd
1369
1370 seg_duration duration
1371 Set the segment length in seconds (fractional value can be set).
1372 The value is treated as average segment duration when use_template
1373 is enabled and use_timeline is disabled and as minimum segment
1374 duration for all the other use cases.
1375
1376 frag_duration duration
1377 Set the length in seconds of fragments within segments (fractional
1378 value can be set).
1379
1380 frag_type type
1381 Set the type of interval for fragmentation.
1382
1383 window_size size
1384 Set the maximum number of segments kept in the manifest.
1385
1386 extra_window_size size
1387 Set the maximum number of segments kept outside of the manifest
1388 before removing from disk.
1389
1390 remove_at_exit remove
1391 Enable (1) or disable (0) removal of all segments when finished.
1392
1393 use_template template
1394 Enable (1) or disable (0) use of SegmentTemplate instead of
1395 SegmentList.
1396
1397 use_timeline timeline
1398 Enable (1) or disable (0) use of SegmentTimeline in
1399 SegmentTemplate.
1400
1401 single_file single_file
1402 Enable (1) or disable (0) storing all segments in one file,
1403 accessed using byte ranges.
1404
1405 single_file_name file_name
1406 DASH-templated name to be used for baseURL. Implies single_file set
1407 to "1". In the template, "$ext$" is replaced with the file name
1408 extension specific for the segment format.
1409
1410 init_seg_name init_name
1411 DASH-templated name to used for the initialization segment. Default
1412 is "init-stream$RepresentationID$.$ext$". "$ext$" is replaced with
1413 the file name extension specific for the segment format.
1414
1415 media_seg_name segment_name
1416 DASH-templated name to used for the media segments. Default is
1417 "chunk-stream$RepresentationID$-$Number%05d$.$ext$". "$ext$" is
1418 replaced with the file name extension specific for the segment
1419 format.
1420
1421 utc_timing_url utc_url
1422 URL of the page that will return the UTC timestamp in ISO format.
1423 Example: "https://time.akamai.com/?iso"
1424
1425 method method
1426 Use the given HTTP method to create output files. Generally set to
1427 PUT or POST.
1428
1429 http_user_agent user_agent
1430 Override User-Agent field in HTTP header. Applicable only for HTTP
1431 output.
1432
1433 http_persistent http_persistent
1434 Use persistent HTTP connections. Applicable only for HTTP output.
1435
1436 hls_playlist hls_playlist
1437 Generate HLS playlist files as well. The master playlist is
1438 generated with the filename hls_master_name. One media playlist
1439 file is generated for each stream with filenames media_0.m3u8,
1440 media_1.m3u8, etc.
1441
1442 hls_master_name file_name
1443 HLS master playlist name. Default is "master.m3u8".
1444
1445 streaming streaming
1446 Enable (1) or disable (0) chunk streaming mode of output. In chunk
1447 streaming mode, each frame will be a moof fragment which forms a
1448 chunk.
1449
1450 adaptation_sets adaptation_sets
1451 Assign streams to AdaptationSets. Syntax is "id=x,streams=a,b,c
1452 id=y,streams=d,e" with x and y being the IDs of the adaptation sets
1453 and a,b,c,d and e are the indices of the mapped streams.
1454
1455 To map all video (or audio) streams to an AdaptationSet, "v" (or
1456 "a") can be used as stream identifier instead of IDs.
1457
1458 When no assignment is defined, this defaults to an AdaptationSet
1459 for each stream.
1460
1461 Optional syntax is
1462 "id=x,seg_duration=x,frag_duration=x,frag_type=type,descriptor=descriptor_string,streams=a,b,c
1463 id=y,seg_duration=y,frag_type=type,streams=d,e" and so on,
1464 descriptor is useful to the scheme defined by ISO/IEC
1465 23009-1:2014/Amd.2:2015. For example, -adaptation_sets
1466 "id=0,descriptor=<SupplementalProperty
1467 schemeIdUri=\"urn:mpeg:dash:srd:2014\"
1468 value=\"0,0,0,1,1,2,2\"/>,streams=v". Please note that descriptor
1469 string should be a self-closing xml tag. seg_duration,
1470 frag_duration and frag_type override the global option values for
1471 each adaptation set. For example, -adaptation_sets
1472 "id=0,seg_duration=2,frag_duration=1,frag_type=duration,streams=v
1473 id=1,seg_duration=2,frag_type=none,streams=a" type_id marks an
1474 adaptation set as containing streams meant to be used for Trick
1475 Mode for the referenced adaptation set. For example,
1476 -adaptation_sets "id=0,seg_duration=2,frag_type=none,streams=0
1477 id=1,seg_duration=10,frag_type=none,trick_id=0,streams=1"
1478
1479 timeout timeout
1480 Set timeout for socket I/O operations. Applicable only for HTTP
1481 output.
1482
1483 index_correction index_correction
1484 Enable (1) or Disable (0) segment index correction logic.
1485 Applicable only when use_template is enabled and use_timeline is
1486 disabled.
1487
1488 When enabled, the logic monitors the flow of segment indexes. If a
1489 streams's segment index value is not at the expected real time
1490 position, then the logic corrects that index value.
1491
1492 Typically this logic is needed in live streaming use cases. The
1493 network bandwidth fluctuations are common during long run
1494 streaming. Each fluctuation can cause the segment indexes fall
1495 behind the expected real time position.
1496
1497 format_options options_list
1498 Set container format (mp4/webm) options using a ":" separated list
1499 of key=value parameters. Values containing ":" special characters
1500 must be escaped.
1501
1502 global_sidx global_sidx
1503 Write global SIDX atom. Applicable only for single file, mp4
1504 output, non-streaming mode.
1505
1506 dash_segment_type dash_segment_type
1507 Possible values:
1508
1509 auto
1510 If this flag is set, the dash segment files format will be
1511 selected based on the stream codec. This is the default mode.
1512
1513 mp4 If this flag is set, the dash segment files will be in in
1514 ISOBMFF format.
1515
1516 webm
1517 If this flag is set, the dash segment files will be in in WebM
1518 format.
1519
1520 ignore_io_errors ignore_io_errors
1521 Ignore IO errors during open and write. Useful for long-duration
1522 runs with network output.
1523
1524 lhls lhls
1525 Enable Low-latency HLS(LHLS). Adds #EXT-X-PREFETCH tag with current
1526 segment's URI. hls.js player folks are trying to standardize an
1527 open LHLS spec. The draft spec is available in
1528 https://github.com/video-dev/hlsjs-rfcs/blob/lhls-spec/proposals/0001-lhls.md
1529 This option tries to comply with the above open spec. It enables
1530 streaming and hls_playlist options automatically. This is an
1531 experimental feature.
1532
1533 Note: This is not Apple's version LHLS. See
1534 <https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis>
1535
1536 ldash ldash
1537 Enable Low-latency Dash by constraining the presence and values of
1538 some elements.
1539
1540 master_m3u8_publish_rate master_m3u8_publish_rate
1541 Publish master playlist repeatedly every after specified number of
1542 segment intervals.
1543
1544 write_prft write_prft
1545 Write Producer Reference Time elements on supported streams. This
1546 also enables writing prft boxes in the underlying muxer. Applicable
1547 only when the utc_url option is enabled. It's set to auto by
1548 default, in which case the muxer will attempt to enable it only in
1549 modes that require it.
1550
1551 mpd_profile mpd_profile
1552 Set one or more manifest profiles.
1553
1554 http_opts http_opts
1555 A :-separated list of key=value options to pass to the underlying
1556 HTTP protocol. Applicable only for HTTP output.
1557
1558 target_latency target_latency
1559 Set an intended target latency in seconds (fractional value can be
1560 set) for serving. Applicable only when streaming and write_prft
1561 options are enabled. This is an informative fields clients can use
1562 to measure the latency of the service.
1563
1564 min_playback_rate min_playback_rate
1565 Set the minimum playback rate indicated as appropriate for the
1566 purposes of automatically adjusting playback latency and buffer
1567 occupancy during normal playback by clients.
1568
1569 max_playback_rate max_playback_rate
1570 Set the maximum playback rate indicated as appropriate for the
1571 purposes of automatically adjusting playback latency and buffer
1572 occupancy during normal playback by clients.
1573
1574 update_period update_period
1575 Set the mpd update period ,for dynamic content.
1576 The unit is second.
1577
1578 fifo
1579 The fifo pseudo-muxer allows the separation of encoding and muxing by
1580 using first-in-first-out queue and running the actual muxer in a
1581 separate thread. This is especially useful in combination with the tee
1582 muxer and can be used to send data to several destinations with
1583 different reliability/writing speed/latency.
1584
1585 API users should be aware that callback functions (interrupt_callback,
1586 io_open and io_close) used within its AVFormatContext must be thread-
1587 safe.
1588
1589 The behavior of the fifo muxer if the queue fills up or if the output
1590 fails is selectable,
1591
1592 • output can be transparently restarted with configurable delay
1593 between retries based on real time or time of the processed stream.
1594
1595 • encoding can be blocked during temporary failure, or continue
1596 transparently dropping packets in case fifo queue fills up.
1597
1598 fifo_format
1599 Specify the format name. Useful if it cannot be guessed from the
1600 output name suffix.
1601
1602 queue_size
1603 Specify size of the queue (number of packets). Default value is 60.
1604
1605 format_opts
1606 Specify format options for the underlying muxer. Muxer options can
1607 be specified as a list of key=value pairs separated by ':'.
1608
1609 drop_pkts_on_overflow bool
1610 If set to 1 (true), in case the fifo queue fills up, packets will
1611 be dropped rather than blocking the encoder. This makes it possible
1612 to continue streaming without delaying the input, at the cost of
1613 omitting part of the stream. By default this option is set to 0
1614 (false), so in such cases the encoder will be blocked until the
1615 muxer processes some of the packets and none of them is lost.
1616
1617 attempt_recovery bool
1618 If failure occurs, attempt to recover the output. This is
1619 especially useful when used with network output, since it makes it
1620 possible to restart streaming transparently. By default this
1621 option is set to 0 (false).
1622
1623 max_recovery_attempts
1624 Sets maximum number of successive unsuccessful recovery attempts
1625 after which the output fails permanently. By default this option is
1626 set to 0 (unlimited).
1627
1628 recovery_wait_time duration
1629 Waiting time before the next recovery attempt after previous
1630 unsuccessful recovery attempt. Default value is 5 seconds.
1631
1632 recovery_wait_streamtime bool
1633 If set to 0 (false), the real time is used when waiting for the
1634 recovery attempt (i.e. the recovery will be attempted after at
1635 least recovery_wait_time seconds). If set to 1 (true), the time of
1636 the processed stream is taken into account instead (i.e. the
1637 recovery will be attempted after at least recovery_wait_time
1638 seconds of the stream is omitted). By default, this option is set
1639 to 0 (false).
1640
1641 recover_any_error bool
1642 If set to 1 (true), recovery will be attempted regardless of type
1643 of the error causing the failure. By default this option is set to
1644 0 (false) and in case of certain (usually permanent) errors the
1645 recovery is not attempted even when attempt_recovery is set to 1.
1646
1647 restart_with_keyframe bool
1648 Specify whether to wait for the keyframe after recovering from
1649 queue overflow or failure. This option is set to 0 (false) by
1650 default.
1651
1652 timeshift duration
1653 Buffer the specified amount of packets and delay writing the
1654 output. Note that queue_size must be big enough to store the
1655 packets for timeshift. At the end of the input the fifo buffer is
1656 flushed at realtime speed.
1657
1658 Examples
1659
1660 • Stream something to rtmp server, continue processing the stream at
1661 real-time rate even in case of temporary failure (network outage)
1662 and attempt to recover streaming every second indefinitely.
1663
1664 ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv -map 0:v -map 0:a
1665 -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 rtmp://example.com/live/stream_name
1666
1667 flv
1668 Adobe Flash Video Format muxer.
1669
1670 This muxer accepts the following options:
1671
1672 flvflags flags
1673 Possible values:
1674
1675 aac_seq_header_detect
1676 Place AAC sequence header based on audio stream data.
1677
1678 no_sequence_end
1679 Disable sequence end tag.
1680
1681 no_metadata
1682 Disable metadata tag.
1683
1684 no_duration_filesize
1685 Disable duration and filesize in metadata when they are equal
1686 to zero at the end of stream. (Be used to non-seekable living
1687 stream).
1688
1689 add_keyframe_index
1690 Used to facilitate seeking; particularly for HTTP pseudo
1691 streaming.
1692
1693 framecrc
1694 Per-packet CRC (Cyclic Redundancy Check) testing format.
1695
1696 This muxer computes and prints the Adler-32 CRC for each audio and
1697 video packet. By default audio frames are converted to signed 16-bit
1698 raw audio and video frames to raw video before computing the CRC.
1699
1700 The output of the muxer consists of a line for each audio and video
1701 packet of the form:
1702
1703 <stream_index>, <packet_dts>, <packet_pts>, <packet_duration>, <packet_size>, 0x<CRC>
1704
1705 CRC is a hexadecimal number 0-padded to 8 digits containing the CRC of
1706 the packet.
1707
1708 Examples
1709
1710 For example to compute the CRC of the audio and video frames in INPUT,
1711 converted to raw audio and video packets, and store it in the file
1712 out.crc:
1713
1714 ffmpeg -i INPUT -f framecrc out.crc
1715
1716 To print the information to stdout, use the command:
1717
1718 ffmpeg -i INPUT -f framecrc -
1719
1720 With ffmpeg, you can select the output format to which the audio and
1721 video frames are encoded before computing the CRC for each packet by
1722 specifying the audio and video codec. For example, to compute the CRC
1723 of each decoded input audio frame converted to PCM unsigned 8-bit and
1724 of each decoded input video frame converted to MPEG-2 video, use the
1725 command:
1726
1727 ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -
1728
1729 See also the crc muxer.
1730
1731 framehash
1732 Per-packet hash testing format.
1733
1734 This muxer computes and prints a cryptographic hash for each audio and
1735 video packet. This can be used for packet-by-packet equality checks
1736 without having to individually do a binary comparison on each.
1737
1738 By default audio frames are converted to signed 16-bit raw audio and
1739 video frames to raw video before computing the hash, but the output of
1740 explicit conversions to other codecs can also be used. It uses the
1741 SHA-256 cryptographic hash function by default, but supports several
1742 other algorithms.
1743
1744 The output of the muxer consists of a line for each audio and video
1745 packet of the form:
1746
1747 <stream_index>, <packet_dts>, <packet_pts>, <packet_duration>, <packet_size>, <hash>
1748
1749 hash is a hexadecimal number representing the computed hash for the
1750 packet.
1751
1752 hash algorithm
1753 Use the cryptographic hash function specified by the string
1754 algorithm. Supported values include "MD5", "murmur3", "RIPEMD128",
1755 "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA160", "SHA224", "SHA256"
1756 (default), "SHA512/224", "SHA512/256", "SHA384", "SHA512", "CRC32"
1757 and "adler32".
1758
1759 Examples
1760
1761 To compute the SHA-256 hash of the audio and video frames in INPUT,
1762 converted to raw audio and video packets, and store it in the file
1763 out.sha256:
1764
1765 ffmpeg -i INPUT -f framehash out.sha256
1766
1767 To print the information to stdout, using the MD5 hash function, use
1768 the command:
1769
1770 ffmpeg -i INPUT -f framehash -hash md5 -
1771
1772 See also the hash muxer.
1773
1774 framemd5
1775 Per-packet MD5 testing format.
1776
1777 This is a variant of the framehash muxer. Unlike that muxer, it
1778 defaults to using the MD5 hash function.
1779
1780 Examples
1781
1782 To compute the MD5 hash of the audio and video frames in INPUT,
1783 converted to raw audio and video packets, and store it in the file
1784 out.md5:
1785
1786 ffmpeg -i INPUT -f framemd5 out.md5
1787
1788 To print the information to stdout, use the command:
1789
1790 ffmpeg -i INPUT -f framemd5 -
1791
1792 See also the framehash and md5 muxers.
1793
1794 gif
1795 Animated GIF muxer.
1796
1797 It accepts the following options:
1798
1799 loop
1800 Set the number of times to loop the output. Use "-1" for no loop, 0
1801 for looping indefinitely (default).
1802
1803 final_delay
1804 Force the delay (expressed in centiseconds) after the last frame.
1805 Each frame ends with a delay until the next frame. The default is
1806 "-1", which is a special value to tell the muxer to re-use the
1807 previous delay. In case of a loop, you might want to customize this
1808 value to mark a pause for instance.
1809
1810 For example, to encode a gif looping 10 times, with a 5 seconds delay
1811 between the loops:
1812
1813 ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif
1814
1815 Note 1: if you wish to extract the frames into separate GIF files, you
1816 need to force the image2 muxer:
1817
1818 ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"
1819
1820 Note 2: the GIF format has a very large time base: the delay between
1821 two frames can therefore not be smaller than one centi second.
1822
1823 hash
1824 Hash testing format.
1825
1826 This muxer computes and prints a cryptographic hash of all the input
1827 audio and video frames. This can be used for equality checks without
1828 having to do a complete binary comparison.
1829
1830 By default audio frames are converted to signed 16-bit raw audio and
1831 video frames to raw video before computing the hash, but the output of
1832 explicit conversions to other codecs can also be used. Timestamps are
1833 ignored. It uses the SHA-256 cryptographic hash function by default,
1834 but supports several other algorithms.
1835
1836 The output of the muxer consists of a single line of the form:
1837 algo=hash, where algo is a short string representing the hash function
1838 used, and hash is a hexadecimal number representing the computed hash.
1839
1840 hash algorithm
1841 Use the cryptographic hash function specified by the string
1842 algorithm. Supported values include "MD5", "murmur3", "RIPEMD128",
1843 "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA160", "SHA224", "SHA256"
1844 (default), "SHA512/224", "SHA512/256", "SHA384", "SHA512", "CRC32"
1845 and "adler32".
1846
1847 Examples
1848
1849 To compute the SHA-256 hash of the input converted to raw audio and
1850 video, and store it in the file out.sha256:
1851
1852 ffmpeg -i INPUT -f hash out.sha256
1853
1854 To print an MD5 hash to stdout use the command:
1855
1856 ffmpeg -i INPUT -f hash -hash md5 -
1857
1858 See also the framehash muxer.
1859
1860 hls
1861 Apple HTTP Live Streaming muxer that segments MPEG-TS according to the
1862 HTTP Live Streaming (HLS) specification.
1863
1864 It creates a playlist file, and one or more segment files. The output
1865 filename specifies the playlist filename.
1866
1867 By default, the muxer creates a file for each segment produced. These
1868 files have the same name as the playlist, followed by a sequential
1869 number and a .ts extension.
1870
1871 Make sure to require a closed GOP when encoding and to set the GOP size
1872 to fit your segment time constraint.
1873
1874 For example, to convert an input file with ffmpeg:
1875
1876 ffmpeg -i in.mkv -c:v h264 -flags +cgop -g 30 -hls_time 1 out.m3u8
1877
1878 This example will produce the playlist, out.m3u8, and segment files:
1879 out0.ts, out1.ts, out2.ts, etc.
1880
1881 See also the segment muxer, which provides a more generic and flexible
1882 implementation of a segmenter, and can be used to perform HLS
1883 segmentation.
1884
1885 Options
1886
1887 This muxer supports the following options:
1888
1889 hls_init_time duration
1890 Set the initial target segment length. Default value is 0.
1891
1892 duration must be a time duration specification, see the Time
1893 duration section in the ffmpeg-utils(1) manual.
1894
1895 Segment will be cut on the next key frame after this time has
1896 passed on the first m3u8 list. After the initial playlist is
1897 filled ffmpeg will cut segments at duration equal to "hls_time"
1898
1899 hls_time duration
1900 Set the target segment length. Default value is 2.
1901
1902 duration must be a time duration specification, see the Time
1903 duration section in the ffmpeg-utils(1) manual. Segment will be
1904 cut on the next key frame after this time has passed.
1905
1906 hls_list_size size
1907 Set the maximum number of playlist entries. If set to 0 the list
1908 file will contain all the segments. Default value is 5.
1909
1910 hls_delete_threshold size
1911 Set the number of unreferenced segments to keep on disk before
1912 "hls_flags delete_segments" deletes them. Increase this to allow
1913 continue clients to download segments which were recently
1914 referenced in the playlist. Default value is 1, meaning segments
1915 older than "hls_list_size+1" will be deleted.
1916
1917 hls_ts_options options_list
1918 Set output format options using a :-separated list of key=value
1919 parameters. Values containing ":" special characters must be
1920 escaped. "hls_ts_options" is deprecated, use hls_segment_options
1921 instead of it..
1922
1923 hls_start_number_source
1924 Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE")
1925 according to the specified source. Unless "hls_flags single_file"
1926 is set, it also specifies source of starting sequence numbers of
1927 segment and subtitle filenames. In any case, if "hls_flags
1928 append_list" is set and read playlist sequence number is greater
1929 than the specified start sequence number, then that value will be
1930 used as start value.
1931
1932 It accepts the following values:
1933
1934 generic (default)
1935 Set the starting sequence numbers according to start_number
1936 option value.
1937
1938 epoch
1939 The start number will be the seconds since epoch (1970-01-01
1940 00:00:00)
1941
1942 epoch_us
1943 The start number will be the microseconds since epoch
1944 (1970-01-01 00:00:00)
1945
1946 datetime
1947 The start number will be based on the current date/time as
1948 YYYYmmddHHMMSS. e.g. 20161231235759.
1949
1950 start_number number
1951 Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE") from
1952 the specified number when hls_start_number_source value is generic.
1953 (This is the default case.) Unless "hls_flags single_file" is set,
1954 it also specifies starting sequence numbers of segment and subtitle
1955 filenames. Default value is 0.
1956
1957 hls_allow_cache allowcache
1958 Explicitly set whether the client MAY (1) or MUST NOT (0) cache
1959 media segments.
1960
1961 hls_base_url baseurl
1962 Append baseurl to every entry in the playlist. Useful to generate
1963 playlists with absolute paths.
1964
1965 Note that the playlist sequence number must be unique for each
1966 segment and it is not to be confused with the segment filename
1967 sequence number which can be cyclic, for example if the wrap option
1968 is specified.
1969
1970 hls_segment_filename filename
1971 Set the segment filename. Unless "hls_flags single_file" is set,
1972 filename is used as a string format with the segment number:
1973
1974 ffmpeg -i in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
1975
1976 This example will produce the playlist, out.m3u8, and segment
1977 files: file000.ts, file001.ts, file002.ts, etc.
1978
1979 filename may contain full path or relative path specification, but
1980 only the file name part without any path info will be contained in
1981 the m3u8 segment list. Should a relative path be specified, the
1982 path of the created segment files will be relative to the current
1983 working directory. When strftime_mkdir is set, the whole expanded
1984 value of filename will be written into the m3u8 segment list.
1985
1986 When "var_stream_map" is set with two or more variant streams, the
1987 filename pattern must contain the string "%v", this string
1988 specifies the position of variant stream index in the generated
1989 segment file names.
1990
1991 ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
1992 -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
1993 -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8
1994
1995 This example will produce the playlists segment file sets:
1996 file_0_000.ts, file_0_001.ts, file_0_002.ts, etc. and
1997 file_1_000.ts, file_1_001.ts, file_1_002.ts, etc.
1998
1999 The string "%v" may be present in the filename or in the last
2000 directory name containing the file, but only in one of them.
2001 (Additionally, %v may appear multiple times in the last sub-
2002 directory or filename.) If the string %v is present in the
2003 directory name, then sub-directories are created after expanding
2004 the directory name pattern. This enables creation of segments
2005 corresponding to different variant streams in subdirectories.
2006
2007 ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
2008 -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
2009 -hls_segment_filename 'vs%v/file_%03d.ts' vs%v/out.m3u8
2010
2011 This example will produce the playlists segment file sets:
2012 vs0/file_000.ts, vs0/file_001.ts, vs0/file_002.ts, etc. and
2013 vs1/file_000.ts, vs1/file_001.ts, vs1/file_002.ts, etc.
2014
2015 strftime
2016 Use strftime() on filename to expand the segment filename with
2017 localtime. The segment number is also available in this mode, but
2018 to use it, you need to specify second_level_segment_index hls_flag
2019 and %%d will be the specifier.
2020
2021 ffmpeg -i in.nut -strftime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
2022
2023 This example will produce the playlist, out.m3u8, and segment
2024 files: file-20160215-1455569023.ts, file-20160215-1455569024.ts,
2025 etc. Note: On some systems/environments, the %s specifier is not
2026 available. See
2027 "strftime()" documentation.
2028
2029 ffmpeg -i in.nut -strftime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
2030
2031 This example will produce the playlist, out.m3u8, and segment
2032 files: file-20160215-0001.ts, file-20160215-0002.ts, etc.
2033
2034 strftime_mkdir
2035 Used together with -strftime_mkdir, it will create all
2036 subdirectories which is expanded in filename.
2037
2038 ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
2039
2040 This example will create a directory 201560215 (if it does not
2041 exist), and then produce the playlist, out.m3u8, and segment files:
2042 20160215/file-20160215-1455569023.ts,
2043 20160215/file-20160215-1455569024.ts, etc.
2044
2045 ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
2046
2047 This example will create a directory hierarchy 2016/02/15 (if any
2048 of them do not exist), and then produce the playlist, out.m3u8, and
2049 segment files: 2016/02/15/file-20160215-1455569023.ts,
2050 2016/02/15/file-20160215-1455569024.ts, etc.
2051
2052 hls_segment_options options_list
2053 Set output format options using a :-separated list of key=value
2054 parameters. Values containing ":" special characters must be
2055 escaped.
2056
2057 hls_key_info_file key_info_file
2058 Use the information in key_info_file for segment encryption. The
2059 first line of key_info_file specifies the key URI written to the
2060 playlist. The key URL is used to access the encryption key during
2061 playback. The second line specifies the path to the key file used
2062 to obtain the key during the encryption process. The key file is
2063 read as a single packed array of 16 octets in binary format. The
2064 optional third line specifies the initialization vector (IV) as a
2065 hexadecimal string to be used instead of the segment sequence
2066 number (default) for encryption. Changes to key_info_file will
2067 result in segment encryption with the new key/IV and an entry in
2068 the playlist for the new key URI/IV if "hls_flags periodic_rekey"
2069 is enabled.
2070
2071 Key info file format:
2072
2073 <key URI>
2074 <key file path>
2075 <IV> (optional)
2076
2077 Example key URIs:
2078
2079 http://server/file.key
2080 /path/to/file.key
2081 file.key
2082
2083 Example key file paths:
2084
2085 file.key
2086 /path/to/file.key
2087
2088 Example IV:
2089
2090 0123456789ABCDEF0123456789ABCDEF
2091
2092 Key info file example:
2093
2094 http://server/file.key
2095 /path/to/file.key
2096 0123456789ABCDEF0123456789ABCDEF
2097
2098 Example shell script:
2099
2100 #!/bin/sh
2101 BASE_URL=${1:-'.'}
2102 openssl rand 16 > file.key
2103 echo $BASE_URL/file.key > file.keyinfo
2104 echo file.key >> file.keyinfo
2105 echo $(openssl rand -hex 16) >> file.keyinfo
2106 ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
2107 -hls_key_info_file file.keyinfo out.m3u8
2108
2109 -hls_enc enc
2110 Enable (1) or disable (0) the AES128 encryption. When enabled
2111 every segment generated is encrypted and the encryption key is
2112 saved as playlist name.key.
2113
2114 -hls_enc_key key
2115 16-octet key to encrypt the segments, by default it is randomly
2116 generated.
2117
2118 -hls_enc_key_url keyurl
2119 If set, keyurl is prepended instead of baseurl to the key filename
2120 in the playlist.
2121
2122 -hls_enc_iv iv
2123 16-octet initialization vector for every segment instead of the
2124 autogenerated ones.
2125
2126 hls_segment_type flags
2127 Possible values:
2128
2129 mpegts
2130 Output segment files in MPEG-2 Transport Stream format. This is
2131 compatible with all HLS versions.
2132
2133 fmp4
2134 Output segment files in fragmented MP4 format, similar to MPEG-
2135 DASH. fmp4 files may be used in HLS version 7 and above.
2136
2137 hls_fmp4_init_filename filename
2138 Set filename to the fragment files header file, default filename is
2139 init.mp4.
2140
2141 Use "-strftime 1" on filename to expand the segment filename with
2142 localtime.
2143
2144 ffmpeg -i in.nut -hls_segment_type fmp4 -strftime 1 -hls_fmp4_init_filename "%s_init.mp4" out.m3u8
2145
2146 This will produce init like this 1602678741_init.mp4
2147
2148 hls_fmp4_init_resend
2149 Resend init file after m3u8 file refresh every time, default is 0.
2150
2151 When "var_stream_map" is set with two or more variant streams, the
2152 filename pattern must contain the string "%v", this string
2153 specifies the position of variant stream index in the generated
2154 init file names. The string "%v" may be present in the filename or
2155 in the last directory name containing the file. If the string is
2156 present in the directory name, then sub-directories are created
2157 after expanding the directory name pattern. This enables creation
2158 of init files corresponding to different variant streams in
2159 subdirectories.
2160
2161 hls_flags flags
2162 Possible values:
2163
2164 single_file
2165 If this flag is set, the muxer will store all segments in a
2166 single MPEG-TS file, and will use byte ranges in the playlist.
2167 HLS playlists generated with this way will have the version
2168 number 4. For example:
2169
2170 ffmpeg -i in.nut -hls_flags single_file out.m3u8
2171
2172 Will produce the playlist, out.m3u8, and a single segment file,
2173 out.ts.
2174
2175 delete_segments
2176 Segment files removed from the playlist are deleted after a
2177 period of time equal to the duration of the segment plus the
2178 duration of the playlist.
2179
2180 append_list
2181 Append new segments into the end of old segment list, and
2182 remove the "#EXT-X-ENDLIST" from the old segment list.
2183
2184 round_durations
2185 Round the duration info in the playlist file segment info to
2186 integer values, instead of using floating point.
2187
2188 discont_start
2189 Add the "#EXT-X-DISCONTINUITY" tag to the playlist, before the
2190 first segment's information.
2191
2192 omit_endlist
2193 Do not append the "EXT-X-ENDLIST" tag at the end of the
2194 playlist.
2195
2196 periodic_rekey
2197 The file specified by "hls_key_info_file" will be checked
2198 periodically and detect updates to the encryption info. Be sure
2199 to replace this file atomically, including the file containing
2200 the AES encryption key.
2201
2202 independent_segments
2203 Add the "#EXT-X-INDEPENDENT-SEGMENTS" to playlists that has
2204 video segments and when all the segments of that playlist are
2205 guaranteed to start with a Key frame.
2206
2207 iframes_only
2208 Add the "#EXT-X-I-FRAMES-ONLY" to playlists that has video
2209 segments and can play only I-frames in the "#EXT-X-BYTERANGE"
2210 mode.
2211
2212 split_by_time
2213 Allow segments to start on frames other than keyframes. This
2214 improves behavior on some players when the time between
2215 keyframes is inconsistent, but may make things worse on others,
2216 and can cause some oddities during seeking. This flag should be
2217 used with the "hls_time" option.
2218
2219 program_date_time
2220 Generate "EXT-X-PROGRAM-DATE-TIME" tags.
2221
2222 second_level_segment_index
2223 Makes it possible to use segment indexes as %%d in
2224 hls_segment_filename expression besides date/time values when
2225 strftime is on. To get fixed width numbers with trailing
2226 zeroes, %%0xd format is available where x is the required
2227 width.
2228
2229 second_level_segment_size
2230 Makes it possible to use segment sizes (counted in bytes) as
2231 %%s in hls_segment_filename expression besides date/time values
2232 when strftime is on. To get fixed width numbers with trailing
2233 zeroes, %%0xs format is available where x is the required
2234 width.
2235
2236 second_level_segment_duration
2237 Makes it possible to use segment duration (calculated in
2238 microseconds) as %%t in hls_segment_filename expression besides
2239 date/time values when strftime is on. To get fixed width
2240 numbers with trailing zeroes, %%0xt format is available where x
2241 is the required width.
2242
2243 ffmpeg -i sample.mpeg \
2244 -f hls -hls_time 3 -hls_list_size 5 \
2245 -hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \
2246 -strftime 1 -strftime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8
2247
2248 This will produce segments like this:
2249 segment_20170102194334_0003_00122200_0000003000000.ts,
2250 segment_20170102194334_0004_00120072_0000003000000.ts etc.
2251
2252 temp_file
2253 Write segment data to filename.tmp and rename to filename only
2254 once the segment is complete. A webserver serving up segments
2255 can be configured to reject requests to *.tmp to prevent access
2256 to in-progress segments before they have been added to the m3u8
2257 playlist. This flag also affects how m3u8 playlist files are
2258 created. If this flag is set, all playlist files will written
2259 into temporary file and renamed after they are complete,
2260 similarly as segments are handled. But playlists with "file"
2261 protocol and with type ("hls_playlist_type") other than "vod"
2262 are always written into temporary file regardless of this flag.
2263 Master playlist files ("master_pl_name"), if any, with "file"
2264 protocol, are always written into temporary file regardless of
2265 this flag if "master_pl_publish_rate" value is other than zero.
2266
2267 hls_playlist_type event
2268 Emit "#EXT-X-PLAYLIST-TYPE:EVENT" in the m3u8 header. Forces
2269 hls_list_size to 0; the playlist can only be appended to.
2270
2271 hls_playlist_type vod
2272 Emit "#EXT-X-PLAYLIST-TYPE:VOD" in the m3u8 header. Forces
2273 hls_list_size to 0; the playlist must not change.
2274
2275 method
2276 Use the given HTTP method to create the hls files.
2277
2278 ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8
2279
2280 This example will upload all the mpegts segment files to the HTTP
2281 server using the HTTP PUT method, and update the m3u8 files every
2282 "refresh" times using the same method. Note that the HTTP server
2283 must support the given method for uploading files.
2284
2285 http_user_agent
2286 Override User-Agent field in HTTP header. Applicable only for HTTP
2287 output.
2288
2289 var_stream_map
2290 Map string which specifies how to group the audio, video and
2291 subtitle streams into different variant streams. The variant stream
2292 groups are separated by space. Expected string format is like this
2293 "a:0,v:0 a:1,v:1 ....". Here a:, v:, s: are the keys to specify
2294 audio, video and subtitle streams respectively. Allowed values are
2295 0 to 9 (limited just based on practical usage).
2296
2297 When there are two or more variant streams, the output filename
2298 pattern must contain the string "%v", this string specifies the
2299 position of variant stream index in the output media playlist
2300 filenames. The string "%v" may be present in the filename or in the
2301 last directory name containing the file. If the string is present
2302 in the directory name, then sub-directories are created after
2303 expanding the directory name pattern. This enables creation of
2304 variant streams in subdirectories.
2305
2306 ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
2307 -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
2308 http://example.com/live/out_%v.m3u8
2309
2310 This example creates two hls variant streams. The first variant
2311 stream will contain video stream of bitrate 1000k and audio stream
2312 of bitrate 64k and the second variant stream will contain video
2313 stream of bitrate 256k and audio stream of bitrate 32k. Here, two
2314 media playlist with file names out_0.m3u8 and out_1.m3u8 will be
2315 created. If you want something meaningful text instead of indexes
2316 in result names, you may specify names for each or some of the
2317 variants as in the following example.
2318
2319 ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
2320 -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0,name:my_hd v:1,a:1,name:my_sd" \
2321 http://example.com/live/out_%v.m3u8
2322
2323 This example creates two hls variant streams as in the previous
2324 one. But here, the two media playlist with file names
2325 out_my_hd.m3u8 and out_my_sd.m3u8 will be created.
2326
2327 ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
2328 -map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
2329 http://example.com/live/out_%v.m3u8
2330
2331 This example creates three hls variant streams. The first variant
2332 stream will be a video only stream with video bitrate 1000k, the
2333 second variant stream will be an audio only stream with bitrate 64k
2334 and the third variant stream will be a video only stream with
2335 bitrate 256k. Here, three media playlist with file names
2336 out_0.m3u8, out_1.m3u8 and out_2.m3u8 will be created.
2337
2338 ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
2339 -map 0:v -map 0:a -map 0:v -map 0:a -f hls -var_stream_map "v:0,a:0 v:1,a:1" \
2340 http://example.com/live/vs_%v/out.m3u8
2341
2342 This example creates the variant streams in subdirectories. Here,
2343 the first media playlist is created at
2344 http://example.com/live/vs_0/out.m3u8 and the second one at
2345 http://example.com/live/vs_1/out.m3u8.
2346
2347 ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k \
2348 -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
2349 -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low v:1,agroup:aud_high" \
2350 -master_pl_name master.m3u8 \
2351 http://example.com/live/out_%v.m3u8
2352
2353 This example creates two audio only and two video only variant
2354 streams. In addition to the #EXT-X-STREAM-INF tag for each variant
2355 stream in the master playlist, #EXT-X-MEDIA tag is also added for
2356 the two audio only variant streams and they are mapped to the two
2357 video only variant streams with audio group names 'aud_low' and
2358 'aud_high'.
2359
2360 By default, a single hls variant containing all the encoded streams
2361 is created.
2362
2363 ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
2364 -map 0:a -map 0:a -map 0:v -f hls \
2365 -var_stream_map "a:0,agroup:aud_low,default:yes a:1,agroup:aud_low v:0,agroup:aud_low" \
2366 -master_pl_name master.m3u8 \
2367 http://example.com/live/out_%v.m3u8
2368
2369 This example creates two audio only and one video only variant
2370 streams. In addition to the #EXT-X-STREAM-INF tag for each variant
2371 stream in the master playlist, #EXT-X-MEDIA tag is also added for
2372 the two audio only variant streams and they are mapped to the one
2373 video only variant streams with audio group name 'aud_low', and the
2374 audio group have default stat is NO or YES.
2375
2376 By default, a single hls variant containing all the encoded streams
2377 is created.
2378
2379 ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
2380 -map 0:a -map 0:a -map 0:v -f hls \
2381 -var_stream_map "a:0,agroup:aud_low,default:yes,language:ENG a:1,agroup:aud_low,language:CHN v:0,agroup:aud_low" \
2382 -master_pl_name master.m3u8 \
2383 http://example.com/live/out_%v.m3u8
2384
2385 This example creates two audio only and one video only variant
2386 streams. In addition to the #EXT-X-STREAM-INF tag for each variant
2387 stream in the master playlist, #EXT-X-MEDIA tag is also added for
2388 the two audio only variant streams and they are mapped to the one
2389 video only variant streams with audio group name 'aud_low', and the
2390 audio group have default stat is NO or YES, and one audio have and
2391 language is named ENG, the other audio language is named CHN.
2392
2393 By default, a single hls variant containing all the encoded streams
2394 is created.
2395
2396 ffmpeg -y -i input_with_subtitle.mkv \
2397 -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
2398 -b:a:0 256k \
2399 -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
2400 -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle" \
2401 -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \
2402 10 -master_pl_publish_rate 10 -hls_flags \
2403 delete_segments+discont_start+split_by_time ./tmp/video.m3u8
2404
2405 This example adds "#EXT-X-MEDIA" tag with "TYPE=SUBTITLES" in the
2406 master playlist with webvtt subtitle group name 'subtitle'. Please
2407 make sure the input file has one text subtitle stream at least.
2408
2409 cc_stream_map
2410 Map string which specifies different closed captions groups and
2411 their attributes. The closed captions stream groups are separated
2412 by space. Expected string format is like this "ccgroup:<group
2413 name>,instreamid:<INSTREAM-ID>,language:<language code> ....".
2414 'ccgroup' and 'instreamid' are mandatory attributes. 'language' is
2415 an optional attribute. The closed captions groups configured using
2416 this option are mapped to different variant streams by providing
2417 the same 'ccgroup' name in the "var_stream_map" string. If
2418 "var_stream_map" is not set, then the first available ccgroup in
2419 "cc_stream_map" is mapped to the output variant stream. The
2420 examples for these two use cases are given below.
2421
2422 ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
2423 -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
2424 -master_pl_name master.m3u8 \
2425 http://example.com/live/out.m3u8
2426
2427 This example adds "#EXT-X-MEDIA" tag with "TYPE=CLOSED-CAPTIONS" in
2428 the master playlist with group name 'cc', language 'en' (english)
2429 and INSTREAM-ID 'CC1'. Also, it adds "CLOSED-CAPTIONS" attribute
2430 with group name 'cc' for the output variant stream.
2431
2432 ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
2433 -a53cc:0 1 -a53cc:1 1\
2434 -map 0:v -map 0:a -map 0:v -map 0:a -f hls \
2435 -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en ccgroup:cc,instreamid:CC2,language:sp" \
2436 -var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
2437 -master_pl_name master.m3u8 \
2438 http://example.com/live/out_%v.m3u8
2439
2440 This example adds two "#EXT-X-MEDIA" tags with
2441 "TYPE=CLOSED-CAPTIONS" in the master playlist for the INSTREAM-IDs
2442 'CC1' and 'CC2'. Also, it adds "CLOSED-CAPTIONS" attribute with
2443 group name 'cc' for the two output variant streams.
2444
2445 master_pl_name
2446 Create HLS master playlist with the given name.
2447
2448 ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8
2449
2450 This example creates HLS master playlist with name master.m3u8 and
2451 it is published at http://example.com/live/
2452
2453 master_pl_publish_rate
2454 Publish master play list repeatedly every after specified number of
2455 segment intervals.
2456
2457 ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 \
2458 -hls_time 2 -master_pl_publish_rate 30 http://example.com/live/out.m3u8
2459
2460 This example creates HLS master playlist with name master.m3u8 and
2461 keep publishing it repeatedly every after 30 segments i.e. every
2462 after 60s.
2463
2464 http_persistent
2465 Use persistent HTTP connections. Applicable only for HTTP output.
2466
2467 timeout
2468 Set timeout for socket I/O operations. Applicable only for HTTP
2469 output.
2470
2471 -ignore_io_errors
2472 Ignore IO errors during open, write and delete. Useful for long-
2473 duration runs with network output.
2474
2475 headers
2476 Set custom HTTP headers, can override built in default headers.
2477 Applicable only for HTTP output.
2478
2479 ico
2480 ICO file muxer.
2481
2482 Microsoft's icon file format (ICO) has some strict limitations that
2483 should be noted:
2484
2485 • Size cannot exceed 256 pixels in any dimension
2486
2487 • Only BMP and PNG images can be stored
2488
2489 • If a BMP image is used, it must be one of the following pixel
2490 formats:
2491
2492 BMP Bit Depth FFmpeg Pixel Format
2493 1bit pal8
2494 4bit pal8
2495 8bit pal8
2496 16bit rgb555le
2497 24bit bgr24
2498 32bit bgra
2499
2500 • If a BMP image is used, it must use the BITMAPINFOHEADER DIB header
2501
2502 • If a PNG image is used, it must use the rgba pixel format
2503
2504 image2
2505 Image file muxer.
2506
2507 The image file muxer writes video frames to image files.
2508
2509 The output filenames are specified by a pattern, which can be used to
2510 produce sequentially numbered series of files. The pattern may contain
2511 the string "%d" or "%0Nd", this string specifies the position of the
2512 characters representing a numbering in the filenames. If the form
2513 "%0Nd" is used, the string representing the number in each filename is
2514 0-padded to N digits. The literal character '%' can be specified in the
2515 pattern with the string "%%".
2516
2517 If the pattern contains "%d" or "%0Nd", the first filename of the file
2518 list specified will contain the number 1, all the following numbers
2519 will be sequential.
2520
2521 The pattern may contain a suffix which is used to automatically
2522 determine the format of the image files to write.
2523
2524 For example the pattern "img-%03d.bmp" will specify a sequence of
2525 filenames of the form img-001.bmp, img-002.bmp, ..., img-010.bmp, etc.
2526 The pattern "img%%-%d.jpg" will specify a sequence of filenames of the
2527 form img%-1.jpg, img%-2.jpg, ..., img%-10.jpg, etc.
2528
2529 The image muxer supports the .Y.U.V image file format. This format is
2530 special in that that each image frame consists of three files, for each
2531 of the YUV420P components. To read or write this image file format,
2532 specify the name of the '.Y' file. The muxer will automatically open
2533 the '.U' and '.V' files as required.
2534
2535 Options
2536
2537 frame_pts
2538 If set to 1, expand the filename with pts from pkt->pts. Default
2539 value is 0.
2540
2541 start_number
2542 Start the sequence from the specified number. Default value is 1.
2543
2544 update
2545 If set to 1, the filename will always be interpreted as just a
2546 filename, not a pattern, and the corresponding file will be
2547 continuously overwritten with new images. Default value is 0.
2548
2549 strftime
2550 If set to 1, expand the filename with date and time information
2551 from "strftime()". Default value is 0.
2552
2553 atomic_writing
2554 Write output to a temporary file, which is renamed to target
2555 filename once writing is completed. Default is disabled.
2556
2557 protocol_opts options_list
2558 Set protocol options as a :-separated list of key=value parameters.
2559 Values containing the ":" special character must be escaped.
2560
2561 Examples
2562
2563 The following example shows how to use ffmpeg for creating a sequence
2564 of files img-001.jpeg, img-002.jpeg, ..., taking one image every second
2565 from the input video:
2566
2567 ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'
2568
2569 Note that with ffmpeg, if the format is not specified with the "-f"
2570 option and the output filename specifies an image file format, the
2571 image2 muxer is automatically selected, so the previous command can be
2572 written as:
2573
2574 ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'
2575
2576 Note also that the pattern must not necessarily contain "%d" or "%0Nd",
2577 for example to create a single image file img.jpeg from the start of
2578 the input video you can employ the command:
2579
2580 ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
2581
2582 The strftime option allows you to expand the filename with date and
2583 time information. Check the documentation of the "strftime()" function
2584 for the syntax.
2585
2586 For example to generate image files from the "strftime()"
2587 "%Y-%m-%d_%H-%M-%S" pattern, the following ffmpeg command can be used:
2588
2589 ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"
2590
2591 You can set the file name with current frame's PTS:
2592
2593 ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg"
2594
2595 A more complex example is to publish contents of your desktop directly
2596 to a WebDAV server every second:
2597
2598 ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg
2599
2600 matroska
2601 Matroska container muxer.
2602
2603 This muxer implements the matroska and webm container specs.
2604
2605 Metadata
2606
2607 The recognized metadata settings in this muxer are:
2608
2609 title
2610 Set title name provided to a single track. This gets mapped to the
2611 FileDescription element for a stream written as attachment.
2612
2613 language
2614 Specify the language of the track in the Matroska languages form.
2615
2616 The language can be either the 3 letters bibliographic ISO-639-2
2617 (ISO 639-2/B) form (like "fre" for French), or a language code
2618 mixed with a country code for specialities in languages (like "fre-
2619 ca" for Canadian French).
2620
2621 stereo_mode
2622 Set stereo 3D video layout of two views in a single video track.
2623
2624 The following values are recognized:
2625
2626 mono
2627 video is not stereo
2628
2629 left_right
2630 Both views are arranged side by side, Left-eye view is on the
2631 left
2632
2633 bottom_top
2634 Both views are arranged in top-bottom orientation, Left-eye
2635 view is at bottom
2636
2637 top_bottom
2638 Both views are arranged in top-bottom orientation, Left-eye
2639 view is on top
2640
2641 checkerboard_rl
2642 Each view is arranged in a checkerboard interleaved pattern,
2643 Left-eye view being first
2644
2645 checkerboard_lr
2646 Each view is arranged in a checkerboard interleaved pattern,
2647 Right-eye view being first
2648
2649 row_interleaved_rl
2650 Each view is constituted by a row based interleaving, Right-eye
2651 view is first row
2652
2653 row_interleaved_lr
2654 Each view is constituted by a row based interleaving, Left-eye
2655 view is first row
2656
2657 col_interleaved_rl
2658 Both views are arranged in a column based interleaving manner,
2659 Right-eye view is first column
2660
2661 col_interleaved_lr
2662 Both views are arranged in a column based interleaving manner,
2663 Left-eye view is first column
2664
2665 anaglyph_cyan_red
2666 All frames are in anaglyph format viewable through red-cyan
2667 filters
2668
2669 right_left
2670 Both views are arranged side by side, Right-eye view is on the
2671 left
2672
2673 anaglyph_green_magenta
2674 All frames are in anaglyph format viewable through green-
2675 magenta filters
2676
2677 block_lr
2678 Both eyes laced in one Block, Left-eye view is first
2679
2680 block_rl
2681 Both eyes laced in one Block, Right-eye view is first
2682
2683 For example a 3D WebM clip can be created using the following command
2684 line:
2685
2686 ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm
2687
2688 Options
2689
2690 This muxer supports the following options:
2691
2692 reserve_index_space
2693 By default, this muxer writes the index for seeking (called cues in
2694 Matroska terms) at the end of the file, because it cannot know in
2695 advance how much space to leave for the index at the beginning of
2696 the file. However for some use cases -- e.g. streaming where
2697 seeking is possible but slow -- it is useful to put the index at
2698 the beginning of the file.
2699
2700 If this option is set to a non-zero value, the muxer will reserve a
2701 given amount of space in the file header and then try to write the
2702 cues there when the muxing finishes. If the reserved space does not
2703 suffice, no Cues will be written, the file will be finalized and
2704 writing the trailer will return an error. A safe size for most use
2705 cases should be about 50kB per hour of video.
2706
2707 Note that cues are only written if the output is seekable and this
2708 option will have no effect if it is not.
2709
2710 default_mode
2711 This option controls how the FlagDefault of the output tracks will
2712 be set. It influences which tracks players should play by default.
2713 The default mode is passthrough.
2714
2715 infer
2716 Every track with disposition default will have the FlagDefault
2717 set. Additionally, for each type of track (audio, video or
2718 subtitle), if no track with disposition default of this type
2719 exists, then the first track of this type will be marked as
2720 default (if existing). This ensures that the default flag is
2721 set in a sensible way even if the input originated from
2722 containers that lack the concept of default tracks.
2723
2724 infer_no_subs
2725 This mode is the same as infer except that if no subtitle track
2726 with disposition default exists, no subtitle track will be
2727 marked as default.
2728
2729 passthrough
2730 In this mode the FlagDefault is set if and only if the
2731 AV_DISPOSITION_DEFAULT flag is set in the disposition of the
2732 corresponding stream.
2733
2734 flipped_raw_rgb
2735 If set to true, store positive height for raw RGB bitmaps, which
2736 indicates bitmap is stored bottom-up. Note that this option does
2737 not flip the bitmap which has to be done manually beforehand, e.g.
2738 by using the vflip filter. Default is false and indicates bitmap
2739 is stored top down.
2740
2741 md5
2742 MD5 testing format.
2743
2744 This is a variant of the hash muxer. Unlike that muxer, it defaults to
2745 using the MD5 hash function.
2746
2747 Examples
2748
2749 To compute the MD5 hash of the input converted to raw audio and video,
2750 and store it in the file out.md5:
2751
2752 ffmpeg -i INPUT -f md5 out.md5
2753
2754 You can print the MD5 to stdout with the command:
2755
2756 ffmpeg -i INPUT -f md5 -
2757
2758 See also the hash and framemd5 muxers.
2759
2760 mov, mp4, ismv
2761 MOV/MP4/ISMV (Smooth Streaming) muxer.
2762
2763 The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 file
2764 has all the metadata about all packets stored in one location (written
2765 at the end of the file, it can be moved to the start for better
2766 playback by adding faststart to the movflags, or using the qt-faststart
2767 tool). A fragmented file consists of a number of fragments, where
2768 packets and metadata about these packets are stored together. Writing a
2769 fragmented file has the advantage that the file is decodable even if
2770 the writing is interrupted (while a normal MOV/MP4 is undecodable if it
2771 is not properly finished), and it requires less memory when writing
2772 very long files (since writing normal MOV/MP4 files stores info about
2773 every single packet in memory until the file is closed). The downside
2774 is that it is less compatible with other applications.
2775
2776 Options
2777
2778 Fragmentation is enabled by setting one of the AVOptions that define
2779 how to cut the file into fragments:
2780
2781 -moov_size bytes
2782 Reserves space for the moov atom at the beginning of the file
2783 instead of placing the moov atom at the end. If the space reserved
2784 is insufficient, muxing will fail.
2785
2786 -movflags frag_keyframe
2787 Start a new fragment at each video keyframe.
2788
2789 -frag_duration duration
2790 Create fragments that are duration microseconds long.
2791
2792 -frag_size size
2793 Create fragments that contain up to size bytes of payload data.
2794
2795 -movflags frag_custom
2796 Allow the caller to manually choose when to cut fragments, by
2797 calling "av_write_frame(ctx, NULL)" to write a fragment with the
2798 packets written so far. (This is only useful with other
2799 applications integrating libavformat, not from ffmpeg.)
2800
2801 -min_frag_duration duration
2802 Don't create fragments that are shorter than duration microseconds
2803 long.
2804
2805 If more than one condition is specified, fragments are cut when one of
2806 the specified conditions is fulfilled. The exception to this is
2807 "-min_frag_duration", which has to be fulfilled for any of the other
2808 conditions to apply.
2809
2810 Additionally, the way the output file is written can be adjusted
2811 through a few other options:
2812
2813 -movflags empty_moov
2814 Write an initial moov atom directly at the start of the file,
2815 without describing any samples in it. Generally, an mdat/moov pair
2816 is written at the start of the file, as a normal MOV/MP4 file,
2817 containing only a short portion of the file. With this option set,
2818 there is no initial mdat atom, and the moov atom only describes the
2819 tracks but has a zero duration.
2820
2821 This option is implicitly set when writing ismv (Smooth Streaming)
2822 files.
2823
2824 -movflags separate_moof
2825 Write a separate moof (movie fragment) atom for each track.
2826 Normally, packets for all tracks are written in a moof atom (which
2827 is slightly more efficient), but with this option set, the muxer
2828 writes one moof/mdat pair for each track, making it easier to
2829 separate tracks.
2830
2831 This option is implicitly set when writing ismv (Smooth Streaming)
2832 files.
2833
2834 -movflags skip_sidx
2835 Skip writing of sidx atom. When bitrate overhead due to sidx atom
2836 is high, this option could be used for cases where sidx atom is not
2837 mandatory. When global_sidx flag is enabled, this option will be
2838 ignored.
2839
2840 -movflags faststart
2841 Run a second pass moving the index (moov atom) to the beginning of
2842 the file. This operation can take a while, and will not work in
2843 various situations such as fragmented output, thus it is not
2844 enabled by default.
2845
2846 -movflags rtphint
2847 Add RTP hinting tracks to the output file.
2848
2849 -movflags disable_chpl
2850 Disable Nero chapter markers (chpl atom). Normally, both Nero
2851 chapters and a QuickTime chapter track are written to the file.
2852 With this option set, only the QuickTime chapter track will be
2853 written. Nero chapters can cause failures when the file is
2854 reprocessed with certain tagging programs, like mp3Tag 2.61a and
2855 iTunes 11.3, most likely other versions are affected as well.
2856
2857 -movflags omit_tfhd_offset
2858 Do not write any absolute base_data_offset in tfhd atoms. This
2859 avoids tying fragments to absolute byte positions in the
2860 file/streams.
2861
2862 -movflags default_base_moof
2863 Similarly to the omit_tfhd_offset, this flag avoids writing the
2864 absolute base_data_offset field in tfhd atoms, but does so by using
2865 the new default-base-is-moof flag instead. This flag is new from
2866 14496-12:2012. This may make the fragments easier to parse in
2867 certain circumstances (avoiding basing track fragment location
2868 calculations on the implicit end of the previous track fragment).
2869
2870 -write_tmcd
2871 Specify "on" to force writing a timecode track, "off" to disable it
2872 and "auto" to write a timecode track only for mov and mp4 output
2873 (default).
2874
2875 -movflags negative_cts_offsets
2876 Enables utilization of version 1 of the CTTS box, in which the CTS
2877 offsets can be negative. This enables the initial sample to have
2878 DTS/CTS of zero, and reduces the need for edit lists for some cases
2879 such as video tracks with B-frames. Additionally, eases conformance
2880 with the DASH-IF interoperability guidelines.
2881
2882 This option is implicitly set when writing ismv (Smooth Streaming)
2883 files.
2884
2885 -write_prft
2886 Write producer time reference box (PRFT) with a specified time
2887 source for the NTP field in the PRFT box. Set value as wallclock to
2888 specify timesource as wallclock time and pts to specify timesource
2889 as input packets' PTS values.
2890
2891 Setting value to pts is applicable only for a live encoding use
2892 case, where PTS values are set as as wallclock time at the source.
2893 For example, an encoding use case with decklink capture source
2894 where video_pts and audio_pts are set to abs_wallclock.
2895
2896 -movie_timescale scale
2897 Set the timescale written in the movie header box ("mvhd"). Range
2898 is 1 to INT_MAX. Default is 1000.
2899
2900 Example
2901
2902 Smooth Streaming content can be pushed in real time to a publishing
2903 point on IIS with this muxer. Example:
2904
2905 ffmpeg -re <<normal input/transcoding options>> -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)
2906
2907 mp3
2908 The MP3 muxer writes a raw MP3 stream with the following optional
2909 features:
2910
2911 • An ID3v2 metadata header at the beginning (enabled by default).
2912 Versions 2.3 and 2.4 are supported, the "id3v2_version" private
2913 option controls which one is used (3 or 4). Setting "id3v2_version"
2914 to 0 disables the ID3v2 header completely.
2915
2916 The muxer supports writing attached pictures (APIC frames) to the
2917 ID3v2 header. The pictures are supplied to the muxer in form of a
2918 video stream with a single packet. There can be any number of those
2919 streams, each will correspond to a single APIC frame. The stream
2920 metadata tags title and comment map to APIC description and picture
2921 type respectively. See <http://id3.org/id3v2.4.0-frames> for
2922 allowed picture types.
2923
2924 Note that the APIC frames must be written at the beginning, so the
2925 muxer will buffer the audio frames until it gets all the pictures.
2926 It is therefore advised to provide the pictures as soon as possible
2927 to avoid excessive buffering.
2928
2929 • A Xing/LAME frame right after the ID3v2 header (if present). It is
2930 enabled by default, but will be written only if the output is
2931 seekable. The "write_xing" private option can be used to disable
2932 it. The frame contains various information that may be useful to
2933 the decoder, like the audio duration or encoder delay.
2934
2935 • A legacy ID3v1 tag at the end of the file (disabled by default). It
2936 may be enabled with the "write_id3v1" private option, but as its
2937 capabilities are very limited, its usage is not recommended.
2938
2939 Examples:
2940
2941 Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
2942
2943 ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
2944
2945 To attach a picture to an mp3 file select both the audio and the
2946 picture stream with "map":
2947
2948 ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1
2949 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3
2950
2951 Write a "clean" MP3 without any extra features:
2952
2953 ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
2954
2955 mpegts
2956 MPEG transport stream muxer.
2957
2958 This muxer implements ISO 13818-1 and part of ETSI EN 300 468.
2959
2960 The recognized metadata settings in mpegts muxer are "service_provider"
2961 and "service_name". If they are not set the default for
2962 "service_provider" is FFmpeg and the default for "service_name" is
2963 Service01.
2964
2965 Options
2966
2967 The muxer options are:
2968
2969 mpegts_transport_stream_id integer
2970 Set the transport_stream_id. This identifies a transponder in DVB.
2971 Default is 0x0001.
2972
2973 mpegts_original_network_id integer
2974 Set the original_network_id. This is unique identifier of a network
2975 in DVB. Its main use is in the unique identification of a service
2976 through the path Original_Network_ID, Transport_Stream_ID. Default
2977 is 0x0001.
2978
2979 mpegts_service_id integer
2980 Set the service_id, also known as program in DVB. Default is
2981 0x0001.
2982
2983 mpegts_service_type integer
2984 Set the program service_type. Default is "digital_tv". Accepts the
2985 following options:
2986
2987 hex_value
2988 Any hexadecimal value between 0x01 and 0xff as defined in ETSI
2989 300 468.
2990
2991 digital_tv
2992 Digital TV service.
2993
2994 digital_radio
2995 Digital Radio service.
2996
2997 teletext
2998 Teletext service.
2999
3000 advanced_codec_digital_radio
3001 Advanced Codec Digital Radio service.
3002
3003 mpeg2_digital_hdtv
3004 MPEG2 Digital HDTV service.
3005
3006 advanced_codec_digital_sdtv
3007 Advanced Codec Digital SDTV service.
3008
3009 advanced_codec_digital_hdtv
3010 Advanced Codec Digital HDTV service.
3011
3012 mpegts_pmt_start_pid integer
3013 Set the first PID for PMTs. Default is 0x1000, minimum is 0x0020,
3014 maximum is 0x1ffa. This option has no effect in m2ts mode where the
3015 PMT PID is fixed 0x0100.
3016
3017 mpegts_start_pid integer
3018 Set the first PID for elementary streams. Default is 0x0100,
3019 minimum is 0x0020, maximum is 0x1ffa. This option has no effect in
3020 m2ts mode where the elementary stream PIDs are fixed.
3021
3022 mpegts_m2ts_mode boolean
3023 Enable m2ts mode if set to 1. Default value is "-1" which disables
3024 m2ts mode.
3025
3026 muxrate integer
3027 Set a constant muxrate. Default is VBR.
3028
3029 pes_payload_size integer
3030 Set minimum PES packet payload in bytes. Default is 2930.
3031
3032 mpegts_flags flags
3033 Set mpegts flags. Accepts the following options:
3034
3035 resend_headers
3036 Reemit PAT/PMT before writing the next packet.
3037
3038 latm
3039 Use LATM packetization for AAC.
3040
3041 pat_pmt_at_frames
3042 Reemit PAT and PMT at each video frame.
3043
3044 system_b
3045 Conform to System B (DVB) instead of System A (ATSC).
3046
3047 initial_discontinuity
3048 Mark the initial packet of each stream as discontinuity.
3049
3050 nit Emit NIT table.
3051
3052 mpegts_copyts boolean
3053 Preserve original timestamps, if value is set to 1. Default value
3054 is "-1", which results in shifting timestamps so that they start
3055 from 0.
3056
3057 omit_video_pes_length boolean
3058 Omit the PES packet length for video packets. Default is 1 (true).
3059
3060 pcr_period integer
3061 Override the default PCR retransmission time in milliseconds.
3062 Default is "-1" which means that the PCR interval will be
3063 determined automatically: 20 ms is used for CBR streams, the
3064 highest multiple of the frame duration which is less than 100 ms is
3065 used for VBR streams.
3066
3067 pat_period duration
3068 Maximum time in seconds between PAT/PMT tables. Default is 0.1.
3069
3070 sdt_period duration
3071 Maximum time in seconds between SDT tables. Default is 0.5.
3072
3073 nit_period duration
3074 Maximum time in seconds between NIT tables. Default is 0.5.
3075
3076 tables_version integer
3077 Set PAT, PMT, SDT and NIT version (default 0, valid values are from
3078 0 to 31, inclusively). This option allows updating stream
3079 structure so that standard consumer may detect the change. To do
3080 so, reopen output "AVFormatContext" (in case of API usage) or
3081 restart ffmpeg instance, cyclically changing tables_version value:
3082
3083 ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
3084 ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
3085 ...
3086 ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
3087 ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
3088 ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
3089 ...
3090
3091 Example
3092
3093 ffmpeg -i file.mpg -c copy \
3094 -mpegts_original_network_id 0x1122 \
3095 -mpegts_transport_stream_id 0x3344 \
3096 -mpegts_service_id 0x5566 \
3097 -mpegts_pmt_start_pid 0x1500 \
3098 -mpegts_start_pid 0x150 \
3099 -metadata service_provider="Some provider" \
3100 -metadata service_name="Some Channel" \
3101 out.ts
3102
3103 mxf, mxf_d10, mxf_opatom
3104 MXF muxer.
3105
3106 Options
3107
3108 The muxer options are:
3109
3110 store_user_comments bool
3111 Set if user comments should be stored if available or never. IRT
3112 D-10 does not allow user comments. The default is thus to write
3113 them for mxf and mxf_opatom but not for mxf_d10
3114
3115 null
3116 Null muxer.
3117
3118 This muxer does not generate any output file, it is mainly useful for
3119 testing or benchmarking purposes.
3120
3121 For example to benchmark decoding with ffmpeg you can use the command:
3122
3123 ffmpeg -benchmark -i INPUT -f null out.null
3124
3125 Note that the above command does not read or write the out.null file,
3126 but specifying the output file is required by the ffmpeg syntax.
3127
3128 Alternatively you can write the command as:
3129
3130 ffmpeg -benchmark -i INPUT -f null -
3131
3132 nut
3133 -syncpoints flags
3134 Change the syncpoint usage in nut:
3135
3136 default use the normal low-overhead seeking aids.
3137 none do not use the syncpoints at all, reducing the overhead but
3138 making the stream non-seekable;
3139 Use of this option is not recommended, as the resulting files are very damage
3140 sensitive and seeking is not possible. Also in general the overhead from
3141 syncpoints is negligible. Note, -C<write_index> 0 can be used to disable
3142 all growing data tables, allowing to mux endless streams with limited memory
3143 and without these disadvantages.
3144
3145 timestamped extend the syncpoint with a wallclock field.
3146
3147 The none and timestamped flags are experimental.
3148
3149 -write_index bool
3150 Write index at the end, the default is to write an index.
3151
3152 ffmpeg -i INPUT -f_strict experimental -syncpoints none - | processor
3153
3154 ogg
3155 Ogg container muxer.
3156
3157 -page_duration duration
3158 Preferred page duration, in microseconds. The muxer will attempt to
3159 create pages that are approximately duration microseconds long.
3160 This allows the user to compromise between seek granularity and
3161 container overhead. The default is 1 second. A value of 0 will fill
3162 all segments, making pages as large as possible. A value of 1 will
3163 effectively use 1 packet-per-page in most situations, giving a
3164 small seek granularity at the cost of additional container
3165 overhead.
3166
3167 -serial_offset value
3168 Serial value from which to set the streams serial number. Setting
3169 it to different and sufficiently large values ensures that the
3170 produced ogg files can be safely chained.
3171
3172 raw muxers
3173 Raw muxers accept a single stream matching the designated codec. They
3174 do not store timestamps or metadata. The recognized extension is the
3175 same as the muxer name unless indicated otherwise.
3176
3177 ac3
3178
3179 Dolby Digital, also known as AC-3, audio.
3180
3181 adx
3182
3183 CRI Middleware ADX audio.
3184
3185 This muxer will write out the total sample count near the start of the
3186 first packet when the output is seekable and the count can be stored in
3187 32 bits.
3188
3189 aptx
3190
3191 aptX (Audio Processing Technology for Bluetooth) audio.
3192
3193 aptx_hd
3194
3195 aptX HD (Audio Processing Technology for Bluetooth) audio.
3196
3197 Extensions: aptxhd
3198
3199 avs2
3200
3201 AVS2-P2/IEEE1857.4 video.
3202
3203 Extensions: avs, avs2
3204
3205 cavsvideo
3206
3207 Chinese AVS (Audio Video Standard) video.
3208
3209 Extensions: cavs
3210
3211 codec2raw
3212
3213 Codec 2 audio.
3214
3215 No extension is registered so format name has to be supplied e.g. with
3216 the ffmpeg CLI tool "-f codec2raw".
3217
3218 data
3219
3220 Data muxer accepts a single stream with any codec of any type. The
3221 input stream has to be selected using the "-map" option with the ffmpeg
3222 CLI tool.
3223
3224 No extension is registered so format name has to be supplied e.g. with
3225 the ffmpeg CLI tool "-f data".
3226
3227 dirac
3228
3229 BBC Dirac video. The Dirac Pro codec is a subset and is standardized as
3230 SMPTE VC-2.
3231
3232 Extensions: drc, vc2
3233
3234 dnxhd
3235
3236 Avid DNxHD video. It is standardized as SMPTE VC-3. Accepts DNxHR
3237 streams.
3238
3239 Extensions: dnxhd, dnxhr
3240
3241 dts
3242
3243 DTS Coherent Acoustics (DCA) audio.
3244
3245 eac3
3246
3247 Dolby Digital Plus, also known as Enhanced AC-3, audio.
3248
3249 g722
3250
3251 ITU-T G.722 audio.
3252
3253 g723_1
3254
3255 ITU-T G.723.1 audio.
3256
3257 Extensions: tco, rco
3258
3259 g726
3260
3261 ITU-T G.726 big-endian ("left-justified") audio.
3262
3263 No extension is registered so format name has to be supplied e.g. with
3264 the ffmpeg CLI tool "-f g726".
3265
3266 g726le
3267
3268 ITU-T G.726 little-endian ("right-justified") audio.
3269
3270 No extension is registered so format name has to be supplied e.g. with
3271 the ffmpeg CLI tool "-f g726le".
3272
3273 gsm
3274
3275 Global System for Mobile Communications audio.
3276
3277 h261
3278
3279 ITU-T H.261 video.
3280
3281 h263
3282
3283 ITU-T H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 video.
3284
3285 h264
3286
3287 ITU-T H.264 / MPEG-4 Part 10 AVC video. Bitstream shall be converted to
3288 Annex B syntax if it's in length-prefixed mode.
3289
3290 Extensions: h264, 264
3291
3292 hevc
3293
3294 ITU-T H.265 / MPEG-H Part 2 HEVC video. Bitstream shall be converted to
3295 Annex B syntax if it's in length-prefixed mode.
3296
3297 Extensions: hevc, h265, 265
3298
3299 m4v
3300
3301 MPEG-4 Part 2 video.
3302
3303 mjpeg
3304
3305 Motion JPEG video.
3306
3307 Extensions: mjpg, mjpeg
3308
3309 mlp
3310
3311 Meridian Lossless Packing, also known as Packed PCM, audio.
3312
3313 mp2
3314
3315 MPEG-1 Audio Layer II audio.
3316
3317 Extensions: mp2, m2a, mpa
3318
3319 mpeg1video
3320
3321 MPEG-1 Part 2 video.
3322
3323 Extensions: mpg, mpeg, m1v
3324
3325 mpeg2video
3326
3327 ITU-T H.262 / MPEG-2 Part 2 video.
3328
3329 Extensions: m2v
3330
3331 obu
3332
3333 AV1 low overhead Open Bitstream Units muxer. Temporal delimiter OBUs
3334 will be inserted in all temporal units of the stream.
3335
3336 rawvideo
3337
3338 Raw uncompressed video.
3339
3340 Extensions: yuv, rgb
3341
3342 sbc
3343
3344 Bluetooth SIG low-complexity subband codec audio.
3345
3346 Extensions: sbc, msbc
3347
3348 truehd
3349
3350 Dolby TrueHD audio.
3351
3352 Extensions: thd
3353
3354 vc1
3355
3356 SMPTE 421M / VC-1 video.
3357
3358 segment, stream_segment, ssegment
3359 Basic stream segmenter.
3360
3361 This muxer outputs streams to a number of separate files of nearly
3362 fixed duration. Output filename pattern can be set in a fashion similar
3363 to image2, or by using a "strftime" template if the strftime option is
3364 enabled.
3365
3366 "stream_segment" is a variant of the muxer used to write to streaming
3367 output formats, i.e. which do not require global headers, and is
3368 recommended for outputting e.g. to MPEG transport stream segments.
3369 "ssegment" is a shorter alias for "stream_segment".
3370
3371 Every segment starts with a keyframe of the selected reference stream,
3372 which is set through the reference_stream option.
3373
3374 Note that if you want accurate splitting for a video file, you need to
3375 make the input key frames correspond to the exact splitting times
3376 expected by the segmenter, or the segment muxer will start the new
3377 segment with the key frame found next after the specified start time.
3378
3379 The segment muxer works best with a single constant frame rate video.
3380
3381 Optionally it can generate a list of the created segments, by setting
3382 the option segment_list. The list type is specified by the
3383 segment_list_type option. The entry filenames in the segment list are
3384 set by default to the basename of the corresponding segment files.
3385
3386 See also the hls muxer, which provides a more specific implementation
3387 for HLS segmentation.
3388
3389 Options
3390
3391 The segment muxer supports the following options:
3392
3393 increment_tc 1|0
3394 if set to 1, increment timecode between each segment If this is
3395 selected, the input need to have a timecode in the first video
3396 stream. Default value is 0.
3397
3398 reference_stream specifier
3399 Set the reference stream, as specified by the string specifier. If
3400 specifier is set to "auto", the reference is chosen automatically.
3401 Otherwise it must be a stream specifier (see the ``Stream
3402 specifiers'' chapter in the ffmpeg manual) which specifies the
3403 reference stream. The default value is "auto".
3404
3405 segment_format format
3406 Override the inner container format, by default it is guessed by
3407 the filename extension.
3408
3409 segment_format_options options_list
3410 Set output format options using a :-separated list of key=value
3411 parameters. Values containing the ":" special character must be
3412 escaped.
3413
3414 segment_list name
3415 Generate also a listfile named name. If not specified no listfile
3416 is generated.
3417
3418 segment_list_flags flags
3419 Set flags affecting the segment list generation.
3420
3421 It currently supports the following flags:
3422
3423 cache
3424 Allow caching (only affects M3U8 list files).
3425
3426 live
3427 Allow live-friendly file generation.
3428
3429 segment_list_size size
3430 Update the list file so that it contains at most size segments. If
3431 0 the list file will contain all the segments. Default value is 0.
3432
3433 segment_list_entry_prefix prefix
3434 Prepend prefix to each entry. Useful to generate absolute paths.
3435 By default no prefix is applied.
3436
3437 segment_list_type type
3438 Select the listing format.
3439
3440 The following values are recognized:
3441
3442 flat
3443 Generate a flat list for the created segments, one segment per
3444 line.
3445
3446 csv, ext
3447 Generate a list for the created segments, one segment per line,
3448 each line matching the format (comma-separated values):
3449
3450 <segment_filename>,<segment_start_time>,<segment_end_time>
3451
3452 segment_filename is the name of the output file generated by
3453 the muxer according to the provided pattern. CSV escaping
3454 (according to RFC4180) is applied if required.
3455
3456 segment_start_time and segment_end_time specify the segment
3457 start and end time expressed in seconds.
3458
3459 A list file with the suffix ".csv" or ".ext" will auto-select
3460 this format.
3461
3462 ext is deprecated in favor or csv.
3463
3464 ffconcat
3465 Generate an ffconcat file for the created segments. The
3466 resulting file can be read using the FFmpeg concat demuxer.
3467
3468 A list file with the suffix ".ffcat" or ".ffconcat" will auto-
3469 select this format.
3470
3471 m3u8
3472 Generate an extended M3U8 file, version 3, compliant with
3473 <http://tools.ietf.org/id/draft-pantos-http-live-streaming>.
3474
3475 A list file with the suffix ".m3u8" will auto-select this
3476 format.
3477
3478 If not specified the type is guessed from the list file name
3479 suffix.
3480
3481 segment_time time
3482 Set segment duration to time, the value must be a duration
3483 specification. Default value is "2". See also the segment_times
3484 option.
3485
3486 Note that splitting may not be accurate, unless you force the
3487 reference stream key-frames at the given time. See the introductory
3488 notice and the examples below.
3489
3490 segment_atclocktime 1|0
3491 If set to "1" split at regular clock time intervals starting from
3492 00:00 o'clock. The time value specified in segment_time is used for
3493 setting the length of the splitting interval.
3494
3495 For example with segment_time set to "900" this makes it possible
3496 to create files at 12:00 o'clock, 12:15, 12:30, etc.
3497
3498 Default value is "0".
3499
3500 segment_clocktime_offset duration
3501 Delay the segment splitting times with the specified duration when
3502 using segment_atclocktime.
3503
3504 For example with segment_time set to "900" and
3505 segment_clocktime_offset set to "300" this makes it possible to
3506 create files at 12:05, 12:20, 12:35, etc.
3507
3508 Default value is "0".
3509
3510 segment_clocktime_wrap_duration duration
3511 Force the segmenter to only start a new segment if a packet reaches
3512 the muxer within the specified duration after the segmenting clock
3513 time. This way you can make the segmenter more resilient to
3514 backward local time jumps, such as leap seconds or transition to
3515 standard time from daylight savings time.
3516
3517 Default is the maximum possible duration which means starting a new
3518 segment regardless of the elapsed time since the last clock time.
3519
3520 segment_time_delta delta
3521 Specify the accuracy time when selecting the start time for a
3522 segment, expressed as a duration specification. Default value is
3523 "0".
3524
3525 When delta is specified a key-frame will start a new segment if its
3526 PTS satisfies the relation:
3527
3528 PTS >= start_time - time_delta
3529
3530 This option is useful when splitting video content, which is always
3531 split at GOP boundaries, in case a key frame is found just before
3532 the specified split time.
3533
3534 In particular may be used in combination with the ffmpeg option
3535 force_key_frames. The key frame times specified by force_key_frames
3536 may not be set accurately because of rounding issues, with the
3537 consequence that a key frame time may result set just before the
3538 specified time. For constant frame rate videos a value of
3539 1/(2*frame_rate) should address the worst case mismatch between the
3540 specified time and the time set by force_key_frames.
3541
3542 segment_times times
3543 Specify a list of split points. times contains a list of comma
3544 separated duration specifications, in increasing order. See also
3545 the segment_time option.
3546
3547 segment_frames frames
3548 Specify a list of split video frame numbers. frames contains a list
3549 of comma separated integer numbers, in increasing order.
3550
3551 This option specifies to start a new segment whenever a reference
3552 stream key frame is found and the sequential number (starting from
3553 0) of the frame is greater or equal to the next value in the list.
3554
3555 segment_wrap limit
3556 Wrap around segment index once it reaches limit.
3557
3558 segment_start_number number
3559 Set the sequence number of the first segment. Defaults to 0.
3560
3561 strftime 1|0
3562 Use the "strftime" function to define the name of the new segments
3563 to write. If this is selected, the output segment name must contain
3564 a "strftime" function template. Default value is 0.
3565
3566 break_non_keyframes 1|0
3567 If enabled, allow segments to start on frames other than keyframes.
3568 This improves behavior on some players when the time between
3569 keyframes is inconsistent, but may make things worse on others, and
3570 can cause some oddities during seeking. Defaults to 0.
3571
3572 reset_timestamps 1|0
3573 Reset timestamps at the beginning of each segment, so that each
3574 segment will start with near-zero timestamps. It is meant to ease
3575 the playback of the generated segments. May not work with some
3576 combinations of muxers/codecs. It is set to 0 by default.
3577
3578 initial_offset offset
3579 Specify timestamp offset to apply to the output packet timestamps.
3580 The argument must be a time duration specification, and defaults to
3581 0.
3582
3583 write_empty_segments 1|0
3584 If enabled, write an empty segment if there are no packets during
3585 the period a segment would usually span. Otherwise, the segment
3586 will be filled with the next packet written. Defaults to 0.
3587
3588 Make sure to require a closed GOP when encoding and to set the GOP size
3589 to fit your segment time constraint.
3590
3591 Examples
3592
3593 • Remux the content of file in.mkv to a list of segments out-000.nut,
3594 out-001.nut, etc., and write the list of generated segments to
3595 out.list:
3596
3597 ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
3598
3599 • Segment input and set output format options for the output
3600 segments:
3601
3602 ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
3603
3604 • Segment the input file according to the split points specified by
3605 the segment_times option:
3606
3607 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
3608
3609 • Use the ffmpeg force_key_frames option to force key frames in the
3610 input at the specified location, together with the segment option
3611 segment_time_delta to account for possible roundings operated when
3612 setting key frame times.
3613
3614 ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
3615 -f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut
3616
3617 In order to force key frames on the input file, transcoding is
3618 required.
3619
3620 • Segment the input file by splitting the input file according to the
3621 frame numbers sequence specified with the segment_frames option:
3622
3623 ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
3624
3625 • Convert the in.mkv to TS segments using the "libx264" and "aac"
3626 encoders:
3627
3628 ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
3629
3630 • Segment the input file, and create an M3U8 live playlist (can be
3631 used as live HLS source):
3632
3633 ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
3634 -segment_list_flags +live -segment_time 10 out%03d.mkv
3635
3636 smoothstreaming
3637 Smooth Streaming muxer generates a set of files (Manifest, chunks)
3638 suitable for serving with conventional web server.
3639
3640 window_size
3641 Specify the number of fragments kept in the manifest. Default 0
3642 (keep all).
3643
3644 extra_window_size
3645 Specify the number of fragments kept outside of the manifest before
3646 removing from disk. Default 5.
3647
3648 lookahead_count
3649 Specify the number of lookahead fragments. Default 2.
3650
3651 min_frag_duration
3652 Specify the minimum fragment duration (in microseconds). Default
3653 5000000.
3654
3655 remove_at_exit
3656 Specify whether to remove all fragments when finished. Default 0
3657 (do not remove).
3658
3659 streamhash
3660 Per stream hash testing format.
3661
3662 This muxer computes and prints a cryptographic hash of all the input
3663 frames, on a per-stream basis. This can be used for equality checks
3664 without having to do a complete binary comparison.
3665
3666 By default audio frames are converted to signed 16-bit raw audio and
3667 video frames to raw video before computing the hash, but the output of
3668 explicit conversions to other codecs can also be used. Timestamps are
3669 ignored. It uses the SHA-256 cryptographic hash function by default,
3670 but supports several other algorithms.
3671
3672 The output of the muxer consists of one line per stream of the form:
3673 streamindex,streamtype,algo=hash, where streamindex is the index of the
3674 mapped stream, streamtype is a single character indicating the type of
3675 stream, algo is a short string representing the hash function used, and
3676 hash is a hexadecimal number representing the computed hash.
3677
3678 hash algorithm
3679 Use the cryptographic hash function specified by the string
3680 algorithm. Supported values include "MD5", "murmur3", "RIPEMD128",
3681 "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA160", "SHA224", "SHA256"
3682 (default), "SHA512/224", "SHA512/256", "SHA384", "SHA512", "CRC32"
3683 and "adler32".
3684
3685 Examples
3686
3687 To compute the SHA-256 hash of the input converted to raw audio and
3688 video, and store it in the file out.sha256:
3689
3690 ffmpeg -i INPUT -f streamhash out.sha256
3691
3692 To print an MD5 hash to stdout use the command:
3693
3694 ffmpeg -i INPUT -f streamhash -hash md5 -
3695
3696 See also the hash and framehash muxers.
3697
3698 tee
3699 The tee muxer can be used to write the same data to several outputs,
3700 such as files or streams. It can be used, for example, to stream a
3701 video over a network and save it to disk at the same time.
3702
3703 It is different from specifying several outputs to the ffmpeg command-
3704 line tool. With the tee muxer, the audio and video data will be encoded
3705 only once. With conventional multiple outputs, multiple encoding
3706 operations in parallel are initiated, which can be a very expensive
3707 process. The tee muxer is not useful when using the libavformat API
3708 directly because it is then possible to feed the same packets to
3709 several muxers directly.
3710
3711 Since the tee muxer does not represent any particular output format,
3712 ffmpeg cannot auto-select output streams. So all streams intended for
3713 output must be specified using "-map". See the examples below.
3714
3715 Some encoders may need different options depending on the output
3716 format; the auto-detection of this can not work with the tee muxer, so
3717 they need to be explicitly specified. The main example is the
3718 global_header flag.
3719
3720 The slave outputs are specified in the file name given to the muxer,
3721 separated by '|'. If any of the slave name contains the '|' separator,
3722 leading or trailing spaces or any special character, those must be
3723 escaped (see the "Quoting and escaping" section in the ffmpeg-utils(1)
3724 manual).
3725
3726 Options
3727
3728 use_fifo bool
3729 If set to 1, slave outputs will be processed in separate threads
3730 using the fifo muxer. This allows to compensate for different
3731 speed/latency/reliability of outputs and setup transparent
3732 recovery. By default this feature is turned off.
3733
3734 fifo_options
3735 Options to pass to fifo pseudo-muxer instances. See fifo.
3736
3737 Muxer options can be specified for each slave by prepending them as a
3738 list of key=value pairs separated by ':', between square brackets. If
3739 the options values contain a special character or the ':' separator,
3740 they must be escaped; note that this is a second level escaping.
3741
3742 The following special options are also recognized:
3743
3744 f Specify the format name. Required if it cannot be guessed from the
3745 output URL.
3746
3747 bsfs[/spec]
3748 Specify a list of bitstream filters to apply to the specified
3749 output.
3750
3751 It is possible to specify to which streams a given bitstream filter
3752 applies, by appending a stream specifier to the option separated by
3753 "/". spec must be a stream specifier (see Format stream
3754 specifiers).
3755
3756 If the stream specifier is not specified, the bitstream filters
3757 will be applied to all streams in the output. This will cause that
3758 output operation to fail if the output contains streams to which
3759 the bitstream filter cannot be applied e.g. "h264_mp4toannexb"
3760 being applied to an output containing an audio stream.
3761
3762 Options for a bitstream filter must be specified in the form of
3763 "opt=value".
3764
3765 Several bitstream filters can be specified, separated by ",".
3766
3767 use_fifo bool
3768 This allows to override tee muxer use_fifo option for individual
3769 slave muxer.
3770
3771 fifo_options
3772 This allows to override tee muxer fifo_options for individual slave
3773 muxer. See fifo.
3774
3775 select
3776 Select the streams that should be mapped to the slave output,
3777 specified by a stream specifier. If not specified, this defaults to
3778 all the mapped streams. This will cause that output operation to
3779 fail if the output format does not accept all mapped streams.
3780
3781 You may use multiple stream specifiers separated by commas (",")
3782 e.g.: "a:0,v"
3783
3784 onfail
3785 Specify behaviour on output failure. This can be set to either
3786 "abort" (which is default) or "ignore". "abort" will cause whole
3787 process to fail in case of failure on this slave output. "ignore"
3788 will ignore failure on this output, so other outputs will continue
3789 without being affected.
3790
3791 Examples
3792
3793 • Encode something and both archive it in a WebM file and stream it
3794 as MPEG-TS over UDP:
3795
3796 ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
3797 "archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
3798
3799 • As above, but continue streaming even if output to local file fails
3800 (for example local drive fills up):
3801
3802 ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
3803 "[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
3804
3805 • Use ffmpeg to encode the input, and send the output to three
3806 different destinations. The "dump_extra" bitstream filter is used
3807 to add extradata information to all the output video keyframes
3808 packets, as requested by the MPEG-TS format. The select option is
3809 applied to out.aac in order to make it contain only audio packets.
3810
3811 ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
3812 -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
3813
3814 • As above, but select only stream "a:1" for the audio output. Note
3815 that a second level escaping must be performed, as ":" is a special
3816 character used to separate options.
3817
3818 ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
3819 -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"
3820
3821 webm_chunk
3822 WebM Live Chunk Muxer.
3823
3824 This muxer writes out WebM headers and chunks as separate files which
3825 can be consumed by clients that support WebM Live streams via DASH.
3826
3827 Options
3828
3829 This muxer supports the following options:
3830
3831 chunk_start_index
3832 Index of the first chunk (defaults to 0).
3833
3834 header
3835 Filename of the header where the initialization data will be
3836 written.
3837
3838 audio_chunk_duration
3839 Duration of each audio chunk in milliseconds (defaults to 5000).
3840
3841 Example
3842
3843 ffmpeg -f v4l2 -i /dev/video0 \
3844 -f alsa -i hw:0 \
3845 -map 0:0 \
3846 -c:v libvpx-vp9 \
3847 -s 640x360 -keyint_min 30 -g 30 \
3848 -f webm_chunk \
3849 -header webm_live_video_360.hdr \
3850 -chunk_start_index 1 \
3851 webm_live_video_360_%d.chk \
3852 -map 1:0 \
3853 -c:a libvorbis \
3854 -b:a 128k \
3855 -f webm_chunk \
3856 -header webm_live_audio_128.hdr \
3857 -chunk_start_index 1 \
3858 -audio_chunk_duration 1000 \
3859 webm_live_audio_128_%d.chk
3860
3861 webm_dash_manifest
3862 WebM DASH Manifest muxer.
3863
3864 This muxer implements the WebM DASH Manifest specification to generate
3865 the DASH manifest XML. It also supports manifest generation for DASH
3866 live streams.
3867
3868 For more information see:
3869
3870 • WebM DASH Specification:
3871 <https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification>
3872
3873 • ISO DASH Specification:
3874 <http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip>
3875
3876 Options
3877
3878 This muxer supports the following options:
3879
3880 adaptation_sets
3881 This option has the following syntax: "id=x,streams=a,b,c
3882 id=y,streams=d,e" where x and y are the unique identifiers of the
3883 adaptation sets and a,b,c,d and e are the indices of the
3884 corresponding audio and video streams. Any number of adaptation
3885 sets can be added using this option.
3886
3887 live
3888 Set this to 1 to create a live stream DASH Manifest. Default: 0.
3889
3890 chunk_start_index
3891 Start index of the first chunk. This will go in the startNumber
3892 attribute of the SegmentTemplate element in the manifest. Default:
3893 0.
3894
3895 chunk_duration_ms
3896 Duration of each chunk in milliseconds. This will go in the
3897 duration attribute of the SegmentTemplate element in the manifest.
3898 Default: 1000.
3899
3900 utc_timing_url
3901 URL of the page that will return the UTC timestamp in ISO format.
3902 This will go in the value attribute of the UTCTiming element in the
3903 manifest. Default: None.
3904
3905 time_shift_buffer_depth
3906 Smallest time (in seconds) shifting buffer for which any
3907 Representation is guaranteed to be available. This will go in the
3908 timeShiftBufferDepth attribute of the MPD element. Default: 60.
3909
3910 minimum_update_period
3911 Minimum update period (in seconds) of the manifest. This will go in
3912 the minimumUpdatePeriod attribute of the MPD element. Default: 0.
3913
3914 Example
3915
3916 ffmpeg -f webm_dash_manifest -i video1.webm \
3917 -f webm_dash_manifest -i video2.webm \
3918 -f webm_dash_manifest -i audio1.webm \
3919 -f webm_dash_manifest -i audio2.webm \
3920 -map 0 -map 1 -map 2 -map 3 \
3921 -c copy \
3922 -f webm_dash_manifest \
3923 -adaptation_sets "id=0,streams=0,1 id=1,streams=2,3" \
3924 manifest.xml
3925
3927 FFmpeg is able to dump metadata from media files into a simple
3928 UTF-8-encoded INI-like text file and then load it back using the
3929 metadata muxer/demuxer.
3930
3931 The file format is as follows:
3932
3933 1. A file consists of a header and a number of metadata tags divided
3934 into sections, each on its own line.
3935
3936 2. The header is a ;FFMETADATA string, followed by a version number
3937 (now 1).
3938
3939 3. Metadata tags are of the form key=value
3940
3941 4. Immediately after header follows global metadata
3942
3943 5. After global metadata there may be sections with
3944 per-stream/per-chapter metadata.
3945
3946 6. A section starts with the section name in uppercase (i.e. STREAM or
3947 CHAPTER) in brackets ([, ]) and ends with next section or end of
3948 file.
3949
3950 7. At the beginning of a chapter section there may be an optional
3951 timebase to be used for start/end values. It must be in form
3952 TIMEBASE=num/den, where num and den are integers. If the timebase
3953 is missing then start/end times are assumed to be in nanoseconds.
3954
3955 Next a chapter section must contain chapter start and end times in
3956 form START=num, END=num, where num is a positive integer.
3957
3958 8. Empty lines and lines starting with ; or # are ignored.
3959
3960 9. Metadata keys or values containing special characters (=, ;, #, \
3961 and a newline) must be escaped with a backslash \.
3962
3963 10. Note that whitespace in metadata (e.g. foo = bar) is considered to
3964 be a part of the tag (in the example above key is foo , value is
3965 bar).
3966
3967 A ffmetadata file might look like this:
3968
3969 ;FFMETADATA1
3970 title=bike\\shed
3971 ;this is a comment
3972 artist=FFmpeg troll team
3973
3974 [CHAPTER]
3975 TIMEBASE=1/1000
3976 START=0
3977 #chapter ends at 0:01:00
3978 END=60000
3979 title=chapter \#1
3980 [STREAM]
3981 title=multi\
3982 line
3983
3984 By using the ffmetadata muxer and demuxer it is possible to extract
3985 metadata from an input file to an ffmetadata file, and then transcode
3986 the file into an output file with the edited ffmetadata file.
3987
3988 Extracting an ffmetadata file with ffmpeg goes as follows:
3989
3990 ffmpeg -i INPUT -f ffmetadata FFMETADATAFILE
3991
3992 Reinserting edited metadata information from the FFMETADATAFILE file
3993 can be done as:
3994
3995 ffmpeg -i INPUT -i FFMETADATAFILE -map_metadata 1 -codec copy OUTPUT
3996
3998 ffmpeg(1), ffplay(1), ffprobe(1), libavformat(3)
3999
4001 The FFmpeg developers.
4002
4003 For details about the authorship, see the Git history of the project
4004 (git://source.ffmpeg.org/ffmpeg), e.g. by typing the command git log in
4005 the FFmpeg source directory, or browsing the online repository at
4006 <http://source.ffmpeg.org>.
4007
4008 Maintainers for the specific components are listed in the file
4009 MAINTAINERS in the source code tree.
4010
4011
4012
4013 FFMPEG-FORMATS(1)