When playing a video stream using HLS technology, you first convert the video to a TS slice and a m3u8 playlist, using FFmpeg to do the conversion (the low version ffmpeg does not support direct turning, and can now be converted to TS and m3u8-segmenter slices, The author uses ffmpeg version-2.1.2), usually using the following command:
Ffmpeg-i input.mp4-c:v libx264-c:a aac-strict-2-F HLS output.m3u8
However, in this state, the default length of 2 seconds per piece, the default in the m3u8 file only save the latest 5 pieces of information, resulting in the last play can only broadcast a small part of the last.
There are actually some other parameters that can control these things:
The following is the original FFmpeg official website:
This muxer supports the following options: ' Hls_time seconds '
Set the segment length in seconds. Default value is 2. ' Hls_list_size size '
Set the maximum number of playlist entries. If set to 0 The list file would contain all the segments. Default value is 5. ' Hls_wrap Wrap '
Set the number after which the "segment filename number" (the number specified in each segment file) wraps. If set to 0 the number would be never wrapped. Default value is 0.
This option is useful to avoid to fill the disk with many segment files, and limits the maximum number of segment files WR Itten to disk Towrap. ' Start_number number '
Start The playlist sequence number from number. Default value is 0.
Note that the playlist sequence number must are unique for each segment and it are not the confused with the segment Filen AME sequence number which can cyclic, for example if the ' wrap ' option is specified.
Translated as follows:
-hls_time N: Sets the length of each slice, the default value is 2. Unit is seconds
-hls_list_size N: Set the maximum number of entries saved by the playlist, set to 0 to save a piece of information, the default value is 5
-hls_wrap N: After setting how many slices to start overwriting, if set to 0 will not overwrite, the default value is 0. This option avoids storing too many slices on disk and can limit the number of slices written to disk
-hls_start_number N: Sets the value of sequence number in the playlist to number, the default value is 0
Note: The sequence number of the playlist must be unique for each segment, and it cannot be confused with the file name of the slice (when the wrap option is used, the file name may be reused)
With these parameters, the small partners can happily control the generated m3u8 file.