Showing
6 changed files
with
109 additions
and
1 deletions
| 1 | +package com.wondertek.dto.image; | ||
| 2 | + | ||
| 3 | +import jakarta.validation.constraints.NotBlank; | ||
| 4 | +import jakarta.validation.constraints.NotEmpty; | ||
| 5 | +import jakarta.validation.constraints.NotNull; | ||
| 6 | +import lombok.Data; | ||
| 7 | + | ||
| 8 | +import java.io.Serializable; | ||
| 9 | +import java.util.*; | ||
| 10 | + | ||
| 11 | +@Data | ||
| 12 | +public class ImageVideoReq implements Serializable { | ||
| 13 | + | ||
| 14 | + // 抽帧偏移量(毫秒) | ||
| 15 | + @NotNull(message = "offset不可为空") | ||
| 16 | + private Long offset; | ||
| 17 | + | ||
| 18 | + // 输入参数,路径逗号分割 | ||
| 19 | + @NotBlank(message = "input参数集不可为空") | ||
| 20 | + private String input; | ||
| 21 | + | ||
| 22 | + // 截图参数 | ||
| 23 | + | ||
| 24 | + @NotEmpty(message = "output参数集不可为空") | ||
| 25 | + private List<OutPut> output; | ||
| 26 | +} |
| 1 | +package com.wondertek.dto.image; | ||
| 2 | +import jakarta.validation.constraints.NotBlank; | ||
| 3 | +import jakarta.validation.constraints.NotNull; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import java.io.Serializable; | ||
| 7 | + | ||
| 8 | +@Data | ||
| 9 | +public class OutPut implements Serializable { | ||
| 10 | + | ||
| 11 | + // 序号1开始 | ||
| 12 | + @NotNull(message = "index不可为空") | ||
| 13 | + private Integer index; | ||
| 14 | + // 图片保存完整路径 | ||
| 15 | + @NotBlank(message = "path不可为空") | ||
| 16 | + private String path; | ||
| 17 | + | ||
| 18 | +} |
| @@ -10,9 +10,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | @@ -10,9 +10,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||
| 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | 10 | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| 11 | import com.fasterxml.jackson.core.type.TypeReference; | 11 | import com.fasterxml.jackson.core.type.TypeReference; |
| 12 | import com.wondertek.dto.*; | 12 | import com.wondertek.dto.*; |
| 13 | +import com.wondertek.dto.image.ImageVideoReq; | ||
| 14 | +import com.wondertek.dto.image.OutPut; | ||
| 13 | import com.wondertek.entity.BackupConfig; | 15 | import com.wondertek.entity.BackupConfig; |
| 14 | import com.wondertek.entity.BackupMaterial; | 16 | import com.wondertek.entity.BackupMaterial; |
| 15 | import com.wondertek.entity.StreamTask; | 17 | import com.wondertek.entity.StreamTask; |
| 18 | +import com.wondertek.enums.MaterialSourceEnum; | ||
| 16 | import com.wondertek.enums.PlayTypeEnum; | 19 | import com.wondertek.enums.PlayTypeEnum; |
| 17 | import com.wondertek.exception.ServiceException; | 20 | import com.wondertek.exception.ServiceException; |
| 18 | import com.wondertek.mapper.BackupConfigMapper; | 21 | import com.wondertek.mapper.BackupConfigMapper; |
| @@ -52,6 +55,8 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | @@ -52,6 +55,8 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | ||
| 52 | private String switchStreamUrl; | 55 | private String switchStreamUrl; |
| 53 | @Value("${transcode.swapBackupUrl}") | 56 | @Value("${transcode.swapBackupUrl}") |
| 54 | private String swapBackupUrl; | 57 | private String swapBackupUrl; |
| 58 | + @Value("${rec.getImageUrl}") | ||
| 59 | + private String recGetImageUrl; | ||
| 55 | 60 | ||
| 56 | 61 | ||
| 57 | @Override | 62 | @Override |
| @@ -103,7 +108,7 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | @@ -103,7 +108,7 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | ||
| 103 | String fileName = backupUploadVo.getBackupName() + "." + backupUploadVo.getFileType(); | 108 | String fileName = backupUploadVo.getBackupName() + "." + backupUploadVo.getFileType(); |
| 104 | ///home/wondertek/material_file_assets/dianpian/2025/07/24/roomid/ | 109 | ///home/wondertek/material_file_assets/dianpian/2025/07/24/roomid/ |
| 105 | String filedir = FileUtils.generateDianPianDir(backupUploadVo.getRoomId().toString(), realPath); | 110 | String filedir = FileUtils.generateDianPianDir(backupUploadVo.getRoomId().toString(), realPath); |
| 106 | - String destFilePath = filedir + fileName;//文件上传目录,绝对路径 | 111 | + String destFilePath = filedir + realName;//文件上传目录,绝对路径 |
| 107 | try { | 112 | try { |
| 108 | fileService.upload(backupFile, destFilePath); | 113 | fileService.upload(backupFile, destFilePath); |
| 109 | } catch (Exception e) { | 114 | } catch (Exception e) { |
| @@ -276,6 +281,9 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | @@ -276,6 +281,9 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | ||
| 276 | } catch (Exception e) { | 281 | } catch (Exception e) { |
| 277 | return ResultBean.error("上传文件异常"); | 282 | return ResultBean.error("上传文件异常"); |
| 278 | } | 283 | } |
| 284 | + // | ||
| 285 | + | ||
| 286 | + | ||
| 279 | //保存垫片素材表 | 287 | //保存垫片素材表 |
| 280 | BackupMaterial backupMaterial = new BackupMaterial(); | 288 | BackupMaterial backupMaterial = new BackupMaterial(); |
| 281 | backupMaterial.setFileId(fileId); | 289 | backupMaterial.setFileId(fileId); |
| @@ -285,6 +293,41 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | @@ -285,6 +293,41 @@ public class BackupMaterialServiceImpl extends ServiceImpl<BackupMaterialMapper, | ||
| 285 | backupMaterial.setFileType(materialUploadVo.getFileType()); | 293 | backupMaterial.setFileType(materialUploadVo.getFileType()); |
| 286 | backupMaterial.setCreatedTime(LocalDateTime.now()); | 294 | backupMaterial.setCreatedTime(LocalDateTime.now()); |
| 287 | backupMaterial.setCreatedBy("admin"); | 295 | backupMaterial.setCreatedBy("admin"); |
| 296 | + backupMaterial.setDel("0"); | ||
| 297 | + backupMaterial.setSource(MaterialSourceEnum.UPLOAD.getCode()); | ||
| 298 | + | ||
| 299 | + //抽封面图,调用定帧抽图接口 | ||
| 300 | + ImageVideoReq imageVideoReq = new ImageVideoReq(); | ||
| 301 | + imageVideoReq.setInput(destFilePath); | ||
| 302 | + imageVideoReq.setOffset(0L); | ||
| 303 | + OutPut outPut = new OutPut(); | ||
| 304 | + outPut.setIndex(0); | ||
| 305 | + String coverPath = filedir + realName.substring(0, realName.lastIndexOf(".")) + ".jpg"; | ||
| 306 | + outPut.setPath(coverPath); | ||
| 307 | + imageVideoReq.setOutput(Arrays.asList(outPut)); | ||
| 308 | + try { | ||
| 309 | + HttpResponse execute = HttpRequest.post(recGetImageUrl) | ||
| 310 | + .header("Content-Type", "application/json") | ||
| 311 | + .body(JSONUtils.obj2json(imageVideoReq)).timeout(30000).execute(); | ||
| 312 | + if (execute.isOk()) { | ||
| 313 | + log.info("-->请求能力平台定帧抽图接口,url:{},paramsMap:{}",recGetImageUrl,imageVideoReq); | ||
| 314 | + String body = execute.body(); | ||
| 315 | + AbilityResp response = JSONUtils.jsonToObject(body, new TypeReference<AbilityResp>() { | ||
| 316 | + }); | ||
| 317 | + if (response.getRet() == 0) { | ||
| 318 | + backupMaterial.setCoverPath(coverPath.replace(realPath, "")); | ||
| 319 | + log.info("请求能力平台定帧抽图接口成功"); | ||
| 320 | + }else { | ||
| 321 | + log.info("请求能力平台定帧抽图接口响应失败,response:{}",response); | ||
| 322 | + throw new ServiceException("请求能力平台定帧抽图接口响应失败"); | ||
| 323 | + } | ||
| 324 | + } else { | ||
| 325 | + log.error("请求能力平台定帧抽图接口失败,url:{},body:{}", switchStreamUrl, execute.body()); | ||
| 326 | + } | ||
| 327 | + } catch (Exception e) { | ||
| 328 | + log.error("请求能力平台定帧抽图接口失败,url:{}", switchStreamUrl, e); | ||
| 329 | + } | ||
| 330 | + | ||
| 288 | backupMaterialMapper.insert(backupMaterial); | 331 | backupMaterialMapper.insert(backupMaterial); |
| 289 | 332 | ||
| 290 | return ResultBean.ok("新增素材成功"); | 333 | return ResultBean.ok("新增素材成功"); |
| 1 | +package com.wondertek.util; | ||
| 2 | + | ||
| 3 | +import com.wondertek.enums.GlobalCodeEnum; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +@Data | ||
| 7 | +public class AbilityResp { | ||
| 8 | + private String msg; | ||
| 9 | + private String taskId; | ||
| 10 | + private Integer ret; | ||
| 11 | + | ||
| 12 | + public Boolean isSuccess() { | ||
| 13 | + return GlobalCodeEnum.SUCCESS.getCode().equals(this.ret.toString()); | ||
| 14 | + } | ||
| 15 | +} |
| @@ -66,6 +66,9 @@ transcode: | @@ -66,6 +66,9 @@ transcode: | ||
| 66 | swapBackupUrl: http://192.168.1.237:9002/api/v1/swapBackup # 切垫片 | 66 | swapBackupUrl: http://192.168.1.237:9002/api/v1/swapBackup # 切垫片 |
| 67 | getTaskDetail: http://192.168.1.237:9002/api/v1/getTaskDetail | 67 | getTaskDetail: http://192.168.1.237:9002/api/v1/getTaskDetail |
| 68 | 68 | ||
| 69 | +rec: | ||
| 70 | + getImageUrl: http://192.168.1.97:12000/api/v3/picture/getImage #定帧抽图接口 | ||
| 71 | + | ||
| 69 | file: | 72 | file: |
| 70 | realPath: /home/wondertek/material_file_assets/dianpian/ | 73 | realPath: /home/wondertek/material_file_assets/dianpian/ |
| 71 | 74 |
| @@ -66,6 +66,9 @@ transcode: | @@ -66,6 +66,9 @@ transcode: | ||
| 66 | swapBackupUrl: http://192.168.1.237:9002/api/v1/swapBackup # 切垫片 | 66 | swapBackupUrl: http://192.168.1.237:9002/api/v1/swapBackup # 切垫片 |
| 67 | getTaskDetail: http://192.168.1.237:9002/api/v1/getTaskDetail | 67 | getTaskDetail: http://192.168.1.237:9002/api/v1/getTaskDetail |
| 68 | 68 | ||
| 69 | +rec: | ||
| 70 | + getImageUrl: http://192.168.1.97:12000/api/v3/picture/getImage #定帧抽图接口 | ||
| 71 | + | ||
| 69 | file: | 72 | file: |
| 70 | realPath: /home/wondertek/material_file_assets/dianpian/ | 73 | realPath: /home/wondertek/material_file_assets/dianpian/ |
| 71 | 74 |
-
Please register or login to post a comment