简体   繁体   中英

How to download a LIVE HLS m3u8 stream on iOS

HLS streams can be "live" or "VOD". Downloading a VOD HLS stream is easy.

However, I want to download (or record) say 5 minutes of a LIVE HLS stream. Is this possible?

If I do so, I am sure I have to make significant changes to the m3u8 file... One reason is live streams do not have a "duration", but the stream I download has to be streamed as VOD so it must have a duration. There might be various other changes required that I am not aware of. Presumably URLs of ts segments would also need to be changed.

Any tips or advice (hopefully actual code!)?

Thanks!

PS. Note that this question is not about playing back the stream in offline mode - I know I need an HTTP server for that.

The Live playlist uses a sliding-window. You need to periodically reload it after target-duration time and download only the new segments as they appear in the list (they will be removed at a later time).

Save the #EXTINF for each segment and start writing them in a VOD playlist using the same target-duration and a media sequence starting at 0.

When you want to stop recording add the EXT-X-ENDLIST tag at the end.

It doesn't matter how you name your segments as long as you use the same name in the m3u8 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM