nginx搭建支持http和rtmp协议的流媒体服务器之三

四、配置Nginx,实现VOD,以RTMP方式播放FLV
1. 设置configure,nginx的补充编译,增加FLV和MP4功能。
# cd cd nginx-1.6.0 
# vim nginx_configure.sh
#!/bin/sh

echo "configure start ..."
./configure --prefix=/opt/nginx \
--add-module=../nginx_mod_h264_streaming-2.2.7 \
--with-http_flv_module \
--with-http_ssl_module \
--with-http_mp4_module \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-pcre=/opt/nginx_http_rtmp/pcre-8.12 \
--with-zlib=/opt/nginx_http_rtmp/soft_source/zlib-1.2.8 \
--user=www --group=www \
--add-module=../nginx-rtmp-module \
--with-cc-opt=-I/opt/ffmpeg/include \
--with-ld-opt=`-L/opt/ffmpeg/lib -Wl, -rpath=/opt/ffmpeg/lib`
echo "configure end!"
【保存并退出】
# chmod +x nginx_configure.sh
# ./nginx_configure.sh
# make && make install

http_flv_module和http_mp4_module即为对应的解析和seek功能支持。

2. 修改 conf/nginx.conf配置
# vim conf/nginx.conf
... 
worker_rlimit_nofile 51200;
events
{
  use epoll;
  worker_connections  51200;
}

# RTMP点播的配置
rtmp {
  server {
    listen 1935;
    chunk_size 4000;
    application vod {
      play /opt/pub/media/nginx/web/vod;  #点播媒体文件存放目录
    }
  }
}

http
{
  ... 
  # 配置RTMP虚拟机
  # VOD for FLV by RTMP
  server
  {
    listen 8080;
    location /stat
    {
      rtmp_stat all;
      rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl
    {
      root /opt/nginx_http_rtmp/nginx-rtmp-module/;   #在nginx-rtmp-module源码根目录
    }
  }
}

3. 启动Nginx
# /opt/nginx/sbin/nginx

4. 创建嵌入播放器的HTML页面
# cd /opt/pub/media/nginx/web
# vim rtmp_player.html
<html>
  <head>
    <script src="/smzy_jwplayer_v6.6/jwplayer.js"></script>
  </head>

<body>
  <div id='my-video'></div>
  <script type='text/javascript'>
    jwplayer('my-video').setup({
      file:'rtmp://192.168.1.10/vod/video.flv',    
      width:'50%',
      aspectratio:'3:2',
      fallback:'false',
      primary:'flash'  
    });
  </script>
</body>
</html>
【保存并退出】

5. 测试
在浏览器输入栏中输入:
http://192.168.1.10/rtmp_player.html 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

北雨南萍

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值