简体   繁体   English

如何在iOS上下载LIVE HLS m3u8流

[英]How to download a LIVE HLS m3u8 stream on iOS

HLS streams can be "live" or "VOD". HLS流可以是“实时”或“ VOD”。 Downloading a VOD HLS stream is easy. 下载VOD HLS流很容易。

However, I want to download (or record) say 5 minutes of a LIVE HLS stream. 但是,我想下载(或记录)5分钟的LIVE HLS流。 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. 如果这样做,我确定我必须对m3u8文件进行重大更改。一个原因是实时流没有“持续时间”,但是我下载的流必须以VOD格式进行流传输,因此必须具有持续时间。 There might be various other changes required that I am not aware of. 我可能不知道还有其他要求。 Presumably URLs of ts segments would also need to be changed. 大概ts段的URL也需要更改。

Any tips or advice (hopefully actual code!)? 有任何提示或建议(希望是实际代码!)?

Thanks! 谢谢!

PS. PS。 Note that this question is not about playing back the stream in offline mode - I know I need an HTTP server for that. 请注意,此问题不是关于以脱机模式回放流-我知道我需要为此使用HTTP服务器。

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. 为每个片段保存#EXTINF ,并开始使用相同的目标持续时间和从0开始的媒体序列将其写入VOD播放列表。

When you want to stop recording add the EXT-X-ENDLIST tag at the end. 当您要停止录制时,请在末尾添加EXT-X-ENDLIST标签。

It doesn't matter how you name your segments as long as you use the same name in the m3u8 . 只要您在m3u8使用相同的名称, m3u8段命名,这m3u8

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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