一、前言
實時視頻直播是這兩年非常火的技術形態,已經滲透到教育、在線互娛等各種業務場景中。但要搭建一套實時視頻直播系統,並非易事,下面針對直播系統的的搭建做一下說明:
1.1 通常的直播系統的技術模型圖:
1.2 一個簡易的直播系統,大致可以由三部分組成:
1.搭建一個rtmp媒體服務器;
2.推流端;
3.拉流端。
1.3 現在目標是快速搭建起來,所以當然是借助開源項目和一些軟件:
1.rtmp媒體服務器:推薦使用srs和nginx;
2.推流端:這里使用obs;
3.拉流端:這里使用播放器vlc。
二、SRS 流媒體服務器的搭建
2.1 搭建過程
1.基於Mac操作系統,使用SRS作為流媒體服務器:https://github.com/ossrs/srs。
2.首先clone到本地,進入到trunk目錄:
git clone [url=https://github.com/ossrs/srs.git]https://github.com/ossrs/srs.git[/url]
cd srs/trunk
3.然后執行:
./configure —osx
注意: Centos6.x/Ubuntu12 32/64bits用戶僅需要執行./configure。
4.最后執行:
make
5.執行成功后,就可以開啟我們的服務了:
./etc/init.d/srs start
因為是mac系統,此時會失敗,原因是srs.conf中max_connections太大,目錄為srs/trunk/conf/srs.conf,可以修改為248(其他操作系統可能無此問題)。
再次回到trunk目錄:
./etc/init.d/srs start
到此我們的srs服務器就搭建起來了。
補充說明:Centos、Ubuntu可以參考官網搭建,比較簡單。
6.如果你啟動過程中還遇到了其他錯誤,可以查看log信息:
srs/trunk/objs/srs.log
2.2 指令整理
開始 ./etc/init.d/srs start
停止 ./etc/init.d/srs stop
重啟 ./etc/init.d/srs restart
2.3 測試服務器
可以使用 rtmp://127.0.0.1/rh/mylive 地址進行直播測試,推流和拉流都可以使用。
三、工具和資料
推薦推流工具
使用OBS推流:https://obsproject.com
使用yasea推流:https://github.com/begeekmyfriend/yasea
使用ffmpeg推流:https://github.com/WritingMinds/ffmpeg-android-java
推薦拉流工具:
使用VLC拉流:http://www.videolan.org/vlc/
參考資料
https://www.cnblogs.com/zhujiabin/p/6812877.html
http://www.52im.net/thread-1154-1-1.html
https://github.com/WritingMinds/ffmpeg-android-java
https://github.com/ossrs/srs
http://blog.csdn.net/ManagerUser/article/details/73840130
https://blog.csdn.net/zjuwwj/article/details/72773704
