63 lines
1.4 KiB
Plaintext
63 lines
1.4 KiB
Plaintext
|
|
# 停止 SRS
|
|||
|
|
docker stop srs-server
|
|||
|
|
docker rm srs-server
|
|||
|
|
|
|||
|
|
# 更新配置文件,添加 http_hooks
|
|||
|
|
cat > /opt/live-streaming/docker/srs/srs.conf << 'EOF'
|
|||
|
|
listen 1935;
|
|||
|
|
max_connections 1000;
|
|||
|
|
daemon off;
|
|||
|
|
srs_log_tank console;
|
|||
|
|
|
|||
|
|
http_server {
|
|||
|
|
enabled on;
|
|||
|
|
listen 8080;
|
|||
|
|
dir ./objs/nginx/html;
|
|||
|
|
crossdomain on;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
http_api {
|
|||
|
|
enabled on;
|
|||
|
|
listen 1985;
|
|||
|
|
crossdomain on;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
vhost __defaultVhost__ {
|
|||
|
|
hls {
|
|||
|
|
enabled on;
|
|||
|
|
hls_path ./objs/nginx/html;
|
|||
|
|
hls_fragment 2;
|
|||
|
|
hls_window 4;
|
|||
|
|
hls_cleanup on;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
http_remux {
|
|||
|
|
enabled on;
|
|||
|
|
mount [vhost]/[app]/[stream].flv;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
play {
|
|||
|
|
gop_cache on;
|
|||
|
|
queue_length 10;
|
|||
|
|
mw_latency 100;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
# 关键:添加 HTTP 回调
|
|||
|
|
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;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
EOF
|
|||
|
|
|
|||
|
|
# 重启 SRS(添加 host.docker.internal 映射)
|
|||
|
|
docker run -d --name srs-server \
|
|||
|
|
-p 25002:1935 \
|
|||
|
|
-p 25003:8080 \
|
|||
|
|
-p 1985:1985 \
|
|||
|
|
-v /opt/live-streaming/docker/srs/srs.conf:/usr/local/srs/conf/srs.conf \
|
|||
|
|
--add-host=host.docker.internal:host-gateway \
|
|||
|
|
--restart unless-stopped \
|
|||
|
|
ossrs/srs:5
|