HTTP Live Streaming for iPhone/iPad(HLS流媒体服务器)

最近研究了一下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: 视频文件编码
[c-sharp:nogutter] view plain copy
  1. configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libx264  
Step3: 下载和编译Segmenter http://svn.assembla.com/svn/legend/segmenter/ 需要修改一下Makefile
[c-sharp:nogutter] view plain copy
  1. all:  
  2.         gcc -Wall -g segmenter.c -o segmenter -lavformat -lavcodec -lavutil -lbz2 -lm -lz -lfaac -lmp3lame -lx264 -lfaad  
  3.   
  4. clean:  
  5.         rm segmenter  
使用:
[c-sharp:nogutter] view plain copy
  1. segmenter <input MPEG-TS file> <segment duration in seconds> <output MPEG-TS file prefix> <output m3u8 index file> <http prefix>  
例如: segmenter sample_low.ts 10 sample_low stream_low.m3u8 http://www.ioncannon.net/ Step4:搭建HTTP Server 以Tomcat为例,修改conf/web.xml文件,增加
[c-sharp] view plain copy
  1. <mime-mapping>  
  2.     <extension>m3u</extension>  
  3.     <mime-type>audio/x-mpegurl</mime-type>  
  4. </mime-mapping>  
  5. <mime-mapping>  
  6.     <extension>m3u8</extension>  
  7.     <mime-type>application/x-mpegurl</mime-type>  
  8. </mime-mapping>  
  9. <mime-mapping>  
  10.     <extension>ts</extension>  
  11.     <mime-type>video/MP2T</mime-type>  
  12. </mime-mapping>  
指定.m3u8和.ts的MIME类型 .m3u8 application/x-mpegURL .ts video/MP2T Step5: 测试流媒体服务器 a)用iPhone的Safari浏览器,注意访问的地址是服务器上以.m3u8后缀的文件 b)用支持html5的浏览器,我还没有试验
[c-sharp] view plain copy
  1. <html>  
  2.   <head>  
  3.     <title>Video Test</title>  
  4.     <meta name="viewport" content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>  
  5.   </head>  
  6.   <body style="background-color:#FFFFFF; " mce_style="background-color:#FFFFFF; ">  
  7.     <center>  
  8.       <video width='150' height='150' src="stream-128k.m3u8" mce_src="stream-128k.m3u8" />  
  9.     </center>  
  10.   </body>  
  11. </html>  
这样在iPhone上就可以播放流媒体了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值