该文章参考地址
1、安装nginx
采用以下方法。因为稍后下面会对nginx添加rtmp模块,然后需要重新编译,所以就不能yum安装了。。。
wget http://nginx.org/download/nginx-1.16.1.tar.gz
解压:
tar -zxvf nginx-1.16.1.tar.gz
2、下载rtmp模块
git clone https://github.com/arut/nginx-rtmp-module
3、添加模块
./configure --prefix=/opt/nginx --with-stream --with-http_ssl_module --with-stream_ssl_module --with-debug --add-module=../nginx-rtmp-module
报错:
解决: 参考地址
yum -y install pcre-devel
报错:
配置文件nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
access_log logs/rtmp_access.log;
application rtmp {
live on;
}
application vod {
play /opt/media/video;
}
application mypush {
live on;
push rtmp://192.168.44.78/live;
}
}
}
http {...
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /opt/nginx-rtmp-module/;
}
...}
重启nginx
cd /opt/nginx/sbin
./nginx -s reload
打开页面 http://192.168.44.78/stat
测试点播
推流
ffmpeg -re -i test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://localhost:1935/live/home
拉流:
下载播放器工具 VLC media player
打开播放器左上角菜单【媒体】/【打开网络串流】,填写地址,点击播放
注意:需要先拉流,在推流。