前置:需要自己開發音視頻直播,
注意不是實時音視頻,不是一對一視頻聊天,不是視頻會議
方案有 srs ,nginx-rtmp,live555,node-media-server,EasyDarwin等
今天是說 nginx-rtmp 怎么用,我是在寶塔上使用
nginx-http-flv-module 這個是新的
下面是老版本
1,先安裝環境安裝nginx
先卸載原有nigix
cd /www/server # 進入寶塔目錄
git clone https://gitee.com/chooosky/nginx-rtmp-module.git
使用源碼安裝nigix
在 自定義模塊 區域點擊「添加」,填寫以下參數:
模塊名稱:nginx_rtmp_module
描述:nginx rtmp
參數:--add-module=/www/server/nginx-rtmp-module記得啟動,后安裝
2,修改配置
創建文件 /www/server/nginx/conf/rtmp.conf
rtmp {server {listen 1935; # RTMP 默認端口 chunk_size 4000; # 數據分塊大小application live {live on; # 開啟直播allow publish all; # 允許所有推流 allow play all; # 允許所有播放 }application hls {live on;hls on; # 啟用 HLS 切片 hls_path /www/wwwroot/your_domain/hls; # HLS 切片存儲路徑 hls_fragment 5s; # 切片時長}}
}打開 /www/server/nginx/conf/nginx.conf
引入配置文件 include rtmp.conf;
3,進行推流實驗
寶塔和服務器都放行,1935端口
推流工具(OBS)設置:
服務器地址:rtmp://你的服務器IP:1935/live
流密鑰:自定義(如 test)912。
播放測試:
RTMP 協議:rtmp://服務器IP:1935/live/test播放正常