From c639fd71ef3ccb0366cda4dfc6d3e74e3e51f6e3 Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Sat, 10 Feb 2024 13:45:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E4=B8=BA=20=E4=BD=BF=E7=94=A8=20rtsp?= =?UTF-8?q?=20=E6=8E=A8=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...{ZlmRtmpConfig.java => ZlmRtspConfig.java} | 6 +-- .../service/device/DeviceProxyService.java | 14 +++--- .../resources/application-local-linux.yml | 6 +-- .../src/main/resources/application-local.yml | 46 +++++++++++-------- .../src/main/resources/application.yml | 6 +-- 5 files changed, 44 insertions(+), 34 deletions(-) rename gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/{ZlmRtmpConfig.java => ZlmRtspConfig.java} (70%) diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtmpConfig.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtspConfig.java similarity index 70% rename from gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtmpConfig.java rename to gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtspConfig.java index 865340e..dfdb016 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtmpConfig.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/config/sip/ZlmRtspConfig.java @@ -6,7 +6,7 @@ import org.springframework.context.annotation.Configuration; @Data @Configuration -@ConfigurationProperties(prefix = "media.rtmp") -public class ZlmRtmpConfig { - int port = 1935; +@ConfigurationProperties(prefix = "media.rtsp") +public class ZlmRtspConfig { + int port = 554; } diff --git a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java index ebc3bd5..919d643 100644 --- a/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java +++ b/gb28181-mocking-service/src/main/java/cn/skcks/docking/gb28181/mocking/service/device/DeviceProxyService.java @@ -26,7 +26,7 @@ import cn.skcks.docking.gb28181.media.proxy.ZlmMediaService; import cn.skcks.docking.gb28181.mocking.config.sip.DeviceProxyConfig; import cn.skcks.docking.gb28181.mocking.config.sip.FfmpegConfig; import cn.skcks.docking.gb28181.mocking.config.sip.ZlmHookConfig; -import cn.skcks.docking.gb28181.mocking.config.sip.ZlmRtmpConfig; +import cn.skcks.docking.gb28181.mocking.config.sip.ZlmRtspConfig; import cn.skcks.docking.gb28181.mocking.core.sip.message.processor.message.request.notify.dto.MediaStatusRequestDTO; import cn.skcks.docking.gb28181.mocking.core.sip.message.subscribe.SipSubscribe; import cn.skcks.docking.gb28181.mocking.core.sip.request.SipRequestBuilder; @@ -91,7 +91,7 @@ public class DeviceProxyService { private final ZlmMediaService zlmMediaService; private final ZlmMediaConfig zlmMediaConfig; private final ZlmStreamChangeHookService zlmStreamChangeHookService; - private final ZlmRtmpConfig zlmRtmpConfig; + private final ZlmRtspConfig zlmRtspConfig; private final VideoCacheManager videoCacheManager; private final String DEFAULT_ZLM_APP = "live"; @@ -174,7 +174,7 @@ public class DeviceProxyService { ScheduledFuture schedule = trying(request); Flow.Subscriber task = ffmpegTask(request, callbackTask, callId, key, device); try { - String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId); + String zlmRtpUrl = getZlmRtspUrl(DEFAULT_ZLM_APP, callId); FfmpegExecuteResultHandler executeResultHandler = mediaStatus(schedule,request, device, key); Executor executor = pushRtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); requestZlmPushStream(schedule, sendOkResponse, request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); @@ -194,7 +194,7 @@ public class DeviceProxyService { ScheduledFuture schedule = trying(request); Flow.Subscriber task = ffmpegTask(request, downloadTask, callId, key, device); try { - String zlmRtpUrl = getZlmRtmpUrl(DEFAULT_ZLM_APP, callId); + String zlmRtpUrl = getZlmRtspUrl(DEFAULT_ZLM_APP, callId); FfmpegExecuteResultHandler executeResultHandler = mediaStatus(schedule, request, device, key); Executor executor = pushDownload2RtpTask(fromUrl, zlmRtpUrl, time + 60, executeResultHandler); requestZlmPushStream(schedule, sendOkResponse, request, callId, fromUrl, toAddr, toPort, device, key, time, ssrc); @@ -209,8 +209,8 @@ public class DeviceProxyService { }; } - private String getZlmRtmpUrl(String app, String streamId){ - return "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/" + app +"/" + streamId; + private String getZlmRtspUrl(String app, String streamId){ + return "rtsp://" + zlmMediaConfig.getIp() + ":" + zlmRtspConfig.getPort() + "/" + app +"/" + streamId; } private ScheduledFuture trying(SIPRequest request){ @@ -355,7 +355,7 @@ public class DeviceProxyService { .withStopStrategy(StopStrategies.stopAfterAttempt(3)) .build(); - String toUrl = "rtmp://" + zlmMediaConfig.getIp() + ":" + zlmRtmpConfig.getPort() + "/" + ZLM_FFMPEG_PROXY_APP +"/" + callId; + String toUrl = "rtsp://" + zlmMediaConfig.getIp() + ":" + zlmRtspConfig.getPort() + "/" + ZLM_FFMPEG_PROXY_APP +"/" + callId; String key = GenericSubscribe.Helper.getKey(Request.BYE, callId); try { ZlmResponse sourceResp = retryer.call(() -> zlmMediaService.addFfmpegSource(AddFFmpegSource.builder() diff --git a/gb28181-mocking-starter/src/main/resources/application-local-linux.yml b/gb28181-mocking-starter/src/main/resources/application-local-linux.yml index c6f5f78..cc8d3a8 100644 --- a/gb28181-mocking-starter/src/main/resources/application-local-linux.yml +++ b/gb28181-mocking-starter/src/main/resources/application-local-linux.yml @@ -60,8 +60,8 @@ gb28181: media: local: hook: http://10.10.10.200:18182/zlm/hook - rtmp: - port: 1935 + rtsp: + port: 554 ip: 10.10.10.200 url: 'http://10.10.10.200:5080' # url: 'http://10.10.10.200:12580/anything/' @@ -81,7 +81,7 @@ ffmpeg-support: ffprobe: /usr/bin/ffmpeg/ffprobe rtp: input: -re -i - output: -vcodec h264 -acodec aac -f flv + output: -vcodec h264 -acodec aac -f rtsp debug: download: false input: false diff --git a/gb28181-mocking-starter/src/main/resources/application-local.yml b/gb28181-mocking-starter/src/main/resources/application-local.yml index f174d90..b30cf1b 100644 --- a/gb28181-mocking-starter/src/main/resources/application-local.yml +++ b/gb28181-mocking-starter/src/main/resources/application-local.yml @@ -11,7 +11,7 @@ spring: # host: 192.168.1.241 host: 10.10.10.200 # [必须修改] 端口号 - port: 6379 + port: 16379 # [可选] 数据库 DB database: 15 # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 @@ -48,7 +48,8 @@ gb28181: # [可选] domain: 4405010000 # [可选] - id: 44050100002000000002 + #id: 44050100002000000002 + id: 44050100002000000009 # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 password: 123456 expire: 3600 @@ -58,17 +59,17 @@ gb28181: ip: 10.10.10.20 # ip: 192.168.10.32 # ip: 192.168.3.12 - port: 5063 -# port: 5061 +# port: 5060 + port: 5061 password: 123456 domain: 4405010000 -# id: 44050100002000000002 - id: 44050100002000000003 + id: 44050100002000000002 +# id: 44050100002000000003 media: local: hook: http://10.10.10.20:18182/zlm/hook - delay: 100ms + delay: 2000ms fixed: 0s ip: 10.10.10.200 url: 'http://10.10.10.200:5081' @@ -76,20 +77,22 @@ media: id: amrWMKmbKqoBjRQ9 # secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333 - rtmp: - port: 1936 + rtsp: + port: 554 proxy: device: # 代理的视频接口地址, 用于获取历史视频 # 参数 device_id, begin_time, end_time - url: http://10.10.10.20:18186 +# url: http://10.10.10.20: + url: http://10.10.10.200:18183 use-download-to-playback: true proxy-video-in-time-range: true proxy-time-range: 5m pre-download-for-record-info: time-range: 5m - cache-path: ./record +# cache-path: ./record enable: true + cache-path: G:/Temp/record ffmpeg-support: task: # 最大同时推流任务数, <= 0 时不做限制 @@ -97,14 +100,21 @@ ffmpeg-support: ffmpeg: D:\Soft\Captura\ffmpeg\ffmpeg.exe ffprobe: D:\Soft\Captura\ffmpeg\ffprobe.exe rtp: - input: -thread_queue_size 128 -re -i http://10.10.10.200:5081/live/test.live.flv -# input: -re -i - output: -tune zerolatency -vcodec libx264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv #rtp_mpegts -# output: -vcodec h264 -acodec aac -vf scale=640:-1 -f rtp_mpegts # -rtsp_transport tcp - download: -i E:\Repository\other\happytime-gb28181-device-x64\666.mp4 -filter:v "setpts=4.0*PTS" + #input: -thread_queue_size 128 -re -i http://10.10.10.200:5081/live/test.live.flv + #input: -thread_queue_size 128 -re -i rtsp://admin:XXXXXX@10.10.11.171/Streaming/Channels/1/ + #input: -hwaccel cuda -re -i rtsp://10.10.11.200/camera/171 + input: -re -i +# output: -tune zerolatency -vcodec libx264 -acodec aac -preset ultrafast -vf scale=640:-1 -f rtsp #flv #rtp_mpegts + output: -c:v copy -an -preset ultrafast -flvflags no_duration_filesize -bf 0 -max_interleave_delta 0 -f rtsp #flv #rtp_mpegts + download: -thread_queue_size 128 -i + # output: -vcodec h264 -acodec aac -vf scale=640:-1 -f rtp_mpegts # -rtsp_transport tcp +# download: -i E:\Repository\other\happytime-gb28181-device-x64\666.mp4 -filter:v "setpts=4.0*PTS" +# download: -i E:\Repository\other\happytime-gb28181-device-x64\666.mp4 -filter:v "setpts=4.0*PTS debug: - download: true - input: true +# download: true +# input: true + download: false + input: false output: false # [可选] 日志配置, 一般不需要改 diff --git a/gb28181-mocking-starter/src/main/resources/application.yml b/gb28181-mocking-starter/src/main/resources/application.yml index bb423b9..7e5870a 100644 --- a/gb28181-mocking-starter/src/main/resources/application.yml +++ b/gb28181-mocking-starter/src/main/resources/application.yml @@ -70,8 +70,8 @@ media: id: amrWMKmbKqoBjRQ9 # secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc secret: 4155cca6-2f9f-11ee-85e6-8de4ce2e7333 - rtmp: - port: 1937 + rtsp: + port: 554 proxy: device: # 代理的视频接口地址, 用于获取历史视频 @@ -105,7 +105,7 @@ ffmpeg-support: #output: -filter:v "setpts=4.0*PTS" -tune zerolatency -vcodec libx264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv # 下载 正常速率 #output: -r 30 -tune zerolatency -vcodec libx264 -acodec aac -preset ultrafast -vf scale=640:-1 -f flv - output: -c:v copy -an -preset ultrafast -flvflags no_duration_filesize -bf 0 -max_interleave_delta 0 -f flv + output: -c:v copy -an -preset ultrafast -flvflags no_duration_filesize -bf 0 -max_interleave_delta 0 -f rtsp #output: -r 30 -vcodec libx264 -acodec aac -filter:v "setpts=1*PTS" -preset ultrafast -flvflags no_duration_filesize -bf 0 -max_interleave_delta 0 -f flv #download: -i E:\Repository\other\happytime-gb28181-device-x64\666.mp4 -filter:v "setpts=4.0*PTS" download: -i