FFMPEG-FORMATS(1)

๐ŸŒธ FFMPEG-FORMATS(1) ๐ŸŒธ

okay so bestie, welcome to the formats page ๐Ÿ’… this is the ffmpeg-formats man page, part of the FFmpeg manual fam, and it's literally your guide to all the formats. iykyk.


โœจ NAME โœจ

ffmpeg-formats โ€” FFmpeg formats ๐Ÿฆ‹


๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so here's the tea โ˜• โ€” this doc is the whole rundown on the formats that the <lavender>libavformat</lavender> library supports. and when we say formats we mean both sides of the vibe:

  • muxers โ€” the ones that write stuff out ๐Ÿ“
  • demuxers โ€” the ones that read stuff in ๐Ÿ“–

that's it, that's the whole energy. slay ๐Ÿซถ


mwa ๐Ÿ’‹ โ€” more parts coming, don't go anywhere ๐ŸŽ€

๐Ÿ’– FORMAT OPTIONS ๐Ÿ’–

okay so the libavformat library ships with a whole bunch of generic global options, and you can slap these on any muxer or demuxer, no cap. on top of that, each individual muxer/demuxer can also have its own little "private options" that only apply to that one component. very main character of them. โœจ

you set these either by writing -option value in the FFmpeg tools, or by explicitly setting the value in the AVFormatContext options, or via the libavutil/opt.h API if you're doing it programmatically. pick your fighter. ๐Ÿ’…

here's the full list of supported options, and yes we're doing all of them:

  • avioflags flags (input/output) โ€” I/O flags bestie. possible values:
    • direct โ€” reduce buffering.
  • probesize integer (input) โ€” sets the probing size in bytes, aka how much data gets analyzed to figure out the stream info. higher value = you can detect more info when it's all scattered around the stream, but it also makes latency go up ๐Ÿ˜ญ. must be an integer not lesser than 32. default is 5000000.
  • max_probe_packets integer (input) โ€” sets the max number of buffered packets when probing a codec. default is 2500 packets. ๐ŸŽ€
  • packetsize integer (output) โ€” set packet size. that's it, that's the option.
  • fflags flags โ€” set format flags. heads up: some of these only work for a limited number of formats. ๐Ÿ™ˆ

possible values for input files:

  • discardcorrupt โ€” discard corrupted packets.
  • fastseek โ€” enable fast, but inaccurate seeks for some formats. (yes, inaccurate. it's giving speed over accuracy, iykyk)
  • genpts โ€” generate missing PTS if DTS is present.
  • igndts โ€” ignore DTS if PTS is also set. in case the PTS is set, the DTS value is set to NOPTS. this one gets ignored when the nofillin flag is set.
  • ignidx โ€” ignore index.
  • nobuffer โ€” reduce the latency introduced by buffering during initial input streams analysis.
  • nofillin โ€” do not fill in missing values in packet fields that can be exactly calculated.
  • noparse โ€” disable AVParsers. this needs +nofillin too!
  • sortdts โ€” try to interleave output packets by DTS. at present, available only for AVIs with an index.

possible values for output files:

  • autobsf โ€” automatically apply bitstream filters as required by the output format. enabled by default. ๐Ÿ‘‘
  • bitexact โ€” only write platform-, build- and time-independent data. this ensures that file and data checksums are reproducible and match between platforms. its primary use is for regression testing.
  • flush_packets โ€” write out packets immediately.
  • shortest โ€” stop muxing at the end of the shortest stream. it may be needed to increase max_interleave_delta to avoid flushing the longer streams before EOF.
  • seek2any integer (input) โ€” allow seeking to non-keyframes on demuxer level when supported if set to 1. default is 0.
  • analyzeduration integer (input) โ€” specify how many microseconds are analyzed to probe the input. higher value = more accurate info detection, but more latency ๐Ÿ˜ด. it defaults to 5,000,000 microseconds = 5 seconds.
  • cryptokey hexadecimal string (input) โ€” set decryption key. ๐Ÿ”
  • indexmem integer (input) โ€” set max memory used for timestamp index (per stream).
  • rtbufsize integer (input) โ€” set max memory used for buffering real-time frames.
  • fdebug flags (input/output) โ€” print specific debug info. possible values:
    • ts
  • max_delay integer (input/output) โ€” set maximum muxing or demuxing delay in microseconds.
  • fpsprobesize integer (input) โ€” set number of frames used to probe fps.
  • audio_preload integer (output) โ€” set microseconds by which audio packets should be interleaved earlier.
  • chunk_duration integer (output) โ€” set microseconds for each chunk.
  • chunk_size integer (output) โ€” set size in bytes for each chunk.
  • err_detect, f_err_detect flags (input) โ€” set error detection flags. heads up: f_err_detect is deprecated and should be used only via the ffmpeg tool. possible values:
    • crccheck โ€” verify embedded CRCs.
    • bitstream โ€” detect bitstream specification deviations.
    • buffer โ€” detect improper bitstream length.
    • explode โ€” abort decoding on minor error detection. ๐Ÿ’€
    • careful โ€” consider things that violate the spec and have not been seen in the wild as errors.
    • compliant โ€” consider all spec non compliancies as errors.
    • aggressive โ€” consider things that a sane encoder should not do as an error.
  • max_interleave_delta integer (output) โ€” set maximum buffering duration for interleaving. the duration is in microseconds, and defaults to 10000000 (10 seconds).

so here's the lore: to make sure all the streams are interleaved correctly, libavformat will wait until it has at least one packet for each stream before actually writing any packets to the output file. but when some streams are "sparse" (i.e. there are large gaps between successive packets), this can result in excessive buffering. ๐Ÿ˜ฌ

this field specifies the maximum difference between the timestamps of the first and the last packet in the muxing queue, above which libavformat will output a packet regardless of whether it has queued a packet for all the streams.

if set to 0, libavformat will continue buffering packets until it has a packet for each stream, regardless of the maximum timestamp difference between the buffered packets.

  • use_wallclock_as_timestamps integer (input) โ€” use wallclock as timestamps if set to 1. default is 0.
  • avoid_negative_ts integer (output) โ€” possible values:
    • make_non_negative โ€” shift timestamps to make them non-negative. also note that this affects only leading negative timestamps, and not non-monotonic negative timestamps.
    • make_zero โ€” shift timestamps so that the first timestamp is 0.
    • auto (default) โ€” enables shifting when required by the target format.
    • disabled โ€” disables shifting of timestamp.

when shifting is enabled, all output timestamps are shifted by the same amount. audio, video, and subtitles desynching and relative timestamp differences are preserved compared to how they would have been without shifting. ๐Ÿซถ

  • skip_initial_bytes integer (input) โ€” set number of bytes to skip before reading header and frames if set to 1. default is 0.
  • correct_ts_overflow integer (input) โ€” correct single timestamp overflows if set to 1. default is 1.
  • flush_packets integer (output) โ€” flush the underlying I/O stream after each packet. default is -1 (auto), which means that the underlying protocol will decide, 1 enables it and has the effect of reducing the latency, and 0 disables it and may increase IO throughput in some cases.
  • output_ts_offset offset (output) โ€” set the output time offset. offset must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

the offset is added by the muxer to the output timestamps.

specifying a positive offset means that the corresponding streams are delayed by the time duration specified in offset โ€” note the original docs say "delayed bt" which is a typo but we're keeping the meaning, bestie. ๐Ÿ’… default value is 0 (meaning that no offset is applied).

  • format_whitelist list (input) โ€” "," separated list of allowed demuxers. by default all are allowed.
  • dump_separator string (input) โ€” separator used to separate the fields printed on the command line about the Stream parameters. for example, to separate the fields with newlines and indentation:
ffprobe -dump_separator "
                          "  -i ~/videos/matrixbench_mpeg2.mpg
  • max_streams integer (input) โ€” specifies the maximum number of streams. this can be used to reject files that would require too many resources due to a large number of streams. goodbye resource-hogging files โœ‹
  • skip_estimate_duration_from_pts bool (input) โ€” skip estimation of input duration if it requires an additional probing for PTS at end of file. at present, applicable for MPEG-PS and MPEG-TS.
  • duration_probesize integer (input) โ€” set probing size, in bytes, for input duration estimation when it actually requires an additional probing for PTS at end of file (at present: MPEG-PS and MPEG-TS). it's aimed at users interested in better durations probing for itself, or indirectly because using the concat demuxer, for example. the typical use case is an MPEG-TS CBR with a high bitrate, high video buffering and ending cleaning with similar PTS for video and audio: in such a scenario, the large physical gap between the last video packet and the last audio packet makes it necessary to read many bytes in order to get the video stream duration. another use case is where the default probing behaviour only reaches a single video frame which is not the last one of the stream due to frame reordering, so the duration is not accurate. setting this option has a performance impact even for small files because the probing size is fixed. default behaviour is a general purpose trade-off, largely adaptive, but the probing size will not be extended to get streams durations at all costs. must be an integer not lesser than 1, or 0 for default behaviour. phew ๐Ÿ˜ฎโ€๐Ÿ’จ
  • strict, f_strict integer (input/output) โ€” specify how strictly to follow the standards. heads up: f_strict is deprecated and should be used only via the ffmpeg tool. possible values:
    • very โ€” strictly conform to an older more strict version of the spec or reference software
    • strict โ€” strictly conform to all the things in the spec no matter what consequences
    • normal
    • unofficial โ€” allow unofficial extensions
    • experimental โ€” allow non standardized experimental things, experimental (unfinished/work in progress/not well tested) decoders and encoders. note: experimental decoders can pose a security risk, do not use this for decoding untrusted input. ๐Ÿ”ฅ like fr fr, don't do it.

๐Ÿฆ‹ Format stream specifiers ๐Ÿฆ‹

okay so format stream specifiers let you select one or more streams that match specific properties. slay. โœจ

the exact semantics of stream specifiers is defined by the avformat_match_stream_specifier() function declared in the libavformat/avformat.h header, and documented in the Stream specifiers section in the ffmpeg(1) manual. go read it if you wanna be a nerd about it (affectionate). ๐Ÿซถ


๐ŸŒˆ DEMUXERS ๐ŸŒˆ

demuxers are configured elements in FFmpeg that can read the multimedia streams from a particular type of file. think of them as the little guys who open the door and let the data in. ๐Ÿšชโœจ

okay so real talk: when you configure your FFmpeg build, every single supported demuxer is enabled by default. all of them. the whole buffet. ๐Ÿ“ you can eyeball the complete list with the configure option --list-demuxers.

Wanna nuke them all at once? --disable-demuxers and they're gone, poof. Wanna be picky instead? --enable-demuxer=DEMUXER switches exactly one back on, and --disable-demuxer=DEMUXER switches exactly one off. selective queen behavior ๐Ÿ‘‘

The -demuxers option on the ff* tools prints out the list of enabled demuxers โ€” think of it as a vibe check for your build ๐Ÿ’…. And -formats gives you the combined list of enabled demuxers and muxers, for when you want the full picture.

Below is the description of some of the currently available demuxers, bestie. buckle up ๐ŸŽ€


aa

Audible Format 2, 3, and 4 demuxer, bestie ๐ŸŽง

This one is literally just here to demux Audible Format 2, 3, and 4 (.aa) files. that's the whole job. iconic, honestly.

aac

Raw Audio Data Transport Stream AAC demuxer.

Use this to demux an ADTS input that contains a single AAC stream, along with any ID3v1/2 or APE tags hanging out in there. tags stay, stream gets demuxed. slay โœจ

apng

Animated Portable Network Graphics demuxer ๐Ÿฆ‹

This demuxer handles APNG files. Here's the tea on how it splits things: all headers โ€” except the PNG signature โ€” up to (but not including) the first fcTL chunk get transmitted as extradata. After that, frames are split as being all the chunks between two fcTL ones, or between the last fcTL and IEND chunks. no cap, that's the whole algorithm.

  • -ignore_loop bool โ€” ignore the loop variable in the file if it's set. Default is enabled.
  • -max_fps int โ€” maximum framerate in frames per second. The default of 0 imposes no limit โ€” go wild ๐Ÿƒโ€โ™€๏ธ.
  • -default_fps int โ€” default framerate in frames per second when none is specified in the file (0 meaning "as fast as possible"). Default is 15.

asf

Advanced Systems Format demuxer.

Demuxes ASF files and MMS network streams. versatile icon ๐Ÿ’…

  • -no_resync_search bool โ€” don't try to resynchronize by looking for a certain optional start code. justโ€ฆ don't look for it. leave it alone.

concat

Virtual concatenation script demuxer โ€” the actual main character of this section ๐Ÿ‘‘

This demuxer reads a list of files and other directives out of a text file, then demuxes them one after the other, as if all their packets had been muxed together. like a little mixtape of files ๐ŸŽ€

The timestamps in the files get adjusted so that the first file starts at 0 and each next file starts exactly where the previous one finishes. heads up though: this is done globally and may totally cause gaps if all streams don't have exactly the same length. ๐Ÿ˜ญ

All files must have the same streams (same codecs, same time base, etc.). no exceptions, no cap.

The duration of each file is used to adjust the timestamps of the next file. so if the duration is wrong โ€” because it was computed from the bit-rate, or because the file is truncated, for example โ€” it can cause artifacts. ugly. the duration directive exists specifically so you can override whatever duration is stored in each file. thank u next ๐Ÿ’œ

Syntax

The script is a text file in extended-ASCII, with one directive per line. Empty lines, leading spaces, and lines starting with '#' are ignored. The following directive is recognized:

  • file path โ€” path to a file to read; special characters and spaces must be escaped with backslash or single quotes. All subsequent file-related directives apply to that file. ๐Ÿ—‚๏ธ
  • ffconcat version 1.0 โ€” identifies the script type and version. For FFmpeg to recognize the format automatically, this directive must appear exactly as is (no extra space, no byte-order-mark) on the very first line of the script. first line or it doesn't count, periodt.
  • duration dur โ€” duration of the file. This info can be specified from the file itself; specifying it here may be more efficient, or it can help if the information from the file is not available or not accurate. Bonus: if the duration is set for all files, then it becomes possible to seek in the whole concatenated video. seek girlies stay winning ๐Ÿงš
  • inpoint timestamp โ€” in point of the file. When the demuxer opens the file, it instantly seeks to the specified timestamp. The seeking is done so that all streams can be presented successfully at In point. This directive works best with intra frame codecs, because with non-intra frame ones you'll usually get extra packets before the actual In point, and the decoded content will most likely contain frames before In point too. ๐Ÿ™ˆ For each file, packets before the file In point will have timestamps less than the calculated start timestamp of the file (negative in the case of the first file), and the duration of the files (if it wasn't specified by the duration directive) will be reduced based on their specified In point. Because of those potential packets before the specified In point, packet timestamps may overlap between two concatenated files. yes, really.
  • outpoint timestamp โ€” out point of the file. When the demuxer reaches the specified decoding timestamp in any of the streams, it treats it as an end of file condition and skips the current packet and all the remaining packets from all streams. Out point is exclusive, which means the demuxer will not output packets with a decoding timestamp greater than or equal to Out point. This works best with intra frame codecs and formats where all streams are tightly interleaved. For non-intra frame codecs you'll usually get additional packets with presentation timestamps after Out point, so the decoded content will most likely contain frames after Out point too. And if your streams are not tightly interleaved, you may not get all the packets from all the streams before Out point โ€” you may only be able to decode the earliest stream until Out point. ๐Ÿ˜ฌ The duration of the files (if it wasn't specified by the duration directive) will be reduced based on their specified Out point.
  • file_packet_metadata key=value โ€” metadata of the packets of the file. The specified metadata gets set for each file packet. You can specify this directive multiple times to add multiple metadata entries. โš ๏ธ this directive is deprecated โ€” use file_packet_meta instead.
  • file_packet_meta key value โ€” metadata of the packets of the file. The specified metadata gets set for each file packet. You can specify this directive multiple times to add multiple metadata entries. this is the glow-up version, use it ๐Ÿ’…
  • option key value โ€” option to access, open, and probe the file. Can be present multiple times.
  • stream โ€” introduces a stream in the virtual file. All subsequent stream-related directives apply to the last introduced stream. Some stream properties must be set in order to allow identifying the matching streams in the subfiles. And if no streams are defined in the script at all, the streams from the first file are copied. (copy-paste queen behavior)
  • exact_stream_id id โ€” set the id of the stream. If this directive is given, the string with the corresponding id in the subfiles will be used. This is especially useful for MPEG-PS (VOB) files, where the order of the streams is not reliable. iykyk ๐ŸŽฌ
  • stream_meta key value โ€” metadata for the stream. Can be present multiple times.
  • stream_codec value โ€” codec for the stream.
  • stream_extradata hex_string โ€” extradata for the string, encoded in hexadecimal.
  • chapter id start end โ€” add a chapter. id is a unique identifier, possibly small and consecutive.

Options

This demuxer accepts the following options:

  • safe โ€” if set to 1, reject unsafe file paths and directives. A file path counts as safe if it does not contain a protocol specification, is relative, and all its components only contain characters from the portable character set (letters, digits, period, underscore, and hyphen), with no period at the beginning of any component. ๐Ÿ”’ If set to 0, any file name is accepted. anything. chaos mode. The default is 1.
  • auto_convert โ€” if set to 1, try to perform automatic conversions on packet data so the streams become concatenable. The default is 1. Currently the only conversion is adding the h264_mp4toannexb bitstream filter to H.264 streams in MP4 format. This is necessary in particular if there are resolution changes. ๐Ÿฆ‹
  • segment_time_metadata โ€” if set to 1, every packet will contain the lavf.concat.start_time and lavf.concat.duration packet metadata values, which are the start_time and the duration of the respective file segments in the concatenated output, expressed in microseconds. The duration metadata is only set if it's known based on the concat file. The default is 0.

Examples

  • Use absolute filenames and include some comments:
# my first filename
file /mnt/share/file-1.wav
# my second filename including whitespace
file '/mnt/share/file 2.wav'
# my third filename including whitespace plus single quote
file '/mnt/share/file 3'\''.wav'
  • Allow for input format auto-probing, use safe filenames, and set the duration of the first file:
ffconcat version 1.0

file file-1.wav
duration 20.0

file subdir/file-2.wav

dash

Dynamic Adaptive Streaming over HTTP demuxer ๐ŸŒˆ

This demuxer presents all the AVStreams found in the manifest. By setting the discard flags on AVStreams, the caller gets to decide which streams are actually received โ€” you're the main character, you choose ๐Ÿ’…. Each stream mirrors the id and bandwidth properties from the <Representation> as metadata keys named id and variant_bitrate respectively.

Options

This demuxer accepts the following options:

  • cenc_decryption_key โ€” default 16-byte key, in hex, used to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7). ๐Ÿ”
  • cenc_decryption_keys โ€” dictionary of 16-byte key ID => 16-byte key, both in hex, used to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).

dvdvideo

DVD-Video demuxer, powered by libdvdnav and libdvdread. vintage tech, still serving ๐ŸŽ€

It can directly ingest DVD titles โ€” specifically sequential PGCs โ€” straight into a conversion pipeline. Menu assets, like background video or audio, can also be demuxed given the menu's coordinates (at best effort). ๐Ÿ“

Block devices (DVD drives), ISO files, and directory structures are all accepted. Activate it with -f dvdvideo in front of one of these inputs.

Heads up bestie: this demuxer does NOT have decryption code of any kind. You are on your own when working with encrypted DVDs, and you should not expect support on the matter. fr fr, don't @ me. ๐Ÿ’€

Underlying playback is handled by libdvdnav, and structure parsing by libdvdread. FFmpeg must be built with GPL library support available, as well as the configure switches --enable-libdvdnav and --enable-libdvdread.

Okay so bestie, here's the deal โ€” you're gonna hand over either the "title number" you want, or the exact PGC/PG coordinates. Lots of open-source DVD players and tools can help you find that info. If you don't specify anything, the demuxer just defaults to title 1, which honestly works for a lot of discs. But โ€” and this is the tea โ€” because the format is so flexible, it's recommended to check manually. There are so many discs out there authored in the weirdest ways or with straight-up invalid headers. ๐Ÿ™ˆ

Also, if your input is a real, physical DVD drive: heads up, some drives will silently fail reading bad sectors and just return random bits instead โ€” which is effectively corrupt data. This is especially prominent on aging or rotting discs ๐Ÿ˜ญ. You'd need a second pass plus integrity checks to even detect that corruption. And no, that's not an FFmpeg issue. Not our problem, not our vibe.

๐ŸŽ€ Background ๐ŸŽ€

Okay so DVD-Video is not a directly accessible, linear container format in the traditional sense โ€” it's giving main character with layers. Instead, it lets you do complex, programmatic playback of carefully muxed MPEG-PS streams that are stored in headerless VOB files. To the end-user, these streams are just called "titles", but the actual logical playback sequence is defined by one or more "PGCs", aka Program Group Chains, inside the title. Each PGC is then made of multiple "PGs", or "Programs", which are the actual video segments (and for a typical video feature, they're in sequential order). The PGC structure, along with stream layout and metadata, lives in IFO files that need to be parsed. Easiest way to think about it? PGCs are basically playlists. ๐Ÿ’…

A real DVD player relies on user GUI interaction via menus and an internal VM to drive the direction of demuxing. Generally the user either navigates (via menus) or gets automatically redirected to the PGC of their choice. During that process and the playback after it, the DVD player's internal VM also keeps a state and executes instructions that can create jumps to different sectors mid-playback. That's why libdvdnav is involved โ€” a linear read of the MPEG-PS blobs on the disc (VOBs) is simply not enough to produce the right sequence in many cases. Periodt.

There are many other DVD structures (whole long subject, don't get me started) that we're not covering here. NAV packets in particular are handled by this demuxer to build accurate timing, but they are not emitted as a stream. Wanna understand this at a high level? Go read this:

<https://code.videolan.org/videolan/libdvdnav/-/blob/master/doc/dvd_structures>

๐ŸŒธ Options ๐ŸŒธ

This demuxer accepts the following options:

  • title int โ€” The title number to play. Must be set if pgc and pg are not set. Not applicable to menus. Default is 0 (auto), which currently only selects the first available title (title 1) and notifies the user about the implications.
  • chapter_start int โ€” The chapter, or PTT (part-of-title), number to start at. Not applicable to menus. Default is 1.
  • chapter_end int โ€” The chapter, or PTT (part-of-title), number to end at. Not applicable to menus. Default is 0, which is a special value that signals "end at the last possible chapter".
  • angle int โ€” The video angle number, referring to what is essentially an additional video stream composed from alternate frames interleaved in the VOBs. Not applicable to menus. Default is 1.
  • region int โ€” The region code to use for playback. Some discs may use this to default playback to a particular angle in different regions. This option will not affect the region code of a real DVD drive if you're using one as input. Not applicable to menus. Default is 0, "world".
  • menu bool โ€” Demux menu assets instead of navigating a title. Requires the exact coordinates of the menu (menu_lu, menu_vts, pgc, pg). Default is false.
  • menu_lu int โ€” The menu language to demux. In DVD, menus are grouped by language. Default is 1, the first language unit.
  • menu_vts int โ€” The VTS where the menu lives, or 0 if it's a VMG menu (root-level). Default is 1, menu of the first VTS.
  • pgc int โ€” The entry PGC to start playback at, in conjunction with pg. This is the alternative to setting title. Chapter markers are not supported at this time. Must be explicitly set for menus. Default is 0, automatically resolved from the value of title.
  • pg int โ€” The entry PG to start playback at, in conjunction with pgc. This is the alternative to setting title. Chapter markers are not supported at this time. Default is 1, the first PG of the PGC.
  • preindex bool โ€” Turn this on to get accurate chapter (PTT) markers and duration measurement โ€” which requires a slow second pass read in order to index the chapter marker timestamps from NAV packets. That's lowkey non-ideal extra work for real optical drives. It's recommended (and faster) to use this option with a backup of the DVD structure stored on a hard drive. Not compatible with pgc and pg. Default is 0, false.
  • trim bool โ€” Skip padding cells (i.e. cells shorter than 1 second) from the beginning. There are so many discs with filler segments at the start of the PGC, often holding junk data meant to control a real DVD player's buffering speed and having no other material data value. Not applicable to menus. Default is 1, true.

๐Ÿฆ‹ Examples ๐Ÿฆ‹

  • Open title 3 from a given DVD structure:
ffmpeg -f dvdvideo -title 3 -i <path to DVD> ...
  • Open chapters 3-6 from title 1 from a given DVD structure:
ffmpeg -f dvdvideo -chapter_start 3 -chapter_end 6 -title 1 -i <path to DVD> ...
  • Open only chapter 5 from title 1 from a given DVD structure:
ffmpeg -f dvdvideo -chapter_start 5 -chapter_end 5 -title 1 -i <path to DVD> ...
  • Demux menu with language 1 from VTS 1, PGC 1, starting at PG 1:
ffmpeg -f dvdvideo -menu 1 -menu_lu 1 -menu_vts 1 -pgc 1 -pg 1 -i <path to DVD> ...

๐Ÿ’œ ea ๐Ÿ’œ

Electronic Arts Multimedia format demuxer.

This format is used by various Electronic Arts games. ๐ŸŽฎ

Options

  • merge_alpha bool โ€” Normally the VP6 alpha channel (if it exists) is returned as a secondary video stream. By setting this option, you can make the demuxer return a single video stream that contains the alpha channel in addition to the ordinary video. Two-for-one, slay.

๐ŸŽ€ imf ๐ŸŽ€

Interoperable Master Format demuxer.

This demuxer presents the audio and video streams it finds in an IMF Composition, as specified in <https://doi.org/10.5594/SMPTE.ST2067-2.2020>.

ffmpeg [-assetmaps <path of ASSETMAP1>,<path of ASSETMAP2>,...] -i <path of CPL> ...

If -assetmaps is not specified, the demuxer goes looking for a file called ASSETMAP.xml in the same directory as the CPL. iykyk ๐Ÿซถ


โœจ flv, live_flv, kux โœจ

Adobe Flash Video Format demuxer.

This demuxer is used to demux FLV files and RTMP network streams. For live network streams, if you force the format, you may use the live_flv option instead of flv so you can survive timestamp discontinuities. KUX is an flv variant used on the Youku platform. ๐Ÿฆ‹

ffmpeg -f flv -i myfile.flv ...
ffmpeg -f live_flv -i rtmp://<any.server>/anything/key ....
  • -flv_metadata bool โ€” Allocate the streams according to the onMetaData array content.
  • -flv_ignore_prevtag bool โ€” Ignore the size of previous tag value.
  • -flv_full_metadata bool โ€” Output all context of the onMetadata.

๐ŸŒˆ gif ๐ŸŒˆ

Animated GIF demuxer.

It accepts the following options:

  • min_delay โ€” Set the minimum valid delay between frames, in hundredths of seconds. Range is 0 to 6000. Default value is 2.
  • max_gif_delay โ€” Set the maximum valid delay between frames, in hundredths of seconds. Range is 0 to 65535. Default value is 65535 (nearly eleven minutes), which is the maximum value allowed by the specification.
  • default_delay โ€” Set the default delay between frames, in hundredths of seconds. Range is 0 to 6000. Default value is 10.
  • ignore_loop โ€” GIF files can contain info to loop a certain number of times (or infinitely). If ignore_loop is set to 1, then the loop setting from the input gets ignored and looping will not occur. If set to 0, then looping will occur and will cycle the number of times according to the GIF. Default value is 1.

For example, with the overlay filter, place an infinitely looping GIF over another video:

ffmpeg -i input.mp4 -ignore_loop 0 -i input.gif -filter_complex overlay=shortest=1 out.mkv
Heads up bestie: in the example above the shortest option for the overlay filter is used to end the output video at the length of the shortest input file โ€” which in this case is input.mp4, since the GIF in this example loops infinitely. ๐Ÿ’…

๐Ÿ“ hls ๐Ÿ“

HLS demuxer

Apple HTTP Live Streaming demuxer.

This demuxer presents all AVStreams from all variant streams. The id field is set to the bitrate variant index number. By setting the discard flags on AVStreams (by pressing a or v in ffplay), the caller can decide which variant streams to actually receive. The total bitrate of the variant that the stream belongs to is available in a metadata key named "variant_bitrate". ๐Ÿ‘‘

It accepts the following options:

  • live_start_index โ€” segment index to start live streams at (negative values are from the end).
  • prefer_x_start โ€” prefer to use #EXT-X-START if it's in the playlist, instead of live_start_index.
  • allowed_extensions โ€” a ','-separated list of file extensions that hls is allowed to access.
  • extension_picky โ€” This blocks disallowed extensions from probing. It also requires all available segments to have matching extensions to the format, except mpegts, which is always allowed. It is recommended to set the whitelists correctly instead of depending on extensions. Enabled by default.
  • max_reload โ€” Maximum number of times a insufficient list is attempted to be reloaded. Default value is 1000.
  • m3u8_hold_counters โ€” The maximum number of times to load m3u8 when it refreshes without new segments. Default value is 1000.
  • http_persistent โ€” Use persistent HTTP connections. Applicable only for HTTP streams. Enabled by default.
  • http_multiple โ€” Use multiple HTTP connections for downloading HTTP segments. Enabled by default for HTTP/1.1 servers.
  • http_seekable โ€” Use HTTP partial requests for downloading HTTP segments. 0 = disable, 1 = enable, -1 = auto. Default is auto.
  • seg_format_options โ€” Set options for the demuxer of media segments using a list of key=value pairs separated by ":".
  • seg_max_retry โ€” Maximum number of times to reload a segment on error, useful when segment skip on network error is not desired. Default value is 0.

๐Ÿงš image2 ๐Ÿงš

Image file demuxer.

okay so this demuxer reads from a list of image files that you give it via a pattern โœจ and the syntax + meaning of that pattern is decided by the pattern_type option, iykyk.

The pattern can also have a suffix, and that suffix is what gets used to automatically figure out the format of the images inside your files ๐ŸŽ€.

โš ๏ธ real talk: the size, the pixel format, and the format of every single image must be the same for all the files in the sequence. no mixing, no chaos, fr fr.

This demuxer accepts the following options:

  • framerate โ€” sets the frame rate for the video stream. defaults to 25.
  • loop โ€” if you set it to 1, it loops over the input. default value is 0.
  • pattern_type โ€” picks the pattern type used to interpret the filename you hand over.

pattern_type accepts one of these values:

  • none โ€” pattern matching is off, so the video will only contain that one specified image. use this one if you don't want to build sequences out of multiple images and your filenames might contain special pattern characters ๐Ÿ’….
  • sequence โ€” picks the sequence pattern type, which is how you specify a sequence of files indexed by sequential numbers.

A sequence pattern can contain the string "%d" or "%0Nd", which marks the position of the characters that represent a sequential number in each filename matched by the pattern. If the form "%d0Nd" is used, the string representing the number in each filename is 0-padded, and N is the total number of 0-padded digits representing that number. The literal character '%' can be written in the pattern with the string "%%".

If the sequence pattern contains "%d" or "%0Nd", then the first filename of the file list specified by the pattern must contain a number inclusively contained between start_number and start_number+start_number_range-1, and all the following numbers must be sequential.

For example the pattern "img-%03d.bmp" will match a sequence of filenames of the form img-001.bmp, img-002.bmp, ..., img-010.bmp, etc.; the pattern "i%%m%%g-%d.jpg" will match a sequence of filenames of the form i%m%g-1.jpg, i%m%g-2.jpg, ..., i%m%g-10.jpg, etc.

Note that the pattern must not necessarily contain "%d" or "%0Nd" โ€” for example to convert a single image file img.jpeg you can employ the command:

ffmpeg -i img.jpeg img.png
  • glob โ€” picks a glob wildcard pattern type.

The pattern is interpreted like a glob() pattern. This is only selectable if libavformat was compiled with globbing support.

Default value is sequence.

  • pixel_format โ€” sets the pixel format of the images to read. If you don't specify it, the pixel format is guessed from the first image file in the sequence.
  • start_number โ€” sets the index of the file matched by the image file pattern that it starts reading from. default value is 0.
  • start_number_range โ€” sets the index interval range to check when it's looking for the first image file in the sequence, starting from start_number. default value is 5.
  • ts_from_file โ€” if set to 1, it'll set the frame timestamp to the modification time of the image file. Note that monotonity of timestamps is not provided: the images go in the same order as without this option. default value is 0. If set to 2, it'll set the frame timestamp to the modification time of the image file in nanosecond precision โฑ๏ธ.
  • video_size โ€” sets the video size of the images to read. If you don't specify it, the video size is guessed from the first image file in the sequence.
  • export_path_metadata โ€” if set to 1, it adds two extra fields to the metadata found in the input, making them also available for other filters (see the drawtext filter for examples). default value is 0. The extra fields are described below:
    • lavf.image2dec.source_path โ€” corresponds to the full path to the input file being read.
    • lavf.image2dec.source_basename โ€” corresponds to the name of the file being read.

๐ŸŒˆ Examples

  • Use ffmpeg for creating a video from the images in the file sequence img-001.jpeg, img-002.jpeg, ..., assuming an input frame rate of 10 frames per second:
ffmpeg -framerate 10 -i 'img-%03d.jpeg' out.mkv
  • As above, but start by reading from a file with index 100 in the sequence:
ffmpeg -framerate 10 -start_number 100 -i 'img-%03d.jpeg' out.mkv
  • Read images matching the "*.png" glob pattern, that is all the files terminating with the .png suffix:
ffmpeg -framerate 10 -pattern_type glob -i "*.png" out.mkv

๐ŸŽฎ libgme

The Game Music Emu library is a whole collection of video game music file emulators ๐Ÿ•น๏ธโœจ

See https://bitbucket.org/mpyne/game-music-emu/overview for more information.

It accepts the following options:

  • track_index โ€” sets the index of which track to demux. The demuxer can only export one track. Track indexes start at 0. Default is to pick the first track. Number of tracks is exported as tracks metadata entry.
  • sample_rate โ€” sets the sampling rate of the exported track. Range is 1000 to 999999. Default is 44100.
  • max_size (bytes) โ€” the demuxer buffers the entire file into memory. Adjust this value to set the maximum buffer size, which in turn acts as a ceiling for the size of files that can be read. Default is 50 MiB.

๐ŸŽ›๏ธ libmodplug

ModPlug based module demuxer ๐ŸŽถ

See https://github.com/Konstanty/libmodplug

It will export one 2-channel 16-bit 44.1 kHz audio stream. Optionally, a "pal8" 16-color video stream can be exported with or without printed metadata ๐Ÿ‘€.

It accepts the following options:

  • noise_reduction โ€” applies a simple low-pass filter. Can be 1 (on) or 0 (off). Default is 0.
  • reverb_depth โ€” sets the amount of reverb. Range 0-100. Default is 0.
  • reverb_delay โ€” sets the delay in ms, clamped to 40-250 ms. Default is 0.
  • bass_amount โ€” applies bass expansion a.k.a. XBass or megabass. Range is 0 (quiet) to 100 (loud). Default is 0.
  • bass_range โ€” sets cutoff, i.e. the upper-bound for bass frequencies. Range is 10-100 Hz. Default is 0.
  • surround_depth โ€” applies a Dolby Pro-Logic surround effect. Range is 0 (quiet) to 100 (heavy). Default is 0.
  • surround_delay โ€” sets the surround delay in ms, clamped to 5-40 ms. Default is 0.
  • max_size โ€” the demuxer buffers the entire file into memory. Adjust this value to set the maximum buffer size, which in turn acts as a ceiling for the size of files that can be read. Range is 0 to 100 MiB. 0 removes the buffer size limit (not recommended ๐Ÿ™ˆ). Default is 5 MiB.
  • video_stream_expr โ€” a string which is evaluated using the eval API to assign colors to the generated video stream. Variables you can use are "x", "y", "w", "h", "t", "speed", "tempo", "order", "pattern" and "row".
  • video_stream โ€” generates a video stream. Can be 1 (on) or 0 (off). Default is 0.
  • video_stream_w โ€” sets the video frame width in 'chars' where one char indicates 8 pixels. Range 20-512. Default is 30.
  • video_stream_h โ€” sets the video frame height in 'chars' where one char indicates 8 pixels. Range 20-512. Default is 30.
  • video_stream_ptxt โ€” prints metadata on the video stream. Includes "speed", "tempo", "order", "pattern", "row" and "ts" (time in ms). Can be 1 (on) or 0 (off). Default is 1.

๐ŸŽผ libopenmpt

libopenmpt based module demuxer ๐ŸŽง

See https://lib.openmpt.org/libopenmpt/ for more information.

Some files have multiple subsongs (tracks), and this can be set with the subsong option.

It accepts the following options:

  • subsong โ€” sets the subsong index. This can be either 'all', 'auto', or the index of the subsong. Subsong indexes start at 0. The default is 'auto'.

The default value is to let libopenmpt choose.

  • layout โ€” sets the channel layout. Valid values are 1, 2, and 4 channel layouts. The default value is STEREO.
  • sample_rate โ€” sets the sample rate for libopenmpt to output. Range is from 1000 to INT_MAX. The value default is 48000.

๐Ÿ“บ mcc

Demuxer for MacCaption MCC files, and it supports MCC versions 1.0 and 2.0 ๐Ÿ’… MCC files store VANC data, which can include closed captions (EIA-608 and CEA-708), ancillary time code, pan-scan data, etc. By default, for backward compatibility, the MCC demuxer extracts just the EIA-608 and CEA-708 closed captions and returns a "EIA_608" stream, ignoring all other VANC data. You can change it to return all VANC data in a "SMPTE_436M_ANC" data stream by setting -eia608_extract 0.

โœจ Examples

  • Convert a MCC file to Scenarist (SCC) format:
ffmpeg -i CC.mcc -c:s copy CC.scc

Note that the SCC format only supports EIA-608, so this will discard all other data such as CEA-708 extensions ๐Ÿ˜ญ.

  • Merge a MCC file into a MXF file:
ffmpeg -i video_and_audio.mxf -eia608_extract 0 -i CC.mcc -c copy -map 0 -map 1 out.mxf

This retains all VANC data and inserts it into the output MXF file as a "SMPTE_436M_ANC" data stream ๐Ÿ”ฅ.


๐ŸŽฌ mov/mp4/3gp

Demuxer for Quicktime File Format & ISO/IEC Base Media File Format (ISO/IEC 14496-12 or MPEG-4 Part 12, ISO/IEC 15444-12 or JPEG 2000 Part 12).

Registered extensions: mov, mp4, m4a, 3gp, 3g2, mj2, psp, m4b, ism, ismv, isma, f4v

โœจ Options

This demuxer accepts the following options:

  • enable_drefs โ€” enables loading of external tracks, disabled by default. Enabling this can theoretically leak information in some use cases ๐Ÿ‘€.
  • use_absolute_path โ€” allows loading of external tracks via absolute paths, disabled by default. Enabling this poses a security risk. It should only be enabled if the source is known to be non-malicious.
โš ๏ธ bestie, seriously: use_absolute_path is a security risk. only turn it on when you 100% know the source isn't malicious.
  • seek_streams_individually โ€” when seeking, it identifies the closest point in each stream individually and demuxes packets in that stream from the identified point. This can lead to a different sequence of packets compared to demuxing linearly from the beginning. Default is true.
  • ignore_editlist โ€” ignores any edit list atoms. The demuxer, by default, modifies the stream index to reflect the timeline described by the edit list. Default is false.
  • advanced_editlist โ€” modifies the stream index to reflect the timeline described by the edit list. "ignore_editlist" must be set to false for this option to be effective. If both "ignore_editlist" and this option are set to false, then only the start of the stream index is modified to reflect initial dwell time or starting timestamp described by the edit list. Default is true.
  • ignore_chapters โ€” okay so this one says donโ€™t parse chapters, bestie. That includes GoPro 'HiLight' tags/moments. The catch: chapters are only parsed when the input is seekable. Default is false.
  • use_mfra_for โ€” for seekable fragmented input, this sets the fragmentโ€™s starting timestamp from the media fragment random access box, if itโ€™s present. The available values are:
    • auto โ€” auto-detect whether to set mfra timestamps as PTS or DTS (default)
    • dts โ€” set mfra timestamps as DTS
    • pts โ€” set mfra timestamps as PTS
    • 0 โ€” donโ€™t use the mfra box to set timestamps
  • use_tfdt โ€” for fragmented input, this sets the fragmentโ€™s starting timestamp to "baseMediaDecodeTime" from the "tfdt" box. Default is enabled, which will prefer to use the "tfdt" box to set DTS. Disable it to use the "earliest_presentation_time" from the "sidx" box. In either case, the timestamp from the "mfra" box will be used if itโ€™s available and "use_mfra_for" is set to pts or dts.
  • export_all โ€” export unrecognized boxes within the udta box as metadata entries. The first four characters of the box type are set as the key. Default is false.
  • export_xmp โ€” export the entire contents of the XMP_ box and uuid box as a string with key "xmp". Note that if "export_all" is set and this option isnโ€™t, the contents of the XMP_ box are still exported but with key "XMP_". Default is false.
  • activation_bytes โ€” 4-byte key required to decrypt Audible AAX and AAX+ files. See the Audible AAX subsection below ๐Ÿ‘‡.
  • audible_fixed_key โ€” fixed key used for handling Audible AAX/AAX+ files. It has been pre-set, so it should not be necessary to specify it.
  • decryption_key โ€” default 16-byte key, in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
  • decryption_keys โ€” dictionary of 16-byte key ID => 16-byte key, both in hex, to decrypt files encrypted using ISO Common Encryption (CENC/AES-128 CTR; ISO/IEC 23001-7).
  • max_stts_delta โ€” very high sample deltas written in a trakโ€™s stts box may occasionally be intended, but usually theyโ€™re written in error or used to store a negative value for dts correction when treated as signed 32-bit integers. This option lets you set an upper limit; beyond that, the delta is clamped to 1. Values greater than the limit, if negative when cast to int32, are used to adjust onward dts.

Unit is the track time scale. Range is 0 to UINT_MAX. Default is "UINT_MAX - 48000*10", which allows up to a 10 second dts correction for 48 kHz audio streams while accommodating 99.9% of "uint32" range.

  • interleaved_read โ€” interleave packets from multiple tracks at demuxer level. For badly interleaved files, this prevents playback issues caused by large gaps between packets in different tracks, as MOV/MP4 do not have packet placement requirements. However, this can cause excessive seeking on very badly interleaved files, due to seeking between tracks, so disabling it may prevent I/O issues โ€” at the expense of playback.

๐ŸŽง Audible AAX ๐ŸŽง

Audible AAX files are encrypted M4B files, and they can be decrypted by specifying a 4 byte activation secret.

ffmpeg -activation_bytes 1CEB00DA -i test.aax -vn -c:a copy output.mp4

๐ŸšŒ mpegts ๐ŸšŒ

MPEG-2 transport stream demuxer.

This demuxer accepts the following options:

  • resync_size โ€” set size limit for looking up a new synchronization. Default value is 65536.
  • skip_unknown_pmt โ€” skip PMTs for programs not defined in the PAT. Default value is 0.
  • fix_teletext_pts โ€” override teletext packet PTS and DTS values with the timestamps calculated from the PCR of the first program which the teletext stream is part of and is not discarded. Default value is 1; set this option to 0 if you want your teletext packet PTS and DTS values untouched.
  • ts_packetsize โ€” output option carrying the raw packet size in bytes. Show the detected raw packet size; it cannot be set by the user.
  • scan_all_pmts โ€” scan and combine all PMTs. The value is an integer with value from -1 to 1 (-1 means automatic setting, 1 means enabled, 0 means disabled). Default value is -1.
  • merge_pmt_versions โ€” reuse existing streams when a PMTโ€™s version is updated and elementary streams move to different PIDs. Default value is 0.
  • max_packet_size โ€” set maximum size, in bytes, of packet emitted by the demuxer. Payloads above this size are split across multiple packets. Range is 184 to INT_MAX/2. Default is 204800 bytes.

๐Ÿ–ผ๏ธ mpjpeg ๐Ÿ–ผ๏ธ

MJPEG encapsulated in multi-part MIME demuxer.

This demuxer allows reading of MJPEG, where each frame is represented as a part of multipart/x-mixed-replace stream.

  • strict_mime_boundary โ€” the default implementation applies a relaxed standard to multi-part MIME boundary detection, to prevent regression with numerous existing endpoints not generating a proper MIME MJPEG stream. Turning this option on by setting it to 1 will result in a stricter check of the boundary value.

๐Ÿ“ผ rawvideo ๐Ÿ“ผ

Raw video demuxer.

This demuxer allows one to read raw video data. Since there is no header specifying the assumed video parameters, the user must specify them in order to be able to decode the data correctly.

This demuxer accepts the following options:

  • framerate โ€” set input video frame rate. Default value is 25.
  • pixel_format โ€” set the input video pixel format. Default value is "yuv420p".
  • stride โ€” set frame line size in bytes, only required if there are extra padding. For multiplane formats, stride is a list of line size for each plane.
  • video_size โ€” set the input video size. This value must be specified explicitly.

For example, to read a rawvideo file input.raw with ffplay, assuming a pixel format of "rgb24", a video size of "320x240", and a frame rate of 10 images per second, use the command:

ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw

Read a rawvideo with ffplay, assuming a pixel format of "yuv420p", a video size of "1080x1920", 8 bytes of padding in each line of the Y plane, and 4 bytes of padding with the UV plane:

ffplay -f rawvideo -pixel_format yuv420p -video_size 1080x1920 -stride 1088,544,544 input.raw

๐Ÿ“บ rcwt ๐Ÿ“บ

RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly used open source tool for processing 608/708 Closed Captions (CC) sources. For more information on the format, see .

This demuxer implements the specification as of March 2024, which has been stable and unchanged since April 2014.

โœจ Examples โœจ

  • Render CC to ASS using the built-in decoder:
ffmpeg -i CC.rcwt.bin CC.ass

Note that if your output appears to be empty, you may have to manually set the decoderโ€™s data_field option to pick the desired CC substream.

  • Convert an RCWT backup to Scenarist (SCC) format:
ffmpeg -i CC.rcwt.bin -c:s copy CC.scc

Note that the SCC format does not support all of the possible CC extensions that can be stored in RCWT (such as EIA-708).

๐ŸŽง sbg ๐ŸŽง

SBaGen script demuxer.

This demuxer reads the script language used by SBaGen (http://uazu.net/sbagen/) to generate binaural beats sessions. A SBG script looks like that:

-SE
a: 300-2.5/3 440+4.5/0
b: 300-2.5/0 440+4.5/3
off: -
NOW      == a
+0:07:00 == b
+0:14:00 == a
+0:21:00 == b
+0:30:00    off

A SBG script can mix absolute and relative timestamps. If the script uses either only absolute timestamps (including the script start time) or only relative ones, then its layout is fixed, and the conversion is straightforward. On the other hand, if the script mixes both kind of timestamps, then the NOW reference for relative timestamps will be taken from the current time of day at the time the script is read, and the script layout will be frozen according to that reference. That means that if the script is directly played, the actual times will match the absolute timestamps up to the sound controllerโ€™s clock accuracy, but if the user somehow pauses the playback or seeks, all times will be shifted accordingly.

๐Ÿ“ tedcaptions ๐Ÿ“

JSON captions used for http://www.ted.com/.

TED does not provide links to the captions, but they can be guessed from the page. The file tools/bookmarklets.html from the FFmpeg source tree contains a bookmarklet to expose them.

This demuxer accepts the following option:

  • start_time โ€” set the start time of the TED talk, in milliseconds. The default is 15000 (15s). It is used to sync the captions with the downloadable videos, because they include a 15s intro.

Example: convert the captions to a format most players understand:

ffmpeg -i http://www.ted.com/talks/subtitles/id/1/lang/en talk1-en.srt

๐Ÿงš vapoursynth ๐Ÿงš

Vapoursynth wrapper.

Due to security concerns, Vapoursynth scripts will not be autodetected, so the input format has to be forced. For ff* CLI tools, add -f vapoursynth before the input -i yourscript.vpy.

This demuxer accepts the following option:

  • max_script_size โ€” the demuxer buffers the entire script into memory. Adjust this value to set the maximum buffer size, which in turn acts as a ceiling for the size of scripts that can be read. Default is 1 MiB.

๐ŸŒŠ w64 ๐ŸŒŠ

Sony Wave64 Audio demuxer.

This demuxer accepts the following options:

  • max_size โ€” see the same option for the wav demuxer.

๐ŸŒŠ wav ๐ŸŒŠ

RIFF Wave Audio demuxer.

This demuxer accepts the following options:

  • max_size โ€” specify the maximum packet size in bytes for the demuxed packets. By default this is set to 0, which means that a sensible value is chosen based on the input format.

๐Ÿ‘‘ MUXERS ๐Ÿ‘‘

Muxers are configured elements in FFmpeg which allow writing multimedia streams to a particular type of file.

When you configure your FFmpeg build, all the supported muxers are enabled by default. You can list all available muxers using the configure option --list-muxers.

You can disable all the muxers with the configure option --disable-muxers and selectively enable / disable single muxers with the options --enable-muxer=MUXER / --disable-muxer=MUXER.

The option -muxers of the ff* tools will display the list of enabled muxers. Use -formats to view a combined list of enabled demuxers and muxers.

A description of some of the currently available muxers follows.

Raw muxers ๐ŸŽฌ

Okay so raw muxers are the โ€œjust the bits, maโ€™amโ€ girlies of the muxer world ๐Ÿ’… They accept a single stream matching the designated codec. They do not store timestamps or metadata. The recognized extension is the same as the muxer name unless it says otherwise, bestie.

Hereโ€™s the whole squad โ€” media type + any extensions that auto-select the muxer from your output extension are shown too โœจ

  • ac3 (audio) โ€” Dolby Digital, also known as AC-3.
  • adx (audio) โ€” CRI Middleware ADX audio.

This muxer will write out the total sample count near the start of the first packet when the output is seekable and the count can be stored in 32 bits.

  • aptx (audio) โ€” aptX (Audio Processing Technology for Bluetooth)
  • aptx_hd (audio; ext: aptxdh) โ€” aptX HD (Audio Processing Technology for Bluetooth) audio
  • avs2 (video; ext: avs, avs2) โ€” AVS2-P2 (Audio Video Standard - Second generation - Part 2) / IEEE 1857.4 video
  • avs3 (video; ext: avs3) โ€” AVS3-P2 (Audio Video Standard - Third generation - Part 2) / IEEE 1857.10 video
  • cavsvideo (video; ext: cavs) โ€” Chinese AVS (Audio Video Standard - First generation)
  • codec2raw (audio) โ€” Codec 2 audio.

No extension is registered so format name has to be supplied e.g. with the ffmpeg CLI tool -f codec2raw.

  • data (any) โ€” Generic data muxer.

This muxer accepts a single stream with any codec of any type. The input stream has to be selected using the -map option with the ffmpeg CLI tool.

No extension is registered so format name has to be supplied e.g. with the ffmpeg CLI tool -f data.

  • dfpwm (audio; ext: dfpwm) โ€” Raw DFPWM1a (Dynamic Filter Pulse With Modulation) audio muxer.
  • dirac (video; ext: drc, vc2) โ€” BBC Dirac video.

The Dirac Pro codec is a subset and is standardized as SMPTE VC-2.

  • dnxhd (video; ext: dnxhd, dnxhr) โ€” Avid DNxHD video.

It is standardized as SMPTE VC-3. Accepts DNxHR streams.

  • dts (audio) โ€” DTS Coherent Acoustics (DCA) audio
  • eac3 (audio) โ€” Dolby Digital Plus, also known as Enhanced AC-3
  • evc (video; ext: evc) โ€” MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC video
  • g722 (audio) โ€” ITU-T G.722 audio
  • g723_1 (audio; ext: tco, rco) โ€” ITU-T G.723.1 audio
  • g726 (audio) โ€” ITU-T G.726 big-endian ("left-justified") audio.

No extension is registered so format name has to be supplied e.g. with the ffmpeg CLI tool -f g726.

  • g726le (audio) โ€” ITU-T G.726 little-endian ("right-justified") audio.

No extension is registered so format name has to be supplied e.g. with the ffmpeg CLI tool -f g726le.

  • gsm (audio) โ€” Global System for Mobile Communications audio
  • h261 (video) โ€” ITU-T H.261 video
  • h263 (video) โ€” ITU-T H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 video
  • h264 (video; ext: h264, 264) โ€” ITU-T H.264 / MPEG-4 Part 10 AVC video. Bitstream shall be converted to Annex B syntax if it's in length-prefixed mode.
  • hevc (video; ext: hevc, h265, 265) โ€” ITU-T H.265 / MPEG-H Part 2 HEVC video. Bitstream shall be converted to Annex B syntax if it's in length-prefixed mode.
  • m4v (video) โ€” MPEG-4 Part 2 video
  • mjpeg (video; ext: mjpg, mjpeg) โ€” Motion JPEG video
  • mlp (audio) โ€” Meridian Lossless Packing, also known as Packed PCM
  • mp2 (audio; ext: mp2, m2a, mpa) โ€” MPEG-1 Audio Layer II audio
  • mpeg1video (video; ext: mpg, mpeg, m1v) โ€” MPEG-1 Part 2 video.
  • mpeg2video (video; ext: m2v) โ€” ITU-T H.262 / MPEG-2 Part 2 video
  • obu (video) โ€” AV1 low overhead Open Bitstream Units muxer.

Temporal delimiter OBUs will be inserted in all temporal units of the stream.

  • rawvideo (video; ext: yuv, rgb) โ€” Raw uncompressed video.
  • sbc (audio; ext: sbc, msbc) โ€” Bluetooth SIG low-complexity subband codec audio
  • truehd (audio; ext: thd) โ€” Dolby TrueHD audio
  • vc1 (video) โ€” SMPTE 421M / VC-1 video

Examples โœจ

  • Store raw video frames with the rawvideo muxer using ffmpeg, bestie:
ffmpeg -f lavfi -i testsrc -t 10 -s hd1080p testsrc.yuv

Since the rawvideo muxer do not store the information related to size and format, this information must be provided when demuxing the file:

ffplay -video_size 1920x1080 -pixel_format rgb24 -f rawvideo testsrc.rgb

Raw PCM muxers ๐Ÿ’ฟ

This section covers raw PCM (Pulse-Code Modulation) audio muxers, and yes they are absolutely iconic for just giving you the raw audio vibes ๐ŸŽ€

They accept a single stream matching the designated codec. They do not store timestamps or metadata. The recognized extension is the same as the muxer name.

Hereโ€™s the lineup. If thereโ€™s an optional extra extension that auto-selects this muxer from the output extension, itโ€™s chillinโ€™ in parentheses ๐Ÿซถ

  • alaw (al) โ€” PCM A-law
  • f32be โ€” PCM 32-bit floating-point big-endian
  • f32le โ€” PCM 32-bit floating-point little-endian
  • f64be โ€” PCM 64-bit floating-point big-endian
  • f64le โ€” PCM 64-bit floating-point little-endian
  • mulaw (ul) โ€” PCM mu-law
  • s16be โ€” PCM signed 16-bit big-endian
  • s16le โ€” PCM signed 16-bit little-endian
  • s24be โ€” PCM signed 24-bit big-endian
  • s24le โ€” PCM signed 24-bit little-endian
  • s32be โ€” PCM signed 32-bit big-endian
  • s32le โ€” PCM signed 32-bit little-endian
  • s8 (sb) โ€” PCM signed 8-bit
  • u16be โ€” PCM unsigned 16-bit big-endian
  • u16le โ€” PCM unsigned 16-bit little-endian
  • u24be โ€” PCM unsigned 24-bit big-endian
  • u24le โ€” PCM unsigned 24-bit little-endian
  • u32be โ€” PCM unsigned 32-bit big-endian
  • u32le โ€” PCM unsigned 32-bit little-endian
  • u8 (ub) โ€” PCM unsigned 8-bit
  • vidc โ€” PCM Archimedes VIDC

MPEG-1/MPEG-2 program stream muxers ๐Ÿ“ผ

This section covers formats belonging to the MPEG-1 and MPEG-2 Systems family. Itโ€™s giving old-school disc energy and honestly? We kind of love her for it ๐Ÿ’…

The MPEG-1 Systems format (also known as ISO/IEEC 11172-1 or MPEG-1 program stream) has been adopted for the format of media track stored in VCD (Video Compact Disc).

The MPEG-2 Systems standard (also known as ISO/IEEC 13818-1) covers two containers formats, one known as transport stream and one known as program stream; only the latter is covered here.

The MPEG-2 program stream format (also known as VOB due to the corresponding file extension) is an extension of MPEG-1 program stream: in addition to support different codecs for the audio and video streams, it also stores subtitles and navigation metadata. MPEG-2 program stream has been adopted for storing media streams in SVCD and DVD storage devices.

This section comprises the following muxers:

  • mpeg (mpg, mpeg) โ€” MPEG-1 Systems / MPEG-1 program stream muxer.
  • vcd โ€” MPEG-1 Systems / MPEG-1 program stream (VCD) muxer.

This muxer can be used to generate tracks in the format accepted by the VCD (Video Compact Disc) storage devices.

It is the same as the mpeg muxer with a few differences.

  • vob โ€” MPEG-2 program stream (VOB) muxer.
  • dvd โ€” MPEG-2 program stream (DVD VOB) muxer.

This muxer can be used to generate tracks in the format accepted by the DVD (Digital Versatile Disc) storage devices.

This is the same as the vob muxer with a few differences.

  • svcd (vob) โ€” MPEG-2 program stream (SVCD VOB) muxer.

This muxer can be used to generate tracks in the format accepted by the SVCD (Super Video Compact Disc) storage devices.

This is the same as the vob muxer with a few differences.


Options โœจ

  • muxrate rate โ€” Set user-defined mux rate expressed as a number of bits/s. If not specified the automatically computed mux rate is employed. Default value is 0.
  • preload delay โ€” Set initial demux-decode delay in microseconds. Default value is 500000.

MOV/MPEG-4/ISOMBFF muxers ๐Ÿ“ฑ

This section covers formats belonging to the QuickTime / MOV family, including the MPEG-4 Part 14 format and ISO base media file format (ISOBMFF). These formats share a common structure based on the ISO base media file format (ISOBMFF), like theyโ€™re all in the same group chat ๐Ÿซถ

The MOV format was originally developed for use with Apple QuickTime. It was later used as the basis for the MPEG-4 Part 1 (later Part 14) format, also known as ISO/IEC 14496-1. That format was then generalized into ISOBMFF, also named MPEG-4 Part 12 format, ISO/IEC 14496-12, or ISO/IEC 15444-12.

It comprises the following muxers:

  • 3gp โ€” Third Generation Partnership Project (3GPP) format for 3G UMTS multimedia services
  • 3g2 โ€” Third Generation Partnership Project 2 (3GP2 or 3GPP2) format for 3G CDMA2000 multimedia services, similar to 3gp with extensions and limitations
  • f4v โ€” Adobe Flash Video format
  • ipod โ€” MPEG-4 audio file format, as MOV/MP4 but limited to contain only audio streams, typically played with the Apple ipod device
  • ismv โ€” Microsoft IIS (Internet Information Services) Smooth Streaming Audio/Video (ISMV or ISMA) format. This is based on MPEG-4 Part 14 format with a few incompatible variants, used to stream media files for the Microsoft IIS server.
  • mov โ€” QuickTime player format identified by the ".mov" extension
  • mp4 โ€” MP4 or MPEG-4 Part 14 format
  • psp โ€” PlayStation Portable MP4/MPEG-4 Part 14 format variant. This is based on MPEG-4 Part 14 format with a few incompatible variants, used to play files on PlayStation devices.

Fragmentation ๐Ÿงฉ

The mov, mp4, and ismv muxers support fragmentation. Normally, a MOV/MP4 file has all the metadata about all packets stored in one location.

This data is usually written at the end of the file, but it can be moved to the start for better playback by adding "+faststart" to the "-movflags", or using the qt-faststart tool).

A fragmented file consists of a number of fragments, where packets and metadata about these packets are stored together. Writing a fragmented file has the advantage that the file is decodable even if the writing is interrupted (while a normal MOV/MP4 is undecodable if it is not properly finished), and it requires less memory when writing very long files (since writing normal MOV/MP4 files stores info about every single packet in memory until the file is closed). The downside is that it is less compatible with other applications.

Fragmentation is enabled by setting one of the options that define how to cut the file into fragments:

  • frag_duration
  • frag_size
  • min_frag_duration
  • movflags +frag_keyframe
  • movflags +frag_custom

If more than one condition is specified, fragments are cut when one of the specified conditions is fulfilled. The exception to this is the option min_frag_duration, which has to be fulfilled for any of the other conditions to apply.


Options โœจ

  • brand brand_string โ€” override the major brand ๐Ÿ’…
  • empty_hdlr_name bool โ€” turn this on and the muxer skips writing the name inside the hdlr box. Default is false, bestie.
  • encryption_key key โ€” sets the media encryption key, in hexadecimal format ๐Ÿ”
  • encryption_kid kid โ€” sets the media encryption key identifier, also hex
  • encryption_scheme scheme โ€” picks the encryption scheme; allowed values are none and cenc-aes-ctr
  • frag_duration duration โ€” create fragments that are duration microseconds long โฑ๏ธ
  • frag_interleave number โ€” interleave the samples inside fragments (that's the max number of consecutive samples; lower = tighter interleaving, but it costs you more overhead). It's set to 0 by default.
  • frag_size size โ€” create fragments that hold up to size bytes of payload data
  • iods_audio_profile profile โ€” specify the iods number for the audio profile atom (from -1 to 255), default is -1
  • iods_video_profile profile โ€” specify the iods number for the video profile atom (from -1 to 255), default is -1
  • ism_lookahead num_entries โ€” how many lookahead entries for ISM files (from 0 to 255), default is 0
  • min_frag_duration duration โ€” do not create fragments shorter than duration microseconds long
  • moov_size bytes โ€” reserves space for the moov atom at the beginning of the file instead of parking the moov atom at the end. Heads up: if the space you reserved isn't enough, muxing will fail ๐Ÿ’€
  • mov_gamma gamma โ€” specify the gamma value for the gama atom (as a decimal number from 0 to 10), default is 0.0 โ€” and it must be set together with + movflags
  • movflags flags โ€” the icon of the whole page, honestly. Sets various muxing switches, and the following flags can be used:
    • cmaf โ€” write CMAF (Common Media Application Format) compatible fragmented MP4 output
    • dash โ€” write DASH (Dynamic Adaptive Streaming over HTTP) compatible fragmented MP4 output
    • default_base_moof โ€” same energy as the omit_tfhd_offset flag: it avoids writing the absolute base_data_offset field in tfhd atoms, but it does it by using the new default-base-is-moof flag instead. This flag is new from 14496-12:2012. It may make fragments easier to parse in certain circumstances (it avoids basing track fragment location calculations on the implicit end of the previous track fragment).
    • delay_moov โ€” delay writing the initial moov until the first fragment is cut, or until the first fragment flush
    • disable_chpl โ€” disable Nero chapter markers (chpl atom). Normally both Nero chapters and a QuickTime chapter track are written to the file. With this option set, only the QuickTime chapter track gets written. Nero chapters can cause failures when the file is reprocessed with certain tagging programs, like mp3Tag 2.61a and iTunes 11.3 โ€” and most likely other versions are affected too ๐Ÿ™ˆ
    • faststart โ€” run a second pass moving the index (moov atom) to the beginning of the file. Warning: this operation can take a while, and it will not work in various situations such as fragmented output, so it's not enabled by default.
    • frag_custom โ€” lets the caller manually choose when to cut fragments, by calling av_write_frame(ctx, NULL) to write a fragment with the packets written so far. (This is only useful with other applications integrating libavformat, not from ffmpeg.)
    • frag_discont โ€” signal that the next fragment is discontinuous from earlier ones
    • frag_every_frame โ€” fragment at every frame
    • frag_keyframe โ€” start a new fragment at each video keyframe
    • global_sidx โ€” write a global sidx index at the start of the file
    • isml โ€” create a live smooth streaming feed (for pushing to a publishing point)
    • negative_cts_offsets โ€” enables utilization of version 1 of the CTTS box, in which the CTS offsets can be negative. This lets the initial sample have DTS/CTS of zero, and reduces the need for edit lists for some cases such as video tracks with B-frames. Bonus: it eases conformance with the DASH-IF interoperability guidelines.

This option is implicitly set when writing ismv (Smooth Streaming) files.

  • omit_tfhd_offset โ€” do not write any absolute base_data_offset in tfhd atoms. This avoids tying fragments to absolute byte positions in the file/streams.
  • prefer_icc โ€” if writing the colr atom, prioritise usage of the ICC profile if it exists in stream packet side data
  • rtphint โ€” add RTP hinting tracks to the output file
  • separate_moof โ€” write a separate moof (movie fragment) atom for each track. Normally packets for all tracks are written in one moof atom (slightly more efficient), but with this option set the muxer writes one moof/mdat pair for each track, which makes it easier to separate tracks.
  • skip_sidx โ€” skip writing of the sidx atom. When the bitrate overhead from the sidx atom is high, this option could be used for cases where the sidx atom isn't mandatory. When the global_sidx flag is enabled, this option is ignored.
  • skip_trailer โ€” skip writing the mfra/tfra/mfro trailer for fragmented files
  • use_metadata_tags โ€” use the mdta atom for metadata
  • write_colr โ€” write the colr atom even if the color info is unspecified. This flag is experimental, may be renamed or changed โ€” do not use from scripts.
  • write_gama โ€” write the deprecated gama atom
  • hybrid_fragmented โ€” for recoverability: write the output file as a fragmented file. This lets the intermediate file be read while it's being written (in particular, if the writing process is aborted uncleanly). When writing finishes, the file is converted to a regular, non-fragmented file, which is more compatible and allows easier and quicker seeking.

If writing is aborted, the intermediate file can manually be remuxed to get a regular, non-fragmented file of what had been written into the unfinished file. ๐Ÿซถ

  • movie_timescale scale โ€” set the timescale written in the movie header box (mvhd). Range is 1 to INT_MAX. Default is 1000.
  • rtpflags flags โ€” add RTP hinting tracks to the output file. The following flags can be used:
    • h264_mode0 โ€” use mode 0 for H.264 in RTP
    • latm โ€” use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC
    • rfc2190 โ€” use RFC 2190 packetization instead of RFC 4629 for H.263
    • send_bye โ€” send RTCP BYE packets when finishing
    • skip_rtcp โ€” do not send RTCP sender reports
  • skip_iods bool โ€” skip writing the iods atom (default value is true)
  • use_editlist bool โ€” use edit list (default value is auto)
  • use_stream_ids_as_track_ids bool โ€” use stream ids as track ids (default value is false)
  • video_track_timescale scale โ€” set the timescale used for video tracks. Range is 0 to INT_MAX. If set to 0, the timescale is automatically set based on the native stream time base. Default is 0.
  • write_btrt bool โ€” force or disable writing the bitrate box inside the stsd box of a track. The box contains the decoding buffer size (in bytes), maximum bitrate and average bitrate for the track. The box will be skipped if none of these values can be computed. Default is -1 or auto, which writes the box only in MP4 mode.
  • write_prft option โ€” write a producer time reference box (PRFT) with a specified time source for the NTP field in the PRFT box. Set the value as wallclock to specify timesource as wallclock time, and pts to specify timesource as input packets' PTS values.
  • write_tmcd bool โ€” specify on to force writing a timecode track, off to disable it, and auto to write a timecode track only for mov and mp4 output (default).
Setting value to pts is applicable only for a live encoding use case, where PTS values are set as wallclock time at the source. For example, an encoding use case with a decklink capture source where video_pts and audio_pts are set to abs_wallclock.

๐ŸŽฌ Examples

  • Push Smooth Streaming content in real time to a publishing point on IIS with the ismv muxer using ffmpeg:
ffmpeg -re <<normal input/transcoding options>> -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)

๐Ÿ•น๏ธ a64

A64 Commodore 64 video muxer.

This muxer accepts a single a64_multi or a64_multi5 codec video stream. retro girlie behavior honestly ๐Ÿ‘พ

๐ŸŽง ac4

Raw AC-4 audio muxer.

This muxer accepts a single ac4 audio stream.

Options

  • write_crc bool โ€” when enabled, write a CRC checksum for each packet to the output, default is false

๐Ÿ“ป adts

Audio Data Transport Stream muxer.

It accepts a single AAC stream.

Options

  • write_id3v2 bool โ€” enable to write ID3v2.4 tags at the start of the stream. Default is disabled.
  • write_apetag bool โ€” enable to write APE tags at the end of the stream. Default is disabled.
  • write_mpeg2 bool โ€” enable to set the MPEG version bit in the ADTS frame header to 1, which indicates MPEG-2. Default is 0, which indicates MPEG-4.

๐Ÿ’พ aea

MD STUDIO audio muxer.

This muxer accepts a single ATRAC1 audio stream with either one or two channels and a sample rate of 44100Hz.

As AEA supports storing the track title, this muxer will also write the title from the stream's metadata to the container. cute ๐ŸŽ€

๐ŸŒŠ aiff

Audio Interchange File Format muxer.

Options

  • write_id3v2 bool โ€” enable ID3v2 tags writing when set to 1. Default is 0 (disabled).
  • id3v2_version bool โ€” select the ID3v2 version to write. Currently only version 3 and 4 (aka. ID3v2.3 and ID3v2.4) are supported. The default is version 4.

๐Ÿงฑ alp

High Voltage Software's Lego Racers game audio muxer.

It accepts a single ADPCM_IMA_ALP stream with no more than 2 channels and a sample rate not greater than 44100 Hz.

Extensions: tun, pcm

Options

  • type type โ€” set the file type.

type accepts the following values:

  • tun โ€” set file type as music. Must have a sample rate of 22050 Hz.
  • pcm โ€” set file type as sfx.
  • auto โ€” set file type as per output file extension. .pcm results in type pcm, else type tun is set. (default)

amr ๐ŸŽง

3GPP AMR (Adaptive Multi-Rate) audio muxer. It accepts a single audio stream containing an AMR NB stream.

amv ๐ŸŽ€

AMV (Actions Media Video) format muxer.

apm ๐Ÿ•น๏ธ

Ubisoft Rayman 2 APM audio muxer. It accepts a single ADPCM IMA APM audio stream.

apng ๐Ÿฆ‹

Animated Portable Network Graphics muxer. It accepts a single APNG video stream.

Options โœจ

  • final_delay delay โ€” force a delay expressed in seconds after the last frame of each repetition. Default value is 0.0.
  • plays repetitions โ€” specify how many times to play the content; 0 causes an infinite loop, with 1 there is no loop.

Examples ๐Ÿ’–

  • Use ffmpeg to generate an APNG output with 2 repetitions, and with a delay of half a second after the first repetition:
ffmpeg -i INPUT -final_delay 0.5 -plays 2 out.apng

argo_asf ๐ŸŒˆ

Argonaut Games ASF audio muxer. It accepts a single ADPCM audio stream.

Options โœจ

  • version_major version โ€” override file major version, specified as an integer, default value is 2.
  • version_minor version โ€” override file minor version, specified as an integer, default value is 1.
  • name name โ€” embed file name into file; if not specified use the output file name. The name is truncated to 8 characters.

argo_cvg ๐Ÿงš

Argonaut Games CVG audio muxer. It accepts a single one-channel ADPCM 22050Hz audio stream.

The loop and reverb options set the corresponding flags in the header which can be later retrieved to process the audio stream accordingly.

Options โœจ

  • skip_rate_check bool โ€” skip sample rate check (default is false).
  • loop bool โ€” set loop flag (default is false).
  • reverb boolean โ€” set reverb flag (default is true).

asf, asf_stream ๐Ÿ“ผ

Advanced / Active Systems (or Streaming) Format audio muxer. The asf_stream variant should be selected for streaming.

Note that Windows Media Audio (wma) and Windows Media Video (wmv) use this muxer too.

Options โœจ

  • packet_size size โ€” set the muxer packet size as a number of bytes. By tuning this setting you may reduce data fragmentation or muxer overhead depending on your source. Default value is 3200, minimum is 100, maximum is 64Ki.

ass ๐Ÿ’ฌ

ASS/SSA (SubStation Alpha) subtitles muxer. It accepts a single ASS subtitles stream.

Options โœจ

  • ignore_readorder bool โ€” write dialogue events immediately, even if they are out-of-order, default is false, otherwise they are cached until the expected time event is found.

ast ๐ŸŒŸ

AST (Audio Stream) muxer. This format is used to play audio on some Nintendo Wii games. It accepts a single audio stream.

The loopstart and loopend options can be used to define a section of the file to loop for players honoring such options.

Options โœจ

  • loopstart start โ€” specify loop start position expressed in milliseconds, from -1 to INT_MAX, in case -1 is set then no loop is specified (default -1) and the loopend value is ignored.
  • loopend end โ€” specify loop end position expressed in milliseconds, from 0 to INT_MAX, default is 0, in case 0 is set it assumes the total stream duration.

au ๐ŸŽต

SUN AU audio muxer. It accepts a single audio stream.

avi ๐ŸŽž๏ธ

Audio Video Interleaved muxer. AVI is a proprietary format developed by Microsoft, and later formally specified through the Open DML specification.

Because of differences in players implementations, it might be required to set some options to make sure that the generated output can be correctly played by the target player.

Options โœจ

  • flipped_raw_rgb bool โ€” if set to true, store positive height for raw RGB bitmaps, which indicates bitmap is stored bottom-up. Note that this option does not flip the bitmap which has to be done manually beforehand, e.g. by using the vflip filter. Default is false and indicates bitmap is stored top down.
  • reserve_index_space size โ€” reserve the specified amount of bytes for the OpenDML master index of each stream within the file header. By default additional master indexes are embedded within the data packets if there is no space left in the first master index and are linked together as a chain of indexes. This index structure can cause problems for some use cases, e.g. third-party software strictly relying on the OpenDML index specification or when file seeking is slow. Reserving enough index space in the file header avoids these problems.

The required index space depends on the output file size and should be about 16 bytes per gigabyte. When this option is omitted or set to zero the necessary index space is guessed.

Default value is 0.

  • write_channel_mask bool โ€” write the channel layout mask into the audio stream header. This option is enabled by default. Disabling the channel mask can be useful in specific scenarios, e.g. when merging multiple audio streams into one for compatibility with software that only supports a single audio stream in AVI (see the amerge section in the ffmpeg-filters manual).

avif ๐Ÿ–ผ๏ธ

AV1 (Alliance for Open Media Video codec 1) image format muxer. This muxer stores images encoded using the AV1 codec.

It accepts one or two video streams. In case two video streams are provided, the second one shall contain a single plane storing the alpha mask.

In case more than one image is provided, the generated output is considered an animated AVIF and the number of loops can be specified with the loop option.

This is based on the specification by Alliance for Open Media at url <https://aomediacodec.github.io/av1-avif>.

Options โœจ

  • loop count โ€” number of times to loop an animated AVIF, 0 specify an infinite loop, default is 0.
  • movie_timescale timescale โ€” set the timescale written in the movie header box (mvhd). Range is 1 to INT_MAX. Default is 1000.

avm2 ๐Ÿ’€

ShockWave Flash (SWF) / ActionScript Virtual Machine 2 (AVM2) format muxer. It accepts one audio stream, one video stream, or both.

bit ๐Ÿ

G.729 (.bit) file format muxer. It accepts a single G.729 audio stream.

caf โ˜•

Apple CAF (Core Audio Format) muxer. It accepts a single audio stream.

codec2 ๐ŸŽ™๏ธ

Codec2 audio audio muxer. It accepts a single codec2 audio stream.

chromaprint ๐ŸŽ€

Chromaprint fingerprinter muxers.

To enable compilation of this filter you need to configure FFmpeg with --enable-chromaprint.

This muxer feeds audio data to the Chromaprint library, which generates a fingerprint for the provided audio data. See: <https://acoustid.org/chromaprint>.

It takes a single signed native-endian 16-bit raw audio stream of at most 2 channels.

Options โœจ

  • algorithm version โ€” select version of algorithm to fingerprint with. Range is 0 to 4. Version 3 enables silence detection. Default is 1.
  • fp_format format โ€” format to output the fingerprint as. Accepts the following options:
    • base64 โ€” Base64 compressed fingerprint (default)
    • compressed โ€” Binary compressed fingerprint
    • raw โ€” Binary raw fingerprint
  • silence_threshold threshold โ€” threshold for detecting silence. Range is from -1 to 32767, where -1 disables silence detection. Silence detection can only be used with version 3 of the algorithm.

Silence detection must be disabled for use with the AcoustID service. Default is -1.

crc ๐Ÿ”ฅ

CRC (Cyclic Redundancy Check) muxer.

This muxer computes and prints the Adler-32 CRC of all the input audio and video frames. By default audio frames are converted to signed 16-bit raw audio and video frames to raw video before computing the CRC.

The output of the muxer consists of a single line of the form: CRC=0xCRC, where CRC is a hexadecimal number 0-padded to 8 digits containing the CRC for all the decoded input frames.

See also the framecrc muxer.

Examples ๐Ÿ’–

  • Use ffmpeg to compute the CRC of the input, and store it in the file out.crc:
ffmpeg -i INPUT -f crc out.crc
  • Use ffmpeg to print the CRC to stdout with the command:
ffmpeg -i INPUT -f crc -
  • You can select the output format of each frame with ffmpeg by specifying the audio and video codec and format. For example, to compute the CRC of the input audio converted to PCM unsigned 8-bit and the input video converted to MPEG-2 video, use the command:
ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f crc -

dash ๐ŸŒˆ

Dynamic Adaptive Streaming over HTTP (DASH) muxer.

This muxer creates segments and manifest files according to the MPEG-DASH standard ISO/IEC 23009-1:2014 and following standard updates.

For more information see:

This muxer creates an MPD (Media Presentation Description) manifest file and segment files for each stream. Segment files are placed in the same directory of the MPD manifest file.

The segment filename might contain pre-defined identifiers used in the manifest SegmentTemplate section as defined in section 5.3.9.4.4 of the standard.

Available identifiers are $RepresentationID$, $Number$, $Bandwidth$, and $Time$. In addition to the standard identifiers, an ffmpeg-specific $ext$ identifier is also supported. When specified, ffmpeg will replace $ext$ in the file name with muxing format's extensions such as mp4, webm etc.

Options โœจ

  • adaptation_sets adaptation_sets โ€” assign streams to adaptation sets, specified in the MPD manifest AdaptationSets section.

An adaptation set contains a set of one or more streams accessed as a single subset, e.g. corresponding streams encoded at different size selectable by the user depending on the available bandwidth, or to different audio streams with a different language.

Each adaptation set is specified with the syntax:

id=<index>,streams=<streams>

where index must be a numerical index, and streams is a sequence of ,-separated stream indices. Multiple adaptation sets can be specified, separated by spaces.

To map all video (or audio) streams to an adaptation set, v (or a) can be used as stream identifier instead of IDs.

When no assignment is defined, this defaults to an adaptation set for each stream.

The following optional fields can also be specified:

  • descriptor โ€” okay so define the descriptor exactly as defined by ISO/IEC 23009-1:2014/Amd.2:2015. The descriptor string should be a self-closing XML tag, bestie. Example time:
<SupplementalProperty schemeIdUri=\"urn:mpeg:dash:srd:2014\" value=\"0,0,0,1,1,2,2\"/>
  • frag_duration โ€” overrides the global fragment duration that was set with the frag_duration option. sneaky little override, iykyk.
  • frag_type โ€” overrides the global fragment type that was set with the frag_type option.
  • seg_duration โ€” overrides the global segment duration that was set with the seg_duration option.
  • trick_id โ€” marks an adaptation set as containing streams meant to be used for Trick Mode for the referenced adaptation set. fancy behavior incoming.

A few examples of possible values for the adaptation_sets option follow, and yes we are keeping them exactly:

id=0,seg_duration=2,frag_duration=1,frag_type=duration,streams=v id=1,seg_duration=2,frag_type=none,streams=a

id=0,seg_duration=2,frag_type=none,streams=0 id=1,seg_duration=10,frag_type=none,trick_id=0,streams=1
  • dash_segment_type type โ€” sets the DASH segment files type. Possible values are:
    • auto โ€” the dash segment files format will be selected based on the stream codec. This is the default mode. default behavior slay.
    • mp4 โ€” the dash segment files will be in ISOBMFF/MP4 format.
    • webm โ€” the dash segment files will be in WebM format.
  • extra_window_size size โ€” sets the maximum number of segments kept outside of the manifest before removing them from disk. cleanup era.
  • format_options options_list โ€” sets container format (mp4/webm) options using a ":"-separated list of key=value parameters. Values containing ":" special characters must be escaped. escape it, don't fight it.
  • frag_duration duration โ€” sets the length in seconds of fragments within segments. Fractional values can also be set.
  • frag_type type โ€” sets the type of interval for fragmentation. Possible values are:
    • auto โ€” set one fragment per segment.
    • every_frame โ€” fragment at every frame.
    • duration โ€” fragment at specific time intervals.
    • pframes โ€” fragment at keyframes and following P-Frame reordering (Video only, experimental). experimental, so proceed with cute caution.
  • global_sidx bool โ€” write global "SIDX" atom. Applicable only for single file, mp4 output, non-streaming mode. very specific vibe check.
  • hls_master_name file_name โ€” HLS master playlist name. Default is master.m3u8.
  • hls_playlist bool โ€” generate HLS playlist files. The master playlist is generated with the filename specified by the hls_master_name option. One media playlist file is generated for each stream with filenames media_0.m3u8, media_1.m3u8, etc. playlist girlies rise.
  • http_opts http_opts โ€” specifies a list of ":"-separated key=value options to pass to the underlying HTTP protocol. Applicable only for HTTP output.
  • http_persistent bool โ€” use persistent HTTP connections. Applicable only for HTTP output.
  • http_user_agent user_agent โ€” override the User-Agent field in the HTTP header. Applicable only for HTTP output.
  • ignore_io_errors bool โ€” ignore IO errors during open and write. Useful for long-duration runs with network output. This is disabled by default. long-run survival mode.
  • index_correction bool โ€” enable or disable segment index correction logic. Applicable only when use_template is enabled and use_timeline is disabled. This is disabled by default.

When enabled, the logic monitors the flow of segment indexes. If a stream's segment index value is not at the expected real time position, then the logic corrects that index value.

Typically this logic is needed in live streaming use cases. Network bandwidth fluctuations are common during long-run streaming. Each fluctuation can cause the segment indexes to fall behind the expected real time position. live streaming chaos, but make it corrected.

  • init_seg_name init_name โ€” DASH-templated name to use for the initialization segment. Default is "init-stream$RepresentationID$.$ext$". "$ext$" is replaced with the file name extension specific for the segment format. template magic, no cap.
  • ldash bool โ€” enable Low-latency Dash by constraining the presence and values of some elements. This is disabled by default.
  • lhls bool โ€” enable Low-latency HLS (LHLS). Add "#EXT-X-PREFETCH" tag with the current segment's URI. hls.js player folks are trying to standardize an open LHLS spec. The draft spec is available at https://github.com/video-dev/hlsjs-rfcs/blob/lhls-spec/proposals/0001-lhls.md.

This option tries to comply with the above open spec. It enables streaming and hls_playlist options automatically. This is an experimental feature. experimental, bestie โ€” don't act surprised.

Note: This is not Apple's version LHLS. See https://datatracker.ietf.org/doc/html/draft-pantos-hls-rfc8216bis.
  • master_m3u8_publish_rate segment_intervals_count โ€” publish the master playlist repeatedly after every specified number of segment intervals.
  • max_playback_rate rate โ€” set the maximum playback rate indicated as appropriate for the purposes of automatically adjusting playback latency and buffer occupancy during normal playback by clients. client-side buffer management realness.
  • media_seg_name segment_name โ€” DASH-templated name to use for the media segments. Default is "chunk-stream$RepresentationID$-$Number%05d$.$ext$". "$ext$" is replaced with the file name extension specific for the segment format.
  • method method โ€” use the given HTTP method to create output files. Generally set to "PUT" or "POST". PUT girlies and POST girlies, unite.
  • min_playback_rate rate โ€” set the minimum playback rate indicated as appropriate for the purposes of automatically adjusting playback latency and buffer occupancy during normal playback by clients.
  • mpd_profile flags โ€” set one or more MPD manifest profiles. Possible values are:
    • dash โ€” MPEG-DASH ISO Base media file format live profile.
    • dvb_dash โ€” DVB-DASH profile.

Default value is "dash".

  • remove_at_exit bool โ€” enable or disable removal of all segments when finished. This is disabled by default. exit cleanup behavior, very considerate.
  • seg_duration duration โ€” set the segment length in seconds (fractional value can be set). The value is treated as average segment duration when the use_template option is enabled and the use_timeline option is disabled, and as minimum segment duration for all the other use cases.

Default value is 5.

  • single_file bool โ€” enable or disable storing all segments in one file, accessed using byte ranges. This is disabled by default.

The name of the single file can be specified with the single_file_name option. If not specified, assume the basename of the manifest file with the output format extension.

  • single_file_name file_name โ€” DASH-templated name to use for the manifest "baseURL" element. Imply that the single_file option is set to true. In the template, "$ext$" is replaced with the file name extension specific for the segment format.
  • streaming bool โ€” enable or disable chunk streaming mode of output. In chunk streaming mode, each frame will be a "moof" fragment which forms a chunk. This is disabled by default.
  • target_latency target_latency โ€” set an intended target latency in seconds for serving (fractional value can be set). Applicable only when the streaming and write_prft options are enabled. This is an informative field clients can use to measure the latency of the service. latency target, very demure.
  • timeout timeout โ€” set timeout for socket I/O operations expressed in seconds (fractional value can be set). Applicable only for HTTP output.
  • update_period period โ€” set the MPD update period, for dynamic content. The unit is second. If set to 0, the period is automatically computed.

Default value is 0.

  • use_template bool โ€” enable or disable use of "SegmentTemplate" instead of "SegmentList" in the manifest. This is enabled by default.
  • use_timeline bool โ€” enable or disable use of "SegmentTimeline" within the "SegmentTemplate" manifest section. This is enabled by default.
  • utc_timing_url url โ€” URL of the page that will return the UTC timestamp in ISO format, for example "https://time.akamai.com/?iso". time server realness.
  • window_size size โ€” set the maximum number of segments kept in the manifest, discard the oldest one. This is useful for live streaming.

If the value is 0, all segments are kept in the manifest. Default value is 0.

  • write_prft write_prft โ€” write Producer Reference Time elements on supported streams. This also enables writing prft boxes in the underlying muxer. Applicable only when the utc_url option is enabled. It is set to auto by default, in which case the muxer will attempt to enable it only in modes that require it. prft boxes showing up where they're needed.

โœจ Example โœจ

Generate a DASH output reading from an input source in realtime using ffmpeg.

Two multimedia streams are generated from the input file, both containing a video stream encoded through libx264, and an audio stream encoded with libfdk_aac. The first multimedia stream contains video with a bitrate of 800k and audio at the default rate; the second with video scaled to 320x170 pixels at 300k and audio resampled at 22005 Hz.

The window_size option keeps only the latest 5 segments with the default duration of 5 seconds. short manifest, cute manifest.

ffmpeg -re -i <input> -map 0 -map 0 -c:a libfdk_aac -c:v libx264 \
-b:v:0 800k -profile:v:0 main \
-b:v:1 300k -s:v:1 320x170 -profile:v:1 baseline -ar:a:1 22050 \
-bf 1 -keyint_min 120 -g 120 -sc_threshold 0 -b_strategy 0 \
-use_timeline 1 -use_template 1 -window_size 5 \
-adaptation_sets "id=0,streams=v id=1,streams=a" \
-f dash /path/to/out.mpd

๐ŸŽ€ daud ๐ŸŽ€

D-Cinema audio muxer.

It accepts a single 6-channels audio stream resampled at 96000 Hz encoded with the pcm_24daud codec. six channels, one job.

โœจ Example โœจ

Use ffmpeg to mux input audio to a 5.1 channel layout resampled at 96000Hz:

ffmpeg -i INPUT -af aresample=96000,pan=5.1 slow.302

For ffmpeg versions before 7.0 you might have to use the asetnsamples filter to limit the muxed packet size, because this format does not support muxing packets larger than 65535 bytes (3640 samples). For newer ffmpeg versions audio is automatically packetized to 36000 byte (2000 sample) packets. old-version lore, bestie.

๐ŸŒˆ dv ๐ŸŒˆ

DV (Digital Video) muxer.

It accepts exactly one dvvideo video stream and at most two pcm_s16 audio streams. More constraints are defined by the property of the video, which must correspond to a DV video supported profile, and on the framerate. exact stream shapes only, no extras.

โœจ Example โœจ

Use ffmpeg to convert the input:

ffmpeg -i INPUT -s:v 720x480 -pix_fmt yuv411p -r 29.97 -ac 2 -ar 48000 -y out.dv

๐ŸŽ€ ffmetadata

The FFmpeg metadata muxer, bestie. It writes the streams' metadata out in the ffmetadata format โ€” that's literally its whole personality.

Go read the Metadata chapter if you wanna know what the format actually looks like inside. โœจ

Example

Wanna yank the metadata out of an input file and drop it into a metadata.ffmeta file in ffmetadata format? Use ffmpeg:

ffmpeg -i INPUT -f ffmetadata metadata.ffmeta

๐Ÿฆ‹ fifo

FIFO muxer โ€” First-In First-Out, and yes it does exactly what the name says. ๐Ÿ‘‘

The fifo pseudo-muxer lets you separate encoding from muxing by parking everything in a first-in-first-out queue and running the real muxer in its own separate thread. It's giving multitasking main character energy.

This is especially iconic when you pair it with the tee muxer โ€” you can send data to several destinations that have wildly different reliability / writing speed / latency, and nobody has to cry about it.

The target muxer gets picked either from the output name or you specify it yourself with the fifo_format option.

So what happens when the queue fills up or the output fails (like, a packet just won't write)? You choose the vibe:

  • The output can be transparently restarted, with a configurable delay between retries โ€” measured either in real time or in time of the processed stream.
  • Encoding can be blocked during a temporary failure, or it can keep going and transparently drop packets when the FIFO queue fills up.
API users, heads up: the callback functions (interrupt_callback, io_open and io_close) used inside its AVFormatContext must be thread-safe. No cap. ๐Ÿ’…

โœจ Options โœจ

  • attempt_recovery bool โ€” if a failure happens, try to recover the output. This is highkey perfect with network output, 'cause it lets you restart streaming transparently. Default is false.
  • drop_pkts_on_overflow bool โ€” set it to true and when the fifo queue fills up, packets get dropped instead of blocking the encoder. That means you keep streaming without delaying the input, at the cost of omitting part of the stream. Default is false, so normally the encoder gets blocked until the muxer chews through some packets and literally none of them are lost. ๐Ÿซถ
  • fifo_format format_name โ€” specify the format name. Useful when it can't be guessed from the output name suffix.
  • format_opts options โ€” specify format options for the underlying muxer. Muxer options go in as a list of key=value pairs separated by :.
  • max_recovery_attempts count โ€” max number of successive unsuccessful recovery attempts before the output fails permanently. Default is 0 (unlimited).
  • queue_size size โ€” size of the queue as a number of packets. Default is 60.
  • recover_any_error bool โ€” set to true and recovery is attempted regardless of what type of error caused the failure. Default is false, and with certain (usually permanent) errors, recovery is not attempted even when attempt_recovery is true.
  • recovery_wait_streamtime bool โ€” if false, real time is used when waiting for the recovery attempt (i.e. recovery happens after the time set by recovery_wait_time). If true, the time of the processed stream is taken into account instead (i.e. recovery happens after discarding the packets that correspond to recovery_wait_time). Default is false.
  • recovery_wait_time duration โ€” waiting time in seconds before the next recovery attempt after the previous unsuccessful one. Default is 5.
  • restart_with_keyframe bool โ€” whether to wait for the keyframe after recovering from queue overflow or failure. Default is false.
  • timeshift duration โ€” buffer the specified amount of packets and delay writing the output. Note that queue_size must be big enough to store the packets for the timeshift. At the end of the input the fifo buffer gets flushed at realtime speed. โณ

Example

Stream to an RTMP server, keep processing at real-time rate even through a temporary failure (network outage who?), and try to recover the stream every second, indefinitely:

ffmpeg -re -i ... -c:v libx264 -c:a aac -f fifo -fifo_format flv \
  -drop_pkts_on_overflow 1 -attempt_recovery 1 -recovery_wait_time 1 \
  -map 0:v -map 0:a rtmp://example.com/live/stream_name

๐ŸŒธ film_cpk

The Sega film (.cpk) muxer. ๐ŸŽฎ

This format was used as the internal format for several Sega games โ€” retro icon behaviour honestly.

Want the lore? The Sega film file format deets live at http://wiki.multimedia.cx/index.php?title=Sega_FILM.

It accepts at maximum one cinepak or raw video stream, and at maximum one audio stream. Periodt.

๐ŸŽ€ filmstrip

The Adobe Filmstrip muxer.

Several Adobe tools use this format to store a generated filmstrip export. It accepts a single raw video stream โ€” that's the whole guest list.

โญ fits

Flexible Image Transport System (FITS) muxer.

This image format is used to store astronomical data. Literally space data. ๐Ÿชโœจ

More info about the format lives at https://fits.gsfc.nasa.gov.

๐Ÿงš flac

Raw FLAC audio muxer.

This one accepts exactly one FLAC audio stream. Also โ€” plot twist โ€” you can add images with the attached_pic disposition. ๐Ÿ’–

Options

  • write_header bool โ€” write the file header if set to true, default is true.

Example

Store the audio stream from an input file together with several pictures using the attached_pic disposition:

ffmpeg -i INPUT -i pic1.png -i pic2.jpg -map 0:a -map 1 -map 2 -disposition:v attached_pic OUTPUT

๐Ÿ’€ flv

Adobe Flash Video Format muxer. Yes, FLV. She's vintage, she's still serving. ๐Ÿ’…

Options

  • flvflags flags โ€” possible values are:
    • aac_seq_header_detect โ€” place the AAC sequence header based on audio stream data.
    • no_sequence_end โ€” disable the sequence end tag.
    • no_metadata โ€” disable the metadata tag.
    • no_duration_filesize โ€” disable duration and filesize in metadata when they're equal to zero at the end of stream. (Be used to non-seekable living stream).
    • add_keyframe_index โ€” used to facilitate seeking; particularly for HTTP pseudo streaming.

๐Ÿ“ framecrc

Per-packet CRC (Cyclic Redundancy Check) testing format.

This muxer computes and prints the Adler-32 CRC for each audio and video packet. By default, audio frames get converted to signed 16-bit raw audio and video frames to raw video before the CRC is computed.

The output is one line per audio and video packet, shaped like this:

<stream_index>, <packet_dts>, <packet_pts>, <packet_duration>, <packet_size>, 0x<CRC>

CRC is a hexadecimal number 0-padded to 8 digits, containing the CRC of the packet. ๐ŸŽฏ

Examples

Compute the CRC of the audio and video frames in INPUT, converted to raw audio and video packets, and stash it in the file out.crc:

ffmpeg -i INPUT -f framecrc out.crc

Print the info to stdout instead:

ffmpeg -i INPUT -f framecrc -

With ffmpeg you can pick which output format the audio and video frames get encoded to before the per-packet CRC is computed โ€” just specify the audio and video codec. Like, to compute the CRC of each decoded input audio frame converted to PCM unsigned 8-bit, and of each decoded input video frame converted to MPEG-2 video:

ffmpeg -i INPUT -c:a pcm_u8 -c:v mpeg2video -f framecrc -

Also go peek at the crc muxer, iykyk. ๐Ÿ‘€

๐Ÿ”ฅ framehash

Per-packet hash testing format.

This muxer computes and prints a cryptographic hash for each audio and video packet. Ideal for packet-by-packet equality checks without having to individually do a binary comparison on each one โ€” nobody has time for that.

By default, audio frames get converted to signed 16-bit raw audio and video frames to raw video before the hash is computed, but the output of explicit conversions to other codecs works too. It uses the SHA-256 cryptographic hash function by default, but supports several other algorithms. ๐ŸŒˆ

The output is one line per audio and video packet, shaped like this:

<stream_index>, <packet_dts>, <packet_pts>, <packet_duration>, <packet_size>, <hash>

hash is a hexadecimal number representing the computed hash for the packet.

  • hash algorithm โ€” use the cryptographic hash function specified by the string algorithm. Supported values include MD5, murmur3, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320, SHA160, SHA224, SHA256 (default), SHA512/224, SHA512/256, SHA384, SHA512, CRC32 and adler32.

Examples

Compute the SHA-256 hash of the audio and video frames in INPUT, converted to raw audio and video packets, and store it in the file out.sha256:

ffmpeg -i INPUT -f framehash out.sha256

Print the info to stdout using the MD5 hash function:

ffmpeg -i INPUT -f framehash -hash md5 -

Also check out the hash muxer. ๐Ÿซถ

๐Ÿฆ‹ framemd5

Per-packet MD5 testing format.

This is a variant of the framehash muxer โ€” except unlike that one, it defaults to using the MD5 hash function. Same energy, different algorithm. โœจ

Examples

Compute the MD5 hash of the audio and video frames in INPUT, converted to raw audio and video packets, and store it in the file out.md5:

ffmpeg -i INPUT -f framemd5 out.md5

Print the info to stdout:

ffmpeg -i INPUT -f framemd5 -

Also see the framehash and md5 muxers.

๐ŸŽ€ gif

Animated GIF muxer. The moment. The legend. ๐Ÿ‘‘

Heads up: the GIF format has a very large time base โ€” the delay between two frames can't be smaller than one centi second. That's just the rules, bestie, can't negotiate with the format. ๐Ÿ˜ญ

Options

  • loop bool โ€” set the number of times to loop the output. Use -1 for no loop, 0 for looping indefinitely (default).
  • final_delay delay โ€” force the delay (expressed in centiseconds) after the last frame. Each frame ends with a delay until the next frame. The default is -1, a special value that tells the muxer to reuse the previous delay. If you're looping, you might want to customize this value to mark a pause or whatever. ๐Ÿ’…

Example

Encode a gif looping 10 times, with a 5 second delay between the loops:

ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif
Note 1: if you wanna extract the frames into separate GIF files, you need to force the image2 muxer:
ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif"

๐ŸŒˆ gxf

General eXchange Format (GXF) muxer.

GXF came from Grass Valley Group, then SMPTE standardized it as SMPTE 360M, and SMPTE RDD 14-2007 extended it to include high-definition video resolutions.

It accepts at most one video stream, and that video stream has to use one of mjpeg, mpeg1video, mpeg2video, or dvvideo with resolution 512x480 or 608x576. On the audio side it accepts several audio streams, all with rate 48000Hz and codec pcm16_le.

hash

This is the hash testing format, and it is genuinely giving checksum couture. โœจ

This muxer computes and prints a cryptographic hash of all the input audio and video frames. Use it for equality checks without having to do a complete binary comparison โ€” way less drama.

By default, audio frames are converted to signed 16-bit raw audio and video frames are converted to raw video before computing the hash, but the output of explicit conversions to other codecs can also be used. Timestamps are ignored. It uses the SHA-256 cryptographic hash function by default, but supports several other algorithms.

The output of the muxer is a single line of the form algo=hash, where algo is a short string representing the hash function used, and hash is a hexadecimal number representing the computed hash.

  • hash algorithm โ€” Use the cryptographic hash function specified by the string algorithm. Supported values include "MD5", "murmur3", "RIPEMD128", "RIPEMD160", "RIPEMD256", "RIPEMD320", "SHA160", "SHA224", "SHA256" (default), "SHA512/224", "SHA512/256", "SHA384", "SHA512", "CRC32" and "adler32".

Examples

To compute the SHA-256 hash of the input converted to raw audio and video, and store it in the file out.sha256:

ffmpeg -i INPUT -f hash out.sha256

To print an MD5 hash to stdout use the command:

ffmpeg -i INPUT -f hash -hash md5 -

Also go peek at the framehash muxer. ๐Ÿซถ

hds

HTTP Dynamic Streaming (HDS) muxer.

HDS is an adaptive bitrate streaming method developed by Adobe. It delivers MP4 video content over HTTP connections, and it can be used for on-demand streaming or live streaming.

This muxer creates an .f4m (Adobe Flash Media Manifest File) manifest, an .abst (Adobe Bootstrap File) for each stream, and segment files in a directory specified as the output.

These need to be accessed by an HDS player through HTTPS for it to be able to perform playback on the generated stream. ๐Ÿ”ฅ

Options

  • extra_window_size int โ€” number of fragments kept outside of the manifest before removing from disk
  • min_frag_duration microseconds โ€” minimum fragment duration (in microseconds), default value is 1 second (10000000)
  • remove_at_exit bool โ€” remove all fragments when finished when set to "true"
  • window_size int โ€” number of fragments kept in the manifest, if set to a value different from 0. By default all segments are kept in the output directory.

Example

Use ffmpeg to generate HDS files to the output.hds directory in real-time rate:

ffmpeg -re -i INPUT -f hds -b:v 200k output.hds

hls

Apple HTTP Live Streaming muxer that segments MPEG-TS according to the HTTP Live Streaming (HLS) specification. ๐Ÿ“

It creates a playlist file, and one or more segment files. The output filename specifies the playlist filename.

By default, the muxer creates a file for each segment produced. These files have the same name as the playlist, followed by a sequential number and a .ts extension.

Bestie warning: make sure to require a closed GOP when encoding and to set the GOP size to fit your segment time constraint. No cap, this one matters.

For example, to convert an input file with ffmpeg:

ffmpeg -i in.mkv -c:v h264 -flags +cgop -g 30 -hls_time 1 out.m3u8

This example will produce the playlist, out.m3u8, and segment files: out0.ts, out1.ts, out2.ts, etc.

See also the segment muxer, which provides a more generic and flexible implementation of a segmenter, and can be used to perform HLS segmentation.

Options

  • hls_init_time duration โ€” Set the initial target segment length. Default value is 0.

duration must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual.

Segment will be cut on the next key frame after this time has passed on the first m3u8 list. After the initial playlist is filled, ffmpeg will cut segments at duration equal to hls_time.

  • hls_time duration โ€” Set the target segment length. Default value is 2.

duration must be a time duration specification, see the Time duration section in the ffmpeg-utils(1) manual. Segment will be cut on the next key frame after this time has passed.

  • hls_list_size size โ€” Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.
  • hls_delete_threshold size โ€” Set the number of unreferenced segments to keep on disk before "hls_flags delete_segments" deletes them. Increase this to allow continue clients to download segments which were recently referenced in the playlist. Default value is 1, meaning segments older than hls_list_size+1 will be deleted.
  • hls_start_number_source source โ€” Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE") according to the specified source. Unless hls_flags single_file is set, it also specifies source of starting sequence numbers of segment and subtitle filenames. In any case, if hls_flags append_list is set and read playlist sequence number is greater than the specified start sequence number, then that value will be used as start value.

It accepts the following values:

  • generic (default) โ€” Set the start numbers according to the start_number option value.
  • epoch โ€” Set the start number as the seconds since epoch (1970-01-01 00:00:00).
  • epoch_us โ€” Set the start number as the microseconds since epoch (1970-01-01 00:00:00).
  • datetime โ€” Set the start number based on the current date/time as YYYYmmddHHMMSS. e.g. 20161231235759.
  • start_number number โ€” Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE") from the specified number when hls_start_number_source value is generic. (This is the default case.) Unless hls_flags single_file is set, it also specifies starting sequence numbers of segment and subtitle filenames. Default value is 0.
  • hls_allow_cache bool โ€” Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
  • hls_base_url baseurl โ€” Append baseurl to every entry in the playlist. Useful to generate playlists with absolute paths.

Note that the playlist sequence number must be unique for each segment and it is not to be confused with the segment filename sequence number which can be cyclic, for example if the wrap option is specified.

  • hls_segment_filename filename โ€” Set the segment filename. Unless the hls_flags option is set with single_file, filename is used as a string format with the segment number appended.

For example:

ffmpeg -i in.nut -hls_segment_filename 'file%03d.ts' out.m3u8

will produce the playlist, out.m3u8, and segment files: file000.ts, file001.ts, file002.ts, etc.

filename may contain a full path or relative path specification, but only the file name part without any path will be contained in the m3u8 segment list. Should a relative path be specified, the path of the created segment files will be relative to the current working directory. When strftime_mkdir is set, the whole expanded value of filename will be written into the m3u8 segment list.

When var_stream_map is set with two or more variant streams, the filename pattern must contain the string "%v", and this string will be expanded to the position of variant stream index in the generated segment file names.

For example:

ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -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" \
  -hls_segment_filename 'file_%v_%03d.ts' out_%v.m3u8

will produce the playlists segment file sets: file_0_000.ts, file_0_001.ts, file_0_002.ts, etc. and file_1_000.ts, file_1_001.ts, file_1_002.ts, etc.

The string "%v" may be present in the filename or in the last directory name containing the file, but only in one of them. (Additionally, %v may appear multiple times in the last sub-directory or filename.) If the string %v is present in the directory name, then sub-directories are created after expanding the directory name pattern. This enables creation of segments corresponding to different variant streams in subdirectories.

For example:

ffmpeg -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -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" \
  -hls_segment_filename 'vs%v/file_%03d.ts' vs%v/out.m3u8

will produce the playlists segment file sets: vs0/file_000.ts, vs0/file_001.ts, vs0/file_002.ts, etc. and vs1/file_000.ts, vs1/file_001.ts, vs1/file_002.ts, etc.

  • strftime bool โ€” Use strftime() on filename to expand the segment filename with localtime. The segment number is also available in this mode, but to use it, you need to set second_level_segment_index in the hls_flag and %%d will be the specifier.

For example:

ffmpeg -i in.nut -strftime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8

will produce the playlist, out.m3u8, and segment files: file-20160215-1455569023.ts, file-20160215-1455569024.ts, etc. Note: On some systems/environments, the %s specifier is not available. See strftime() documentation.

For example:

ffmpeg -i in.nut -strftime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8

will produce the playlist, out.m3u8, and segment files: file-20160215-0001.ts, file-20160215-0002.ts, etc.

  • strftime_mkdir bool โ€” Used together with strftime, it will create all subdirectories which are present in the expanded values of option hls_segment_filename.

For example:

ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8

will create a directory 201560215 (if it does not exist), and then produce the playlist, out.m3u8, and segment files: 20160215/file-20160215-1455569023.ts, 20160215/file-20160215-1455569024.ts, etc.

For example:

ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8

โ€ฆwill create a directory hierarchy 2016/02/15 (if any of them do not exist), and then produce the playlist, out.m3u8, and segment files like 2016/02/15/file-20160215-1455569023.ts, 2016/02/15/file-20160215-1455569024.ts, etc. bestie it literally makes folders for you, it's giving personal assistant โœจ

  • hls_segment_options options_list โ€” set output format options with a :-separated list of key=value parameters. and listen ๐Ÿ‘€ if a value contains : special characters it must be escaped, no cap.
  • hls_key_info_file key_info_file โ€” use the info inside key_info_file for segment encryption ๐ŸŽ€. the first line of key_info_file is the key URI written to the playlist โ€” that's the URL used to grab the encryption key during playback. the second line is the path to the key file used to get the key while encrypting. that key file gets read as a single packed array of 16 octets in binary format, periodt. the optional third line is the initialization vector (IV) as a hexadecimal string, used instead of the segment sequence number (which is the default) for encryption. and heads up ๐Ÿ’…: changes to key_info_file will result in segment encryption with the new key/IV and an entry in the playlist for the new key URI/IV, but only if hls_flags periodic_rekey is enabled.

key info file format:

<key URI>
<key file path>
<IV> (optional)

example key URIs:

http://server/file.key
/path/to/file.key
file.key

example key file paths:

file.key
/path/to/file.key

example IV:

0123456789ABCDEF0123456789ABCDEF

key info file example:

http://server/file.key
/path/to/file.key
0123456789ABCDEF0123456789ABCDEF

example shell script:

#!/bin/sh
BASE_URL=${1:-'.'}
openssl rand 16 > file.key
echo $BASE_URL/file.key > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo
ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
  -hls_key_info_file file.keyinfo out.m3u8
  • hls_enc bool โ€” enable (1) or disable (0) the AES128 encryption ๐Ÿ”. when it's on, every segment generated is encrypted and the encryption key is saved as playlist name.key.
  • hls_enc_key key โ€” specify a 16-octet key to encrypt the segments with. by default it's randomly generated, so likeโ€ฆ chaos key, cute key ๐Ÿ’–
  • hls_enc_key_url keyurl โ€” if you set this, keyurl gets prepended instead of baseurl to the key filename in the playlist.
  • hls_enc_iv iv โ€” specify the 16-octet initialization vector for every segment, instead of the autogenerated ones ๐ŸŒธ
  • hls_segment_type flags โ€” possible values:
    • mpegts โ€” output segment files in MPEG-2 Transport Stream format. this one is compatible with all HLS versions, king behavior ๐Ÿ‘‘
    • fmp4 โ€” output segment files in fragmented MP4 format, similar to MPEG-DASH. fmp4 files may be used in HLS version 7 and above.
  • hls_fmp4_init_filename filename โ€” set the filename for the fragment files header file; the default filename is init.mp4.

when strftime is enabled, filename is expanded to the segment filename with localtime ๐Ÿ•ฐ๏ธ.

for example:

ffmpeg -i in.nut -hls_segment_type fmp4 -strftime 1 -hls_fmp4_init_filename "%s_init.mp4" out.m3u8

will produce init like this 1602678741_init.mp4 โ€” iconic naming scheme fr fr.

  • hls_fmp4_init_resend bool โ€” resend the init file after the m3u8 file refresh, every single time. default is 0.

when var_stream_map is set with two or more variant streams, the filename pattern must contain the string "%v" โ€” this string specifies the position of the variant stream index in the generated init file names ๐Ÿ‘€. the string "%v" may be present in the filename or in the last directory name containing the file. if the string is in the directory name, then sub-directories are created after expanding the directory name pattern. this enables creation of init files corresponding to different variant streams in subdirectories ๐Ÿ’…

โœจ hls_flags flags

possible values, buckle up bestie, there's a lot ๐Ÿซถ

  • single_file โ€” if this flag is set, the muxer will store all segments in a single MPEG-TS file, and will use byte ranges in the playlist. HLS playlists generated this way will have the version number 4.

for example:

ffmpeg -i in.nut -hls_flags single_file out.m3u8

will produce the playlist, out.m3u8, and a single segment file, out.ts.

  • delete_segments โ€” segment files removed from the playlist are deleted after a period of time equal to the duration of the segment plus the duration of the playlist ๐Ÿ—‘๏ธ
  • append_list โ€” append new segments into the end of the old segment list, and remove the "#EXT-X-ENDLIST" from the old segment list.
  • round_durations โ€” round the duration info in the playlist file segment info to integer values, instead of using floating point. if there are no other features requiring higher HLS versions be used, then this will allow ffmpeg to output an HLS version 2 m3u8 โญ
  • discont_start โ€” add the "#EXT-X-DISCONTINUITY" tag to the playlist, before the first segment's information.
  • omit_endlist โ€” do not append the "EXT-X-ENDLIST" tag at the end of the playlist.
  • periodic_rekey โ€” the file specified by "hls_key_info_file" will be checked periodically and updates to the encryption info will be detected ๐Ÿ‘€. be sure to replace this file atomically, including the file containing the AES encryption key. like, genuinely, atomic or it's cursed.
  • independent_segments โ€” add the "#EXT-X-INDEPENDENT-SEGMENTS" tag to playlists that have video segments and when all the segments of that playlist are guaranteed to start with a key frame.
  • iframes_only โ€” add the "#EXT-X-I-FRAMES-ONLY" tag to playlists that have video segments and can play only I-frames in the "#EXT-X-BYTERANGE" mode.
  • split_by_time โ€” allow segments to start on frames other than key frames. this improves behavior on some players when the time between key frames is inconsistent, but may make things worse on others, and can cause some oddities during seeking ๐Ÿ˜ญ. this flag should be used with the hls_time option. (yes it's a tradeoff, no I'm not gonna pretend it isn't)
  • program_date_time โ€” generate "EXT-X-PROGRAM-DATE-TIME" tags.
  • second_level_segment_index โ€” makes it possible to use segment indexes as %%d in the hls_segment_filename option expression, besides date/time values, when the strftime option is on. to get fixed width numbers with trailing zeroes, the %%0xd format is available, where x is the required width.
  • second_level_segment_size โ€” makes it possible to use segment sizes (counted in bytes) as %%s in the hls_segment_filename option expression, besides date/time values, when strftime is on. to get fixed width numbers with trailing zeroes, the %%0xs format is available, where x is the required width.
  • second_level_segment_duration โ€” makes it possible to use segment duration (calculated in microseconds) as %%t in the hls_segment_filename option expression, besides date/time values, when strftime is on. to get fixed width numbers with trailing zeroes, the %%0xt format is available, where x is the required width.

for example:

ffmpeg -i sample.mpeg \
   -f hls -hls_time 3 -hls_list_size 5 \
   -hls_flags second_level_segment_index+second_level_segment_size+second_level_segment_duration \
   -strftime 1 -strftime_mkdir 1 -hls_segment_filename "segment_%Y%m%d%H%M%S_%%04d_%%08s_%%013t.ts" stream.m3u8

will produce segments like this: segment_20170102194334_0003_00122200_0000003000000.ts, segment_20170102194334_0004_00120072_0000003000000.ts etc. look at those filenames, they ate ๐Ÿ”ฅ

  • temp_file โ€” write segment data to filename.tmp and rename to filename only once the segment is complete.

a webserver serving up segments can be configured to reject requests to *.tmp to prevent access to in-progress segments before they've been added to the m3u8 playlist ๐Ÿ™ˆ

this flag also affects how m3u8 playlist files are created. if this flag is set, all playlist files will be written into a temporary file and renamed after they're complete, similarly as segments are handled. but playlists with "file" protocol and with hls_playlist_type type other than vod are always written into a temporary file regardless of this flag.

master playlist files specified with master_pl_name, if any, with "file" protocol, are always written into a temporary file regardless of this flag if master_pl_publish_rate value is other than zero ๐Ÿ’…

  • hls_playlist_type type โ€” if type is event, emit "#EXT-X-PLAYLIST-TYPE:EVENT" in the m3u8 header. this forces hls_list_size to 0; the playlist can only be appended to.

if type is vod, emit "#EXT-X-PLAYLIST-TYPE:VOD" in the m3u8 header. this forces hls_list_size to 0; the playlist must not change. frozen. locked. periodt ๐ŸงŠ

  • method method โ€” use the given HTTP method to create the hls files.

for example:

ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8

will upload all the mpegts segment files to the HTTP server using the HTTP PUT method, and update the m3u8 files every "refresh" times using the same method. note that the HTTP server must support the given method for uploading files, bestie โ€” don't come crying to me if it 405s you ๐Ÿ˜ญ

  • http_user_agent agent โ€” override the User-Agent field in the HTTP header. applicable only for HTTP output ๐Ÿฆ‹
  • var_stream_map stream_map โ€” specify a map string defining how to group the audio, video and subtitle streams into different variant streams. the variant stream groups are separated by space.

expected string format is like this "a:0,v:0 a:1,v:1 ....". here a:, v:, s: are the keys to specify audio, video and subtitle streams respectively. allowed values are 0 to 9 (limited just based on practical usage) ๐Ÿ‘‘

okay so when you've got two or more variant streams, your output filename pattern has to contain the string %v โ€” that's the little guy that says where the variant stream index goes in your output media playlist filenames. no %v, no vibes. The string %v can live in the filename or in the last directory name containing the file. And if it's in the directory name? Then sub-directories get created after expanding the directory name pattern โ€” which is literally how you get variant streams chilling in subdirectories. ๐Ÿ—‚๏ธโœจ

A few examples follow.

  • Create two hls variant streams. The first variant stream will contain video stream of bitrate 1000k and audio stream of bitrate 64k, and the second variant stream will contain video stream of bitrate 256k and audio stream of bitrate 32k. Here, two media playlist with file names out_0.m3u8 and out_1.m3u8 will be created. ๐ŸŽ€
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -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" \
  http://example.com/live/out_%v.m3u8
  • Want something meaningful instead of indexes in your result names? Say less โ€” you can specify names for each or some of the variants. This example creates the same two hls variant streams as the previous one, but here the two media playlist with file names out_my_hd.m3u8 and out_my_sd.m3u8 will be created. aesthetic naming, we love to see it ๐Ÿ’…
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -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" \
  http://example.com/live/out_%v.m3u8
  • Create three hls variant streams. The first variant stream will be a video only stream with video bitrate 1000k, the second variant stream will be an audio only stream with bitrate 64k, and the third variant stream will be a video only stream with bitrate 256k. Here, three media playlist with file names out_0.m3u8, out_1.m3u8 and out_2.m3u8 will be created. ๐Ÿฆ‹
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
  -map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
  http://example.com/live/out_%v.m3u8
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -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" \
  http://example.com/live/vs_%v/out.m3u8
  • Two audio only and two video only variant streams. In addition to the "#EXT-X-STREAM-INF" tag for each variant stream in the master playlist, the "#EXT-X-MEDIA" tag is also added for the two audio only variant streams, and they are mapped to the two video only variant streams with audio group names 'aud_low' and 'aud_high'. By default, a single hls variant containing all the encoded streams is created. group chat assignments, basically ๐Ÿซถ
ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k -b:v:1 3000k  \
  -map 0:a -map 0:a -map 0:v -map 0:v -f hls \
  -var_stream_map "a:0,agroup:aud_low a:1,agroup:aud_high v:0,agroup:aud_low v:1,agroup:aud_high" \
  -master_pl_name master.m3u8 \
  http://example.com/live/out_%v.m3u8
  • Two audio only and one video only variant stream. In addition to the "#EXT-X-STREAM-INF" tag for each variant stream in the master playlist, the "#EXT-X-MEDIA" tag is also added for the two audio only variant streams, and they are mapped to the one video only variant streams with audio group name 'aud_low', and the audio group have default stat is NO or YES. By default, a single hls variant containing all the encoded streams is created. ๐ŸŒธ
ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
  -map 0:a -map 0:a -map 0:v -f hls \
  -var_stream_map "a:0,agroup:aud_low,default:yes a:1,agroup:aud_low v:0,agroup:aud_low" \
  -master_pl_name master.m3u8 \
  http://example.com/live/out_%v.m3u8
  • Two audio only and one video only variant stream, but make it multilingual. In addition to the "#EXT-X-STREAM-INF" tag for each variant stream in the master playlist, the "#EXT-X-MEDIA" tag is also added for the two audio only variant streams, and they are mapped to the one video only variant streams with audio group name 'aud_low', and the audio group have default stat is NO or YES, and one audio have and language is named ENG, the other audio language is named CHN. By default, a single hls variant containing all the encoded streams is created. ๐ŸŒˆ๐ŸŒ
ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
  -map 0:a -map 0:a -map 0:v -f hls \
  -var_stream_map "a:0,agroup:aud_low,default:yes,language:ENG a:1,agroup:aud_low,language:CHN v:0,agroup:aud_low" \
  -master_pl_name master.m3u8 \
  http://example.com/live/out_%v.m3u8
  • A single variant stream, but with subtitles. Add the "#EXT-X-MEDIA" tag with "TYPE=SUBTITLES" in the master playlist with webvtt subtitle group name 'subtitle' and optional subtitle name, e.g. 'English'. Make sure the input file has one text subtitle stream at least. subtitle girlies rise ๐ŸŽ€
ffmpeg -y -i input_with_subtitle.mkv \
 -b:v:0 5250k -c:v h264 -pix_fmt yuv420p -profile:v main -level 4.1 \
 -b:a:0 256k \
 -c:s webvtt -c:a mp2 -ar 48000 -ac 2 -map 0:v -map 0:a:0 -map 0:s:0 \
 -f hls -var_stream_map "v:0,a:0,s:0,sgroup:subtitle,sname:English" \
 -master_pl_name master.m3u8 -t 300 -hls_time 10 -hls_init_time 4 -hls_list_size \
 10 -master_pl_publish_rate 10 -hls_flags \
 delete_segments+discont_start+split_by_time ./tmp/video.m3u8

  • cc_stream_map cc_stream_map โ€” map string which specifies different closed captions groups and their attributes. The closed captions stream groups are separated by space. ๐Ÿ“บ

Expected string format is like this "ccgroup:<group name>,instreamid:<INSTREAM-ID>,language:<language code> ....". 'ccgroup' and 'instreamid' are mandatory attributes. 'language' is an optional attribute.

The closed captions groups configured using this option are mapped to different variant streams by providing the same 'ccgroup' name in the var_stream_map string.

For example:

ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -b:a:1 32k \
  -a53cc:0 1 -a53cc:1 1 \
  -map 0:v -map 0:a -map 0:v -map 0:a -f hls \
  -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en ccgroup:cc,instreamid:CC2,language:sp" \
  -var_stream_map "v:0,a:0,ccgroup:cc v:1,a:1,ccgroup:cc" \
  -master_pl_name master.m3u8 \
  http://example.com/live/out_%v.m3u8

will add two "#EXT-X-MEDIA" tags with "TYPE=CLOSED-CAPTIONS" in the master playlist for the INSTREAM-IDs 'CC1' and 'CC2'. Also, it will add "CLOSED-CAPTIONS" attribute with group name 'cc' for the two output variant streams. ๐Ÿ”ฅ

If var_stream_map is not set, then the first available ccgroup in cc_stream_map is mapped to the output variant stream.

For example:

ffmpeg -re -i in.ts -b:v 1000k -b:a 64k -a53cc 1 -f hls \
  -cc_stream_map "ccgroup:cc,instreamid:CC1,language:en" \
  -master_pl_name master.m3u8 \
  http://example.com/live/out.m3u8

this will add "#EXT-X-MEDIA" tag with "TYPE=CLOSED-CAPTIONS" in the master playlist with group name 'cc', language 'en' (english) and INSTREAM-ID 'CC1'. Also, it will add "CLOSED-CAPTIONS" attribute with group name 'cc' for the output variant stream. ๐Ÿ’–

  • master_pl_name name โ€” create HLS master playlist with the given name. ๐Ÿ‘‘

For example:

ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8

creates an HLS master playlist with name master.m3u8 which is published at <http://example.com/live/>.

  • master_pl_publish_rate count โ€” publish master play list repeatedly every after specified number of segment intervals. ๐Ÿ”

For example:

ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 \
-hls_time 2 -master_pl_publish_rate 30 http://example.com/live/out.m3u8

creates an HLS master playlist with name master.m3u8 and keeps publishing it repeatedly every after 30 segments i.e. every after 60s. โฐ

  • http_persistent bool โ€” use persistent HTTP connections. Applicable only for HTTP output.
  • timeout timeout โ€” set timeout for socket I/O operations. Applicable only for HTTP output. โณ
  • ignore_io_errors bool โ€” ignore IO errors during open, write and delete. Useful for long-duration runs with network output. ngl this one's a lifesaver for the marathon sessions ๐Ÿƒโ€โ™€๏ธ
  • headers headers โ€” set custom HTTP headers, can override built in default headers. Applicable only for HTTP output. ๐Ÿ’Œ

iamf ๐ŸŽง

Immersive Audio Model and Formats (IAMF) muxer.

IAMF is used to provide immersive audio content for presentation on a wide range of devices in both streaming and offline applications. These applications include internet audio streaming, multicasting/broadcasting services, file download, gaming, communication, virtual and augmented reality, and others. In these applications, audio may be played back on a wide range of devices, e.g., headphones, mobile phones, tablets, TVs, sound bars, home theater systems, and big screens. ๐ŸŽฎ๐Ÿ“ฑ๐ŸŽฌ

This format was promoted and designed by Alliance for Open Media.

For more information about this format, see <https://aomedia.org/iamf/>.

ico ๐Ÿ–ผ๏ธ

ICO file muxer.

Microsoft's icon file format (ICO) has some strict limitations that should be noted โ€” read these before you come crying to me ๐Ÿ˜ญ:

  • Size cannot exceed 256 pixels in any dimension
  • Only BMP and PNG images can be stored
  • If a BMP image is used, it must be one of the following pixel formats:
BMP Bit DepthFFmpeg Pixel Format

That table above? Here it is as a vibe-check list, bestie โ€” because a table is not the moment ๐ŸŽ€

  • 1bit โ†’ pal8
  • 4bit โ†’ pal8
  • 8bit โ†’ pal8
  • 16bit โ†’ rgb555le
  • 24bit โ†’ bgr24
  • 32bit โ†’ bgra
  • ๐Ÿ”ฅ If a BMP image is used, it must use the BITMAPINFOHEADER DIB header
  • ๐Ÿ”ฅ If a PNG image is used, it must use the rgba pixel format

ilbc

Internet Low Bitrate Codec (iLBC) raw muxer. Literally just the raw thing, no container drama โœจ

It accepts a single ilbc audio stream. One. That's the whole rule. ๐Ÿ’…


image2, image2pipe

Image file muxer โ€” the one that writes video frames out as image files, and honestly it's iconic for it ๐Ÿ‘‘

The image2 muxer writes video frames to image files.

The output filenames are specified by a pattern, and that pattern can be used to produce sequentially numbered series of files. The pattern may contain the string "%d" or "%0Nd" โ€” that string specifies the position of the characters representing a numbering in the filenames. If the form "%0Nd" is used, the string representing the number in each filename is 0-padded to N digits. And if you want a literal '%' character in the pattern, you write it as the string "%%". periodt.

If the pattern contains "%d" or "%0Nd", the first filename of the file list specified will contain the number 1, and all the following numbers will be sequential. yes bestie, it starts at one, not zero ๐ŸŒธ

The pattern may contain a suffix which is used to automatically determine the format of the image files to write. So the extension is lowkey doing the werk.

For example the pattern "img-%03d.bmp" will specify a sequence of filenames of the form img-001.bmp, img-002.bmp, ..., img-010.bmp, etc. The pattern "img%%-%d.jpg" will specify a sequence of filenames of the form img%-1.jpg, img%-2.jpg, ..., img%-10.jpg, etc. see how the %% became a single %? ate. ๐Ÿ”ฅ

The image muxer supports the .Y.U.V image file format. This format is special in that each image frame consists of three files, one for each of the YUV420P components. To read or write this image file format, specify the name of the '.Y' file. The muxer will automatically open the '.U' and '.V' files as required. three files, one frame, she's high-maintenance but we love her ๐Ÿฆ‹

The image2pipe muxer accepts the same options as the image2 muxer, but ignores the pattern verification and expansion, as it is supposed to write to the command output rather than to an actual stored file. pipes only, no filesystem bestie ๐Ÿ’…

Options

  • frame_pts bool โ€” If set to 1, expand the filename with the packet PTS (presentation time stamp). Default value is 0.
  • start_number count โ€” Start the sequence from the specified number. Default value is 1.
  • update bool โ€” If set to 1, the filename will always be interpreted as just a filename, not a pattern, and the corresponding file will be continuously overwritten with new images. Default value is 0.
  • strftime bool โ€” If set to 1, expand the filename with date and time information from strftime(). Default value is 0.
  • atomic_writing bool โ€” Write output to a temporary file, which is renamed to target filename once writing is completed. Default is disabled.
  • protocol_opts options_list โ€” Set protocol options as a :-separated list of key=value parameters. Values containing the ":" special character must be escaped.

Examples

  • Use ffmpeg for creating a sequence of files img-001.jpeg, img-002.jpeg, ..., taking one image every second from the input video:
ffmpeg -i in.avi -vsync cfr -r 1 -f image2 'img-%03d.jpeg'

Note that with ffmpeg, if the format is not specified with the "-f" option and the output filename specifies an image file format, the image2 muxer is automatically selected, so the previous command can be written as:

ffmpeg -i in.avi -vsync cfr -r 1 'img-%03d.jpeg'

Note also that the pattern must not necessarily contain "%d" or "%0Nd", for example to create a single image file img.jpeg from the start of the input video you can employ the command:

ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg
  • The strftime option allows you to expand the filename with date and time information. Check the documentation of the strftime() function for the syntax. iykyk ๐Ÿ“…

To generate image files from the strftime() "%Y-%m-%d_%H-%M-%S" pattern, the following ffmpeg command can be used:

ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg"
  • Set the file name with current frame's PTS:
ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg
  • Publish contents of your desktop directly to a WebDAV server every second:
ffmpeg -f x11grab -framerate 1 -i :0.0 -q:v 6 -update 1 -protocol_opts method=PUT http://example.com/desktop.jpg

ircam

Berkeley / IRCAM / CARL Sound Filesystem (BICSF) format muxer. a whole historical moment, honestly ๐Ÿ›๏ธ

The Berkeley/IRCAM/CARL Sound Format, developed in the 1980s, is a result of the merging of several different earlier sound file formats and systems including the csound system developed by Dr Gareth Loy at the Computer Audio Research Lab (CARL) at UC San Diego, the IRCAM sound file system developed by Rob Gross and Dan Timis at the Institut de Recherche et Coordination Acoustique / Musique in Paris and the Berkeley Fast Filesystem. the lore is unmatched fr fr ๐Ÿ“œ

It was developed initially as part of the Berkeley/IRCAM/CARL Sound Filesystem, a suite of programs designed to implement a filesystem for audio applications running under Berkeley UNIX. It was particularly popular in academic music research centres, and was used a number of times in the creation of early computer-generated compositions. academic music girlies stay winning ๐ŸŽ“

This muxer accepts a single audio stream containing PCM data.


ivf

On2 IVF muxer.

IVF was developed by On2 Technologies (formerly known as Duck Corporation), to store internally developed codecs. duck corporation?? iconic name ngl ๐Ÿฆ†

This muxer accepts a single vp8, vp9, or av1 video stream.


jacosub

JACOsub subtitle format muxer.

This muxer accepts a single jacosub subtitles stream.

For more information about the format, see http://unicorn.us.com/jacosub/jscripts.html.


kvag

Simon & Schuster Interactive VAG muxer.

This custom VAG container is used by some Simon & Schuster Interactive games such as "Real War", and "Real War: Rogue States". video game lore bestie ๐ŸŽฎ

This muxer accepts a single adpcm_ima_ssi audio stream.


lc3

Bluetooth SIG Low Complexity Communication Codec audio (LC3), or ETSI TS 103 634 Low Complexity Communication Codec plus (LC3plus). bluetooth audio, but make it official standards documents ๐Ÿ’™

This muxer accepts a single lc3 audio stream.


lrc

LRC lyrics file format muxer. yes. the karaoke one. we love her ๐ŸŽค

LRC (short for LyRiCs) is a computer file format that synchronizes song lyrics with an audio file, such as MP3, Vorbis, or MIDI.

This muxer accepts a single subrip or text subtitles stream.

Metadata

The following metadata tags are converted to the format corresponding metadata:

  • title
  • album
  • artist
  • author
  • creator
  • encoder
  • encoder_version

If encoder_version is not explicitly set, it is automatically set to the libavformat version. it's giving self-aware โœจ


matroska

Matroska container muxer. the big one. main character energy fr ๐Ÿ‘‘

This muxer implements the matroska and webm container specs.

Metadata

The recognized metadata settings in this muxer are:

  • title โ€” Set title name provided to a single track. This gets mapped to the FileDescription element for a stream written as attachment.
  • language โ€” Specify the language of the track in the Matroska languages form.

The language can be either the 3 letters bibliographic ISO-639-2 (ISO 639-2/B) form (like "fre" for French), or a language code mixed with a country code for specialities in languages (like "fre-ca" for Canadian French).

  • stereo_mode โ€” Set stereo 3D video layout of two views in a single video track.

The following values are recognized:

  • mono โ€” video is not stereo
  • left_right โ€” Both views are arranged side by side, Left-eye view is on the left
  • bottom_top โ€” Both views are arranged in top-bottom orientation, Left-eye view is at bottom
  • top_bottom โ€” Both views are arranged in top-bottom orientation, Left-eye view is on top
  • checkerboard_rl โ€” Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
  • checkerboard_lr โ€” Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
  • row_interleaved_rl โ€” Each view is constituted by a row based interleaving, Right-eye view is first row
  • row_interleaved_lr โ€” Each view is constituted by a row based interleaving, Left-eye view is first row
  • col_interleaved_rl โ€” Both views are arranged in a column based interleaving manner, Right-eye view is first column
  • col_interleaved_lr โ€” Both views are arranged in a column based interleaving manner, Left-eye view is first column
  • anaglyph_cyan_red โ€” All frames are in anaglyph format viewable through red-cyan filters
  • right_left โ€” Both views are arranged side by side, Right-eye view is on the left
  • anaglyph_green_magenta โ€” All frames are in anaglyph format viewable through green-magenta filters
  • block_lr โ€” Both eyes laced in one Block, Left-eye view is first
  • block_rl โ€” Both eyes laced in one Block, Right-eye view is first

For example a 3D WebM clip can be created using the following command line:

ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm

Options

  • reserve_index_space size โ€” By default, this muxer writes the index for seeking (called cues in Matroska terms) at the end of the file, because it cannot know in advance how much space to leave for the index at the beginning of the file. However for some use cases -- e.g. streaming where seeking is possible but slow -- it is useful to put the index at the beginning of the file.

If this option is set to a non-zero value, the muxer will reserve size bytes of space in the file header and then try to write the cues there when the muxing finishes. If the reserved space does not suffice, no Cues will be written, the file will be finalized and writing the trailer will return an error. A safe size for most use cases should be about 50kB per hour of video.

๐Ÿซถ Heads up bestie: cues are only written if the output is seekable, and this option will have no effect if it is not. no seeking, no cues, no exceptions.
  • cues_to_front bool โ€” If set, the muxer will write the index at the beginning of the file by shifting the main data if necessary. This can be combined with reserve_index_space in which case the data is only shifted if the initially reserved space turns out to be insufficient.
๐Ÿ’€ This option is ignored if the output is unseekable.

Okay so these cluster knobs are giving storage-limit realness ๐ŸŒธ โ€” you can cap a cluster at size bytes, and if you donโ€™t set it, the limit gets picked automatically from a sensible hardcoded fixed value โœจ.

  • cluster_size_limit size โ€” Store at most the provided amount of bytes in a cluster. If not specified, the limit is set automatically to a sensible hardcoded fixed value.
  • cluster_time_limit duration โ€” Store at most the provided number of milliseconds in a cluster. If not specified, the limit is set automatically to a sensible hardcoded fixed value.
  • dash bool โ€” Create a WebM file conforming to WebM DASH specification. By default it is set to "false".
  • dash_track_number index โ€” Track number for the DASH stream. By default it is set to 1.
  • live bool โ€” Write files assuming it is a live stream. By default it is set to "false".
  • allow_raw_vfw bool โ€” Allow raw VFW mode. By default it is set to "false".
  • flipped_raw_rgb bool โ€” If set to "true", store positive height for raw RGB bitmaps, which indicates the bitmap is stored bottom-up. Heads up: this option does not flip the bitmap โ€” that has to be done manually beforehand, e.g. by using the vflip filter. Default is "false" and indicates bitmap is stored top down.
  • write_crc32 bool โ€” Write a CRC32 element inside every Level 1 element. By default it is set to "true". This option is ignored for WebM.
  • default_mode mode โ€” Control how the FlagDefault of the output tracks will be set. It influences which tracks players should play by default. The default mode is passthrough.
    • infer โ€” Every track with disposition default will have the FlagDefault set. Additionally, for each type of track (audio, video or subtitle), if no track with disposition default of this type exists, then the first track of this type will be marked as default (if existing). This ensures that the default flag is set in a sensible way even if the input originated from containers that lack the concept of default tracks.
    • infer_no_subs โ€” This mode is the same as infer except that if no subtitle track with disposition default exists, no subtitle track will be marked as default.
    • passthrough โ€” In this mode the FlagDefault is set if and only if the AV_DISPOSITION_DEFAULT flag is set in the disposition of the corresponding stream.

๐Ÿ’พ md5 ๐Ÿ’พ

MD5 testing format. This is a variant of the hash muxer. Unlike that muxer, it defaults to using the MD5 hash function.

See also the hash and framemd5 muxers.

๐ŸŒŸ Examples ๐ŸŒŸ

  • To compute the MD5 hash of the input converted to raw audio and video, and store it in the file out.md5:
ffmpeg -i INPUT -f md5 out.md5
  • To print the MD5 hash to stdout:
ffmpeg -i INPUT -f md5 -

๐Ÿ“ผ mcc ๐Ÿ“ผ

Muxer for MacCaption MCC files โ€” it supports MCC versions 1.0 and 2.0. MCC files store VANC data, which can include closed captions (EIA-608 and CEA-708), ancillary time code, pan-scan data, etc. ๐Ÿ‘‘

โœจ Options โœจ

The muxer options are:

  • override_time_code_rate โ€” Override the "Time Code Rate" value in the output. Defaults to trying to deduce from the streamโ€™s "time_base", which often doesnโ€™t work. ๐Ÿ˜ญ
  • use_u_alias โ€” Use the "U" alias for the byte sequence "E1h 00h 00h 00h". Disabled by default because some .mcc files disagree on whether it has 2 or 3 zero bytes.
  • mcc_version โ€” The MCC file format version. Must be either 1 or 2, defaults to 2.
  • creation_program โ€” The creation program. Defaults to this version of FFmpeg.
  • creation_time โ€” The creation time. Defaults to the current time.

๐Ÿงช Examples ๐Ÿงช

  • Extract a MXF "SMPTE_436M_ANC" stream from a MXF file and write it to a MCC file at 30 fps.
ffmpeg -i input.mxf -c copy -map 0:d -override_time_code_rate 30 out.mcc
  • Extract EIA-608/CTA-708 closed captions from a .mp4 file and write them to a MCC file at 29.97 fps.
ffmpeg -f lavfi -i "movie=input.mp4[out+subcc]" -c:s copy -map 0:s -override_time_code_rate 30000/1001 out.mcc

๐ŸŽฌ microdvd ๐ŸŽฌ

MicroDVD subtitle format muxer.

This muxer accepts a single microdvd subtitles stream.

๐ŸŽน mmf ๐ŸŽน

Synthetic music Mobile Application Format (SMAF) format muxer.

SMAF is a music data format specified by Yamaha for portable electronic devices, such as mobile phones and personal digital assistants.

This muxer accepts a single adpcm_yamaha audio stream.

๐ŸŽง mp3 ๐ŸŽง

The MP3 muxer writes a raw MP3 stream with the following optional features:

  • An ID3v2 metadata header at the beginning (enabled by default). Versions 2.3 and 2.4 are supported, and the id3v2_version private option controls which one is used (3 or 4). Setting id3v2_version to 0 disables the ID3v2 header completely.

The muxer supports writing attached pictures (APIC frames) to the ID3v2 header. The pictures are supplied to the muxer in form of a video stream with a single packet. There can be any number of those streams, each will correspond to a single APIC frame. The stream metadata tags title and comment map to APIC description and picture type respectively. See http://id3.org/id3v2.4.0-frames for allowed picture types.

Note that the APIC frames must be written at the beginning, so the muxer will buffer the audio frames until it gets all the pictures. It is therefore advised to provide the pictures as soon as possible to avoid excessive buffering. ๐Ÿซถ

  • A Xing/LAME frame right after the ID3v2 header (if present). It is enabled by default, but will be written only if the output is seekable. The write_xing private option can be used to disable it. The frame contains various information that may be useful to the decoder, like the audio duration or encoder delay.
  • A legacy ID3v1 tag at the end of the file (disabled by default). It may be enabled with the write_id3v1 private option, but as its capabilities are very limited, its usage is not recommended.

๐ŸŽ€ Examples ๐ŸŽ€

Write an mp3 with an ID3v2.3 header and an ID3v1 footer:

ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3

To attach a picture to an mp3 file select both the audio and the picture stream with map:

ffmpeg -i input.mp3 -i cover.png -c copy -map 0 -map 1 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (Front)" out.mp3

Write a "clean" MP3 without any extra features:

ffmpeg -i input.wav -write_xing 0 -id3v2_version 0 out.mp3

๐Ÿ“บ mpegts ๐Ÿ“บ

MPEG transport stream muxer.

This muxer implements ISO 13818-1 and part of ETSI EN 300 468.

The recognized metadata settings in mpegts muxer are service_provider and service_name. If they are not set the default for service_provider is FFmpeg and the default for service_name is Service01.

๐Ÿ› ๏ธ Options ๐Ÿ› ๏ธ

The muxer options are:

  • mpegts_transport_stream_id integer โ€” Set the transport_stream_id. This identifies a transponder in DVB. Default is 0x0001.
  • mpegts_original_network_id integer โ€” Set the original_network_id. This is unique identifier of a network in DVB. Its main use is in the unique identification of a service through the path Original_Network_ID, Transport_Stream_ID. Default is 0x0001.
  • mpegts_service_id integer โ€” Set the service_id, also known as program in DVB. Default is 0x0001.
  • mpegts_service_type integer โ€” Set the program service_type. Default is digital_tv. Accepts the following options:
    • hex_value โ€” Any hexadecimal value between 0x01 and 0xff as defined in ETSI 300 468.
    • digital_tv โ€” Digital TV service.
    • digital_radio โ€” Digital Radio service.
    • teletext โ€” Teletext service.
    • advanced_codec_digital_radio โ€” Advanced Codec Digital Radio service.
    • mpeg2_digital_hdtv โ€” MPEG2 Digital HDTV service.
    • advanced_codec_digital_sdtv โ€” Advanced Codec Digital SDTV service.
    • advanced_codec_digital_hdtv โ€” Advanced Codec Digital HDTV service.
  • mpegts_pmt_start_pid integer โ€” Set the first PID for PMTs. Default is 0x1000, minimum is 0x0020, maximum is 0x1ffa. This option has no effect in m2ts mode where the PMT PID is fixed 0x0100.
  • mpegts_start_pid integer โ€” Set the first PID for elementary streams. Default is 0x0100, minimum is 0x0020, maximum is 0x1ffa. This option has no effect in m2ts mode where the elementary stream PIDs are fixed.
  • mpegts_m2ts_mode boolean โ€” Enable m2ts mode if set to 1. Default value is -1 which disables m2ts mode.
  • muxrate integer โ€” Set a constant muxrate. Default is VBR.
  • pes_payload_size integer โ€” Set minimum PES packet payload in bytes. Default is 2930.
  • mpegts_flags flags โ€” Set mpegts flags. Accepts the following options:
    • resend_headers โ€” Reemit PAT/PMT before writing the next packet.
    • latm โ€” Use LATM packetization for AAC.
    • pat_pmt_at_frames โ€” Reemit PAT and PMT at each video frame.
    • system_b โ€” Conform to System B (DVB) instead of System A (ATSC).
    • initial_discontinuity โ€” Mark the initial packet of each stream as discontinuity.
    • nit โ€” Emit NIT table.
    • omit_rai โ€” Disable writing of random access indicator.
  • mpegts_copyts boolean โ€” Preserve original timestamps, if value is set to 1. Default value is -1, which results in shifting timestamps so that they start from 0.
  • omit_video_pes_length boolean โ€” Omit the PES packet length for video packets. Default is 1 (true).
  • pcr_period integer โ€” Override the default PCR retransmission time in milliseconds. Default is -1 which means that the PCR interval will be determined automatically: 20 ms is used for CBR streams, the highest multiple of the frame duration which is less than 100 ms is used for VBR streams.
  • pat_period duration โ€” Maximum time in seconds between PAT/PMT tables. Default is 0.1.
  • sdt_period duration โ€” Maximum time in seconds between SDT tables. Default is 0.5.
  • nit_period duration โ€” Maximum time in seconds between NIT tables. Default is 0.5.
  • tables_version integer โ€” Set PAT, PMT, SDT and NIT version (default 0, valid values are from 0 to 31, inclusively). This option allows updating stream structure so that standard consumer may detect the change. To do so, reopen output AVFormatContext (in case of API usage) or restart ffmpeg instance, cyclically changing tables_version value:
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
...
ffmpeg -i source3.ts -codec copy -f mpegts -tables_version 31 udp://1.1.1.1:1111
ffmpeg -i source1.ts -codec copy -f mpegts -tables_version 0 udp://1.1.1.1:1111
ffmpeg -i source2.ts -codec copy -f mpegts -tables_version 1 udp://1.1.1.1:1111
...

Example ๐Ÿซถ

ffmpeg -i file.mpg -c copy \
     -mpegts_original_network_id 0x1122 \
     -mpegts_transport_stream_id 0x3344 \
     -mpegts_service_id 0x5566 \
     -mpegts_pmt_start_pid 0x1500 \
     -mpegts_start_pid 0x150 \
     -metadata service_provider="Some provider" \
     -metadata service_name="Some Channel" \
     out.ts

mxf, mxf_d10, mxf_opatom ๐ŸŽฌ

The MXF muxer, bestie. Three flavors, one vibe.

Options โœจ

The muxer options are:

  • store_user_comments bool โ€” sets whether user comments get stored if they're available, or never at all. Real talk: IRT D-10 straight up does not allow user comments, so the default writes them for mxf and mxf_opatom but not for mxf_d10. That's just how D-10 rolls ๐Ÿ’…

null ๐Ÿ’€

The Null muxer. It's giving "I'm here but I'm not really here."

This muxer does not generate any output file at all โ€” it's mainly useful for testing or benchmarking purposes. Iconic lazy queen behavior honestly.

For example, to benchmark decoding with ffmpeg you can use the command:

ffmpeg -benchmark -i INPUT -f null out.null
Heads up: that command above does not read or write the out.null file โ€” but specifying the output file is required by the ffmpeg syntax. Annoying? Yes. Stuck with it? Also yes ๐Ÿ˜ญ

Alternatively you can write the command as:

ffmpeg -benchmark -i INPUT -f null -

nut ๐Ÿฅœ

  • -syncpoints flags โ€” changes the syncpoint usage in nut:
    • default โ€” use the normal low-overhead seeking aids.
    • none โ€” do not use the syncpoints at all, reducing the overhead but making the stream non-seekable;
Use of this option is not recommended, as the resulting files are very damage sensitive and seeking is not possible. Also in general the overhead from syncpoints is negligible. Note, -C<write_index> 0 can be used to disable all growing data tables, allowing to mux endless streams with limited memory and without these disadvantages. ๐Ÿ™ˆ
  • timestamped โ€” extend the syncpoint with a wallclock field.

The none and timestamped flags are experimental โญ

  • -write_index bool โ€” write index at the end; the default is to write an index.
ffmpeg -i INPUT -f_strict experimental -syncpoints none - | processor

ogg ๐Ÿฆ‹

Ogg container muxer, she's a classic.

  • -page_duration duration โ€” preferred page duration, in microseconds. The muxer will attempt to create pages that are approximately duration microseconds long. This allows you to compromise between seek granularity and container overhead. The default is 1 second. A value of 0 will fill all segments, making pages as large as possible. A value of 1 will effectively use 1 packet-per-page in most situations, giving a small seek granularity at the cost of additional container overhead.
  • -serial_offset value โ€” serial value from which to set the streams serial number. Setting it to different and sufficiently large values ensures that the produced ogg files can be safely chained. Chain them, bestie ๐Ÿ”—

rcwt ๐ŸŒˆ

RCWT (Raw Captions With Time) is a format native to ccextractor, a commonly used open source tool for processing 608/708 Closed Captions (CC) sources. It can be used to archive the original extracted CC bitstream and to produce a source file for later processing or conversion. The format allows for interoperability between ccextractor and FFmpeg, is simple to parse, and can be used to create a backup of the CC presentation. Love a low-effort legend ๐Ÿ’–

This muxer implements the specification as of March 2024, which has been stable and unchanged since April 2014. Ten years of consistency? We stan.

This muxer will have some nuances from the way that ccextractor muxes RCWT. No compatibility issues when processing the output with ccextractor have been observed as a result of this so far, but mileage may vary and outputs will not be a bit-exact match. Ngl, close enough ๐Ÿ‘‘

A free specification of RCWT can be found here: https://github.com/CCExtractor/ccextractor/blob/master/docs/BINARY_FILE_FORMAT.TXT

Examples

  • Extract Closed Captions to RCWT using lavfi:
ffmpeg -f lavfi -i "movie=INPUT.mkv[out+subcc]" -map 0:s:0 -c:s copy -f rcwt CC.rcwt.bin

segment, stream_segment, ssegment โœ‚๏ธ

Basic stream segmenter. The chopping block of muxers, and we're obsessed.

This muxer outputs streams to a number of separate files of nearly fixed duration. Output filename pattern can be set in a fashion similar to image2, or by using a strftime template if the strftime option is enabled.

stream_segment is a variant of the muxer used to write to streaming output formats, i.e. which do not require global headers, and is recommended for outputting e.g. to MPEG transport stream segments. ssegment is a shorter alias for stream_segment. Aliases, we love a rebrand ๐Ÿ’…

Every segment starts with a keyframe of the selected reference stream, which is set through the reference_stream option.

Note that if you want accurate splitting for a video file, you need to make the input key frames correspond to the exact splitting times expected by the segmenter, or the segment muxer will start the new segment with the key frame found next after the specified start time. Yeah, she's picky ๐Ÿ˜ญ

The segment muxer works best with a single constant frame rate video.

Optionally it can generate a list of the created segments, by setting the option segment_list. The list type is specified by the segment_list_type option. The entry filenames in the segment list are set by default to the basename of the corresponding segment files.

See also the hls muxer, which provides a more specific implementation for HLS segmentation.

Options

The segment muxer supports the following options:

  • increment_tc 1|0 โ€” if set to 1, increment timecode between each segment. If this is selected, the input need to have a timecode in the first video stream. Default value is 0.
  • reference_stream specifier โ€” set the reference stream, as specified by the string specifier. If specifier is set to "auto", the reference is chosen automatically. Otherwise it must be a stream specifier (see the ``Stream specifiers'' chapter in the ffmpeg manual) which specifies the reference stream. The default value is "auto".
  • segment_format format โ€” override the inner container format; by default it is guessed by the filename extension.
  • segment_format_options options_list โ€” set output format options using a :-separated list of key=value parameters. Values containing the : special character must be escaped.
  • segment_list name โ€” generate also a listfile named name. If not specified no listfile is generated.
  • segment_list_flags flags โ€” set flags affecting the segment list generation. It currently supports the following flags:
    • cache โ€” allow caching (only affects M3U8 list files).
    • live โ€” allow live-friendly file generation.
  • segment_list_size size โ€” update the list file so that it contains at most size segments. If 0 the list file will contain all the segments. Default value is 0.
  • segment_list_entry_prefix prefix โ€” prepend prefix to each entry. Useful to generate absolute paths. By default no prefix is applied.
  • segment_list_type type โ€” select the listing format. The following values are recognized:
    • flat โ€” generate a flat list for the created segments, one segment per line.
    • csv, ext โ€” generate a list for the created segments, one segment per line, each line matching the format (comma-separated values):
<segment_filename>,<segment_start_time>,<segment_end_time>

segment_filename is the name of the output file generated by the muxer according to the provided pattern. CSV escaping (according to RFC4180) is applied if required.

segment_start_time and segment_end_time specify the segment start and end time expressed in seconds.

A list file with the suffix ".csv" or ".ext" will auto-select this format.

ext is deprecated in favor of csv. Don't be that person still using it ๐Ÿซ 
  • ffconcat โ€” generate an ffconcat file for the created segments. The resulting file can be read using the FFmpeg concat demuxer.

A list file with the suffix ".ffcat" or ".ffconcat" will auto-select this format.

A list file with the suffix ".m3u8" will auto-select this format.

If not specified the type is guessed from the list file name suffix.

  • segment_time time โ€” set segment duration to time, the value must be a duration specification. Default value is "2". See also the segment_times option.
Note that splitting may not be accurate, unless you force the reference stream key-frames at the given time. See the introductory notice and the examples below. No cap, she'll split where she wants ๐ŸŒธ
  • min_seg_duration time โ€” set minimum segment duration to time, the value must be a duration specification. This prevents the muxer ending segments at a duration below this value. Only effective with segment_time. Default value is "0".
  • segment_atclocktime 1|0 โ€” if set to "1" split at regular clock time intervals starting from 00:00 o'clock. The time value specified in segment_time is used for setting the length of the splitting interval.

For example with segment_time set to "900" this makes it possible to create files at 12:00 o'clock, 12:15, 12:30, etc.

Default value is "0".

  • segment_clocktime_offset duration โ€” delay the segment splitting times with the specified duration when using segment_atclocktime.

For example with segment_time set to "900" and segment_clocktime_offset set to "300" this makes it possible to create files at 12:05, 12:20, 12:35, etc.

Default value is "0".

  • segment_clocktime_wrap_duration duration โ€” force the segmenter to only start a new segment if a packet reaches the muxer within the specified duration after the segmenting clock time. This way you can make the segmenter more resilient to backward local time jumps, such as leap seconds or transition to standard time from daylight savings time. She's just protecting herself ๐Ÿงš

Default is the maximum possible duration which means starting a new segment regardless of the elapsed time since the last clock time.

  • segment_time_delta delta โ€” the accuracy time used when picking the start time for a segment, expressed as a duration spec. Default is 0 โœจ

When delta is given, a key-frame will start a new segment if its PTS satisfies this relation:

PTS >= start_time - time_delta

This one is lowkey a lifesaver when you're splitting video content โ€” which is always split at GOP boundaries โ€” and a key frame shows up just before the split time you asked for. ๐Ÿ™ˆ

Specifically it pairs with the ffmpeg force_key_frames option. The key frame times you specify with force_key_frames may not land accurately because of rounding issues, and the consequence is a key frame time that ends up set just before the specified time ๐Ÿ˜ญ. For constant frame rate videos a value of 1/(2*frame_rate) should cover the worst case mismatch between the specified time and the time set by force_key_frames. Math queen behavior fr fr ๐Ÿ’…

  • segment_times times โ€” specify a list of split points. times contains a comma separated list of duration specifications, in increasing order. Also peep the segment_time option ๐Ÿ‘€
  • segment_frames frames โ€” specify a list of split video frame numbers. frames contains a comma separated list of integer numbers, in increasing order.

This option says: start a new segment whenever a reference stream key frame is found and the sequential number (starting from 0) of the frame is greater or equal to the next value in the list. ๐ŸŽฏ

  • segment_wrap limit โ€” wrap around the segment index once it reaches limit.
  • segment_start_number number โ€” set the sequence number of the first segment. Defaults to 0.
  • strftime 1|0 โ€” use the strftime function to define the name of the new segments to write. If you pick this, the output segment name must contain a strftime function template. Default value is 0. ๐Ÿ•ฐ๏ธ
  • break_non_keyframes 1|0 โ€” if enabled, segments are allowed to start on frames other than keyframes. This improves behavior on some players when the time between keyframes is inconsistent, but it may make things worse on others, and can cause some oddities during seeking. Defaults to 0. So likeโ€ฆ proceed with caution bestie ๐Ÿ’€
  • reset_timestamps 1|0 โ€” reset timestamps at the beginning of each segment, so every segment starts with near-zero timestamps. It's meant to ease playback of the generated segments ๐Ÿซถ. May not work with some combinations of muxers/codecs. Set to 0 by default.
  • initial_offset offset โ€” specify the timestamp offset to apply to the output packet timestamps. The argument must be a time duration specification, and defaults to 0.
  • write_empty_segments 1|0 โ€” if enabled, write an empty segment if there are no packets during the period a segment would usually span. Otherwise, the segment gets filled with the next packet written. Defaults to 0.

Make sure to require a closed GOP when encoding and to set the GOP size to fit your segment time constraint. No cap, this matters ๐ŸŽ€

Examples

  • Remux the content of file in.mkv to a list of segments out-000.nut, out-001.nut, etc., and write the list of generated segments to out.list:
ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut
  • Segment input and set output format options for the output segments:
ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
  • Segment the input file according to the split points specified by the segment_times option:
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
  • Use the ffmpeg force_key_frames option to force key frames in the input at the specified location, together with the segment option segment_time_delta to account for possible roundings operated when setting key frame times. ๐Ÿงš
ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \
-f segment -segment_list out.csv -segment_times 1,2,3,5,8,13,21 -segment_time_delta 0.05 out%03d.nut

In order to force key frames on the input file, transcoding is required. (Yes, actually required โ€” not optional, sorry ๐Ÿ˜ญ)

  • Segment the input file by splitting it according to the frame numbers sequence specified with the segment_frames option:
ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut
  • Convert the in.mkv to TS segments using the libx264 and aac encoders:
ffmpeg -i in.mkv -map 0 -codec:v libx264 -codec:a aac -f ssegment -segment_list out.list out%03d.ts
  • Segment the input file, and create an M3U8 live playlist (can be used as live HLS source):
ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \
-segment_list_flags +live -segment_time 10 out%03d.mkv

๐ŸŒŠ smoothstreaming ๐ŸŒŠ

The Smooth Streaming muxer generates a set of files (Manifest, chunks) suitable for serving with a conventional web server. It's giving "just works" energy โœจ

  • window_size โ€” specify the number of fragments kept in the manifest. Default 0 (keep all). ๐Ÿ‘‘
  • extra_window_size โ€” specify the number of fragments kept outside of the manifest before removing from disk. Default 5.
  • lookahead_count โ€” specify the number of lookahead fragments. Default 2.
  • min_frag_duration โ€” specify the minimum fragment duration (in microseconds). Default 5000000.
  • remove_at_exit โ€” specify whether to remove all fragments when finished. Default 0 (do not remove).

๐Ÿงฌ streamhash ๐Ÿงฌ

Per stream hash testing format. Bestie, this is the vibe check for your files ๐Ÿ’…

This muxer computes and prints a cryptographic hash of all the input frames, on a per-stream basis. This can be used for equality checks without having to do a complete binary comparison. Obsessed, honestly.

By default audio frames are converted to signed 16-bit raw audio and video frames to raw video before computing the hash, but the output of explicit conversions to other codecs can also be used. Timestamps are ignored. It uses the SHA-256 cryptographic hash function by default, but supports several other algorithms. ๐ŸŒˆ

The output of the muxer consists of one line per stream of the form: streamindex,streamtype,algo=hash, where streamindex is the index of the mapped stream, streamtype is a single character indicating the type of stream, algo is a short string representing the hash function used, and hash is a hexadecimal number representing the computed hash.

  • hash algorithm โ€” use the cryptographic hash function specified by the string algorithm. Supported values include MD5, murmur3, RIPEMD128, RIPEMD160, RIPEMD256, RIPEMD320, SHA160, SHA224, SHA256 (default), SHA512/224, SHA512/256, SHA384, SHA512, CRC32 and adler32. Take your pick, queen ๐Ÿ‘‘

Examples

To compute the SHA-256 hash of the input converted to raw audio and video, and store it in the file out.sha256:

ffmpeg -i INPUT -f streamhash out.sha256

To print an MD5 hash to stdout use the command:

ffmpeg -i INPUT -f streamhash -hash md5 -

See also the hash and framehash muxers. ๐Ÿ‘€


๐Ÿซ– tee ๐Ÿซ–

The tee muxer can be used to write the same data to several outputs, such as files or streams. It can be used, for example, to stream a video over a network and save it to disk at the same time. Multitasking icon behavior ๐ŸŽ€

It is different from specifying several outputs to the ffmpeg command-line tool. With the tee muxer, the audio and video data will be encoded only once ๐Ÿ”ฅ. With conventional multiple outputs, multiple encoding operations in parallel are initiated, which can be a very expensive process ๐Ÿ˜ญ. The tee muxer is not useful when using the libavformat API directly because it is then possible to feed the same packets to several muxers directly.

Since the tee muxer does not represent any particular output format, ffmpeg cannot auto-select output streams. So all streams intended for output must be specified using -map. See the examples below. No shortcuts, bestie ๐Ÿ’…

Some encoders may need different options depending on the output format; the auto-detection of this can not work with the tee muxer, so they need to be explicitly specified. The main example is the global_header flag. ๐Ÿšฉ

The slave outputs are specified in the file name given to the muxer, separated by |. If any of the slave name contains the | separator, leading or trailing spaces or any special character, those must be escaped (see the Quoting and escaping section in the ffmpeg-utils(1) manual).

Options

  • use_fifo bool โ€” if set to 1, slave outputs will be processed in separate threads using the fifo muxer. This allows to compensate for different speed/latency/reliability of outputs and setup transparent recovery. By default this feature is turned off.
  • fifo_options โ€” options to pass to fifo pseudo-muxer instances. See fifo.

Muxer options can be specified for each slave by prepending them as a list of key=value pairs separated by :, between square brackets. If the options values contain a special character or the : separator, they must be escaped; note that this is a second level escaping. Escape-ception, truly ๐ŸŒ€

The following special options are also recognized:

  • f โ€” specify the format name. Required if it cannot be guessed from the output URL.
  • bsfs[/spec] โ€” specify a list of bitstream filters to apply to the specified output.

It is possible to specify to which streams a given bitstream filter applies, by appending a stream specifier to the option separated by /. spec must be a stream specifier (see Format stream specifiers).

If the stream specifier is not specified, the bitstream filters will be applied to all streams in the output. This will cause that output operation to fail if the output contains streams to which the bitstream filter cannot be applied, e.g. h264_mp4toannexb being applied to an output containing an audio stream. ๐Ÿ’€ Yeah. That'll do it.

Options for a bitstream filter must be specified in the form of opt=value.

Several bitstream filters can be specified, separated by ,.

  • use_fifo bool โ€” this allows to override tee muxer use_fifo option for individual slave muxer.
  • fifo_options โ€” this allows to override tee muxer fifo_options for individual slave muxer. See fifo.
  • select โ€” select the streams that should be mapped to the slave output, specified by a stream specifier. If not specified, this defaults to all the mapped streams. This will cause that output operation to fail if the output format does not accept all mapped streams. ๐Ÿ™ˆ

You may use multiple stream specifiers separated by commas (,) e.g.: a:0,v

  • onfail โ€” okay so this is the โ€œwhat happens if an output ghosts usโ€ knob. Set it to abort (which is the default) or ignore. abort makes the whole process fail if this slave output fails. ignore means failure on this output gets ignored, so the other outputs keep going unbothered. ๐Ÿ’…

๐Ÿ“ Examples ๐Ÿ“

  • Encode something and both archive it in a WebM file and stream it as MPEG-TS over UDP:
ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  "archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  • Same energy, but keep streaming even if output to the local file fails (like when the local drive fills up):
ffmpeg -i ... -c:v libx264 -c:a mp2 -f tee -map 0:v -map 0:a
  "[onfail=ignore]archive-20121107.mkv|[f=mpegts]udp://10.0.1.255:1234/"
  • Use ffmpeg to encode the input, and send the output to three different destinations. The dump_extra bitstream filter is used to add extradata information to all the output video keyframe packets, as requested by the MPEG-TS format. The select option is applied to out.aac in order to make it contain only audio packets.
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
       -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac"
  • As above, but select only stream "a:1" for the audio output. Note that a second level of escaping must be performed, as : is a special character used to separate options.
ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac
       -f tee "[bsfs/v=dump_extra=freq=keyframe]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac"

โœจ webm_chunk โœจ

WebM Live Chunk Muxer.

This muxer writes out WebM headers and chunks as separate files which can be consumed by clients that support WebM Live streams via DASH. ๐Ÿฆ‹

๐ŸŽ€ Options ๐ŸŽ€

This muxer supports the following options:

  • chunk_start_index โ€” index of the first chunk (defaults to 0).
  • header โ€” filename of the header where the initialization data will be written.
  • audio_chunk_duration โ€” duration of each audio chunk in milliseconds (defaults to 5000).

๐ŸŒธ Example ๐ŸŒธ

ffmpeg -f v4l2 -i /dev/video0 \
       -f alsa -i hw:0 \
       -map 0:0 \
       -c:v libvpx-vp9 \
       -s 640x360 -keyint_min 30 -g 30 \
       -f webm_chunk \
       -header webm_live_video_360.hdr \
       -chunk_start_index 1 \
       webm_live_video_360_%d.chk \
       -map 1:0 \
       -c:a libvorbis \
       -b:a 128k \
       -f webm_chunk \
       -header webm_live_audio_128.hdr \
       -chunk_start_index 1 \
       -audio_chunk_duration 1000 \
       webm_live_audio_128_%d.chk

๐Ÿฆ‹ webm_dash_manifest ๐Ÿฆ‹

WebM DASH Manifest muxer.

This muxer implements the WebM DASH Manifest specification to generate the DASH manifest XML. It also supports manifest generation for DASH live streams.

For more information see:

๐ŸŽ€ Options ๐ŸŽ€

This muxer supports the following options:

  • adaptation_sets โ€” this option has the syntax "id=x,streams=a,b,c id=y,streams=d,e", where x and y are the unique identifiers of the adaptation sets, and a,b,c,d and e are the indices of the corresponding audio and video streams. Any number of adaptation sets can be added using this option.
  • live โ€” set this to 1 to create a live stream DASH Manifest. Default: 0.
  • chunk_start_index โ€” start index of the first chunk. This will go in the startNumber attribute of the SegmentTemplate element in the manifest. Default: 0.
  • chunk_duration_ms โ€” duration of each chunk in milliseconds. This will go in the duration attribute of the SegmentTemplate element in the manifest. Default: 1000.
  • utc_timing_url โ€” URL of the page that will return the UTC timestamp in ISO format. This will go in the value attribute of the UTCTiming element in the manifest. Default: None.
  • time_shift_buffer_depth โ€” smallest time (in seconds) shifting buffer for which any Representation is guaranteed to be available. This will go in the timeShiftBufferDepth attribute of the MPD element. Default: 60.
  • minimum_update_period โ€” minimum update period (in seconds) of the manifest. This will go in the minimumUpdatePeriod attribute of the MPD element. Default: 0.

๐ŸŒธ Example ๐ŸŒธ

ffmpeg -f webm_dash_manifest -i video1.webm \
       -f webm_dash_manifest -i video2.webm \
       -f webm_dash_manifest -i audio1.webm \
       -f webm_dash_manifest -i audio2.webm \
       -map 0 -map 1 -map 2 -map 3 \
       -c copy \
       -f webm_dash_manifest \
       -adaptation_sets "id=0,streams=0,1 id=1,streams=2,3" \
       manifest.xml

๐ŸŒˆ whip ๐ŸŒˆ

WebRTC (Real-Time Communication) muxer that supports sub-second latency streaming according to the WHIP (WebRTC-HTTP ingestion protocol) specification.

โš ๏ธ This is an experimental feature.

It uses HTTP as a signaling protocol to exchange SDP capabilities and ICE lite candidates. Then, it uses STUN binding requests and responses to establish a session over UDP. Subsequently, it initiates a DTLS handshake to exchange the SRTP encryption keys. Lastly, it splits video and audio frames into RTP packets and encrypts them using SRTP. ๐Ÿ”ฅ

Ensure that you use H.264 without B frames and Opus for the audio codec. For example, to convert an input file with ffmpeg to WebRTC:

ffmpeg -re -i input.mp4 -acodec libopus -ar 48000 -ac 2 \
  -vcodec libx264 -profile:v baseline -tune zerolatency -threads 1 -bf 0 \
  -f whip "http://localhost:1985/rtc/v1/whip/?app=live&stream=livestream"

For this example, we have employed low latency options, resulting in an end-to-end latency of approximately 150ms.

๐ŸŽ€ Options ๐ŸŽ€

This muxer supports the following options:

  • handshake_timeout integer โ€” set the timeout in milliseconds for ICE and DTLS handshake. Default value is 5000.
  • pkt_size integer โ€” set the maximum size, in bytes, of RTP packets that send out. Default value is 1200.
  • ts_buffer_size integer โ€” set the buffer size, in bytes, of underlying protocol. Default value is -1(auto). The UDP auto selects a reasonable value.
  • whip_flags flags โ€” possible values:
    • dtls_active โ€” the muxer will try to set dtls active role and send the first client hello.
  • rtp_history integer โ€” set the number of RTP history items to store. Default value is 512.
  • authorization string โ€” the optional Bearer token for WHIP Authorization.
  • cert_file string โ€” the optional certificate file path for DTLS.
  • key_file string โ€” the optional private key file path for DTLS.

๐Ÿท๏ธ METADATA ๐Ÿท๏ธ

FFmpeg is able to dump metadata from media files into a simple UTF-8-encoded INI-like text file and then load it back using the metadata muxer/demuxer.

The file format is as follows:

  1. A file consists of a header and a number of metadata tags divided into sections, each on its own line.
  2. The header is a ;FFMETADATA string, followed by a version number (now 1).
  3. Metadata tags are of the form key=value
  4. Immediately after header follows global metadata
  5. After global metadata there may be sections with per-stream/per-chapter metadata.
  6. A section starts with the section name in uppercase (i.e. STREAM or CHAPTER) in brackets ([, ]) and ends with next section or end of file.
  7. At the beginning of a chapter section there may be an optional timebase to be used for start/end values. It must be in form TIMEBASE=num/den, where num and den are integers. If the timebase is missing then start/end times are assumed to be in nanoseconds.

Next a chapter section must contain chapter start and end times in form START=num, END=num, where num is a positive integer.

  1. Empty lines and lines starting with ; or # are ignored.
  2. Metadata keys or values containing special characters (=, ;, #, \ and a newline) must be escaped with a backslash \.
  3. Note that whitespace in metadata (e.g. foo = bar) is considered to be a part of the tag (in the example above key is foo , value is bar).

A ffmetadata file might look like this:

;FFMETADATA1
title=bike\\shed
;this is a comment
artist=FFmpeg troll team

[CHAPTER]
TIMEBASE=1/1000
START=0
#chapter ends at 0:01:00
END=60000
title=chapter \#1
[STREAM]
title=multi\
line

By using the ffmetadata muxer and demuxer it is possible to extract metadata from an input file to an ffmetadata file, and then transcode the file into an output file with the edited ffmetadata file.

Extracting an ffmetadata file with ffmpeg goes as follows:

ffmpeg -i INPUT -f ffmetadata FFMETADATAFILE

Reinserting edited metadata information from the FFMETADATAFILE file can be done as:

ffmpeg -i INPUT -i FFMETADATAFILE -map_metadata 1 -codec copy OUTPUT

๐Ÿ‘€ SEE ALSO ๐Ÿ‘€

Go check out ffmpeg(1), ffplay(1), ffprobe(1), libavformat(3) when youโ€™re done here, bestie ๐Ÿ’–

๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

The FFmpeg developers.

For details about the authorship, see the Git history of the project (https://git.ffmpeg.org/ffmpeg), e.g. by typing the command git log in the FFmpeg source directory, or browsing the online repository at https://git.ffmpeg.org/ffmpeg.

Maintainers for the specific components are listed in the file MAINTAINERS in the source code tree.


Thatโ€™s a wrap on FFMPEG-FORMATS(1), bestie โ€” source/version: FFmpeg manual page; date: the one your local manpage build stamped on it ๐Ÿซถ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from