1、先安裝homeView
安裝指令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
移除指令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
2、安裝Nginx伺服器
增加對 nginx 的擴充;也就是從github上下載下傳,home-brew對ngixnx的擴充
brew tap homebrew/nginx
3、安裝Nginx伺服器和rtmp子產品,安裝過程有點久。稍等。
brew install nginx-full --with-rtmp-module
4、檢視nginx的資訊
brew info nginx-full
nginx的安裝位置
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx
nginx配置檔案所在位置
/usr/local/etc/nginx/nginx.conf
nginx伺服器根目錄所在位置
/usr/local/var/www
使用指令開啟nginx:
nginx
在浏覽器位址欄輸入:
http://localhost:8080(直接點選)
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZlBnauUTMiBjZ3ATZ0YmNzMjM5UTMiBjMmRWOiRDOzMjYldDMfdWbp9CXt92Yu4GZjlGbh5SZslmZxl3Lc9CX6MHc0RHaiojIsJye.jpeg)
圖1.jpg
5、配置rtmp
open /usr/local/etc/nginx
打開niginx的檔案夾,找到nginx.conf檔案,用xcode打開。添加下面配置
#在http節點下面(也就是檔案的尾部)加上rtmp配置:
rtmp {#協定名稱
server {#說明内部中是伺服器相關配置
listen 12345;#監聽的端口号, rtmp協定的預設端口号是1935
application zbcs {#通路的應用路徑是 zbcs
live on; #開啟實時
record off;#不記錄資料
}
}
}
圖2.jpg
6、 儲存檔案後,重新加載nginx的配置檔案。
重要操作!一定要重新開機nginx
nginx -s reload
7、 安裝ffmepg工具
brew install ffmpeg
8、推流
ffmpeg -re -i /Users/mazaiting/Downloads/撞球.mp4 -vcodec copy -f flv rtmp://localhost:12345/zbcs/room
其中abcs是配置檔案中的應用名,12345是配置檔案中的端口,room可以随便寫,"/Users/mazaiting/Downloads/撞球.mp4"是推流的視訊。
9、觀看
使用軟體
VLC MediaPlayer打開網絡串流,Open Media...->Network,輸入
rtmp://localhost:12345/zbcs/room
,點選Open進行觀看。
圖3.jpg