From 6714c13a26c7ed5229c0cccc2f3fc1c284690148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Sat, 21 Jun 2025 13:05:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- environment.sh | 5 +++++ init/7.srs.sh | 31 +++++++++---------------------- init/volumes/srs/conf/srs.conf | 27 +++++++++++++++++++++++++++ nginx/vhosts/srs.conf | 8 ++++++++ 4 files changed, 49 insertions(+), 22 deletions(-) diff --git a/environment.sh b/environment.sh index ef202ca..b4c782d 100644 --- a/environment.sh +++ b/environment.sh @@ -203,6 +203,11 @@ if [ -z "$SRS_RTC_PORT" ]; then else echo "环境变量 SRS_RTC_PORT 已设置,设置为 ${SRS_RTC_PORT}" fi +if [ -z "$SRS_SRT_PORT" ]; then + export SRS_SRT_PORT=10080 +else + echo "环境变量 SRS_SRT_PORT 已设置,设置为 ${SRS_SRT_PORT}" +fi export SRS_RTMP_DOMAIN_FULL=${SRS_DOMAIN}:${SRS_RTMP_PORT} export SRS_MEMORY=512m export SRS_IMAGE=${REGISTRY_HOST}srs:6 diff --git a/init/7.srs.sh b/init/7.srs.sh index 0a24431..95a8be2 100755 --- a/init/7.srs.sh +++ b/init/7.srs.sh @@ -54,42 +54,29 @@ docker run --rm \ # 启动SRS容器 默认也有8080端口 # export CANDIDATE="192.168.50.143" #echo ${SRS_DOMAIN} -CANDIDATE=${SRS_DOMAIN} -echo $CANDIDATE - -# docker run -d \ -# --name ${SRS_NAME} \ -# --network $NETWORK \ -# --memory $SRS_MEMORY \ -# --restart unless-stopped \ -# -p ${SRS_RTMP_PORT}:1935 \ -# -p ${SRS_RTC_PORT}:8000/udp \ -# -v "$(pwd)/volumes/srs/conf/srs.conf:/usr/local/srs/conf/docker.conf" \ -# -v "${SRS_DATA}:/usr/local/srs/objs/nginx/html" \ -# --mount type=bind,source=/etc/localtime,target=/etc/localtime,readonly \ -# $SRS_IMAGE -# --env CANDIDATE=$CANDIDATE \ - +# CANDIDATE=${SRS_DOMAIN} +# echo $CANDIDATE docker run -d \ --name ${SRS_NAME} \ --network $NETWORK \ --memory $SRS_MEMORY \ --restart unless-stopped \ - --env CANDIDATE=139.224.117.253 \ -p ${SRS_RTMP_PORT}:1935 \ -p ${SRS_RTC_PORT}:8000/udp \ - -p 1985:1985 \ - -p 8080:8080 \ - -p 10080:10080/udp + -p ${SRS_SRT_PORT}:10080/udp \ -v "$(pwd)/volumes/srs/conf/srs.conf:/usr/local/srs/conf/docker.conf" \ -v "${SRS_DATA}:/usr/local/srs/objs/nginx/html" \ --mount type=bind,source=/etc/localtime,target=/etc/localtime,readonly \ $SRS_IMAGE + -# docker run --name SRS --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 10080:10080/udp -p 8000:8000/udp \ -# --env CANDIDATE=$CANDIDATE \ + + + + +# docker run -d --name SRS --network $NETWORK --rm -it -p 1935:1935 -p 1985:1985 -p 8080:8080 -p 10080:10080/udp -p 8000:8000/udp \ # $SRS_IMAGE ./objs/srs -c conf/srt2rtc.conf \ No newline at end of file diff --git a/init/volumes/srs/conf/srs.conf b/init/volumes/srs/conf/srs.conf index 9293fc5..f29e5e4 100644 --- a/init/volumes/srs/conf/srs.conf +++ b/init/volumes/srs/conf/srs.conf @@ -37,6 +37,26 @@ rtc_server { # @doc https://github.com/ossrs/srs/issues/1147#issuecomment-577607026 vhost __defaultVhost__ { + + # dvr { + # enabled on; + # #all表示录制所有视频流,也可以按频道录制 + # #规则为/,例:live/stream1 live/stream2 + # #规则为/,例:live/stream1 live/stream2 + # dvr_apply all; + # #dvr计划 + # dvr_plan segment; + # #录制的路径,详细配置规则见附录三 + # dvr_path ./objs/nginx/html/record/[2006][01][02]/[app][stream]/[timestamp].flv; + # #segment方式录制时间设置,单位: s + # dvr_duration 900; + # #开启按关键帧且flv + # dvr_wait_keyframe on; + # #时间戳抖动算法。full使用完全的时间戳矫正; + # #zero只是保证从0开始;off不矫正时间戳。 + # time_jitter full; + # } + srt { enabled on; } @@ -51,4 +71,11 @@ vhost __defaultVhost__ { enabled on; mount [vhost]/[app]/[stream].flv; } + + # hls { + # enabled on; + # hls_path ./objs/nginx/html; + # hls_fragment 10; + # hls_window 60; + # } } \ No newline at end of file diff --git a/nginx/vhosts/srs.conf b/nginx/vhosts/srs.conf index d3758da..634778f 100644 --- a/nginx/vhosts/srs.conf +++ b/nginx/vhosts/srs.conf @@ -17,6 +17,14 @@ server { proxy_pass http://${SRS_NAME}:8080; } + location /rtc { + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_pass http://${SRS_NAME}:1985; + } + + location /recording/ { alias /data/recording/; autoindex on;