`brew tap denji/nginx`
*****
~~~
brew install nginx-full --with-rtmp-module
~~~
*****
`nginx` 测试是否正确安装
*****
配置rtmp 修改配置文件:
```
rtmp {
server {
listen 1935;
#直播流配置
application rtmplive {
live on;
#为 rtmp 引擎设置最大连接数。默认为 off
max_connections 1024;
}
application hls{
live on;
hls on;
hls_path /usr/local/var/www/hls;
hls_fragment 1s;
}
}
}
```
*****
`nginx -s reload`
*****
`brew install ffmpeg`
*****
ffmpeg推流 准备一个视频文件来推流,再安装一个流媒体视频播放器。Mac下可以使用VLC. 修改以下代码视频路径,进行推流。注意修改视频地址
`ffmpeg -re -i /Users/xushuduo/Desktop/test.mp4 -vcodec libx264 -acodec aac -strict -2 -f flv rtmp://localhost:1935/rtmplive/room`
*****
将视频推流到服务器后,打开VLC,然后file->open network->输入:
`rtmp://localhost:1935/rtmplive/room`
*****
Refs:
[https://www.jianshu.com/p/cf74a34af15d](https://www.jianshu.com/p/cf74a34af15d)