centos配置nginx-rtmp实现ffmpeg转码rtsp为rtmp视频流

简介: centos配置nginx-rtmp实现ffmpeg转码rtsp为rtmp视频流

服务器安装的环境是centos7.8+lnmp1.18

  1. 安装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
  1. 安装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
  1. 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
  1. 拷贝nginx-rtmp(将附件拷贝到 /usr/local/src目录下


    nginx-rtmp-module.zip


  1. 安装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
  1. 配置nginx.conf

# 在http节点后面加上rtmp配置:

rtmp {
    server {
        listen 1935;
        application rtmplive {
            live on;
            record off;
        }
    }
}
  1. 重启nginx(经测试service nginx reload无效,需要lnmp restart或者重启服务器)


  1. 安装结束,来试试吧


查看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
目录
相关文章
|
17天前
|
人工智能 JavaScript 前端开发
实战使用 Qwen3-coder 低代码开发 HTML 个人网站
阿里巴巴开源的Qwen3-coder模型,凭借强大性能和低代码能力,助力用户快速搭建个人网站。本文详解环境配置、提示词设计与部署流程,适合编程新手快速上手,掌握AI辅助开发技能。
1136 8