登录站点

用户名

密码

注册

查看日志|返回日志列表

nginx增加rtmp直播流模块

2018-01-26 10:28
增加rtmp模块,可以使nginx具有直播流功能。
1.下载模块并解压
  wget  https://github.com/arut/nginx-rtmp-module/archive/master.zip
  unzip master.zip
2.查看原nginx编译参数并记录
 nginx -V
3.重新编译nginx
   nginx/src 目录下
  ./configure --user=www --group=www --prefix=/www/server/nginx --with-openssl=/www/server/nginx/src/openssl --add-module=/www/server/nginx/src/ngx_cache_purge --with-http_stub_status_module --with-http_ssl_module --with-http_spdy_module --with-http_gzip_static_module --with-http_gunzip_module --with-ipv6 --with-http_sub_module --with-http_flv_module --with-http_addition_module --with-http_realip_module --with-http_mp4_module --with-ld-opt=-Wl,-E --with-ld-opt=-ljemalloc --add-module=/home/temp/nginx-rtmp-module-master 红色部分为新增加模块
make 不再使用mke install 以防止破坏原有的文件
拷贝安装源objs/nginx 到对应目录,并重新启动nginx。
4.修改nginx参数
     rtmp_auto_push on;
   rtmp_auto_push_reconnect 1s;
rtmp {
        server {
                listen 1935;//监听端口
                chunk_size 2048;
                application hls { #主要此名称和文件夹的对应关系
                    hls on;
                    live on;
                    hls_path /www/wwwroot/tv.com/wwwroot/hls;  #hls推流是存放目录 
                    hls_fragment 4s;  
                }
        }
}
5.建立对应的网站,保证直播流的访问,修改对应的配置文件
     location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            add_header Cache-Control no-cache;
      }
6.网页播放测试
  建议使用jwplayer ckplayer 均可以完美支持m3u8的视频格式,移动端及PC端完美支持
分享 1455 次阅读 | 0 个评论

留下脚印

评论