最近研究了一下Http Live Streaming机制,顺便搭建了一个测试环境。
参考:http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/comment-page-1/
Step 1: 编译ffmpeg
这个就不多讲了,先要编译facc和x264
a)编译faac和faad
b)编译x264
c)编译ffmpeg
configure --enable-gpl --enable-nonfree --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264
Step2: 视频文件编码
Step3: 下载和编译Segmenter
http://svn.assembla.com/svn/legend/segmenter/
需要修改一下Makefile
使用:
例如:
segmenter sample_low.ts 10 sample_low stream_low.m3u8 http://www.ioncannon.net/
Step4:搭建HTTP Server
以Tomcat为例,修改conf/web.xml文件,增加
指定.m3u8和.ts的MIME类型
.m3u8 application/x-mpegURL
.ts video/MP2T
Step5: 测试流媒体服务器
a)用iPhone的Safari浏览器,注意访问的地址是服务器上以.m3u8后缀的文件
b)用支持html5的浏览器,我还没有试验
这样在iPhone上就可以播放流媒体了。