本地已安装好ffmpeg
以下操作是在Centos7系统下:
1.安装git(为了方便下载git文件)
yum install git
2.下载nginx-rtmp-module
git clone https://github.com/arut/nginx-rtmp-module.git
3.下载nginx
wget http://nginx.org/download/nginx-1.12.1.tar.gz
4.解压nginx,进入nginx目录下,进行配置并安装
tar -zxvf nginx-1.12.1.tar.gz
cd nginx-1.12.1
./configure --add-module=/路径/nginx-rtmp-module
make
make install
5.配置nginx.conf
...
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
}
}
}
http {
...
server {
listen 8080;
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
root /路径/nginx-rtmp-module;
}
}
...
}
6.重启nginx
浏览器监听直播状态访问地址:http://192.168.0.156:8080/stat
推流地址:ffmpeg -i test.mp4 -f flv rtmp://192.168.0.156/live
播放地址:rtmp://192.168.0.156/live