-
-
- 首先確保你的電腦是否安裝了Homebrew
-
man brew
- 如果出現以下頁面說明已經安裝直接輸入 Q 退出,然后執行第一步

-
- 如果沒有安裝,則在終端輸入以下命令安裝
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果安裝了想卸載,則輸入以下命令:ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
- 第一步 先clone nginx項目到本地
brew tap homebrew/nginx
- 如果沒有安裝,則在終端輸入以下命令安裝
- 第二步 安裝
brew install nginx-full --with-rtmp-module
- 第三步,在終端輸入
nginx
- 第四步,打開瀏覽器打開http://localhost:8080 如果出現以下所示,那么環境就搭建好了
- 第五步,在終端輸入
brew info nginx-full
- 第六步,在終端 Command+F 搜索nginx.conf
- 第七步,進入該路徑,以文本編輯形式打開配置文件,直接在最后面插入以下代碼
rtmp { server { listen 1935; application rtmplive { live on; record off; } } }
- 第八步,查看nginx版本號,在終端輸入:
nginx -v
demo
- 第九步,重啟ngix,把版本號替換成你電腦的nginx的版本號
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx -s reload
- 下載VLC客戶端
將視頻推流到服務器后,打開VLC,然后File->open network->輸入:
rtmp://192.168.1.105:1935/rtmplive/room (192.168.1.105為本機IP地址)
![]()
在XLPlayLiveViewContorller類中找到一下代碼,替換本機IP就可以測試直播效果了

項目下載地址:https://github.com/XLAccount/MiaoBo
ffmpeg推流播放本地視頻命令行代碼:(更多ffmep命令行操作請訪問:http://www.code4app.com/blog-843201-336.html)
ffmpeg -re -i /Users/mac/Desktop/video.mp4 -vcodec libx264 -acodec aac -strict -2 -f flv rtmp://192.168.1.105:1935/rtmplive/room
(/Users/mac/Desktop/video.mp4為視頻路徑,192.168.1.105為本機IP地址)