服务器安装的环境是centos7.8+lnmp1.18
- 安装yasm扩展
wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar zxvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure make && make install
- 安装ffmpeg(如果提示./configure没有权限,执行 chmod u+x ./configure)
https://ffmpeg.org/releases/ffmpeg-4.4.tar.xz tar -xvf ffmpeg-4.4.tar.xz cd ffmpeg ./configure make && make install
- nginx安装
[root~]# wget http://nginx.org/download/nginx-1.10.3.tar.gz [root~]# tar -zxvf nginx-1.10.3.tar.gz [root~]# cd nginx-1.10.3
//添加rtmp和openssl支持
[root~]# ./configure --add-module=/usr/local/src/nginx-rtmp-module-master --with-http_ssl_module [root~]# make && make install
- 拷贝nginx-rtmp(将附件拷贝到 /usr/local/src目录下)
- 安装nginx支持
- //如果已经安装
- 1.查看当前安装的Nginx版本
nginx -v
- 查询结果:nginx version: nginx/1.18
- 2.cd到查询到的源目录
cd /root/nginx-1.18
- 3.添加rtmp的支持(如果看到一个绿色的 configure 文件就说明查找对了)
./configure --add-module=/usr/local/src/nginx-rtmp-module make && make install
- 重启nginx报错:Reload nginx... nginx: [emerg] unknown directive "stub_status" in /usr/local/nginx/conf/nginx.conf:86
- 解决方案:
./configure --prefix=/usr/local/nginx --with-http_stub_status_module
- 如果报错Reload nginx... nginx: [emerg] the "ssl" parameter requires ngx_http_ssl_module in /usr/local/nginx/conf/vhost/www.cn_.conf
./configure --add-module=/usr/local/src/nginx-rtmp-module --with-http_stub_status_module --with-http_ssl_module
- 然后
make && make install
- 配置nginx.conf
# 在http节点后面加上rtmp配置:
rtmp { server { listen 1935; application rtmplive { live on; record off; } } }
- 重启nginx(经测试service nginx reload无效,需要lnmp restart或者重启服务器)
- 安装结束,来试试吧
查看1935端口是否监听
netstat -ntlp semanage port -l | grep 1935
测试转码:
1、本地视频
ffmpeg -re -i 2.mp4 -f flv rtmp://127.0.0.1:1935/rtmplive/
2、线上rtsp资源
nohup ffmpeg -f rtsp -rtsp_transport tcp -i 'rtsp://192.168.0.108:554/cam/realmonitor' -acodec copy -f flv -an 'rtmp://127.0.0.1:1935/rtmplive' > /tmp/test1.log 2>&1