Commit bae5170052c58b1e99b5eb7bfff8d53397fbc5c1
1 parent
841e314f
修复合并功能
Showing
4 changed files
with
109 additions
and
11 deletions
src/main/java/top/panll/assist/controller/RecordController.java
| ... | ... | @@ -266,7 +266,7 @@ public class RecordController { |
| 266 | 266 | if (videoTaskInfo.getFilePathList() == null || videoTaskInfo.getFilePathList().isEmpty()) { |
| 267 | 267 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "视频文件列表不可为空"); |
| 268 | 268 | } |
| 269 | - String id = videoFileService.mergeOrCut(videoTaskInfo.getFilePathList(), videoTaskInfo.getRemoteHost()); | |
| 269 | + String id = videoFileService.mergeOrCut(videoTaskInfo); | |
| 270 | 270 | if (id== null) { |
| 271 | 271 | throw new ControllerException(ErrorCode.ERROR100.getCode(), "可能未找到视频文件"); |
| 272 | 272 | } | ... | ... |
src/main/java/top/panll/assist/dto/MergeOrCutTaskInfo.java
| ... | ... | @@ -12,6 +12,12 @@ public class MergeOrCutTaskInfo { |
| 12 | 12 | |
| 13 | 13 | private String playFile; |
| 14 | 14 | |
| 15 | + private String app; | |
| 16 | + private String stream; | |
| 17 | + private String startTime; | |
| 18 | + private String endTime; | |
| 19 | + private String callId; | |
| 20 | + | |
| 15 | 21 | public String getId() { |
| 16 | 22 | return id; |
| 17 | 23 | } |
| ... | ... | @@ -59,4 +65,44 @@ public class MergeOrCutTaskInfo { |
| 59 | 65 | public void setCreateTime(String createTime) { |
| 60 | 66 | this.createTime = createTime; |
| 61 | 67 | } |
| 68 | + | |
| 69 | + public String getApp() { | |
| 70 | + return app; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setApp(String app) { | |
| 74 | + this.app = app; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getStream() { | |
| 78 | + return stream; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setStream(String stream) { | |
| 82 | + this.stream = stream; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public String getStartTime() { | |
| 86 | + return startTime; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setStartTime(String startTime) { | |
| 90 | + this.startTime = startTime; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getEndTime() { | |
| 94 | + return endTime; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setEndTime(String endTime) { | |
| 98 | + this.endTime = endTime; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getCallId() { | |
| 102 | + return callId; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setCallId(String callId) { | |
| 106 | + this.callId = callId; | |
| 107 | + } | |
| 62 | 108 | } | ... | ... |
src/main/java/top/panll/assist/dto/VideoTaskInfo.java
| ... | ... | @@ -8,6 +8,13 @@ import java.util.List; |
| 8 | 8 | @Schema(description = "视频合并任务的信息") |
| 9 | 9 | public class VideoTaskInfo { |
| 10 | 10 | |
| 11 | + private String app; | |
| 12 | + private String stream; | |
| 13 | + private String startTime; | |
| 14 | + private String endTime; | |
| 15 | + private String callId; | |
| 16 | + | |
| 17 | + | |
| 11 | 18 | @Schema(description = "视频文件路径列表") |
| 12 | 19 | private List<String> filePathList; |
| 13 | 20 | |
| ... | ... | @@ -29,4 +36,44 @@ public class VideoTaskInfo { |
| 29 | 36 | public void setRemoteHost(String remoteHost) { |
| 30 | 37 | this.remoteHost = remoteHost; |
| 31 | 38 | } |
| 39 | + | |
| 40 | + public String getApp() { | |
| 41 | + return app; | |
| 42 | + } | |
| 43 | + | |
| 44 | + public void setApp(String app) { | |
| 45 | + this.app = app; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public String getStream() { | |
| 49 | + return stream; | |
| 50 | + } | |
| 51 | + | |
| 52 | + public void setStream(String stream) { | |
| 53 | + this.stream = stream; | |
| 54 | + } | |
| 55 | + | |
| 56 | + public String getStartTime() { | |
| 57 | + return startTime; | |
| 58 | + } | |
| 59 | + | |
| 60 | + public void setStartTime(String startTime) { | |
| 61 | + this.startTime = startTime; | |
| 62 | + } | |
| 63 | + | |
| 64 | + public String getEndTime() { | |
| 65 | + return endTime; | |
| 66 | + } | |
| 67 | + | |
| 68 | + public void setEndTime(String endTime) { | |
| 69 | + this.endTime = endTime; | |
| 70 | + } | |
| 71 | + | |
| 72 | + public String getCallId() { | |
| 73 | + return callId; | |
| 74 | + } | |
| 75 | + | |
| 76 | + public void setCallId(String callId) { | |
| 77 | + this.callId = callId; | |
| 78 | + } | |
| 32 | 79 | } | ... | ... |
src/main/java/top/panll/assist/service/VideoFileService.java
| ... | ... | @@ -207,13 +207,13 @@ public class VideoFileService { |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | |
| 210 | - public String mergeOrCut(List<String> filePathList, String remoteHost) { | |
| 211 | - assert filePathList != null; | |
| 212 | - assert !filePathList.isEmpty(); | |
| 210 | + public String mergeOrCut(VideoTaskInfo videoTaskInfo) { | |
| 211 | + assert videoTaskInfo.getFilePathList() != null; | |
| 212 | + assert !videoTaskInfo.getFilePathList().isEmpty(); | |
| 213 | 213 | String taskId = DigestUtils.md5DigestAsHex(String.valueOf(System.currentTimeMillis()).getBytes()); |
| 214 | 214 | logger.info("[录像合并] 开始合并, 任务ID:{}: ", taskId); |
| 215 | 215 | List<File> fileList = new ArrayList<>(); |
| 216 | - for (String filePath : filePathList) { | |
| 216 | + for (String filePath : videoTaskInfo.getFilePathList()) { | |
| 217 | 217 | File file = new File(filePath); |
| 218 | 218 | if (!file.exists()) { |
| 219 | 219 | logger.info("[录像合并] 失败, 任务ID:{}, 文件不存在: {}", taskId, filePath); |
| ... | ... | @@ -226,6 +226,11 @@ public class VideoFileService { |
| 226 | 226 | File recordFile = new File(userSettings.getRecord() ); |
| 227 | 227 | MergeOrCutTaskInfo mergeOrCutTaskInfo = new MergeOrCutTaskInfo(); |
| 228 | 228 | mergeOrCutTaskInfo.setId(taskId); |
| 229 | + mergeOrCutTaskInfo.setApp(videoTaskInfo.getApp()); | |
| 230 | + mergeOrCutTaskInfo.setStream(videoTaskInfo.getStream()); | |
| 231 | + mergeOrCutTaskInfo.setCallId(videoTaskInfo.getCallId()); | |
| 232 | + mergeOrCutTaskInfo.setStartTime(videoTaskInfo.getStartTime()); | |
| 233 | + mergeOrCutTaskInfo.setEndTime(videoTaskInfo.getEndTime()); | |
| 229 | 234 | mergeOrCutTaskInfo.setCreateTime(simpleDateFormatForTime.format(System.currentTimeMillis())); |
| 230 | 235 | if (fileList.size() == 1) { |
| 231 | 236 | |
| ... | ... | @@ -241,9 +246,9 @@ public class VideoFileService { |
| 241 | 246 | throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); |
| 242 | 247 | } |
| 243 | 248 | mergeOrCutTaskInfo.setRecordFile("/download/" + relativize.toString()); |
| 244 | - if (remoteHost != null) { | |
| 245 | - mergeOrCutTaskInfo.setDownloadFile(remoteHost + "/download.html?url=download/" + relativize); | |
| 246 | - mergeOrCutTaskInfo.setPlayFile(remoteHost + "/download/" + relativize); | |
| 249 | + if (videoTaskInfo.getRemoteHost() != null) { | |
| 250 | + mergeOrCutTaskInfo.setDownloadFile(videoTaskInfo.getRemoteHost() + "/download.html?url=download/" + relativize); | |
| 251 | + mergeOrCutTaskInfo.setPlayFile(videoTaskInfo.getRemoteHost() + "/download/" + relativize); | |
| 247 | 252 | } |
| 248 | 253 | String key = String.format("%S_%S_%S", AssistConstants.MERGEORCUT , userSettings.getId(), mergeOrCutTaskInfo.getId()); |
| 249 | 254 | redisUtil.set(key, mergeOrCutTaskInfo); |
| ... | ... | @@ -257,9 +262,9 @@ public class VideoFileService { |
| 257 | 262 | // 处理文件路径 |
| 258 | 263 | Path relativize = Paths.get(userSettings.getRecord()).relativize(Paths.get(result)); |
| 259 | 264 | mergeOrCutTaskInfo.setRecordFile(relativize.toString()); |
| 260 | - if (remoteHost != null) { | |
| 261 | - mergeOrCutTaskInfo.setDownloadFile(remoteHost + "/download.html?url=download/" + relativize); | |
| 262 | - mergeOrCutTaskInfo.setPlayFile(remoteHost + "/download/" + relativize); | |
| 265 | + if (videoTaskInfo.getRemoteHost() != null) { | |
| 266 | + mergeOrCutTaskInfo.setDownloadFile(videoTaskInfo.getRemoteHost() + "/download.html?url=download/" + relativize); | |
| 267 | + mergeOrCutTaskInfo.setPlayFile(videoTaskInfo.getRemoteHost() + "/download/" + relativize); | |
| 263 | 268 | } |
| 264 | 269 | logger.info("[录像合并] 成功, 任务ID:{}", taskId); |
| 265 | 270 | }else { | ... | ... |