doc/demuxers.texi
ef298ea7
 @chapter Demuxers
 @c man begin DEMUXERS
 
a6be21d3
 Demuxers are configured elements in FFmpeg which allow to read the
ef298ea7
 multimedia streams from a particular type of file.
 
a6be21d3
 When you configure your FFmpeg build, all the supported demuxers
ef298ea7
 are enabled by default. You can list all available ones using the
2acd5fb5
 configure option @code{--list-demuxers}.
ef298ea7
 
 You can disable all the demuxers using the configure option
2acd5fb5
 @code{--disable-demuxers}, and selectively enable a single demuxer with
 the option @code{--enable-demuxer=@var{DEMUXER}}, or disable it
 with the option @code{--disable-demuxer=@var{DEMUXER}}.
ef298ea7
 
2acd5fb5
 The option @code{-formats} of the ff* tools will display the list of
ef298ea7
 enabled demuxers.
 
 The description of some of the currently available demuxers follows.
 
11169717
 @section applehttp
 
 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".
 
d95143ec
 @anchor{concat}
11169717
 @section concat
 
 Virtual concatenation script demuxer.
 
 This demuxer reads a list of files and other directives from a text file and
 demuxes them one after the other, as if all their packet had been muxed
 together.
 
 The timestamps in the files are adjusted so that the first file starts at 0
 and each next file starts where the previous one finishes. Note that it is
 done globally and may cause gaps if all streams do not have exactly the same
 length.
 
 All files must have the same streams (same codecs, same time base, etc.).
 
87a954d6
 The duration of each file is used to adjust the timestamps of the next file:
 if the duration is incorrect (because it was computed using the bit-rate or
 because the file is truncated, for example), it can cause artifacts. The
 @code{duration} directive can be used to override the duration stored in
 each file.
 
11169717
 @subsection 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:
 
 @table @option
 
 @item @code{file @var{path}}
 Path to a file to read; special characters and spaces must be escaped with
 backslash or single quotes.
 
ea2de3d0
 All subsequent directives apply to that file.
 
db9dc515
 @item @code{ffconcat version 1.0}
 Identify the script type and version. It also sets the @option{safe} option
 to 1 if it was to its default -1.
 
b68dd8a1
 To make FFmpeg recognize the format automatically, this directive must
 appears exactly as is (no extra space or byte-order-mark) on the very first
 line of the script.
 
ea2de3d0
 @item @code{duration @var{dur}}
 Duration of the file. This information can be specified from the file;
 specifying it here may be more efficient or help if the information from the
 file is not available or accurate.
 
11169717
 @end table
 
6d680d20
 @subsection Options
 
 This demuxer accepts the following option:
 
 @table @option
 
 @item safe
 If set to 1, reject unsafe file paths. A file path is considered safe if it
 does not contain a protocol specification and is relative and all components
 only contain characters from the portable character set (letters, digits,
 period, underscore and hyphen) and have no period at the beginning of a
 component.
 
 If set to 0, any file name is accepted.
 
 The default is -1, it is equivalent to 1 if the format was automatically
 probed and 0 otherwise.
 
 @end table
 
2bd02e2f
 @section image2
 
 Image file demuxer.
 
 This demuxer reads from a list of image files specified by a pattern.
3a06ea84
 The syntax and meaning of the pattern is specified by the
 option @var{pattern_type}.
2bd02e2f
 
3a06ea84
 The pattern may contain a suffix which is used to automatically
 determine the format of the images contained in the files.
 
 The size, the pixel format, and the format of each image must be the
 same for all the files in the sequence.
 
 This demuxer accepts the following options:
 @table @option
 @item framerate
 Set the framerate for the video stream. It defaults to 25.
 @item loop
 If set to 1, loop over the input. Default value is 0.
 @item pattern_type
 Select the pattern type used to interpret the provided filename.
 
 @var{pattern_type} accepts one of the following values.
 @table @option
 @item sequence
 Select a sequence pattern type, used to specify a sequence of files
 indexed by sequential numbers.
 
 A sequence pattern may contain the string "%d" or "%0@var{N}d", which
10ed96c7
 specifies the position of the characters representing a sequential
2bd02e2f
 number in each filename matched by the pattern. If the form
 "%d0@var{N}d" is used, the string representing the number in each
 filename is 0-padded and @var{N} is the total number of 0-padded
 digits representing the number. The literal character '%' can be
 specified in the pattern with the string "%%".
 
3a06ea84
 If the sequence pattern contains "%d" or "%0@var{N}d", the first filename of
10ed96c7
 the file list specified by the pattern must contain a number
b0d23ae2
 inclusively contained between @var{start_number} and
9bece760
 @var{start_number}+@var{start_number_range}-1, and all the following
 numbers must be sequential.
2bd02e2f
 
 For example the pattern "img-%03d.bmp" will match a sequence of
 filenames of the form @file{img-001.bmp}, @file{img-002.bmp}, ...,
 @file{img-010.bmp}, etc.; the pattern "i%%m%%g-%d.jpg" will match a
 sequence of filenames of the form @file{i%m%g-1.jpg},
 @file{i%m%g-2.jpg}, ..., @file{i%m%g-10.jpg}, etc.
 
3a06ea84
 Note that the pattern must not necessarily contain "%d" or
 "%0@var{N}d", for example to convert a single image file
 @file{img.jpeg} you can employ the command:
 @example
 ffmpeg -i img.jpeg img.png
 @end example
2bd02e2f
 
3a06ea84
 @item glob
 Select a glob wildcard pattern type.
 
 The pattern is interpreted like a @code{glob()} pattern. This is only
 selectable if libavformat was compiled with globbing support.
 
 @item glob_sequence @emph{(deprecated, will be removed)}
 Select a mixed glob wildcard/sequence pattern.
 
 If your version of libavformat was compiled with globbing support, and
 the provided pattern contains at least one glob meta character among
 @code{%*?[]@{@}} that is preceded by an unescaped "%", the pattern is
 interpreted like a @code{glob()} pattern, otherwise it is interpreted
 like a sequence pattern.
 
 All glob special characters @code{%*?[]@{@}} must be prefixed
 with "%". To escape a literal "%" you shall use "%%".
 
 For example the pattern @code{foo-%*.jpeg} will match all the
 filenames prefixed by "foo-" and terminating with ".jpeg", and
 @code{foo-%?%?%?.jpeg} will match all the filenames prefixed with
 "foo-", followed by a sequence of three characters, and terminating
 with ".jpeg".
 
 This pattern type is deprecated in favor of @var{glob} and
 @var{sequence}.
 @end table
 
 Default value is @var{glob_sequence}.
b0d23ae2
 @item pixel_format
 Set the pixel format of the images to read. If not specified the pixel
 format is guessed from the first image file in the sequence.
 @item start_number
 Set the index of the file matched by the image file pattern to start
 to read from. Default value is 0.
9bece760
 @item start_number_range
 Set the index interval range to check when looking for the first image
 file in the sequence, starting from @var{start_number}. Default value
 is 5.
b0d23ae2
 @item video_size
 Set the video size of the images to read. If not specified the video
 size is guessed from the first image file in the sequence.
 @end table
 
0325e01f
 @subsection Examples
 
 @itemize
 @item
 Use @command{ffmpeg} for creating a video from the images in the file
 sequence @file{img-001.jpeg}, @file{img-002.jpeg}, ..., assuming an
 input frame rate of 10 frames per second:
2bd02e2f
 @example
c59b80c8
 ffmpeg -i 'img-%03d.jpeg' -r 10 out.mkv
2bd02e2f
 @end example
 
0325e01f
 @item
b0d23ae2
 As above, but start by reading from a file with index 100 in the sequence:
 @example
 ffmpeg -start_number 100 -i 'img-%03d.jpeg' -r 10 out.mkv
 @end example
 
3a06ea84
 @item
 Read images matching the "*.png" glob pattern , that is all the files
 terminating with the ".png" suffix:
10ed96c7
 @example
3a06ea84
 ffmpeg -pattern_type glob -i "*.png" -r 10 out.mkv
10ed96c7
 @end example
3a06ea84
 @end itemize
10ed96c7
 
bad82243
 @section rawvideo
 
 Raw video demuxer.
 
 This demuxer allows 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:
 @table @option
 
 @item framerate
 Set input video frame rate. Default value is 25.
 
 @item pixel_format
 Set the input video pixel format. Default value is @code{yuv420p}.
 
 @item video_size
 Set the input video size. This value must be specified explicitly.
 @end table
 
 For example to read a rawvideo file @file{input.raw} with
 @command{ffplay}, assuming a pixel format of @code{rgb24}, a video
 size of @code{320x240}, and a frame rate of 10 images per second, use
 the command:
 @example
 ffplay -f rawvideo -pixel_format rgb24 -video_size 320x240 -framerate 10 input.raw
 @end example
 
2c82ab94
 @section sbg
 
 SBaGen script demuxer.
 
 This demuxer reads the script language used by SBaGen
 @url{http://uazu.net/sbagen/} to generate binaural beats sessions. A SBG
 script looks like that:
 @example
 -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
 @end example
 
 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 @var{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.
 
16001373
 @section tedcaptions
 
 JSON captions used for @url{http://www.ted.com/, TED Talks}.
 
 TED does not provide links to the captions, but they can be guessed from the
 page. The file @file{tools/bookmarklets.html} from the FFmpeg source tree
 contains a bookmarklet to expose them.
 
 This demuxer accepts the following option:
 @table @option
 @item start_time
 Set the start time of the TED talk, in milliseconds. The default is 15000
 (15s). It is used to sync the captions with the downloadable videos, because
 they include a 15s intro.
 @end table
 
 Example: convert the captions to a format most players understand:
 @example
 ffmpeg -i http://www.ted.com/talks/subtitles/id/1/lang/en talk1-en.srt
 @end example
 
9b9b5a47
 @c man end DEMUXERS