Live m3u8播放3个文件自动停止问题
2013-07-17 10:44
609 查看
Live m3u8播放3个文件自动停止问题
1.问题描述
最近做一个转码切片播放测试,使用HLS(HTTP Live Streaming)来做直播, 每个TS分片时间为10s,根据TS分片文件生成以下
live m3u8文件
#EXTM3U #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-TARGETDURATION:10 #EXTINF:10 hls/1.ts #EXTINF:10 hls/2.ts #EXTINF:10 hls/3.ts #EXTINF:10 hls/4.ts #EXTINF:10 hls/5.ts #EXTINF:10 hls/6.ts #EXTINF:10 hls/7.ts #EXTINF:10 hls/8.ts #EXTINF:10 hls/9.ts #EXTINF:10 hls/10.ts
将上述
m3u8文件保存为
live.m3u8,放到
Apache文档目录下,用
VLC播放以下网址:
http://localhost/live.m3u8
测试发现,开始播放的第一个文件不是1.ts,多次测试后发现:
[code]只要列表中的文件超过三个,播放的总是列表中的最后三个文件[/code]
2.问题解决
很悲惨的是,上网搜索后,没有找到任何有效的信息,有个哥们遇到同样的情况,解决后有没有将经验分享出来。向一位同事请教后,同事说,这是有可能的,因为
live m3u8文件列表是需要实时更新的,我们做测试的话,可以先在最后面加上
#EXT-X-ENDLIST,这个方法经测试有效,但这样已经不是
live m3u8模式
再次上网搜索后,确认,终于找到一篇
live m3u8说明
Live Playlist (Sliding Window)
For live sessions, the index file is updated by removing media URIs from the file as new media files are created and made available.Important: The
EXT-X-ENDLISTtag is not present in the Live playlist, indicating that new media files will be added to the index file as they become available.
See Listing 3 for an example live playlist as it would appear at the beginning of a session.
Listing 3 Live Playlist at the beginning of a session.
#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:1 #EXTINF:10, fileSequence1.ts #EXTINF:10, fileSequence2.ts #EXTINF:10, fileSequence3.ts #EXTINF:10, fileSequence4.ts #EXTINF:10, fileSequence5.ts
The
EXT-X-MEDIA-SEQUENCEtag value MUST be incremented by 1 for every media URI that is removed from the playlist file. Media URIs must be removed from the playlist file in the order that they appear in the playlist. The updated index file presents a moving window into a continuous stream. This type of session is suitable for continuous broadcasts.
Here's the same playlist after it has been updated with new media URIs:
Listing 4 Live Playlist after updating the media URIs.
#EXTM3U #EXT-X-TARGETDURATION:10 #EXT-X-VERSION:3 #EXT-X-MEDIA-SEQUENCE:2 #EXTINF:10, fileSequence2.ts #EXTINF:10, fileSequence3.ts #EXTINF:10, fileSequence4.ts #EXTINF:10, fileSequence5.ts #EXTINF:10, fileSequence6.ts
3.live m3u8
更新规则
live m3u8文件列表需要不断更新,更新规则:
移除一个文件播放列表中靠前的(认为已播放的)文件
不断更新
EXT-X-MEDIA-SEQUENCE标签,以步长为1进行递增
4.实验
写了一个生成live m3u8的小程序,进行测试Usage: m3u8_gen.exe start_num list_count duration filename.m3u8 [prefix]
使用示例:
m3u8_gen.exe 1 3 10 live.m3u8 hls/
生成
live.m3u8文件为
#EXTM3U #EXT-X-MEDIA-SEQUENCE:1 #EXT-X-TARGETDURATION:10 #EXTINF:10 hls/1.ts #EXTINF:10 hls/2.ts #EXTINF:10 hls/3.ts
写一个BAT脚本,每
10s循环更新
live.m3u8文件
@echo off for /l %%i in (1,1,420) do ( echo m3u8_gen.exe %%i 3 10 live.m3u8 hls/ m3u8_gen.exe %%i 3 10 live.m3u8 hls/ call :SLEEP 10000 ) ::延时函数实现 :SLEEP ping 192.168.11.1 -n 1 -w %1 > nul
经VLC播放测试正常!!
相关文章推荐
- Flash加载一直在更新的资源的缓存问题,比如 在hls(HTTP Live Streaming)获取m3u8的文件
- android 逐帧动画自动播放以及逐帧动画与渐变动画结合的停止问题
- 流媒体技术学习笔记之(四)解决问题video.js 播放m3u8格式的文件,根据官方的文档添加videojs-contrib-hls也不行的原因解决了
- 安卓分享音乐文件后点击可自动播放的问题
- 流媒体测试笔记记录之————解决问题video.js 播放m3u8格式的文件,根据官方的文档添加videojs-contrib-hls也不行的原因解决了
- iOS AVPlayer 后台播放问题自动停止问题 防止应用被后台挂起方法
- R.java文件无法自动生成的问题
- web项目中js文件修改后不能自动编译的问题
- 当上传文件的时候自动过滤掉其他格式的文件(ie8 ie9问题待解决)
- 锁屏后会自动唤醒并播放----遇到的问题及解决方案
- 【Xcode 5】 资源文件更新后不自动复制的问题
- 网页无法播放flv文件,服务器也无法下载,提示找不到文件的问题
- tomca配置文件自动还原问题的解决 server.xml content.xml 等
- IE6下页面gif图片停止播放的问题
- iphone 微信打开H5自动播放音乐问题
- Android 离线播放 (HLS)m3u8文件
- android JNI调用百度地图API,.so文件总是被自动删除的问题
- eclipse 不自动编译java文件的问题.
- Realplayer在Fedora中播放rmvb和rm文件比较卡的问题
- ssh上传带中文的视频文件不能播放的问题