ubutun18.0.4 + opencv获取rtsp流推流到rtmp

因为要将处理过的图片串成rtmp码流,因此,需要搭建一个rtmp服务器,常用的方案是Nginx服务器。

1.安装nginx

安装依赖

sudo apt-get update
sudo apt-get install openssl libssl-dev
sudo apt-get install libpcre3 libpcre3-dev

编译源码

下载nginxnginx-rtmp-module

  1. 安装nginx
    注意一定要加上 --add-module=…/nginx-rtmp-module
cd nginx-1.8.1
./configure --add-module=../nginx-rtmp-module
make
make install

经过上述默认配置安装后,nginx目录如下

nginx安装目录 /usr/local/nginx
nginx配置目录 /usr/local/nginx/conf/nginx.conf
nginx运行目录 /usr/local/nginx/sbin/nginx --options`
启动nginx

进入安装目录/usr/local/nginx,运行以下命令
./sbin/nginx

重启nginx

/usr/local/nginx/sbin/nginx -s reload

nginx.conf
#user  nobody;
worker_processes  1;

error_log  logs/error.log;
error_log  logs/error.log  notice;
error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    server {
        listen       8888;

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /opt/soft/services/nginx/nginx-rtmp-module/;
        }

   }

}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;
        application vod {
            play /opt/soft/services/nginx/vedio/;#点播媒体存放目录
        }
        application live {
            live on;
        }
    }
}
查看网页效果

http://ip:port/stat


用ffmpeg推流

  1. 推本地视频到rtmp
ffmpeg -re -i D:/ai/data/beijingjiaotonguniversity/2.mp4 -c copy -f flv rtmp://144.34.165.106/live/streamName
  1. 推本地摄像头到rtmp
ffmpeg -f dshow -i video="Integrated Camera" -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://144.34.165.106/live/streamName

猜你喜欢

转载自blog.csdn.net/qq122716072/article/details/108959687