From a24d08b0c23d61cc6b9d15b8299f9df50d7af7bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E5=B0=8F=E4=BA=91?= Date: Sat, 27 Dec 2025 13:04:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/StreamRecordController.java | 64 ++++++++++++++++++- src/main/resources/application.properties | 36 ++++++++--- 2 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/tuoheng/steam/controller/StreamRecordController.java b/src/main/java/com/tuoheng/steam/controller/StreamRecordController.java index 50dfc1c..899ac53 100644 --- a/src/main/java/com/tuoheng/steam/controller/StreamRecordController.java +++ b/src/main/java/com/tuoheng/steam/controller/StreamRecordController.java @@ -25,6 +25,7 @@ import org.apache.logging.log4j.util.Strings; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -198,7 +199,42 @@ public class StreamRecordController { return "OK"; } - public String streamSwitch(String source) { + @Value("${srs.domain}") + private String srsdomain; + + @Value("${srs.name}") + private String srsname; + +// public String streamSwitch(String source) { +// if (source.contains("stream.t-aaron.com")) { +// return source; +// } else if (source.contains("rtmp://live.push.t-aaron.com")) { +// source = source.replace("rtmp://live.push.t-aaron.com", "http://live.play.t-aaron.com"); +// if (source.endsWith("_")) { +// String var10000 = source.substring(0, source.length() - 1); +// source = var10000 + ".flv_"; +// } else { +// source = source + ".flv"; +// } +// +// return source; +// } else { +// if (source.contains("https://live.play.t-aaron.com")) { +// source = source.replace("https://live.play.t-aaron.com", "http://live.play.t-aaron.com"); +// } +// +// return source; +// } +// } + + public String streamSwitch(String source){ + + if(Objects.nonNull(srsname) && !srsname.isEmpty()){ + if(Objects.nonNull(source) && !source.isEmpty()){ + return dockerFix(source); + } + } + if (source.contains("stream.t-aaron.com")) { return source; } else if (source.contains("rtmp://live.push.t-aaron.com")) { @@ -218,5 +254,31 @@ public class StreamRecordController { return source; } + } + + public String dockerFix(String url) { + logger.info("dockerFix{}",url); + if (url == null || url.isEmpty()) { + return url; + } + url = url.replaceFirst("^https?://", "rtmp://"); + // 删除末尾的 .flv + url = url.replaceFirst("\\.flv$", ""); + if(url.contains("srs-jndsj")){ + return url; + } + // 处理 RTMP URL + if (url.startsWith("rtmp://")) { + // 先删除端口号 + String withoutPort = url.replaceFirst("(rtmp://[^:/]+):\\d+", "$1"); + // 替换域名为 aaa + String withNewDomain = withoutPort.replaceFirst("rtmp://[^/]+", "rtmp://"+srsname); + // 删除 .flv 后缀 + return withNewDomain.replaceFirst("\\.flv$", ""); + } + + return url; + } + } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ffd838e..b438419 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -8,15 +8,16 @@ #livedates=8 #cangneiwai=false -#大数据局 -spring.application.name=stream_server -server.port = 8989 -srs.splitPath=/data/java/srs/stream_server/temp -srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html/recording -ffmpeg=ffmpeg -recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record -livedates=8 -cangneiwai=true +#大数据局生产 +#spring.application.name=stream_server +#server.port = 8989 +#srs.splitPath=/data/java/srs/stream_server/temp +#srs.targetPath=/data/java/srs/srs/trunk/objs/nginx/html/recording +#ffmpeg=ffmpeg +#recordPath=/data/java/srs/srs/trunk/objs/nginx/html/record +#livedates=8 +#cangneiwai=true + # 录制码率配置 (单位: kbps, 2000k = 2Mbps) video.bitrate=4000k audio.bitrate=128k @@ -29,4 +30,19 @@ audio.bitrate=128k #ffmpeg=ffmpeg #recordPath=/Users/sunpeng/workspace/stream/record #livedates=7 -#cangneiwai=false \ No newline at end of file +#cangneiwai=false + +#大数据容器化 +##通过注入 +srs.name = STREAM +spring.application.name=stream_server +server.port = 8080 +#零时文件 +srs.splitPath=/data/temp +#拍照 + 录像 +srs.targetPath=/data/recording +ffmpeg=ffmpeg +# +recordPath=/data/record +livedates=8 +cangneiwai=false