- 下载lede源代码
git clone https://github.com/coolsnowwolf/lede
cd lede
- 下载 Nginx rtmp module
wget https://github.com/aileone/nginx-rtmp-module/archive/refs/heads/master.zip
unzip master.zip
- 下载nginx并添加设置选项
./scripts/feeds update
./scripts/feeds search nginx
./scripts/feeds install nginx
修改 package/feeds/packages/nginx/Config_ssl.in 添加,注意git项目地址:
config NGINX_RTMP_MODULE
bool
prompt "Enable RTMP module"
help
Add support for NGINX-based Media Streaming Server module.
DASH enhanced - https://github.com/aileone/nginx-rtmp-module
default n
config NGINX_TS_MODULE
bool
prompt "Enable TS module"
help
Add support for MPEG-TS Live Module module.
default n
修改 package/feeds/packages/nginx/Makefile ,在213行附近(TARGET_CFLAGS前)添加下载的模块路径:
ifeq ($(CONFIG_NGINX_RTMP_MODULE),y)
ADDITIONAL_MODULES += --add-module=/home/weiyc/lede/nginx-rtmp-module-master
endif
ifeq ($(CONFIG_NGINX_TS_MODULE),y)
ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-ts
endif
- 修改和编译
make menuconfig
在Network->Web Servers/Proxies->nginx-ssl->Configuration->开启 Enable TS module和Enable RTMP module,也可以开启Enable SSL module
选上Collections->luci-nginx 让nginx作为Web Server
# (如没有RTMP module请检查是否在Config_ssl.in重添加)
make -j4
可以直接编译进系统,也可以编译成ipk包
- ipk包路径
lede/bin/packages/mipsel_24kc/nginx
mipsel_24kc是设备芯片名
- rtmp配置文件
#uci.conf主配置文件
rtmp {
server {
listen 1935;
chunk_size 4096;
application live {
live on;
hls on;
hls_path /tmp/live;
hls_fragment 5s; #分片时长
hls_playlist_length 25s; #列表总时长
record off;
}
}
}
# 还需要添加conf.d/hls.conf模块,如下
server {
listen 8080;
listen [::]:8080;
server_name localhost;
location /live {
types {
application/vnd.apple.mpegurl m3u8;
video/mp2t ts;
}
root /tmp;
add_header Cache-Control no-cache;
}
}
/etc/nginx/uci.conf.template是nginx配置文件的uci.conf的根文件,这里添加配置不会被覆盖,在uci.conf添加配置重启会覆盖