`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)