1.nginx安装
(1)克隆github的项目
brew tap denji/nginx
(2)安装nginx+rtmp模块
brew install nginx-full --with-rtmp-module
(3)查看一下nginx的安装信息
brew info nginx-full
2.配置rtmp
(2)修改nginx配置文件
vi /usr/local/etc/nginx/nginx.conf
在http节点后面添加rtmp配置
rtmp {
server {
listen 1935;
application myapp {
live on;
#record keyframes;
#record_path /tmp;
#record_max_size 128K;
#record_interval 30s;
#record_suffix .this.is.flv;
#on_publish http://localhost:8080/publish;
#on_play http://localhost:8080/play;
#on_record_done http://localhost:8080/record_done;
}
application hls {
live on;
hls on;
hls_path /tmp/app;
hls_fragment 5s;
}
}
}
(2)启动nginx
/usr/local/opt/nginx-full/bin/nginx
3.查询rtmp和nginx是否启动
-
浏览器中输入http://localhost:8080/
-
查看rtmp端口是否启动
netstat -an |grep 1935
4.直播测试
(1)安装ffmpeg
mac安装流程如下:
https://blog.csdn.net/fy_java1995/article/details/98756903
(2)通过ffmpeg进行推流
ffmpeg -re -i /Users/apple/workspace//bgm/test.mp4 -vcodec libx264 -acodec aac -f flv rtmp://127.0.0.1:1935/myapp/room1
myapp和nginx中的配置一样即可
room1随便定义即可
(3)测试
打开vlc播放器,输入该路径
这样就能看到通过ffmpeg推过来的视频了