前段时间做1078车载终端,实现实时视频播放,为此基于nginx-http-flv-module搭建了RTMP直播服务,使用ffmpeg完成推流,使用flv完成拉流。效果还不错。以下为搭建步骤:
1、Linux安装Nginx前置环境Linux服务器是CentOS7直接执行yum命令安装,如下
安装gcc-c++编译器
yum install gcc-c++
yum install -y openssl openssl-devel
安装pcre,zlib包
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
2、安装Nginx和nginx-http-flv-module提前建立了一个目录/usr/local/mysoft,把都下载好的安装包都放在里面
下载安装包
Nginx-1.18.0: https://nginx.org/download
nginx-http-flv-module: https://github.com/winshining/nginx-http-flv-module
可以自己下载上传到Linux上,也可以直接wget命令下载;以下是已经下载好的安装包
nginx-http-flv-module搭建rtmp服务-Java文档类资源-CSDN下载
解压nginx-http-flv-module
unzip nginx-http-flv-module-1.2.6.zip
再解压nginx并进行安装
执行解压并进入nginx目录
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
依次执行下面三个命令,编译并安装,./configure后面的是一定不要漏了,这就是在nginx里添加http-flv模块。
./configure --add-module=/usr/local/mysoft/nginx-http-flv-module-1.2.6 --with-http_ssl_module
make
make install
等安装完成后,Nginx 会被安装在 /usr/local/nginx下。
可以使用whereis nginx命令进行验证。
3、配置Nginx并启动使用 vi 或其他工具编辑/usr/local/nginx/conf/nginx.conf ,添加和替换掉部分配置,内容如下:
vim /usr/local/nginx/conf/nginx.conf
配置nginx.conf如下
搭建rtmp服务nginx配置-Java文档类资源-CSDN下载
配置完成后在/usr/local/nginx/sbin目录下输入./nginx启动Nginx即可。
以上配置中的端口要注意,是否在Linux有开启防火墙或端口被占用如果有请启用配置中的相关端口
4、客户端用ffmpeg推流,这里用的是在windows下推流D:/Tools/ffmpeg-20200315-c467328-win64-static/bin/ffmpeg.exe -i http://localhost:3333/video/013800138999-2 -vcodec copy -acodec aac -f flv rtmp://47.108.179.133:1935/mlive/013800138999-2
D:/Tools/ffmpeg-20200315-c467328-win64-static/bin/ffmpeg.exe指用ffmpeg命令推流
http://localhost:3333/video/013800138999-2指定推流的原文件流
rtmp://47.108.179.133:1935/mlive/013800138999-2指定推流的服务器IP+端口+模块名+推流唯一标识
5、web拉流flv直播拉流,实时视频播放demo-Javascript文档类资源-CSDN下载
替换其中配置,如下
http://47.108.179.133:80?port=1935&app=mlive&stream=tag
其中对应【服务器IP:拉流端口?port=推流端口&app=推流模块&stream=推流唯一标识】
直接在桌面双击打开multimedia.html,填入推流的唯一标识tag,点播放即可
centos7搭建ftp服务器
手动搭建FTP站点(CentOS 7) - 云服务器 ECS - 阿里云



