diff options
Diffstat (limited to 'ffmpeg/doc/muxers.texi')
| -rw-r--r-- | ffmpeg/doc/muxers.texi | 430 |
1 files changed, 298 insertions, 132 deletions
diff --git a/ffmpeg/doc/muxers.texi b/ffmpeg/doc/muxers.texi index 9d119c3..776ba2b 100644 --- a/ffmpeg/doc/muxers.texi +++ b/ffmpeg/doc/muxers.texi @@ -18,6 +18,23 @@ enabled muxers. A description of some of the currently available muxers follows. +@anchor{aiff} +@section aiff + +Audio Interchange File Format muxer. + +It accepts the following options: + +@table @option +@item write_id3v2 +Enable ID3v2 tags writing when set to 1. Default is 0 (disabled). + +@item id3v2_version +Select ID3v2 version to write. Currently only version 3 and 4 (aka. +ID3v2.3 and ID3v2.4) are supported. The default is version 4. + +@end table + @anchor{crc} @section crc @@ -129,6 +146,40 @@ ffmpeg -i INPUT -f framemd5 - See also the @ref{md5} muxer. +@anchor{gif} +@section gif + +Animated GIF muxer. + +It accepts the following options: + +@table @option +@item loop +Set the number of times to loop the output. Use @code{-1} for no loop, @code{0} +for looping indefinitely (default). + +@item final_delay +Force the delay (expressed in centiseconds) after the last frame. Each frame +ends with a delay until the next frame. The default is @code{-1}, which is a +special value to tell the muxer to re-use the previous delay. In case of a +loop, you might want to customize this value to mark a pause for instance. +@end table + +For example, to encode a gif looping 10 times, with a 5 seconds delay between +the loops: +@example +ffmpeg -i INPUT -loop 10 -final_delay 500 out.gif +@end example + +Note 1: if you wish to extract the frames in separate GIF files, you need to +force the @ref{image2} muxer: +@example +ffmpeg -i INPUT -c:v gif -f image2 "out%d.gif" +@end example + +Note 2: the GIF format has a very small time base: the delay between two frames +can not be smaller than one centi second. + @anchor{hls} @section hls @@ -243,11 +294,13 @@ ffmpeg -i in.avi -f image2 -frames:v 1 img.jpeg @table @option @item start_number @var{number} Start the sequence from @var{number}. Default value is 1. Must be a -positive number. +non-negative number. + +@item -update @var{number} +If @var{number} is nonzero, the filename will always be interpreted as just a +filename, not a pattern, and this file will be continuously overwritten with new +images. -@item updatefirst 1|0 -If set to 1, update the first written image file again and -again. Default value is 0. @end table The image muxer supports the .Y.U.V image file format. This format is @@ -256,6 +309,90 @@ 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. +@section matroska + +Matroska container muxer. + +This muxer implements the matroska and webm container specs. + +The recognized metadata settings in this muxer are: + +@table @option + +@item title=@var{title name} +Name provided to a single track +@end table + +@table @option + +@item language=@var{language name} +Specifies the language of the track in the Matroska languages form +@end table + +@table @option + +@item stereo_mode=@var{mode} +Stereo 3D video layout of two views in a single video track +@table @option +@item mono +video is not stereo +@item left_right +Both views are arranged side by side, Left-eye view is on the left +@item bottom_top +Both views are arranged in top-bottom orientation, Left-eye view is at bottom +@item top_bottom +Both views are arranged in top-bottom orientation, Left-eye view is on top +@item checkerboard_rl +Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first +@item checkerboard_lr +Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first +@item row_interleaved_rl +Each view is constituted by a row based interleaving, Right-eye view is first row +@item row_interleaved_lr +Each view is constituted by a row based interleaving, Left-eye view is first row +@item col_interleaved_rl +Both views are arranged in a column based interleaving manner, Right-eye view is first column +@item col_interleaved_lr +Both views are arranged in a column based interleaving manner, Left-eye view is first column +@item anaglyph_cyan_red +All frames are in anaglyph format viewable through red-cyan filters +@item right_left +Both views are arranged side by side, Right-eye view is on the left +@item anaglyph_green_magenta +All frames are in anaglyph format viewable through green-magenta filters +@item block_lr +Both eyes laced in one Block, Left-eye view is first +@item block_rl +Both eyes laced in one Block, Right-eye view is first +@end table +@end table + +For example a 3D WebM clip can be created using the following command line: +@example +ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm +@end example + +This muxer supports the following options: + +@table @option + +@item reserve_index_space +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 a given amount +of space in the file header and then try to write the cues there when the muxing +finishes. If the available space does not suffice, muxing will fail. A safe size +for most use cases should be about 50kB per hour of video. + +Note that cues are only written if the output is seekable and this option will +have no effect if it is not. + +@end table + @anchor{md5} @section md5 @@ -283,7 +420,9 @@ ffmpeg -i INPUT -f md5 - See also the @ref{framemd5} muxer. -@section MOV/MP4/ISMV +@section mov/mp4/ismv + +MOV/MP4/ISMV (Smooth Streaming) muxer. The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 file has all the metadata about all packets stored in one location @@ -348,8 +487,8 @@ pair for each track, making it easier to separate tracks. This option is implicitly set when writing ismv (Smooth Streaming) files. @item -movflags faststart -Run a second pass moving the moov atom on top of the file. This -operation can take a while, and will not work in various situations such +Run a second pass moving the index (moov atom) to the beginning of the file. +This operation can take a while, and will not work in various situations such as fragmented output, thus it is not enabled by default. @item -movflags rtphint Add RTP hinting tracks to the output file. @@ -361,6 +500,42 @@ point on IIS with this muxer. Example: ffmpeg -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1) @end example +@section mp3 + +The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and +optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the +@code{id3v2_version} option controls which one is used. The legacy ID3v1 tag is +not written by default, but may be enabled with the @code{write_id3v1} option. + +For seekable output the muxer also writes a Xing frame at the beginning, which +contains the number of frames in the file. It is useful for computing duration +of VBR files. + +The muxer supports writing ID3v2 attached pictures (APIC frames). 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 @var{title} and @var{comment} map to APIC +@var{description} and @var{picture type} respectively. See +@url{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. + +Examples: + +Write an mp3 with an ID3v2.3 header and an ID3v1 footer: +@example +ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3 +@end example + +To attach a picture to an mp3 file select both the audio and the picture stream +with @code{map}: +@example +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 +@end example + @section mpegts MPEG transport stream muxer. @@ -383,6 +558,40 @@ Set the service_id (default 0x0001) also known as program in DVB. Set the first PID for PMT (default 0x1000, max 0x1f00). @item -mpegts_start_pid @var{number} Set the first PID for data packets (default 0x0100, max 0x0f00). +@item -mpegts_m2ts_mode @var{number} +Enable m2ts mode if set to 1. Default value is -1 which disables m2ts mode. +@item -muxrate @var{number} +Set muxrate. +@item -pes_payload_size @var{number} +Set minimum PES packet payload in bytes. +@item -mpegts_flags @var{flags} +Set flags (see below). +@item -mpegts_copyts @var{number} +Preserve original timestamps, if value is set to 1. Default value is -1, which +results in shifting timestamps so that they start from 0. +@item -tables_version @var{number} +Set PAT, PMT and SDT version (default 0, valid values are from 0 to 31, inclusively). +This option allows updating stream structure so that standard consumer may +detect the change. To do so, reopen output AVFormatContext (in case of API +usage) or restart ffmpeg instance, cyclically changing tables_version value: +@example +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 +... +@end example +@end table + +Option mpegts_flags may take a set of such flags: + +@table @option +@item resend_headers +Reemit PAT/PMT before writing the next packet. +@item latm +Use LATM packetization for AAC. @end table The recognized metadata settings in mpegts muxer are @code{service_provider} @@ -424,69 +633,21 @@ Alternatively you can write the command as: ffmpeg -benchmark -i INPUT -f null - @end example -@section matroska - -Matroska container muxer. - -This muxer implements the matroska and webm container specs. - -The recognized metadata settings in this muxer are: - -@table @option - -@item title=@var{title name} -Name provided to a single track -@end table - -@table @option - -@item language=@var{language name} -Specifies the language of the track in the Matroska languages form -@end table +@section ogg -@table @option +Ogg container muxer. -@item stereo_mode=@var{mode} -Stereo 3D video layout of two views in a single video track @table @option -@item mono -video is not stereo -@item left_right -Both views are arranged side by side, Left-eye view is on the left -@item bottom_top -Both views are arranged in top-bottom orientation, Left-eye view is at bottom -@item top_bottom -Both views are arranged in top-bottom orientation, Left-eye view is on top -@item checkerboard_rl -Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first -@item checkerboard_lr -Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first -@item row_interleaved_rl -Each view is constituted by a row based interleaving, Right-eye view is first row -@item row_interleaved_lr -Each view is constituted by a row based interleaving, Left-eye view is first row -@item col_interleaved_rl -Both views are arranged in a column based interleaving manner, Right-eye view is first column -@item col_interleaved_lr -Both views are arranged in a column based interleaving manner, Left-eye view is first column -@item anaglyph_cyan_red -All frames are in anaglyph format viewable through red-cyan filters -@item right_left -Both views are arranged side by side, Right-eye view is on the left -@item anaglyph_green_magenta -All frames are in anaglyph format viewable through green-magenta filters -@item block_lr -Both eyes laced in one Block, Left-eye view is first -@item block_rl -Both eyes laced in one Block, Right-eye view is first -@end table +@item -page_duration @var{duration} +Preferred page duration, in microseconds. The muxer will attempt to create +pages that are approximately @var{duration} microseconds long. This allows the +user to compromise between seek granularity and container overhead. The default +is 1 second. A value of 0 will fill all segments, making pages as large as +possible. A value of 1 will effectively use 1 packet-per-page in most +situations, giving a small seek granularity at the cost of additional container +overhead. @end table -For example a 3D WebM clip can be created using the following command line: -@example -ffmpeg -i sample_left_right_clip.mpg -an -c:v libvpx -metadata stereo_mode=left_right -y stereo_clip.webm -@end example - @section segment, stream_segment, ssegment Basic stream segmenter. @@ -513,7 +674,9 @@ 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 @var{segment_list}. The list type is specified by the -@var{segment_list_type} option. +@var{segment_list_type} option. The entry filenames in the segment +list are set by default to the basename of the corresponding segment +files. The segment muxer supports the following options: @@ -523,7 +686,7 @@ Set the reference stream, as specified by the string @var{specifier}. If @var{specifier} is set to @code{auto}, the reference is choosen 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''. +reference stream. The default value is @code{auto}. @item segment_format @var{format} Override the inner container format, by default it is guessed by the filename @@ -537,7 +700,7 @@ listfile is generated. Set flags affecting the segment list generation. It currently supports the following flags: -@table @var +@table @samp @item cache Allow caching (only affects M3U8 list files). @@ -545,18 +708,20 @@ Allow caching (only affects M3U8 list files). Allow live-friendly file generation. @end table -Default value is @code{cache}. - @item segment_list_size @var{size} Update the list file so that it contains at most the last @var{size} segments. If 0 the list file will contain all the segments. Default value is 0. -@item segment_list type @var{type} +@item segment_list_entry_prefix @var{prefix} +Set @var{prefix} to prepend to the name of each entry filename. By +default no prefix is applied. + +@item segment_list_type @var{type} Specify the format for the segment list file. The following values are recognized: -@table @option +@table @samp @item flat Generate a flat list for the created segments, one segment per line. @@ -577,7 +742,7 @@ the segment start and end time expressed in seconds. A list file with the suffix @code{".csv"} or @code{".ext"} will auto-select this format. -@code{ext} is deprecated in favor or @code{csv}. +@samp{ext} is deprecated in favor or @samp{csv}. @item ffconcat Generate an ffconcat file for the created segments. The resulting file @@ -650,6 +815,10 @@ Reset timestamps at the begin of each segment, so that each segment will start with near-zero timestamps. It is meant to ease the playback of the generated segments. May not work with some combinations of muxers/codecs. It is set to @code{0} by default. + +@item initial_offset @var{offset} +Specify timestamp offset to apply to the output packet timestamps. The +argument must be a time duration specification, and defaults to 0. @end table @subsection Examples @@ -671,9 +840,9 @@ ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_ti @end example @item -As the example above, but use the @code{ffmpeg} @var{force_key_frames} +As the example above, but use the @command{ffmpeg} @option{force_key_frames} option to force key frames in the input at the specified location, together -with the segment option @var{segment_time_delta} to account for +with the segment option @option{segment_time_delta} to account for possible roundings operated when setting key frame times. @example ffmpeg -i in.mkv -force_key_frames 1,2,3,5,8,13,21 -codec:v mpeg4 -codec:a pcm_s16le -map 0 \ @@ -684,7 +853,7 @@ required. @item Segment the input file by splitting the input file according to the -frame numbers sequence specified with the @var{segment_frames} option: +frame numbers sequence specified with the @option{segment_frames} option: @example ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.csv -segment_frames 100,200,300,500,800 out%03d.nut @end example @@ -705,57 +874,6 @@ ffmpeg -re -i in.mkv -codec copy -map 0 -f segment -segment_list playlist.m3u8 \ @end example @end itemize -@section mp3 - -The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and -optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the -@code{id3v2_version} option controls which one is used. The legacy ID3v1 tag is -not written by default, but may be enabled with the @code{write_id3v1} option. - -For seekable output the muxer also writes a Xing frame at the beginning, which -contains the number of frames in the file. It is useful for computing duration -of VBR files. - -The muxer supports writing ID3v2 attached pictures (APIC frames). 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 @var{title} and @var{comment} map to APIC -@var{description} and @var{picture type} respectively. See -@url{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. - -Examples: - -Write an mp3 with an ID3v2.3 header and an ID3v1 footer: -@example -ffmpeg -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3 -@end example - -To attach a picture to an mp3 file select both the audio and the picture stream -with @code{map}: -@example -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 -@end example - -@section ogg - -Ogg container muxer. - -@table @option -@item -page_duration @var{duration} -Preferred page duration, in microseconds. The muxer will attempt to create -pages that are approximately @var{duration} microseconds long. This allows the -user to compromise between seek granularity and container overhead. The default -is 1 second. A value of 0 will fill all segments, making pages as large as -possible. A value of 1 will effectively use 1 packet-per-page in most -situations, giving a small seek granularity at the cost of additional container -overhead. -@end table - @section tee The tee muxer can be used to write the same data to several files or any @@ -771,22 +889,70 @@ to feed the same packets to several muxers directly. 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, it must be -escaped (see the ``Quoting and escaping'' section in the ffmpeg-utils -manual). +escaped (see @ref{quoting_and_escaping,,the "Quoting and escaping" +section in the ffmpeg-utils(1) manual,ffmpeg-utils}). -Options can be specified for each slave by prepending them as a list of +Muxer options can be specified for each slave by prepending them as a list of @var{key}=@var{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. -Example: encode something and both archive it in a WebM file and stream it -as MPEG-TS over UDP (the streams need to be explicitly mapped): +The following special options are also recognized: +@table @option +@item f +Specify the format name. Useful if it cannot be guessed from the +output name suffix. + +@item bsfs[/@var{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 +@code{/}. @var{spec} must be a stream specifier (see @ref{Format +stream specifiers}). If the stream specifier is not specified, the +bistream filters will be applied to all streams in the output. + +Several bitstream filters can be specified, separated by ",". + +@item 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 input streams. +@end table +Some examples follow. +@itemize +@item +Encode something and both archive it in a WebM file and stream it +as MPEG-TS over UDP (the streams need to be explicitly mapped): @example 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/" @end example +@item +Use @command{ffmpeg} to encode the input, and send the output +to three different destinations. The @code{dump_extra} bitstream +filter is used to add extradata information to all the output video +keyframes packets, as requested by the MPEG-TS format. The select +option is applied to @file{out.aac} in order to make it contain only +audio packets. +@example +ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental + -f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=a]out.aac" +@end example + +@item +As below, but select only stream @code{a:1} for the audio output. Note +that a second level escaping must be performed, as ":" is a special +character used to separate options. +@example +ffmpeg -i ... -map 0 -flags +global_header -c:v libx264 -c:a aac -strict experimental + -f tee "[bsfs/v=dump_extra]out.ts|[movflags=+faststart]out.mp4|[select=\'a:1\']out.aac" +@end example +@end itemize + Note: some codecs may need different options depending on the output format; the auto-detection of this can not work with the tee muxer. The main example is the @option{global_header} flag. |
