Github 專案地址:https://github.com/MichaelHuyp/Bilibili_Wuxianda


手機端推流之後,電腦要怎麼看?最簡單的組合是 nginx + RTMP 模組做伺服器,再用 VLC 拉流。
man brew
如果沒有安裝,在終端機執行官方安裝指令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew tap homebrew/nginx
brew install nginx-full --with-rtmp-module
nginx
接著開啟瀏覽器訪問 https://localhost:8080,如果看到 nginx 的歡迎頁,代表環境沒問題。

brew info nginx-full
在終端機按 Command + F 搜尋 nginx.conf,取得設定檔路徑。

進入該路徑,用純文字編輯器打開 nginx.conf,在檔案最後插入:
rtmp {
server {
listen 1935;
application rtmplive {
live on;
record off;
}
}
}


nginx -v

重啟 nginx 時,把路徑中的版本號換成你電腦實際的版本號:
/usr/local/Cellar/nginx-full/1.10.1/bin/nginx -s reload
先下載並安裝 VLC 客戶端。

打開專案,找到 YPPhoneLiveViewController.m,把推流地址中的 IP 換成你電腦的區域網路 IP。

執行專案,進入個人頁點擊「我要直播」→「開始直播」,然後在 VLC 中選擇 File → Open Network,輸入:
rtmp://你的IP:1935/rtmplive/room


如果一切順利,VLC 裡就會出現手機推送的即時畫面。








這個專案還沒寫完,仍有大量功能點排隊等著實作,會持續更新。