更新
This commit is contained in:
parent
41c6c887f5
commit
5061c3fdda
@ -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);
|
writeFileHeader(response, deviceCode, startTime, endTime, fileHeader);
|
||||||
log.info("videoInfo {}", videoInfo);
|
log.info("videoInfo {}", videoInfo);
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
@ -230,6 +230,7 @@ public class Gb28181DownloadService {
|
|||||||
} else if (videoInfo == null) {
|
} else if (videoInfo == null) {
|
||||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||||
} else if (wvpProxyConfig.getUseFfmpeg()) {
|
} else if (wvpProxyConfig.getUseFfmpeg()) {
|
||||||
|
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||||
executor.execute(()-> {
|
executor.execute(()-> {
|
||||||
videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND), videoInfo.getDevice(), videoInfo.getCallId());
|
||||||
|
|
||||||
@ -240,7 +241,7 @@ public class Gb28181DownloadService {
|
|||||||
} else {
|
} else {
|
||||||
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND) + 15);
|
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime, endTime, DateUnit.SECOND) + 15);
|
||||||
}
|
}
|
||||||
});
|
}, executor);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
||||||
} finally {
|
} finally {
|
||||||
@ -370,13 +371,14 @@ public class Gb28181DownloadService {
|
|||||||
DateTime start = DateUtil.date();
|
DateTime start = DateUtil.date();
|
||||||
HttpServletResponse asyncResponse = (HttpServletResponse)asyncContext.getResponse();
|
HttpServletResponse asyncResponse = (HttpServletResponse)asyncContext.getResponse();
|
||||||
try{
|
try{
|
||||||
download(deviceCode, startTime,endTime).whenComplete((videoInfo, e)->{
|
download(deviceCode, startTime,endTime).whenCompleteAsync((videoInfo, e)->{
|
||||||
streamHeader(asyncResponse);
|
streamHeader(asyncResponse);
|
||||||
if(e != null){
|
if(e != null){
|
||||||
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
||||||
} else if(videoInfo == null){
|
} else if(videoInfo == null){
|
||||||
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
writeErrorToResponse(asyncResponse, JsonResponse.error("下载失败"));
|
||||||
} else if(wvpProxyConfig.getUseFfmpeg()){
|
} else if(wvpProxyConfig.getUseFfmpeg()){
|
||||||
|
log.info("开始 ffmpeg 录制, deviceCode {}, startTime {}, endTime {}", deviceCode, DateUtil.formatDateTime(startTime), DateUtil.formatDateTime(endTime));
|
||||||
executor.execute(()->{
|
executor.execute(()->{
|
||||||
videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND),videoInfo.getDevice(),videoInfo.getCallId());
|
videoService.ffmpegRecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND),videoInfo.getDevice(),videoInfo.getCallId());
|
||||||
|
|
||||||
@ -387,7 +389,7 @@ public class Gb28181DownloadService {
|
|||||||
} else {
|
} else {
|
||||||
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND) + 15);
|
videoService.javaCVrecord(asyncResponse, videoInfo.getUrl(), DateUtil.between(startTime,endTime,DateUnit.SECOND) + 15);
|
||||||
}
|
}
|
||||||
});
|
}, executor);
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
writeErrorToResponse(asyncResponse, JsonResponse.error(e.getMessage()));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user