目錄:
RTMP(一)錄屏直播理論入門
RTMP(二)搭建推流服務(wù)
RTMP (三)音視頻采集與數(shù)據(jù)封包
RTMP(四)交叉編譯與CameraX
RTMP (五)攝像頭數(shù)據(jù)處理
RTMP (六)音視頻編碼推流
mac + nginx + rtmp 模塊
brew tap denji/nginx
brew install nginx-full --with-rtmp-module
配置
接下來(lái)配置config掌猛,在 /usr/local/etc/nginx 下的nginx.conf
添加rtmp
rtmp {
server {
listen 1935;
ping 30s;
notify_method get;
application myapp {
live on;
record off;
#丟棄閑置5s的連接
drop_idle_publisher 5s;
max_connections 1024;
}
#增加對(duì)HLS支持開(kāi)始
application hls {
live on;
hls on;
hls_path /usr/local/var/www/hls;
hls_fragment 5s;
}
#增加對(duì)HLS支持結(jié)束
}
}
下載模塊并解壓
wget https://codeload.github.com/arut/nginx-rtmp-module/tar.gz/v1.2.1
tar xvf v1.2.1
解壓的到 nginx-rtmp-module-1.2.1
配置
server {
listen 8080;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#...................
#添加的部分
location /stat {
rtmp_stat all;
rtmp_stat_stylesheet stat.xsl;
}
location /stat.xsl {
#為nginx-rtmp-module解壓的地址
#root /usr/local/live/nginx-rtmp-module-master/;
root /xxxx/dev/server_workspace/nginx-rtmp-module-1.2.1;
}
#...................
location / {
root html;
index index.html index.htm;
}
省略后面默認(rèn)的盏浙。。荔茬。。
}
- 測(cè)試啟動(dòng)
nginx 啟動(dòng)
ngix -s reload 重啟
nginx -s stop 停止
注意點(diǎn)
其實(shí)就是從 nginx-rtmp-module-1.2.1/test/nginx.conf 中拷貝竹海。
端口占用檢查: lsof -i:8080 需要注意的是目錄與端口是否被占用慕蔚,比如8080端口被占用,可以改為了8081斋配,然后需要開(kāi)放端口孔飒。
如果使用的阿里云服務(wù)器可以進(jìn)入阿里云控制臺(tái)開(kāi)放
測(cè)試
ip:8080/stat推流測(cè)試
https://obsproject.com/welcome
先用Obs測(cè)試
在OBS 推流軟件設(shè)置
地址: rtmp://ip:1935/myapp
秘鑰:abc
成功后會(huì)有記錄
推流服務(wù)顯示.png
然后用vlc輸入播放的流地址
vlc.png