zhibo/live-streaming/docker/srs/srs.conf

99 lines
2.3 KiB
Plaintext
Raw Normal View History

2025-12-23 15:38:35 +08:00
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
# 全局优化配置
# 减少缓冲区大小,降低延迟
mr_enabled off;
# 启用快速启动
fast_cache 10;
# 优化TCP配置
tcp_nodelay on;
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
# 启用跨域支持
crossdomain on;
}
http_api {
enabled on;
listen 1985;
# 启用跨域支持
crossdomain on;
}
stats {
network 0;
}
vhost __defaultVhost__ {
# RTMP 配置 - 优化延迟
rtmp {
enabled on;
# 减少缓冲区大小,降低延迟
chunk_size 4096;
}
# HLS 配置 - 低延迟模式
2025-12-23 15:38:35 +08:00
hls {
enabled on;
hls_path ./objs/nginx/html;
# 最小分片时长 1秒降低延迟
hls_fragment 1;
# 保留 3 个分片
hls_window 3;
# 快速清理过期分片
hls_dispose 10;
# 启用 ts 文件清理
hls_cleanup on;
# 等待关键帧
hls_wait_keyframe on;
2025-12-23 15:38:35 +08:00
}
# HTTP-FLV 配置 - 低延迟播放
http_remux {
enabled on;
mount [vhost]/[app]/[stream].flv;
# 启用快速启动
fast_cache 10;
}
# 转码配置(可选)
transcode {
enabled off;
}
# 播放配置 - 优化延迟
play {
# 关闭 GOP 缓存,降低延迟
2025-12-23 15:38:35 +08:00
gop_cache off;
# 启用时间校正
time_jitter full;
# 减少队列长度
queue_length 10;
# 降低首帧等待
mw_latency 100;
2025-12-23 15:38:35 +08:00
}
# 发布配置 - 优化延迟
publish {
# 减少首帧等待时间
firstpkt_timeout 20000;
# 减少正常包超时
normal_timeout 5000;
}
# HTTP Hooks: 推流/播放事件回调到 Node APINode API 再转发到 Java 后端
http_hooks {
enabled on;
on_publish http://api-server:3001/api/srs/on_publish;
on_unpublish http://api-server:3001/api/srs/on_unpublish;
on_play http://api-server:3001/api/srs/on_play;
on_stop http://api-server:3001/api/srs/on_stop;
}
}