FFMpeg HLS 相关参数
21.25 segment, stream_segment, ssegment
Basic stream segmenter.
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.
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.
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.
24.11 hls
Read Apple HTTP Live Streaming compliant segmented stream as a uniform one. The M3U8 playlists describing the segments can be remote HTTP resources or local files, accessed using the standard file protocol. The nested protocol is declared by specifying "+proto" after the hls URI scheme name, where proto is either "file" or "http".
hls+http://host/path/to/remote/resource.m3u8
hls+file://path/to/local/resource.m3u8
Using this protocol is discouraged - the hls demuxer should work just as well (if not, please report the issues) and is more complete. To use the hls demuxer instead, simply use the direct URLs to the m3u8 files.
24.12 http
HTTP (Hyper Text Transfer Protocol).
This protocol accepts the following options:
seekable
Control seekability of connection. If set to 1 the resource is supposed to be seekable, if set to 0 it is assumed not to be seekable, if set to -1 it will try to autodetect if it is seekable. Default value is -1.
chunked_post
If set to 1 use chunked Transfer-Encoding for posts, default is 1.
content_type
Set a specific content type for the POST messages or for listen mode.
http_proxy
set HTTP proxy to tunnel through e.g. http://example.com:1234
headers
Set custom HTTP headers, can override built in default headers. The value must be a string encoding the headers.
multiple_requests
Use persistent connections if set to 1, default is 0.
post_data
Set custom HTTP post data.
referer
Set the Referer header. Include ’Referer: URL’ header in HTTP request.
user_agent
Override the User-Agent header. If not specified the protocol will use a string describing the libavformat build. ("Lavf/<version>")
user-agent
This is a deprecated option, you can use user_agent instead it.
timeout
Set timeout in microseconds of socket I/O operations used by the underlying low level operation. By default it is set to -1, which means that the timeout is not specified.
reconnect_at_eof
If set then eof is treated like an error and causes reconnection, this is useful for live / endless streams.
reconnect_streamed
If set then even streamed/non seekable streams will be reconnected on errors.
reconnect_delay_max
Sets the maximum delay in seconds after which to give up reconnecting
mime_type
Export the MIME type.
http_version
Exports the HTTP response version number. Usually "1.0" or "1.1".
icy
If set to 1 request ICY (SHOUTcast) metadata from the server. If the server supports this, the metadata has to be retrieved by the application by reading the icy_metadata_headers and icy_metadata_packet options. The default is 1.
icy_metadata_headers
If the server supports ICY metadata, this contains the ICY-specific HTTP reply headers, separated by newline characters.
icy_metadata_packet
If the server supports ICY metadata, and icy was set to 1, this contains the last non-empty metadata packet sent by the server. It should be polled in regular intervals by applications interested in mid-stream metadata updates.
cookies
Set the cookies to be sent in future requests. The format of each cookie is the same as the value of a Set-Cookie HTTP response field. Multiple cookies can be delimited by a newline character.
offset
Set initial byte offset.
end_offset
Try to limit the request to bytes preceding this offset.
method
When used as a client option it sets the HTTP method for the request.
When used as a server option it sets the HTTP method that is going to be expected from the client(s). If the expected and the received HTTP method do not match the client will be given a Bad Request response. When unset the HTTP method is not checked for now. This will be replaced by autodetection in the future.
listen
If set to 1 enables experimental HTTP server. This can be used to send data when used as an output option, or read data from a client with HTTP POST when used as an input option. If set to 2 enables experimental multi-client HTTP server. This is not yet implemented in ffmpeg.c and thus must not be used as a command line option.
# Server side (sending):
ffmpeg -i somefile.ogg -c copy -listen 1 -f ogg http://server:port
# Client side (receiving):
ffmpeg -i http://server:port -c copy somefile.ogg
# Client can also be done with wget:
wget http://server:port -O somefile.ogg
# Server side (receiving):
ffmpeg -listen 1 -i http://server:port -c copy somefile.ogg
# Client side (sending):
ffmpeg -i somefile.ogg -chunked_post 0 -c copy -f ogg http://server:port
# Client can also be done with wget:
wget --post-file=somefile.ogg http://server:port
send_expect_100
Send an Expect: 100-continue header for POST. If set to 1 it will send, if set to 0 it won’t, if set to -1 it will try to send if it is applicable. Default value is -1.
20.8 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).
allowed_extensions
’,’ separated list of file extensions that hls is allowed to access.
max_reload
Maximum number of times a insufficient list is attempted to be reloaded. Default value is 1000.
m3u8_hold_counters
The maximum number of times to load m3u8 when it refreshes without new segments. Default value is 1000.
http_persistent
Use persistent HTTP connections. Applicable only for HTTP streams. Enabled by default.
http_multiple
Use multiple HTTP connections for downloading HTTP segments. Enabled by default for HTTP/1.1 servers.
http_seekable
Use HTTP partial requests for downloading HTTP segments. 0 = disable, 1 = enable, -1 = auto, Default is auto.
21.13 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.
Make sure to require a closed GOP when encoding and to set the GOP size to fit your segment time constraint.
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.
21.13.1 Options
This muxer supports the following options:
hls_init_time seconds
Set the initial target segment length in seconds. Default value is 0. Segment will be cut on the next key frame after this time has passed on the first m3u8 list. After the initial playlist is filled ffmpeg will cut segments at duration equal to hls_time
hls_time seconds
Set the target segment length in seconds. Default value is 2. Segment will be cut on the next key frame after this time has passed.
hls_list_size size
Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. Default value is 5.
hls_delete_threshold size
Set the number of unreferenced segments to keep on disk before hls_flags delete_segments deletes them. Increase this to allow continue clients to download segments which were recently referenced in the playlist. Default value is 1, meaning segments older than hls_list_size+1 will be deleted.
hls_ts_options options_list
Set output format options using a :-separated list of key=value parameters. Values containing : special characters must be escaped.
hls_wrap wrap
This is a deprecated option, you can use hls_list_size and hls_flags delete_segments instead it
This option is useful to avoid to fill the disk with many segment files, and limits the maximum number of segment files written to disk to wrap.
hls_start_number_source
Start the playlist sequence number (#EXT-X-MEDIA-SEQUENCE) according to the specified source. Unless hls_flags single_file is set, it also specifies source of starting sequence numbers of segment and subtitle filenames. In any case, if hls_flags append_list is set and read playlist sequence number is greater than the specified start sequence number, then that value will be used as start value.
It accepts the following values:
generic (default)
Set the starting sequence numbers according to start_number option value.
epoch
The start number will be the seconds since epoch (1970-01-01 00:00:00)
datetime
The start number will be based on the current date/time as YYYYmmddHHMMSS. e.g. 20161231235759.
start_number number
Start the playlist sequence number (#EXT-X-MEDIA-SEQUENCE) from the specified number when hls_start_number_source value is generic. (This is the default case.) Unless hls_flags single_file is set, it also specifies starting sequence numbers of segment and subtitle filenames. Default value is 0.
hls_allow_cache allowcache
Explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments.
hls_base_url baseurl
Append baseurl to every entry in the playlist. Useful to generate playlists with absolute paths.
Note that the playlist sequence number must be unique for each segment and it is not to be confused with the segment filename sequence number which can be cyclic, for example if the wrap option is specified.
hls_segment_filename filename
Set the segment filename. Unless hls_flags single_file is set, filename is used as a string format with the segment number:
ffmpeg -i in.nut -hls_segment_filename 'file%03d.ts' out.m3u8
This example will produce the playlist, out.m3u8, and segment files: file000.ts, file001.ts, file002.ts, etc.
filename may contain full path or relative path specification, but only the file name part without any path info 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", this string specifies the position of variant stream index in the generated segment file names.
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
This example 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.
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
This example 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.
use_localtime
Same as strftime option, will be deprecated.
strftime
Use strftime() on filename to expand the segment filename with localtime. The segment number is also available in this mode, but to use it, you need to specify second_level_segment_index hls_flag and %%d will be the specifier.
ffmpeg -i in.nut -strftime 1 -hls_segment_filename 'file-%Y%m%d-%s.ts' out.m3u8
This example 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.
ffmpeg -i in.nut -strftime 1 -hls_flags second_level_segment_index -hls_segment_filename 'file-%Y%m%d-%%04d.ts' out.m3u8
This example will produce the playlist, out.m3u8, and segment files: file-20160215-0001.ts, file-20160215-0002.ts, etc.
use_localtime_mkdir
Same as strftime_mkdir option, will be deprecated .
strftime_mkdir
Used together with -strftime_mkdir, it will create all subdirectories which is expanded in filename.
ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y%m%d/file-%Y%m%d-%s.ts' out.m3u8
This example 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.
ffmpeg -i in.nut -strftime 1 -strftime_mkdir 1 -hls_segment_filename '%Y/%m/%d/file-%Y%m%d-%s.ts' out.m3u8
This example 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: 2016/02/15/file-20160215-1455569023.ts, 2016/02/15/file-20160215-1455569024.ts, etc.
hls_key_info_file key_info_file
Use the information in key_info_file for segment encryption. The first line of key_info_file specifies the key URI written to the playlist. The key URL is used to access the encryption key during playback. The second line specifies the path to the key file used to obtain the key during the encryption process. The key file is read as a single packed array of 16 octets in binary format. The optional third line specifies the initialization vector (IV) as a hexadecimal string to be used instead of the segment sequence number (default) for encryption. 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 if hls_flags periodic_rekey is enabled.
Key info file format:
key URI
key file path
IV (optional)
Example key URIs:
http://server/file.key
/path/to/file.key
file.key
Example key file paths:
file.key
/path/to/file.key
Example IV:
0123456789ABCDEF0123456789ABCDEF
Key info file example:
http://server/file.key
/path/to/file.key
0123456789ABCDEF0123456789ABCDEF
Example shell script:
#!/bin/sh
BASE_URL=${1:-'.'}
openssl rand 16 > file.key
echo $BASE_URL/file.key > file.keyinfo
echo file.key >> file.keyinfo
echo $(openssl rand -hex 16) >> file.keyinfo
ffmpeg -f lavfi -re -i testsrc -c:v h264 -hls_flags delete_segments \
-hls_key_info_file file.keyinfo out.m3u8
-hls_enc enc
Enable (1) or disable (0) the AES128 encryption. When enabled every segment generated is encrypted and the encryption key is saved as playlist name.key.
-hls_enc_key key
Hex-coded 16byte key to encrypt the segments, by default it is randomly generated.
-hls_enc_key_url keyurl
If set, keyurl is prepended instead of baseurl to the key filename in the playlist.
-hls_enc_iv iv
Hex-coded 16byte initialization vector for every segment instead of the autogenerated ones.
hls_segment_type flags
Possible values:
‘mpegts’
Output segment files in MPEG-2 Transport Stream format. This is compatible with all HLS versions.
‘fmp4’
Output segment files in fragmented MP4 format, similar to MPEG-DASH. fmp4 files may be used in HLS version 7 and above.
hls_fmp4_init_filename filename
Set filename to the fragment files header file, default filename is init.mp4.
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 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 present 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:
‘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 with this way will have the version number 4. For example:
ffmpeg -i in.nut -hls_flags single_file out.m3u8
Will produce the playlist, out.m3u8, and a single segment file, out.ts.
‘delete_segments’
Segment files removed from the playlist are deleted after a period of time equal to the duration of the segment plus the duration of the playlist.
‘append_list’
Append new segments into the end of 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.
‘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 detect updates to the encryption info. Be sure to replace this file atomically, including the file containing the AES encryption key.
‘independent_segments’
Add the #EXT-X-INDEPENDENT-SEGMENTS to playlists that has 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 to playlists that has 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 keyframes. This improves behavior on some players when the time between keyframes is inconsistent, but may make things worse on others, and can cause some oddities during seeking. This flag should be used with the hls_time option.
‘program_date_time’
Generate EXT-X-PROGRAM-DATE-TIME tags.
‘second_level_segment_index’
Makes it possible to use segment indexes as %%d in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xd format is available where x is the required width.
‘second_level_segment_size’
Makes it possible to use segment sizes (counted in bytes) as %%s in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xs format is available where x is the required width.
‘second_level_segment_duration’
Makes it possible to use segment duration (calculated in microseconds) as %%t in hls_segment_filename expression besides date/time values when strftime is on. To get fixed width numbers with trailing zeroes, %%0xt format is available where x is the required width.
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
This will produce segments like this: segment_20170102194334_0003_00122200_0000003000000.ts, segment_20170102194334_0004_00120072_0000003000000.ts etc.
‘temp_file’
Write segment data to filename.tmp and rename to filename only once the segment is complete. A webserver serving up segments can be configured to reject requests to *.tmp to prevent access to in-progress segments before they have 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 written into temporary file and renamed after they are complete, similarly as segments are handled. But playlists with file protocol and with type (hls_playlist_type) other than vod are always written into temporary file regardless of this flag. Master playlist files (master_pl_name), if any, with file protocol, are always written into temporary file regardless of this flag if master_pl_publish_rate value is other than zero.
hls_playlist_type event
Emit #EXT-X-PLAYLIST-TYPE:EVENT in the m3u8 header. Forces hls_list_size to 0; the playlist can only be appended to.
hls_playlist_type vod
Emit #EXT-X-PLAYLIST-TYPE:VOD in the m3u8 header. Forces hls_list_size to 0; the playlist must not change.
method
Use the given HTTP method to create the hls files.
ffmpeg -re -i in.ts -f hls -method PUT http://example.com/live/out.m3u8
This example 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.
http_user_agent
Override User-Agent field in HTTP header. Applicable only for HTTP output.
var_stream_map
Map string which specifies 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).
When there are two or more variant streams, the output filename pattern must contain the string "%v", this string specifies the position of variant stream index in the output media playlist filenames. The string "%v" may be present in the filename or in the last directory name containing the file. If the string is present in the directory name, then sub-directories are created after expanding the directory name pattern. This enables creation of variant streams in subdirectories.
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
This example creates two hls variant streams. The first variant stream will contain video stream of bitrate 1000k and audio stream of bitrate 64k and the second variant stream will contain video stream of bitrate 256k and audio stream of bitrate 32k. Here, two media playlist with file names out_0.m3u8 and out_1.m3u8 will be created. If you want something meaningful text instead of indexes in result names, you may specify names for each or some of the variants as in the following example.
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
This example creates two hls variant streams as in the previous one. But here, the two media playlist with file names out_my_hd.m3u8 and out_my_sd.m3u8 will be created.
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k \
-map 0:v -map 0:a -map 0:v -f hls -var_stream_map "v:0 a:0 v:1" \
http://example.com/live/out_%v.m3u8
This example creates three hls variant streams. The first variant stream will be a video only stream with video bitrate 1000k, the second variant stream will be an audio only stream with bitrate 64k and the third variant stream will be a video only stream with bitrate 256k. Here, three media playlist with file names out_0.m3u8, out_1.m3u8 and out_2.m3u8 will be created.
ffmpeg -re -i in.ts -b:v:0 1000k -b:v:1 256k -b:a:0 64k -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
This example creates the variant streams in subdirectories. Here, the first media playlist is created at http://example.com/live/vs_0/out.m3u8 and the second one at http://example.com/live/vs_1/out.m3u8.
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
This example creates 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, #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.
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
This example creates two audio only and one video only variant streams. In addition to the #EXT-X-STREAM-INF tag for each variant stream in the master playlist, #EXT-X-MEDIA tag is also added for the two audio only variant streams and they are mapped to the one video only variant streams with audio group name ’aud_low’, and the audio group have default stat is NO or YES.
By default, a single hls variant containing all the encoded streams is created.
ffmpeg -re -i in.ts -b:a:0 32k -b:a:1 64k -b:v:0 1000k \
-map 0:a -map 0:a -map 0:v -f hls \
-var_stream_map "a:0,agroup:aud_low,default:yes,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
This example creates two audio only and one video only variant streams. In addition to the #EXT-X-STREAM-INF tag for each variant stream in the master playlist, #EXT-X-MEDIA tag is also added for the two audio only variant streams and they are mapped to the one video only variant streams with audio group name ’aud_low’, and the audio group have default stat is NO or YES, and one audio have and language is named ENG, the other audio language is named CHN.
By default, a single hls variant containing all the encoded streams is created.
cc_stream_map
Map string which specifies different closed captions groups and their attributes. The closed captions stream groups are separated by space. Expected string format is like this "ccgroup:<group name>,instreamid:<INSTREAM-ID>,language:<language code> ....". ’ccgroup’ and ’instreamid’ are mandatory attributes. ’language’ is an optional attribute. The closed captions groups configured using this option are mapped to different variant streams by providing the same ’ccgroup’ name in the var_stream_map string. If var_stream_map is not set, then the first available ccgroup in cc_stream_map is mapped to the output variant stream. The examples for these two use cases are given below.
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 example adds #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 adds CLOSED-CAPTIONS attribute with group name ’cc’ for the output variant stream.
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
This example adds two #EXT-X-MEDIA tags with TYPE=CLOSED-CAPTIONS in the master playlist for the INSTREAM-IDs ’CC1’ and ’CC2’. Also, it adds CLOSED-CAPTIONS attribute with group name ’cc’ for the two output variant streams.
master_pl_name
Create HLS master playlist with the given name.
ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8
This example creates HLS master playlist with name master.m3u8 and it is published at http://example.com/live/
master_pl_publish_rate
Publish master play list repeatedly every after specified number of segment intervals.
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
This example creates HLS master playlist with name master.m3u8 and keep publishing it repeatedly every after 30 segments i.e. every after 60s.
http_persistent
Use persistent HTTP connections. Applicable only for HTTP output.
timeout
Set timeout for socket I/O operations. Applicable only for HTTP output.
-ignore_io_errors
Ignore IO errors during open, write and delete. Useful for long-duration runs with network output.
headers
Set custom HTTP headers, can override built in default headers. Applicable only for HTTP output.