简体   繁体   English

HLS直播stream服务器

[英]HLS live stream server

I am planning to write my own live stream server in python using the HLS protocol for a small project.我计划使用 HLS 协议为一个小项目在 python 中编写自己的实时 stream 服务器。

My idea is to use Amazon S3 for storage and have the python server just output the m3u8 file.我的想法是使用 Amazon S3 进行存储,并让 python 服务器只有 output m3u8 文件。

This is all straightforward, now to the problem: I want to stream live video from a camera over an unreliable.network and if there is a congestion the player could end up with completing playing of the last file referenced in the m3u8 file.这一切都很简单,现在问题来了:我想通过 unreliable.network 从摄像机播放 stream 实时视频,如果出现拥塞,播放器最终可能会完成播放 m3u8 文件中引用的最后一个文件。 Can i in some way mark the stream as a live stream having the player try again reloading the m3u8 for a specific time looking for a next segment or how should live streaming using HLS be handled?我能否以某种方式将 stream 标记为实时 stream 让播放器再次尝试重新加载 m3u8 寻找下一段的特定时间,或者应该如何处理使用 HLS 的直播? Maybe live streaming over HLS is not supported?也许不支持通过 HLS 进行直播?

This is explictly allowed in the HLS spec as a "live Playlist". HLS 规范明确允许将其作为“实时播放列表”。 There are a few things you need to be aware of, but notably, from section 6.2.1:您需要注意一些事项,但值得注意的是,来自第 6.2.1 节:

The server MUST NOT change the Media Playlist file, except to:服务器不得更改媒体播放列表文件,除了:

o Append lines to it (Section 6.2.1). o Append 行(第 6.2.1 节)。

And if we take a look at Section 4.3.3.4:如果我们看一下第 4.3.3.4 节:

The EXT-X-ENDLIST tag indicates that no more Media Segments will be added to the Media Playlist file. EXT-X-ENDLIST 标签表示不再有 Media Segments 被添加到 Media Playlist 文件中。 It MAY occur anywhere in the Media Playlist file.它可能出现在媒体播放列表文件中的任何位置。

In other words, if a playlist does not include the #EXT-X-ENDLIST tag, it's expected that the player will keep loading the playlist from whatever source it originally loaded it from with some frequency, looking for the server to append segments to the playlist.换句话说,如果播放列表包含#EXT-X-ENDLIST标签,则预计播放器将继续以某种频率从最初加载播放列表的任何源加载播放列表,查找服务器到 append 段到播放列表。

Most players will do this taking into account current.network conditions so they have a chance to get new segments before the playback is caught up.大多数播放器会在考虑当前网络条件的情况下执行此操作,以便他们有机会在回放赶上之前获得新的片段。 If the server needs to interrupt the segments, or otherwise introduce a gap, it has the responsibility to introduce a #EXT-X-DISCONTINUITY-SEQUENCE tag.如果服务器需要中断段,或者以其他方式引入间隙,则它有责任引入#EXT-X-DISCONTINUITY-SEQUENCE标记。

Apple provides a more concrete example of a Live Playlist on their developer website. Apple 在其开发者网站上提供了一个更具体的实时播放列表示例

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

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