How to create byte-range m3u8 playlist for HLS?

biomancer picture biomancer · May 6, 2014 · Viewed 20.9k times · Source

Apple gives an example of support for byte-range segments in m3u8 files for HLS

#EXTM3U
#EXT-X-TARGETDURATION:11
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-VERSION:4
#EXTINF:10.0,
#EXT-X-BYTERANGE:75232@0
media.ts
#EXTINF:10.0,
#EXT-X-BYTERANGE:82112@752321
media.ts 
#EXTINF:10.0, 
#EXT-X-BYTERANGE:69864
media.ts

But I cannot figure out how to create such playlist for given .ts file. Are there any tools for that?

Answer

sangwonl picture sangwonl · Mar 21, 2016

There is -hls_flags as a ffmpeg option. (https://www.ffmpeg.org/ffmpeg-formats.html)

Following command generates single ts file which is segmented by byte range feature(supported from HLS version 4) in m3u8 index file.

$ ffmpeg -i sample.mp3 -hls_time 20 -hls_flags single_file out.m3u8