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

93 lines
2.2 KiB
Plaintext
Raw Normal View History

2025-12-15 11:34:49 +08:00
listen 1935;
max_connections 1000;
daemon off;
srs_log_tank console;
2025-12-17 17:23:54 +08:00
# 全局优化配置
# 减少缓冲区大小,降低延迟
mr_enabled off;
# 启用快速启动
fast_cache 10;
# 优化TCP配置
tcp_nodelay on;
2025-12-15 11:34:49 +08:00
http_server {
enabled on;
listen 8080;
dir ./objs/nginx/html;
2025-12-17 17:23:54 +08:00
# 启用跨域支持
2025-12-15 11:34:49 +08:00
crossdomain on;
}
http_api {
enabled on;
listen 1985;
2025-12-17 17:23:54 +08:00
# 启用跨域支持
crossdomain on;
}
stats {
network 0;
2025-12-15 11:34:49 +08:00
}
vhost __defaultVhost__ {
2025-12-17 17:23:54 +08:00
# RTMP 配置 - 优化延迟
rtmp {
enabled on;
# 减少缓冲区大小,降低延迟
chunk_size 4096;
}
# HLS 配置 - 优化延迟
2025-12-15 11:34:49 +08:00
hls {
enabled on;
hls_path ./objs/nginx/html;
2025-12-17 17:23:54 +08:00
# 减少分片时长,降低延迟
hls_fragment 2;
hls_window 6;
# 启用低延迟模式
hls_dispose 30;
2025-12-15 11:34:49 +08:00
}
2025-12-17 17:23:54 +08:00
# HTTP-FLV 配置 - 低延迟播放
2025-12-15 11:34:49 +08:00
http_remux {
enabled on;
2025-12-17 17:23:54 +08:00
mount [vhost]/[app]/[stream].flv;
# 启用快速启动
fast_cache 10;
2025-12-15 11:34:49 +08:00
}
2025-12-17 17:23:54 +08:00
# 转码配置(可选)
transcode {
enabled off;
2025-12-15 11:34:49 +08:00
}
2025-12-17 17:23:54 +08:00
# 播放配置 - 优化延迟
2025-12-15 11:34:49 +08:00
play {
2025-12-17 17:23:54 +08:00
# 减少GOP缓存
gop_cache off;
# 启用时间校正
time_jitter full;
# 减少队列长度
2025-12-15 11:34:49 +08:00
queue_length 10;
}
2025-12-17 17:23:54 +08:00
# 发布配置 - 优化延迟
publish {
# 减少首帧等待时间
firstpkt_timeout 20000;
# 减少正常包超时
normal_timeout 5000;
}
# HTTP Hooks: 推流/播放事件回调到 Java 后端
# Windows Docker Desktop 下建议用 host.docker.internal 访问宿主机
http_hooks {
enabled on;
on_publish http://host.docker.internal:8081/api/front/live/srs/on_publish;
on_unpublish http://host.docker.internal:8081/api/front/live/srs/on_unpublish;
on_play http://host.docker.internal:8081/api/front/live/srs/on_play;
on_stop http://host.docker.internal:8081/api/front/live/srs/on_stop;
}
2025-12-15 11:34:49 +08:00
}