93 lines
2.2 KiB
Plaintext
93 lines
2.2 KiB
Plaintext
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 配置 - 优化延迟
|
|
hls {
|
|
enabled on;
|
|
hls_path ./objs/nginx/html;
|
|
# 减少分片时长,降低延迟
|
|
hls_fragment 2;
|
|
hls_window 6;
|
|
# 启用低延迟模式
|
|
hls_dispose 30;
|
|
}
|
|
|
|
# HTTP-FLV 配置 - 低延迟播放
|
|
http_remux {
|
|
enabled on;
|
|
mount [vhost]/[app]/[stream].flv;
|
|
# 启用快速启动
|
|
fast_cache 10;
|
|
}
|
|
|
|
# 转码配置(可选)
|
|
transcode {
|
|
enabled off;
|
|
}
|
|
|
|
# 播放配置 - 优化延迟
|
|
play {
|
|
# 减少GOP缓存
|
|
gop_cache off;
|
|
# 启用时间校正
|
|
time_jitter full;
|
|
# 减少队列长度
|
|
queue_length 10;
|
|
}
|
|
|
|
# 发布配置 - 优化延迟
|
|
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;
|
|
}
|
|
}
|