1.Mac環境下直播服務器搭建
2.rtmp推流
3.ijkplayer拉流
4.linux服務器搭建
1.Mac環境下直播服務器搭建
2.rtmp推流
3.ijkplayer拉流
4.linux服務器搭建
1.lamp服務器搭建 參考文章 (部分庫文件不全,編譯報錯安裝一下。)
2.nginx 添加rtmp模塊 參考文章
3.nginx 重新編譯添加模塊 參考文章
重編譯配置
--with-openssl=/lnmp/src/openssl-1.1.0b --with-pcre=/lnmp/src/pcre-8.39
路徑要換成自己服務器文件路徑
./configure --prefix=/usr/local/nginx --without-http_memcached_module --user=www --group=www --with-http_stub_status_module --with-openssl=/lnmp/src/openssl-1.1.0b --with-pcre=/lnmp/src/pcre-8.39 --with-http_ssl_module --add-module=../nginx-rtmp-module-master
make
推流地址 :
stream153 是直播間號 實際項目中每個主播分配一個唯一的直播間號
rtmp://www.chaisz.xyz:1935/live/stream153
LFKit 推流
LFKit git地址:https://github.com/LaiFengiOS/LFLiveKit
下載后 Demo 打開(先 pod install)
修改以下代碼
rtmp://www.chaisz.xyz:1935/live/stream153
屏幕快照 2017-07-25 上午12.12.27.png
然后真機測試開始直播(可用VLC播放器播放直播)
屏幕快照 2017-07-25 上午12.17.44.png
Ijkplayer拉流
新建項目,導入ijkplayer庫
屏幕快照 2017-07-25 上午12.38.40.png
SRS直播服務器搭建
推流地址:rtmp://www.chaisz.xyz/live/livestream
拉流地址:
rtmp: rtmp://www.chaisz.xyz/live/livestream1
hls: http://www.chaisz.xyz:8080/live/livestream1.m3u8
http-flv: http://www.chaisz.xyz:8080/live/livestream1.flv
電腦版推流 OBS使用
主要設置以下兩個地方就可以直播屏幕了。
屏幕快照 2017-07-31 下午5.39.12.png
屏幕快照 2017-07-31 下午5.40.42.png
點擊開始串流
屏幕快照 2017-07-31 下午5.45.22.png
直播身份認證
配置
http_hooks {
enabled on;
on_connect http://www.chaisz.xyz/srstest/clients.php;
on_close http://www.chaisz.xyz/srstest/clients.php;
on_publish http://www.chaisz.xyz/srstest/streams.php;
on_unpublish http://www.chaisz.xyz/srstest/streams.php;
on_play http://www.chaisz.xyz/srstest/sessions.php;
on_stop http://www.chaisz.xyz/srstest/sessions.php;
}
不支持https
obs 推流設置
屏幕快照 2017-08-04 上午5.04.28.png
推流地址:rtmp://www.chaisz.xyz/live?user=feiyu&pwd=123456/livestream
地址?參數/room
srs.conf配置
# main config for srs.
# @see full.conf for detail config.
listen 1935;
max_connections 1000;
srs_log_tank file;
srs_log_file ./objs/srs.log;
http_api {
enabled on;
listen 1985;
}
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
}
stats {
network 0;
disk sda sdb xvda xvdb;
}
vhost __defaultVhost__ {
#最小延遲打開,默認是打開的,該選項打開的時候,mr默認關閉。
min_latency on;
#Merged-Read,針對RTMP協議,為了提高性能,SRS對于上行的read使用merged-read,
即SRS在讀寫時一次讀取N毫秒的數據
mr {
enabled off;
#默認350ms,范圍[300-2000]
#latency 350;
}
#Merged-Write,SRS永遠使用Merged-Write,即一次發送N毫秒的包給客戶端。這個算法
可以將RTMP下行的效率提升5倍左右,范圍[350-1800]
mw_latency 100;
#enabled on;
#https://github.com/simple-rtmp-server/srs/wiki/v2_CN_LowLatency#gop-cache
gop_cache off;
#配置直播隊列的長度,服務器會將數據放在直播隊列中,如果超過這個長度就清空到>最后一個I幀
#https://github.com/simple-rtmp-server/srs/wiki/v2_CN_LowLatency#%E7%B4%AF%E7%A7%AF%E5%BB%B6%E8%BF%9F
queue_length 10;
#http_flv配置
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
hstrs on;
}
hls {
enabled on;
hls_path ./objs/nginx/html;
hls_fragment 10;
hls_window 60;
}
http_hooks {
enabled on;
on_connect http://www.chaisz.xyz/srstest/clients.php;
on_close http://www.chaisz.xyz/srstest/clients.php;
on_publish http://www.chaisz.xyz/srstest/streams.php;
on_unpublish http://www.chaisz.xyz/srstest/streams.php;
on_play http://www.chaisz.xyz/srstest/sessions.php;
on_stop http://www.chaisz.xyz/srstest/sessions.php;
}
}