From 5061c3fdda3693d0441ff614f9771428781c791c Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Fri, 15 Mar 2024 15:55:32 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wvp/service/gb28181/Gb28181DownloadService.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java index e7a2e48..ff76ae2 100644 --- a/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java +++ b/gb28181-wvp-proxy-service/src/main/java/cn/skcks/docking/gb28181/wvp/service/gb28181/Gb28181DownloadService.java @@ -222,7 +222,7 @@ public class Gb28181DownloadService { }); } - download(deviceCode, startTime, endTime, useDownload).whenComplete((videoInfo, e) -> { + download(deviceCode, startTime, endTime, useDownload).whenCompleteAsync((videoInfo, e) -> { writeFileHeader(response, deviceCode, startTime, endTime, fileHeader); log.info("videoInfo {}", videoInfo); if (e != null) { @@ -230,6 +230,7 @@ public class Gb28181DownloadService { } else if (videoInfo == null) { writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败")); } else if (wvpProxyConfig.getUseFfmpeg()) { + log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime)); executor.execute(()-> { videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId()); @@ -240,7 +241,7 @@ public class Gb28181DownloadService { } else { videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND) + 15); } - }); + }, executor); } catch(Exception e) { writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage())); } finally { @@ -370,13 +371,14 @@ public class Gb28181DownloadService { DateTime start = DateUtil.date(); HttpServletResponse asyncResponse = (HttpServletResponse)asyncContext.getResponse(); try{ - download(deviceCode, startTime,endTime).whenComplete((videoInfo, e)->{ + download(deviceCode, startTime,endTime).whenCompleteAsync((videoInfo, e)->{ streamHeader(asyncResponse); if(e != null){ writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage())); } else if(videoInfo == null){ writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败")); } else if(wvpProxyConfig.getUseFfmpeg()){ + log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime)); executor.execute(()->{ videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND),videoInfo.getDevice(),videoInfo.getCallId()); @@ -387,7 +389,7 @@ public class Gb28181DownloadService { } else { videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND) + 15); } - }); + }, executor); } catch(Exception e) { writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));