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:
avioflagsflags (input/output) โ I/O flags bestie. possible values:directโ reduce buffering.
probesizeinteger (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 than32. default is5000000.max_probe_packetsinteger (input) โ sets the max number of buffered packets when probing a codec. default is2500packets. ๐packetsizeinteger (output) โ set packet size. that's it, that's the option.fflagsflags โ 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 toNOPTS. this one gets ignored when thenofillinflag 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+nofillintoo!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 increasemax_interleave_deltato avoid flushing the longer streams before EOF.
seek2anyinteger (input) โ allow seeking to non-keyframes on demuxer level when supported if set to1. default is0.analyzedurationinteger (input) โ specify how many microseconds are analyzed to probe the input. higher value = more accurate info detection, but more latency ๐ด. it defaults to5,000,000microseconds =5seconds.cryptokeyhexadecimal string (input) โ set decryption key. ๐indexmeminteger (input) โ set max memory used for timestamp index (per stream).rtbufsizeinteger (input) โ set max memory used for buffering real-time frames.fdebugflags (input/output) โ print specific debug info. possible values:ts
max_delayinteger (input/output) โ set maximum muxing or demuxing delay in microseconds.fpsprobesizeinteger (input) โ set number of frames used to probe fps.audio_preloadinteger (output) โ set microseconds by which audio packets should be interleaved earlier.chunk_durationinteger (output) โ set microseconds for each chunk.chunk_sizeinteger (output) โ set size in bytes for each chunk.err_detect,f_err_detectflags (input) โ set error detection flags. heads up:f_err_detectis deprecated and should be used only via theffmpegtool. 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_deltainteger (output) โ set maximum buffering duration for interleaving. the duration is in microseconds, and defaults to10000000(10seconds).
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_timestampsinteger (input) โ use wallclock as timestamps if set to1. default is0.avoid_negative_tsinteger (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 is0.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_bytesinteger (input) โ set number of bytes to skip before reading header and frames if set to1. default is0.correct_ts_overflowinteger (input) โ correct single timestamp overflows if set to1. default is1.flush_packetsinteger (output) โ flush the underlying I/O stream after each packet. default is-1(auto), which means that the underlying protocol will decide,1enables it and has the effect of reducing the latency, and0disables it and may increase IO throughput in some cases.output_ts_offsetoffset (output) โ set the output time offset. offset must be a time duration specification, see the Time duration section in theffmpeg-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_whitelistlist (input) โ","separated list of allowed demuxers. by default all are allowed.dump_separatorstring (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_streamsinteger (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_ptsbool (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_probesizeinteger (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 than1, or0for default behaviour. phew ๐ฎโ๐จstrict,f_strictinteger (input/output) โ specify how strictly to follow the standards. heads up:f_strictis deprecated and should be used only via theffmpegtool. possible values:veryโ strictly conform to an older more strict version of the spec or reference softwarestrictโ strictly conform to all the things in the spec no matter what consequencesnormalunofficialโ allow unofficial extensionsexperimentalโ 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_loopbool โ ignore the loop variable in the file if it's set. Default is enabled.-max_fpsint โ maximum framerate in frames per second. The default of0imposes no limit โ go wild ๐โโ๏ธ.-default_fpsint โ default framerate in frames per second when none is specified in the file (0meaning "as fast as possible"). Default is15.
asf
Advanced Systems Format demuxer.
Demuxes ASF files and MMS network streams. versatile icon ๐
-no_resync_searchbool โ 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:
filepath โ 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.durationdur โ 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 ๐งinpointtimestamp โ 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 thedurationdirective) 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.outpointtimestamp โ 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 thedurationdirective) will be reduced based on their specified Out point.file_packet_metadatakey=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 โ usefile_packet_metainstead.file_packet_metakey 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 ๐optionkey 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_idid โ 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_metakey value โ metadata for the stream. Can be present multiple times.stream_codecvalue โ codec for the stream.stream_extradatahex_string โ extradata for the string, encoded in hexadecimal.chapterid start end โ add a chapter. id is a unique identifier, possibly small and consecutive.
Options
This demuxer accepts the following options:
safeโ if set to1, 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 to0, any file name is accepted. anything. chaos mode. The default is1.auto_convertโ if set to1, try to perform automatic conversions on packet data so the streams become concatenable. The default is1. Currently the only conversion is adding theh264_mp4toannexbbitstream filter to H.264 streams in MP4 format. This is necessary in particular if there are resolution changes. ๐ฆsegment_time_metadataโ if set to1, every packet will contain thelavf.concat.start_timeandlavf.concat.durationpacket 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 is0.
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:
titleint โ The title number to play. Must be set ifpgcandpgare not set. Not applicable to menus. Default is0(auto), which currently only selects the first available title (title 1) and notifies the user about the implications.chapter_startint โ The chapter, or PTT (part-of-title), number to start at. Not applicable to menus. Default is1.chapter_endint โ The chapter, or PTT (part-of-title), number to end at. Not applicable to menus. Default is0, which is a special value that signals "end at the last possible chapter".angleint โ 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 is1.regionint โ 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 is0, "world".menubool โ Demux menu assets instead of navigating a title. Requires the exact coordinates of the menu (menu_lu,menu_vts,pgc,pg). Default isfalse.menu_luint โ The menu language to demux. In DVD, menus are grouped by language. Default is1, the first language unit.menu_vtsint โ The VTS where the menu lives, or0if it's a VMG menu (root-level). Default is1, menu of the first VTS.pgcint โ The entry PGC to start playback at, in conjunction withpg. This is the alternative to settingtitle. Chapter markers are not supported at this time. Must be explicitly set for menus. Default is0, automatically resolved from the value oftitle.pgint โ The entry PG to start playback at, in conjunction withpgc. This is the alternative to settingtitle. Chapter markers are not supported at this time. Default is1, the first PG of the PGC.preindexbool โ 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 withpgcandpg. Default is0,false.trimbool โ 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 is1,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_alphabool โ 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_metadatabool โ Allocate the streams according to theonMetaDataarray content.-flv_ignore_prevtagbool โ Ignore the size of previous tag value.-flv_full_metadatabool โ Output all context of theonMetadata.
๐ gif ๐
Animated GIF demuxer.
It accepts the following options:
min_delayโ Set the minimum valid delay between frames, in hundredths of seconds. Range is0to6000. Default value is2.max_gif_delayโ Set the maximum valid delay between frames, in hundredths of seconds. Range is0to65535. Default value is65535(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 is0to6000. Default value is10.ignore_loopโ GIF files can contain info to loop a certain number of times (or infinitely). Ifignore_loopis set to1, then the loop setting from the input gets ignored and looping will not occur. If set to0, then looping will occur and will cycle the number of times according to the GIF. Default value is1.
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 theshortestoption for the overlay filter is used to end the output video at the length of the shortest input file โ which in this case isinput.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-STARTif it's in the playlist, instead oflive_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, exceptmpegts, 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 is1000.m3u8_hold_countersโ The maximum number of times to load m3u8 when it refreshes without new segments. Default value is1000.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 ofkey=valuepairs 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 is0.
๐ง 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 to25.loopโ if you set it to1, it loops over the input. default value is0.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 is0.start_number_rangeโ sets the index interval range to check when it's looking for the first image file in the sequence, starting fromstart_number. default value is5.ts_from_fileโ if set to1, 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 is0. If set to2, 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 to1, 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 is0. 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
ffmpegfor creating a video from the images in the file sequenceimg-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.pngsuffix:
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 at0. Default is to pick the first track. Number of tracks is exported astracksmetadata entry.sample_rateโ sets the sampling rate of the exported track. Range is1000to999999. Default is44100.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 is50 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 be1(on) or0(off). Default is0.reverb_depthโ sets the amount of reverb. Range0-100. Default is0.reverb_delayโ sets the delay in ms, clamped to40-250ms. Default is0.bass_amountโ applies bass expansion a.k.a. XBass or megabass. Range is0(quiet) to100(loud). Default is0.bass_rangeโ sets cutoff, i.e. the upper-bound for bass frequencies. Range is10-100Hz. Default is0.surround_depthโ applies a Dolby Pro-Logic surround effect. Range is0(quiet) to100(heavy). Default is0.surround_delayโ sets the surround delay in ms, clamped to5-40ms. Default is0.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 is0to100 MiB.0removes the buffer size limit (not recommended ๐). Default is5 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 be1(on) or0(off). Default is0.video_stream_wโ sets the video frame width in 'chars' where one char indicates 8 pixels. Range20-512. Default is30.video_stream_hโ sets the video frame height in 'chars' where one char indicates 8 pixels. Range20-512. Default is30.video_stream_ptxtโ prints metadata on the video stream. Includes"speed","tempo","order","pattern","row"and"ts"(time in ms). Can be1(on) or0(off). Default is1.
๐ผ 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 at0. The default is'auto'.
The default value is to let libopenmpt choose.
layoutโ sets the channel layout. Valid values are1,2, and4channel layouts. The default value isSTEREO.sample_rateโ sets the sample rate for libopenmpt to output. Range is from1000toINT_MAX. The value default is48000.
๐บ 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 istrue.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 isfalse.advanced_editlistโ modifies the stream index to reflect the timeline described by the edit list."ignore_editlist"must be set tofalsefor this option to be effective. If both"ignore_editlist"and this option are set tofalse, then only the start of the stream index is modified to reflect initial dwell time or starting timestamp described by the edit list. Default istrue.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 isfalse.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 DTSptsโ set mfra timestamps as PTS0โ 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 toptsordts.export_allโ export unrecognized boxes within theudtabox as metadata entries. The first four characters of the box type are set as the key. Default isfalse.export_xmpโ export the entire contents of theXMP_box anduuidbox as a string with key"xmp". Note that if"export_all"is set and this option isnโt, the contents of theXMP_box are still exported but with key"XMP_". Default isfalse.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 atrakโssttsbox 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 to1. Values greater than the limit, if negative when cast toint32, 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 is65536.skip_unknown_pmtโ skip PMTs for programs not defined in the PAT. Default value is0.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 is1; set this option to0if 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-1to1(-1means automatic setting,1means enabled,0means 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 is0.max_packet_sizeโ set maximum size, in bytes, of packet emitted by the demuxer. Payloads above this size are split across multiple packets. Range is184toINT_MAX/2. Default is204800bytes.
๐ผ๏ธ 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 to1will 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 is25.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 is15000(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 is1 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 to0, 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) audioavs2(video; ext:avs,avs2) โ AVS2-P2 (Audio Video Standard - Second generation - Part 2) / IEEE 1857.4 videoavs3(video; ext:avs3) โ AVS3-P2 (Audio Video Standard - Third generation - Part 2) / IEEE 1857.10 videocavsvideo(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) audioeac3(audio) โ Dolby Digital Plus, also known as Enhanced AC-3evc(video; ext:evc) โ MPEG-5 Essential Video Coding (EVC) / EVC / MPEG-5 Part 1 EVC videog722(audio) โ ITU-T G.722 audiog723_1(audio; ext:tco,rco) โ ITU-T G.723.1 audiog726(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 audioh261(video) โ ITU-T H.261 videoh263(video) โ ITU-T H.263 / H.263-1996, H.263+ / H.263-1998 / H.263 version 2 videoh264(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 videomjpeg(video; ext:mjpg,mjpeg) โ Motion JPEG videomlp(audio) โ Meridian Lossless Packing, also known as Packed PCMmp2(audio; ext:mp2,m2a,mpa) โ MPEG-1 Audio Layer II audiompeg1video(video; ext:mpg,mpeg,m1v) โ MPEG-1 Part 2 video.mpeg2video(video; ext:m2v) โ ITU-T H.262 / MPEG-2 Part 2 videoobu(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 audiotruehd(audio; ext:thd) โ Dolby TrueHD audiovc1(video) โ SMPTE 421M / VC-1 video
Examples โจ
- Store raw video frames with the
rawvideomuxer usingffmpeg, 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-lawf32beโ PCM 32-bit floating-point big-endianf32leโ PCM 32-bit floating-point little-endianf64beโ PCM 64-bit floating-point big-endianf64leโ PCM 64-bit floating-point little-endianmulaw(ul) โ PCM mu-laws16beโ PCM signed 16-bit big-endians16leโ PCM signed 16-bit little-endians24beโ PCM signed 24-bit big-endians24leโ PCM signed 24-bit little-endians32beโ PCM signed 32-bit big-endians32leโ PCM signed 32-bit little-endians8(sb) โ PCM signed 8-bitu16beโ PCM unsigned 16-bit big-endianu16leโ PCM unsigned 16-bit little-endianu24beโ PCM unsigned 24-bit big-endianu24leโ PCM unsigned 24-bit little-endianu32beโ PCM unsigned 32-bit big-endianu32leโ PCM unsigned 32-bit little-endianu8(ub) โ PCM unsigned 8-bitvidcโ 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 โจ
muxraterate โ Set user-defined mux rate expressed as a number of bits/s. If not specified the automatically computed mux rate is employed. Default value is0.preloaddelay โ Set initial demux-decode delay in microseconds. Default value is500000.
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 services3g2โ Third Generation Partnership Project 2 (3GP2 or 3GPP2) format for 3G CDMA2000 multimedia services, similar to3gpwith extensions and limitationsf4vโ Adobe Flash Video formatipodโ MPEG-4 audio file format, as MOV/MP4 but limited to contain only audio streams, typically played with the Apple ipod deviceismvโ 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"extensionmp4โ MP4 or MPEG-4 Part 14 formatpspโ 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_durationfrag_sizemin_frag_durationmovflags +frag_keyframemovflags +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 โจ
brandbrand_string โ override the major brand ๐empty_hdlr_namebool โ turn this on and the muxer skips writing the name inside thehdlrbox. Default isfalse, bestie.encryption_keykey โ sets the media encryption key, in hexadecimal format ๐encryption_kidkid โ sets the media encryption key identifier, also hexencryption_schemescheme โ picks the encryption scheme; allowed values arenoneandcenc-aes-ctrfrag_durationduration โ create fragments that are duration microseconds long โฑ๏ธfrag_interleavenumber โ 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 to0by default.frag_sizesize โ create fragments that hold up to size bytes of payload dataiods_audio_profileprofile โ specify the iods number for the audio profile atom (from-1to255), default is-1iods_video_profileprofile โ specify the iods number for the video profile atom (from-1to255), default is-1ism_lookaheadnum_entries โ how many lookahead entries for ISM files (from0to255), default is0min_frag_durationduration โ do not create fragments shorter than duration microseconds longmoov_sizebytes โ reserves space for themoovatom at the beginning of the file instead of parking themoovatom at the end. Heads up: if the space you reserved isn't enough, muxing will fail ๐mov_gammagamma โ specify the gamma value for thegamaatom (as a decimal number from0to10), default is0.0โ and it must be set together with+ movflagsmovflagsflags โ 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 outputdashโ write DASH (Dynamic Adaptive Streaming over HTTP) compatible fragmented MP4 outputdefault_base_moofโ same energy as theomit_tfhd_offsetflag: it avoids writing the absolutebase_data_offsetfield intfhdatoms, but it does it by using the newdefault-base-is-moofflag instead. This flag is new from14496-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 initialmoovuntil the first fragment is cut, or until the first fragment flushdisable_chplโ disable Nero chapter markers (chplatom). 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 (moovatom) 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 callingav_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 onesfrag_every_frameโ fragment at every framefrag_keyframeโ start a new fragment at each video keyframeglobal_sidxโ write a globalsidxindex at the start of the fileismlโ 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 absolutebase_data_offsetintfhdatoms. This avoids tying fragments to absolute byte positions in the file/streams.prefer_iccโ if writing thecolratom, prioritise usage of the ICC profile if it exists in stream packet side datartphintโ add RTP hinting tracks to the output fileseparate_moofโ write a separatemoof(movie fragment) atom for each track. Normally packets for all tracks are written in onemoofatom (slightly more efficient), but with this option set the muxer writes onemoof/mdatpair for each track, which makes it easier to separate tracks.skip_sidxโ skip writing of thesidxatom. When the bitrate overhead from thesidxatom is high, this option could be used for cases where thesidxatom isn't mandatory. When theglobal_sidxflag is enabled, this option is ignored.skip_trailerโ skip writing themfra/tfra/mfrotrailer for fragmented filesuse_metadata_tagsโ use themdtaatom for metadatawrite_colrโ write thecolratom 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 deprecatedgamaatomhybrid_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_timescalescale โ set the timescale written in the movie header box (mvhd). Range is1toINT_MAX. Default is1000.rtpflagsflags โ add RTP hinting tracks to the output file. The following flags can be used:skip_iodsbool โ skip writing theiodsatom (default value istrue)use_editlistbool โ use edit list (default value isauto)use_stream_ids_as_track_idsbool โ use stream ids as track ids (default value isfalse)video_track_timescalescale โ set the timescale used for video tracks. Range is0toINT_MAX. If set to0, the timescale is automatically set based on the native stream time base. Default is0.write_btrtbool โ force or disable writing the bitrate box inside thestsdbox 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-1orauto, which writes the box only in MP4 mode.write_prftoption โ write a producer time reference box (PRFT) with a specified time source for the NTP field in the PRFT box. Set the value aswallclockto specify timesource as wallclock time, andptsto specify timesource as input packets' PTS values.write_tmcdbool โ specifyonto force writing a timecode track,offto disable it, andautoto write a timecode track only for mov and mp4 output (default).
Setting value toptsis 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 wherevideo_ptsandaudio_ptsare set toabs_wallclock.
๐ฌ Examples
- Push Smooth Streaming content in real time to a publishing point on IIS with the
ismvmuxer usingffmpeg:
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_crcbool โ when enabled, write a CRC checksum for each packet to the output, default isfalse
๐ป adts
Audio Data Transport Stream muxer.
It accepts a single AAC stream.
Options
write_id3v2bool โ enable to write ID3v2.4 tags at the start of the stream. Default is disabled.write_apetagbool โ enable to write APE tags at the end of the stream. Default is disabled.write_mpeg2bool โ enable to set the MPEG version bit in the ADTS frame header to1, which indicates MPEG-2. Default is0, 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_id3v2bool โ enable ID3v2 tags writing when set to1. Default is0(disabled).id3v2_versionbool โ 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
typetype โ set the file type.
type accepts the following values:
tunโ set file type as music. Must have a sample rate of22050 Hz.pcmโ set file type as sfx.autoโ set file type as per output file extension..pcmresults in typepcm, else typetunis 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_delaydelay โ force a delay expressed in seconds after the last frame of each repetition. Default value is0.0.playsrepetitions โ specify how many times to play the content;0causes an infinite loop, with1there is no loop.
Examples ๐
- Use
ffmpegto 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_majorversion โ override file major version, specified as an integer, default value is2.version_minorversion โ override file minor version, specified as an integer, default value is1.namename โ 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_checkbool โ skip sample rate check (default isfalse).loopbool โ set loop flag (default isfalse).reverbboolean โ set reverb flag (default istrue).
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_sizesize โ 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 is3200, minimum is100, maximum is64Ki.
ass ๐ฌ
ASS/SSA (SubStation Alpha) subtitles muxer. It accepts a single ASS subtitles stream.
Options โจ
ignore_readorderbool โ write dialogue events immediately, even if they are out-of-order, default isfalse, 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 โจ
loopstartstart โ specify loop start position expressed in milliseconds, from-1toINT_MAX, in case-1is set then no loop is specified (default-1) and theloopendvalue is ignored.loopendend โ specify loop end position expressed in milliseconds, from0toINT_MAX, default is0, in case0is 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_rgbbool โ if set totrue, 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 thevflipfilter. Default isfalseand indicates bitmap is stored top down.reserve_index_spacesize โ 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_maskbool โ 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 theamergesection 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 โจ
loopcount โ number of times to loop an animated AVIF,0specify an infinite loop, default is0.movie_timescaletimescale โ set the timescale written in the movie header box (mvhd). Range is1toINT_MAX. Default is1000.
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 โจ
algorithmversion โ select version of algorithm to fingerprint with. Range is0to4. Version3enables silence detection. Default is1.fp_formatformat โ format to output the fingerprint as. Accepts the following options:base64โ Base64 compressed fingerprint (default)compressedโ Binary compressed fingerprintrawโ Binary raw fingerprint
silence_thresholdthreshold โ threshold for detecting silence. Range is from-1to32767, where-1disables silence detection. Silence detection can only be used with version3of 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
ffmpegto compute the CRC of the input, and store it in the fileout.crc:
ffmpeg -i INPUT -f crc out.crc
- Use
ffmpegto print the CRC to stdout with the command:
ffmpeg -i INPUT -f crc -
- You can select the output format of each frame with
ffmpegby 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:
- ISO DASH Specification:
<http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip> - WebM DASH Specification:
<https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification>
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_setsadaptation_sets โ assign streams to adaptation sets, specified in the MPD manifestAdaptationSetssection.
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 thefrag_durationoption. sneaky little override, iykyk.frag_typeโ overrides the global fragment type that was set with thefrag_typeoption.seg_durationโ overrides the global segment duration that was set with theseg_durationoption.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 ofkey=valueparameters. 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 ismaster.m3u8.hls_playlist boolโ generate HLS playlist files. The master playlist is generated with the filename specified by thehls_master_nameoption. One media playlist file is generated for each stream with filenamesmedia_0.m3u8,media_1.m3u8, etc. playlist girlies rise.http_opts http_optsโ specifies a list of":"-separatedkey=valueoptions 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 whenuse_templateis enabled anduse_timelineis 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 athttps://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 theuse_templateoption is enabled and theuse_timelineoption 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 thesingle_fileoption is set totrue. 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 thestreamingandwrite_prftoptions 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 to0, 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 theutc_urloption is enabled. It is set toautoby 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_openandio_close) used inside itsAVFormatContextmust be thread-safe. No cap. ๐
โจ Options โจ
attempt_recoverybool โ if a failure happens, try to recover the output. This is highkey perfect with network output, 'cause it lets you restart streaming transparently. Default isfalse.drop_pkts_on_overflowbool โ set it totrueand 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 isfalse, so normally the encoder gets blocked until the muxer chews through some packets and literally none of them are lost. ๐ซถfifo_formatformat_name โ specify the format name. Useful when it can't be guessed from the output name suffix.format_optsoptions โ specify format options for the underlying muxer. Muxer options go in as a list ofkey=valuepairs separated by:.max_recovery_attemptscount โ max number of successive unsuccessful recovery attempts before the output fails permanently. Default is0(unlimited).queue_sizesize โ size of the queue as a number of packets. Default is60.recover_any_errorbool โ set totrueand recovery is attempted regardless of what type of error caused the failure. Default isfalse, and with certain (usually permanent) errors, recovery is not attempted even whenattempt_recoveryistrue.recovery_wait_streamtimebool โ iffalse, real time is used when waiting for the recovery attempt (i.e. recovery happens after the time set byrecovery_wait_time). Iftrue, the time of the processed stream is taken into account instead (i.e. recovery happens after discarding the packets that correspond torecovery_wait_time). Default isfalse.recovery_wait_timeduration โ waiting time in seconds before the next recovery attempt after the previous unsuccessful one. Default is5.restart_with_keyframebool โ whether to wait for the keyframe after recovering from queue overflow or failure. Default isfalse.timeshiftduration โ buffer the specified amount of packets and delay writing the output. Note thatqueue_sizemust 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_headerbool โ write the file header if set totrue, default istrue.
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
flvflagsflags โ 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.
hashalgorithm โ use the cryptographic hash function specified by the string algorithm. Supported values includeMD5,murmur3,RIPEMD128,RIPEMD160,RIPEMD256,RIPEMD320,SHA160,SHA224,SHA256(default),SHA512/224,SHA512/256,SHA384,SHA512,CRC32andadler32.
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
loopbool โ set the number of times to loop the output. Use-1for no loop,0for looping indefinitely (default).final_delaydelay โ 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.
hashalgorithm โ 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_sizeint โ number of fragments kept outside of the manifest before removing from diskmin_frag_durationmicroseconds โ minimum fragment duration (in microseconds), default value is 1 second (10000000)remove_at_exitbool โ remove all fragments when finished when set to"true"window_sizeint โ number of fragments kept in the manifest, if set to a value different from0. 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_timeduration โ Set the initial target segment length. Default value is0.
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_timeduration โ Set the target segment length. Default value is2.
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_sizesize โ Set the maximum number of playlist entries. If set to0the list file will contain all the segments. Default value is5.hls_delete_thresholdsize โ 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 is1, meaning segments older thanhls_list_size+1will be deleted.hls_start_number_sourcesource โ Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE") according to the specified source. Unlesshls_flags single_fileis set, it also specifies source of starting sequence numbers of segment and subtitle filenames. In any case, ifhls_flags append_listis 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_numberoption 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_numbernumber โ Start the playlist sequence number ("#EXT-X-MEDIA-SEQUENCE") from the specified number whenhls_start_number_sourcevalue isgeneric. (This is the default case.) Unlesshls_flags single_fileis set, it also specifies starting sequence numbers of segment and subtitle filenames. Default value is0.hls_allow_cachebool โ Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.hls_base_urlbaseurl โ 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_filenamefilename โ Set the segment filename. Unless thehls_flagsoption is set withsingle_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.
strftimebool โ Usestrftime()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 setsecond_level_segment_indexin thehls_flagand%%dwill 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_mkdirbool โ Used together withstrftime, it will create all subdirectories which are present in the expanded values of optionhls_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_optionsoptions_list โ set output format options with a:-separated list ofkey=valueparameters. and listen ๐ if a value contains:special characters it must be escaped, no cap.hls_key_info_filekey_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 ifhls_flags periodic_rekeyis 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_encbool โ enable (1) or disable (0) the AES128 encryption ๐. when it's on, every segment generated is encrypted and the encryption key is saved asplaylist name.key.hls_enc_keykey โ 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_urlkeyurl โ if you set this, keyurl gets prepended instead ofbaseurlto the key filename in the playlist.hls_enc_iviv โ specify the 16-octet initialization vector for every segment, instead of the autogenerated ones ๐ธhls_segment_typeflags โ 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_filenamefilename โ set the filename for the fragment files header file; the default filename isinit.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_resendbool โ resend the init file after the m3u8 file refresh, every single time. default is0.
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 number4.
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 version2m3u8 โญ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 thehls_timeoption. (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%%din thehls_segment_filenameoption expression, besides date/time values, when thestrftimeoption is on. to get fixed width numbers with trailing zeroes, the%%0xdformat is available, where x is the required width.second_level_segment_sizeโ makes it possible to use segment sizes (counted in bytes) as%%sin thehls_segment_filenameoption expression, besides date/time values, whenstrftimeis on. to get fixed width numbers with trailing zeroes, the%%0xsformat is available, where x is the required width.second_level_segment_durationโ makes it possible to use segment duration (calculated in microseconds) as%%tin thehls_segment_filenameoption expression, besides date/time values, whenstrftimeis on. to get fixed width numbers with trailing zeroes, the%%0xtformat 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 tofilename.tmpand rename tofilenameonly 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_typetype โ if type isevent, emit"#EXT-X-PLAYLIST-TYPE:EVENT"in the m3u8 header. this forceshls_list_sizeto0; 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 ๐ง
methodmethod โ 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_agentagent โ override theUser-Agentfield in the HTTP header. applicable only for HTTP output ๐ฆvar_stream_mapstream_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
1000kand audio stream of bitrate64k, and the second variant stream will contain video stream of bitrate256kand audio stream of bitrate32k. Here, two media playlist with file namesout_0.m3u8andout_1.m3u8will 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.m3u8andout_my_sd.m3u8will 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 bitrate64k, and the third variant stream will be a video only stream with bitrate256k. Here, three media playlist with file namesout_0.m3u8,out_1.m3u8andout_2.m3u8will 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
- Create the variant streams in subdirectories. Here, the first media playlist is created at
http://example.com/live/vs_0/out.m3u8and the second one athttp://example.com/live/vs_1/out.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 isNOorYES. 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 isNOorYES, and one audio have and language is namedENG, the other audio language is namedCHN. 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_mapcc_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_namename โ 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_ratecount โ 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_persistentbool โ use persistent HTTP connections. Applicable only for HTTP output.timeouttimeout โ set timeout for socket I/O operations. Applicable only for HTTP output. โณignore_io_errorsbool โ 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 ๐โโ๏ธheadersheaders โ 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
256pixels 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 Depth | FFmpeg 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
BITMAPINFOHEADERDIB header - ๐ฅ If a PNG image is used, it must use the
rgbapixel 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_ptsbool โ If set to1, expand the filename with the packet PTS (presentation time stamp). Default value is0.start_numbercount โ Start the sequence from the specified number. Default value is1.updatebool โ If set to1, 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 is0.strftimebool โ If set to1, expand the filename with date and time information fromstrftime(). Default value is0.atomic_writingbool โ Write output to a temporary file, which is renamed to target filename once writing is completed. Default is disabled.protocol_optsoptions_list โ Set protocol options as a:-separated list ofkey=valueparameters. Values containing the":"special character must be escaped.
Examples
- Use
ffmpegfor creating a sequence of filesimg-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
strftimeoption allows you to expand the filename with date and time information. Check the documentation of thestrftime()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:
titlealbumartistauthorcreatorencoderencoder_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 theFileDescriptionelement 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 stereoleft_rightโ Both views are arranged side by side, Left-eye view is on the leftbottom_topโ Both views are arranged in top-bottom orientation, Left-eye view is at bottomtop_bottomโ Both views are arranged in top-bottom orientation, Left-eye view is on topcheckerboard_rlโ Each view is arranged in a checkerboard interleaved pattern, Left-eye view being firstcheckerboard_lrโ Each view is arranged in a checkerboard interleaved pattern, Right-eye view being firstrow_interleaved_rlโ Each view is constituted by a row based interleaving, Right-eye view is first rowrow_interleaved_lrโ Each view is constituted by a row based interleaving, Left-eye view is first rowcol_interleaved_rlโ Both views are arranged in a column based interleaving manner, Right-eye view is first columncol_interleaved_lrโ Both views are arranged in a column based interleaving manner, Left-eye view is first columnanaglyph_cyan_redโ All frames are in anaglyph format viewable through red-cyan filtersright_leftโ Both views are arranged side by side, Right-eye view is on the leftanaglyph_green_magentaโ All frames are in anaglyph format viewable through green-magenta filtersblock_lrโ Both eyes laced in one Block, Left-eye view is firstblock_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_spacesize โ 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_frontbool โ 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 withreserve_index_spacein 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_limitsize โ 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_limitduration โ 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.dashbool โ Create a WebM file conforming to WebM DASH specification. By default it is set to"false".dash_track_numberindex โ Track number for the DASH stream. By default it is set to1.livebool โ Write files assuming it is a live stream. By default it is set to"false".allow_raw_vfwbool โ Allow raw VFW mode. By default it is set to"false".flipped_raw_rgbbool โ 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 thevflipfilter. Default is"false"and indicates bitmap is stored top down.write_crc32bool โ Write a CRC32 element inside every Level 1 element. By default it is set to"true". This option is ignored for WebM.default_modemode โ Control how theFlagDefaultof the output tracks will be set. It influences which tracks players should play by default. The default mode ispassthrough.inferโ Every track with disposition default will have theFlagDefaultset. 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 asinferexcept that if no subtitle track with disposition default exists, no subtitle track will be marked as default.passthroughโ In this mode theFlagDefaultis set if and only if theAV_DISPOSITION_DEFAULTflag 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.mccfiles disagree on whether it has 2 or 3 zero bytes.mcc_versionโ The MCC file format version. Must be either1or2, defaults to2.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
.mp4file 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_versionprivate option controls which one is used (3or4). Settingid3v2_versionto0disables 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_xingprivate 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_id3v1private 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_idinteger โ Set thetransport_stream_id. This identifies a transponder in DVB. Default is0x0001.mpegts_original_network_idinteger โ Set theoriginal_network_id. This is unique identifier of a network in DVB. Its main use is in the unique identification of a service through the pathOriginal_Network_ID,Transport_Stream_ID. Default is0x0001.mpegts_service_idinteger โ Set theservice_id, also known as program in DVB. Default is0x0001.mpegts_service_typeinteger โ Set the programservice_type. Default isdigital_tv. Accepts the following options:hex_valueโ Any hexadecimal value between0x01and0xffas 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_pidinteger โ Set the first PID for PMTs. Default is0x1000, minimum is0x0020, maximum is0x1ffa. This option has no effect in m2ts mode where the PMT PID is fixed0x0100.mpegts_start_pidinteger โ Set the first PID for elementary streams. Default is0x0100, minimum is0x0020, maximum is0x1ffa. This option has no effect in m2ts mode where the elementary stream PIDs are fixed.mpegts_m2ts_modeboolean โ Enable m2ts mode if set to1. Default value is-1which disables m2ts mode.muxrateinteger โ Set a constant muxrate. Default is VBR.pes_payload_sizeinteger โ Set minimum PES packet payload in bytes. Default is2930.mpegts_flagsflags โ 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_copytsboolean โ Preserve original timestamps, if value is set to1. Default value is-1, which results in shifting timestamps so that they start from0.omit_video_pes_lengthboolean โ Omit the PES packet length for video packets. Default is1(true).pcr_periodinteger โ Override the default PCR retransmission time in milliseconds. Default is-1which means that the PCR interval will be determined automatically:20 msis used for CBR streams, the highest multiple of the frame duration which is less than100 msis used for VBR streams.pat_periodduration โ Maximum time in seconds between PAT/PMT tables. Default is0.1.sdt_periodduration โ Maximum time in seconds between SDT tables. Default is0.5.nit_periodduration โ Maximum time in seconds between NIT tables. Default is0.5.tables_versioninteger โ Set PAT, PMT, SDT and NIT version (default0, valid values are from0to31, inclusively). This option allows updating stream structure so that standard consumer may detect the change. To do so, reopen outputAVFormatContext(in case of API usage) or restart ffmpeg instance, cyclically changingtables_versionvalue:
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_commentsbool โ 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 formxfandmxf_opatombut not formxf_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 theout.nullfile โ but specifying the output file is required by theffmpegsyntax. Annoying? Yes. Stuck with it? Also yes ๐ญ
Alternatively you can write the command as:
ffmpeg -benchmark -i INPUT -f null -
nut ๐ฅ
-syncpointsflags โ 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_indexbool โ 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_durationduration โ 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 is1second. A value of0will fill all segments, making pages as large as possible. A value of1will effectively use 1 packet-per-page in most situations, giving a small seek granularity at the cost of additional container overhead.-serial_offsetvalue โ 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_tc1|0 โ if set to1, increment timecode between each segment. If this is selected, the input need to have a timecode in the first video stream. Default value is0.reference_streamspecifier โ 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_formatformat โ override the inner container format; by default it is guessed by the filename extension.segment_format_optionsoptions_list โ set output format options using a:-separated list ofkey=valueparameters. Values containing the:special character must be escaped.segment_listname โ generate also a listfile named name. If not specified no listfile is generated.segment_list_flagsflags โ 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_sizesize โ update the list file so that it contains at most size segments. If0the list file will contain all the segments. Default value is0.segment_list_entry_prefixprefix โ prepend prefix to each entry. Useful to generate absolute paths. By default no prefix is applied.segment_list_typetype โ 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.
extis deprecated in favor ofcsv. 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 FFmpegconcatdemuxer.
A list file with the suffix ".ffcat" or ".ffconcat" will auto-select this format.
m3u8โ generate an extended M3U8 file, version 3, compliant withhttp://tools.ietf.org/id/draft-pantos-http-live-streaming.
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_timetime โ set segment duration to time, the value must be a duration specification. Default value is"2". See also thesegment_timesoption.
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_durationtime โ 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 withsegment_time. Default value is"0".segment_atclocktime1|0 โ if set to"1"split at regular clock time intervals starting from 00:00 o'clock. The time value specified insegment_timeis 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_offsetduration โ delay the segment splitting times with the specified duration when usingsegment_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_durationduration โ 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_deltadelta โ the accuracy time used when picking the start time for a segment, expressed as a duration spec. Default is0โจ
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_timestimes โ specify a list of split points. times contains a comma separated list of duration specifications, in increasing order. Also peep thesegment_timeoption ๐segment_framesframes โ 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_wraplimit โ wrap around the segment index once it reaches limit.segment_start_numbernumber โ set the sequence number of the first segment. Defaults to0.strftime1|0โ use thestrftimefunction to define the name of the new segments to write. If you pick this, the output segment name must contain astrftimefunction template. Default value is0. ๐ฐ๏ธbreak_non_keyframes1|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 to0. So likeโฆ proceed with caution bestie ๐reset_timestamps1|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 to0by default.initial_offsetoffset โ specify the timestamp offset to apply to the output packet timestamps. The argument must be a time duration specification, and defaults to0.write_empty_segments1|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 to0.
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.mkvto a list of segmentsout-000.nut,out-001.nut, etc., and write the list of generated segments toout.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_timesoption:
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_framesoption to force key frames in the input at the specified location, together with the segment optionsegment_time_deltato 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_framesoption:
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.mkvto TS segments using thelibx264andaacencoders:
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. Default0(keep all). ๐extra_window_sizeโ specify the number of fragments kept outside of the manifest before removing from disk. Default5.lookahead_countโ specify the number of lookahead fragments. Default2.min_frag_durationโ specify the minimum fragment duration (in microseconds). Default5000000.remove_at_exitโ specify whether to remove all fragments when finished. Default0(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.
hashalgorithm โ use the cryptographic hash function specified by the string algorithm. Supported values includeMD5,murmur3,RIPEMD128,RIPEMD160,RIPEMD256,RIPEMD320,SHA160,SHA224,SHA256(default),SHA512/224,SHA512/256,SHA384,SHA512,CRC32andadler32. 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_fifobool โ if set to1, slave outputs will be processed in separate threads using thefifomuxer. 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 tofifopseudo-muxer instances. Seefifo.
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_fifobool โ this allows to overrideteemuxeruse_fifooption for individual slave muxer.fifo_optionsโ this allows to overrideteemuxerfifo_optionsfor individual slave muxer. Seefifo.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 toabort(which is the default) orignore.abortmakes the whole process fail if this slave output fails.ignoremeans 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_extrabitstream filter is used to add extradata information to all the output video keyframe packets, as requested by the MPEG-TS format. Theselectoption is applied toout.aacin 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 to0).headerโ filename of the header where the initialization data will be written.audio_chunk_durationโ duration of each audio chunk in milliseconds (defaults to5000).
๐ธ 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:
- WebM DASH Specification:
https://sites.google.com/a/webmproject.org/wiki/adaptive-streaming/webm-dash-specification - ISO DASH Specification:
http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip
๐ 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", wherexandyare the unique identifiers of the adaptation sets, anda,b,c,dandeare the indices of the corresponding audio and video streams. Any number of adaptation sets can be added using this option.liveโ set this to1to create a live stream DASH Manifest. Default:0.chunk_start_indexโ start index of the first chunk. This will go in thestartNumberattribute of theSegmentTemplateelement in the manifest. Default:0.chunk_duration_msโ duration of each chunk in milliseconds. This will go in thedurationattribute of theSegmentTemplateelement 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 thevalueattribute of theUTCTimingelement 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 thetimeShiftBufferDepthattribute of theMPDelement. Default:60.minimum_update_periodโ minimum update period (in seconds) of the manifest. This will go in theminimumUpdatePeriodattribute of theMPDelement. 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_timeoutinteger โ set the timeout in milliseconds for ICE and DTLS handshake. Default value is5000.pkt_sizeinteger โ set the maximum size, in bytes, of RTP packets that send out. Default value is1200.ts_buffer_sizeinteger โ set the buffer size, in bytes, of underlying protocol. Default value is-1(auto). The UDP auto selects a reasonable value.whip_flagsflags โ possible values:dtls_activeโ the muxer will try to set dtls active role and send the first client hello.
rtp_historyinteger โ set the number of RTP history items to store. Default value is512.authorizationstring โ the optional Bearer token for WHIP Authorization.cert_filestring โ the optional certificate file path for DTLS.key_filestring โ 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:
- A file consists of a header and a number of metadata tags divided into sections, each on its own line.
- The header is a
;FFMETADATAstring, followed by a version number (now1). - Metadata tags are of the form
key=value - Immediately after header follows global metadata
- After global metadata there may be sections with per-stream/per-chapter metadata.
- A section starts with the section name in uppercase (i.e.
STREAMorCHAPTER) in brackets ([,]) and ends with next section or end of file. - 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, wherenumanddenare 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.
- Empty lines and lines starting with
;or#are ignored. - Metadata keys or values containing special characters (
=,;,#,\and a newline) must be escaped with a backslash\. - Note that whitespace in metadata (e.g.
foo = bar) is considered to be a part of the tag (in the example above key isfoo, value isbar).
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
- alpine 3.24: ffmpeg-doc 8.1.3-r0 ยท GPL-2.0-or-later AND LGPL-2.1-or-later
- nixos 26.05: ffmpeg 8.1.3
- nixos 26.05: ffmpeg-full 8.1.3
- nixos 26.05: ffmpeg-headless 8.1.3
- nixpkgs unstable: jellyfin-ffmpeg 8.1.3-1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms