Http Live Streaming not working on Apache

依然范特西╮ 提交于 2019-12-18 05:29:25

问题


My Http Live Streaming setup: Apache hosts the html, m3u8, and ts files

The ts files are copied over from http:devimages.apple.com/iphone/samples/bipbop/gear1/fileSequence*.ts. There is nothing wrong with the video encoding (verified by actually playing these files)

m3u8 files (both the multi-bitrate and leaf-level) are copied over from apple's example and are syntactically correct, as follows:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10, no desc
fileSequence0.ts
...
#EXTINF:1, no desc
fileSequence180.ts
#EXT-X-ENDLIST

videoplay.html (below) fails to stream the video from my apache server

<video src="bipbop/bipbopall.m3u8" controls autoplay ></video>

However on modifying videoplay.html (below), the video streams just fine from Apple's website

<video src="http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8" controls autoplay ></video>

I suspected something wrong with mime type settings because Chrome was handling http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8 and http://localhost/bipbop/bipbopall.m3u8 differently. While Chrome tries to play the former, it downloads and saves the latter one. So I double checked my mime type setting, which is set as below in my httpd.conf

AddType application/x-mpegURL .m3u8
AddType video/MP2T .ts
  • Is my mime type setting correct?
  • How do we figure the mime type association advertised by apple's website?
  • Or do we have to look elsewhere to fix this?

回答1:


This might seem strange but I also faced similar problems, and after much debugging I found that empty lines in the .m3u8 index file can cause such issues. Please double check for empty lines in your index file.




回答2:


According to the HLS rfc documentation you should use "application/vnd.apple.mpegurl" or "audio/mpegurl" but you could also simply make the path end with .m3u8 or .m3u.

Each Playlist file MUST be identifiable either by the path component of its URI or by HTTP Content-Type. In the first case, the path MUST end with either .m3u8 or .m3u. In the second, the HTTP Content-Type MUST be "application/vnd.apple.mpegurl" or "audio/mpegurl". Clients SHOULD refuse to parse Playlists that are not so identified.

~ Chapter 4 of rfc8216, HTTP Live Streaming




回答3:


Bit late, but for clarity's sake:

File extension |                 MIME type
-------------------------------------------------------------
.M3U8          | application/x-mpegURL (or vnd.apple.mpegURL)
.ts            | video/MP2T

Source: Apple Developer Streaming Media Guide – HTTP Streaming Architecture



来源:https://stackoverflow.com/questions/6438680/http-live-streaming-not-working-on-apache

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!