nginx_rtmp_module初体验

来源:互联网 发布:网络存储工程师 编辑:程序博客网 时间:2024/04/30 13:20

编译安装

  1. git clone https://github.com/arut/nginx-rtmp-module.git
  2. 设nginx_rtmp_module文件目录为path,在nginx编译步骤中的configure中添加参数 –add-module=path;
  3. 编译nginx

配置

打开nginx文件,添加如下配置信息:

 rtmp{      server{          listen 1935;          chunk_size 4096;          application test{              live on;          }      } }

测试

1. 启动nginx
2. 利用ffmpeg推流,命令如下:

ffmpeg -re -i test.mp4 -c copy -f flv rtmp://192.168.103.171/test/sxc

3. 利用ffpaly观看视频。

ffplay rtmp://192.168.103.171/test/sxc

备注

在利用ffmpeg推流时提示如下错误:

[tcp @ 0x7f98dc7003c0] Connection to tcp://192.168.103.171:1935 failed: Connection refused[rtmp @ 0x7f98dc50dae0] Cannot open connection tcp://192.168.103.171:1935rtmp://192.168.103.171/test/sxc: Connection refused

直接利用telnet命令也无法连接1935端口,与当初首次安装nginx时无法连接80端口类似,猜想是由于centos的防火墙引起的。
解决办法:
1. vim /etc/sysconfig/iptables
2. 在-A INPUT -j REJECT –reject-with icmp-host-prohibited的上面添加*-A INPUT -p tcp -m tcp –dport 1935 -j ACCEPT
3. service iptables restart
4. 再次利用telnet连接80端口,成功。

0 0
原创粉丝点击