X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=doc%2Fmuxers.texi;h=b060c4f36014f245920d7e932c7650abea659d92;hb=5409f065f2c48ad9c4baf787d08384176cbc62a4;hp=91bbe673c53f76be8c05404decc0d64bc8ab4d06;hpb=869401cefc22e221edbf135bacaa1f21014fd001;p=ffmpeg diff --git a/doc/muxers.texi b/doc/muxers.texi index 91bbe673c53..b060c4f3601 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -247,6 +247,13 @@ DASH-templated name to used for the initialization segment. Default is "init-str DASH-templated name to used for the media segments. Default is "chunk-stream$RepresentationID$-$Number%05d$.m4s" @item -utc_timing_url @var{utc_url} URL of the page that will return the UTC timestamp in ISO format. Example: "https://time.akamai.com/?iso" +@item -http_user_agent @var{user_agent} +Override User-Agent field in HTTP header. Applicable only for HTTP output. +@item -http_persistent @var{http_persistent} +Use persistent HTTP connections. Applicable only for HTTP output. +@item -hls_playlist @var{hls_playlist} +Generate HLS playlist files as well. The master playlist is generated with the filename master.m3u8. +One media playlist file is generated for each stream with filenames media_0.m3u8, media_1.m3u8, etc. @item -adaptation_sets @var{adaptation_sets} Assign streams to AdaptationSets. Syntax is "id=x,streams=a,b,c id=y,streams=d,e" with x and y being the IDs of the adaptation sets and a,b,c,d and e are the indices of the mapped streams. @@ -468,9 +475,12 @@ 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 @command{ffmpeg}: @example -ffmpeg -i in.nut out.m3u8 +ffmpeg -i in.mkv -c:v h264 -flags +cgop -g 30 -hls_time 1 out.m3u8 @end example This example will produce the playlist, @file{out.m3u8}, and segment files: @file{out0.ts}, @file{out1.ts}, @file{out2.ts}, etc. @@ -567,6 +577,31 @@ Should a relative path be specified, the path of the created segment files will be relative to the current working directory. When use_localtime_mkdir is set, the whole expanded value of @var{filename} will be written into the m3u8 segment list. +When @code{var_stream_map} is set with two or more variant streams, the +@var{filename} pattern must contain the string "%v", this string specifies +the position of variant stream index in the generated segment file names. +@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 +@end example +This example will produce the playlists segment file sets: +@file{file_0_000.ts}, @file{file_0_001.ts}, @file{file_0_002.ts}, etc. and +@file{file_1_000.ts}, @file{file_1_001.ts}, @file{file_1_002.ts}, etc. + +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 segments corresponding to different variant streams in +subdirectories. +@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 +@end example +This example will produce the playlists segment file sets: +@file{vs0/file_000.ts}, @file{vs0/file_001.ts}, @file{vs0/file_002.ts}, etc. and +@file{vs1/file_000.ts}, @file{vs1/file_001.ts}, @file{vs1/file_002.ts}, etc. @item use_localtime Use strftime() on @var{filename} to expand the segment filename with localtime. @@ -693,6 +728,15 @@ the fmp4 files is used in hls after version 7. @item hls_fmp4_init_filename @var{filename} set filename to the fragment files header file, default filename is @file{init.mp4}. +When @code{var_stream_map} is set with two or more variant streams, the +@var{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. + @item hls_flags @var{flags} Possible values: @@ -732,6 +776,10 @@ The file specified by @code{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. +@item independent_segments +Add the @code{#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. + @item 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, @@ -794,6 +842,88 @@ files. @item http_user_agent Override User-Agent field in HTTP header. Applicable only for HTTP output. +@item 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. + +@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 v:1,a:1" \ + http://example.com/live/out_%v.m3u8 +@end example +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. +@example +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 +@end example +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. +@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 v:1,a:1" \ + http://example.com/live/vs_%v/out.m3u8 +@end example +This example creates the variant streams in subdirectories. Here, the first +media playlist is created at @file{http://example.com/live/vs_0/out.m3u8} and +the second one at @file{http://example.com/live/vs_1/out.m3u8}. +@example +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 +@end example +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. + +@item master_pl_name +Create HLS master playlist with the given name. + +@example +ffmpeg -re -i in.ts -f hls -master_pl_name master.m3u8 http://example.com/live/out.m3u8 +@end example +This example creates HLS master playlist with name master.m3u8 and it is +published at http://example.com/live/ + +@item master_pl_publish_rate +Publish master play list repeatedly every after specified number of segment intervals. + +@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 +@end example + +This example creates HLS master playlist with name master.m3u8 and keep +publishing it repeatedly every after 30 segments i.e. every after 60s. + +@item http_persistent +Use persistent HTTP connections. Applicable only for HTTP output. + @end table @anchor{ico} @@ -894,9 +1024,18 @@ can be used: ffmpeg -f v4l2 -r 1 -i /dev/video0 -f image2 -strftime 1 "%Y-%m-%d_%H-%M-%S.jpg" @end example +You can set the file name with current frame's PTS: +@example +ffmpeg -f v4l2 -r 1 -i /dev/video0 -copyts -f image2 -frame_pts true %d.jpg" +@end example + @subsection Options @table @option +@item frame_pts +If set to 1, expand the filename with pts from pkt->pts. +Default value is 0. + @item start_number Start the sequence from the specified number. Default value is 1. @@ -1649,6 +1788,9 @@ segment would usually span. Otherwise, the segment will be filled with the next packet written. Defaults to @code{0}. @end table +Make sure to require a closed GOP when encoding and to set the GOP +size to fit your segment time constraint. + @subsection Examples @itemize @@ -1657,7 +1799,7 @@ Remux the content of file @file{in.mkv} to a list of segments @file{out-000.nut}, @file{out-001.nut}, etc., and write the list of generated segments to @file{out.list}: @example -ffmpeg -i in.mkv -codec copy -map 0 -f segment -segment_list out.list out%03d.nut +ffmpeg -i in.mkv -codec hevc -flags +cgop -g 60 -map 0 -f segment -segment_list out.list out%03d.nut @end example @item