HLS流无法在Apple设备上运行 [英] HLS stream not working on Apple devices

查看:627
本文介绍了HLS流无法在Apple设备上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个实时RTSP流,我已设法通过VLC转码为HLS。现在它在Android和桌面浏览器上运行完美(通过闪存)。

I have a live RTSP stream that i have managed to transcode to HLS via VLC. Now it works perfect on Android and on desktop browsers (via flash).

但不在Apple上(我可以在我的虚拟机上的iPad和桌面Safari上测试它)。我可以看到播放器但是当我按下播放按钮时,我看到的只是播放器内部的黑色矩形。在桌面Safari上,播放/暂停按钮附近还有一个文本正在加载...,没有其他任何事情发生。

But not on Apple (i can test it on iPad and desktop Safari on my virtual machine). I can see the player but when i press the 'play' button all i see is a black rectangle inside the player. On desktop Safari there is also a text 'Loading...' near the play/pause button and nothing else happens.

我的HTML:

<video id="player" controls style="width:100%; height:100%">
  <source src="http://178.79.164.114/playlist.m3u8" type="application/x-mpegURL">
</video>

vlc的命令:

vlc -I dummy rtsp://<stream-url> --sout '#transcode{width=320,height=240,fps=25,vcodec=h264,vb=256,acodec=none,venc=x264{aud,profile=baseline,level=30,keyint=30,bframes=0,ref=1,nocabac}}:std{access=livehttp{seglen=10,delsegs=true,numsegs=5,index=/path/to/server/directory/playlist.m3u8,index-url=http://178.79.164.114/seg-########.ts},mux=ts{use-key-frames},dst=/path/to/server/directory/seg-########.ts}'

以及播放列表文件的示例:

And an example of the playlist file:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-MEDIA-SEQUENCE:179
#EXTINF:9.60,
http://178.79.164.114/seg-00000179.ts
#EXTINF:9.60,
http://178.79.164.114/seg-00000180.ts
#EXTINF:9.60,
http://178.79.164.114/seg-00000181.ts
#EXTINF:9.61,
http://178.79.164.114/seg-00000182.ts
#EXTINF:9.59,
http://178.79.164.114/seg-00000183.ts

这是 ffprobe http://178.79的奇怪输出。 1 64.114 / playlist.m3u8 (为什么有这些N / A且variant_bitrate为0?)。也许它可以提供帮助:

And here is the strange output of ffprobe http://178.79.164.114/playlist.m3u8 (why there are these N/A and the variant_bitrate is 0?). Maybe it can help:

Input #0, hls,applehttp, from 'http://178.79.164.114/playlist.m3u8':
  Duration: N/A, start: 3995.330722, bitrate: N/A
  Program 0 
    Metadata:
      variant_bitrate : 0
    Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 320x240 [SAR 11:12 DAR 11:9], 25 fps, 25 tbr, 90k tbn, 50 tbc

我还为.m3u8和.ts文件配置了正确的MIME类型,并花了一天的时间搜索并尝试不同的转码命令的选项:宽度,高度,比特率,fps,不同的配置文件和级别...... - 没有任何作用。但如果我尝试苹果的一些例子( http://devimages.apple.com/ iphone / samples / bipbop / bipbopall.m3u8 ) - 一切都很好,虽然它不是直播。

I have also configured correct MIME types for .m3u8 and .ts files and spent a day searching and trying different options for the transcode command: width, height, bitrate, fps, different profiles and levels... - nothing works. But if i try some examples from apple (http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8) - all is fine, though it's not a live stream.

如果有人有任何想法或有可能使用 mediastreamvalidator 测试我的流 - 请帮助。

If anyone has any ideas or has a possibility to test my stream with the mediastreamvalidator - please help.

更新

现在我正在尝试使用变体播放列表,但它什么都没有改变。

Now i'm experimenting with variant playlist but it changes nothing.

推荐答案

播放器可能需要多路复用的视频和音频,因此请添加无声音轨。

The player might expect muxed video and audio so add a silent audio track.

Apple HLS文档说:


媒体段文件通常由流分段器生成,基于来自编码器的输入,由一系列.ts文件组成,包含携带H.264视频 AAC,MP3或AC-3音频的MPEG-2传输流段

The media segment files are normally produced by the stream segmenter, based on input from the encoder, and consist of a series of .ts files containing segments of an MPEG-2 Transport Stream carrying H.264 video and AAC, MP3, or AC-3 audio

技术说明TN2224 和协议的第7版修订版引入了对备用再现(unmuxed streams)的支持,但这是在控制播放的主播放列表中使用 EXT-X-MEDIA 标签完成(您的是媒体播放列表)。

Support for audio-only streams is mentioned in Technical Note TN2224 and the 7th revision of the protocol introduced support for alternate renditions (unmuxed streams) but this is done with EXT-X-MEDIA tags in a master playlist controlling the playback (yours is a media playlist).

这篇关于HLS流无法在Apple设备上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆