|
@@ -1,6 +1,7 @@
|
|
|
package com.taais.biz.service.impl;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
@@ -11,6 +12,7 @@ import com.taais.biz.domain.bo.Video2imageBo;
|
|
|
import com.taais.biz.domain.vo.Video2imageVo;
|
|
|
import com.taais.biz.mapper.Video2imageMapper;
|
|
|
import com.taais.biz.service.IVideo2imageService;
|
|
|
+import com.taais.biz.utils.VideoCapture;
|
|
|
import com.taais.common.core.utils.MapstructUtils;
|
|
|
import com.taais.common.orm.core.page.PageQuery;
|
|
|
import com.taais.common.core.core.page.PageResult;
|
|
@@ -19,6 +21,8 @@ import jakarta.annotation.Resource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import static com.taais.biz.constant.BizConstant.VideoStatus.END;
|
|
|
+import static com.taais.biz.constant.BizConstant.VideoStatus.RUNNING;
|
|
|
import static com.taais.biz.domain.table.Video2imageTableDef.VIDEO2IMAGE;
|
|
|
|
|
|
/**
|
|
@@ -141,4 +145,54 @@ public class Video2imageServiceImpl extends BaseServiceImpl<Video2imageMapper, V
|
|
|
return this.removeByIds(Arrays.asList(ids));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public void updateStatusToEnd(Long id, String log) {
|
|
|
+ Video2image video2image = this.getById(id);
|
|
|
+ video2image.setStatus(END);
|
|
|
+ video2image.setLog(log);
|
|
|
+ video2image.setEndTime(new Date());
|
|
|
+ video2image.setCostSecond((video2image.getEndTime().getTime() - video2image.getStartTime().getTime()) / 1000);
|
|
|
+ this.updateById(video2image);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public boolean startToImage(Long id) {
|
|
|
+ Video2image video2image = this.getById(id);
|
|
|
+ if (ObjectUtil.isNull(video2image)) {
|
|
|
+ System.out.println("ObjectUtil.isNotNull(video2image)...");
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ System.out.println("开始截取图片...");
|
|
|
+
|
|
|
+ String videoPath = video2image.getPath();
|
|
|
+ String outPath = video2image.getOutPath();
|
|
|
+ Long fps = video2image.getFps();
|
|
|
+
|
|
|
+ System.out.println("videoPath: " + videoPath);
|
|
|
+ System.out.println("outPath: " + outPath);
|
|
|
+ System.out.println("fps: " + fps);
|
|
|
+
|
|
|
+ video2image.setStatus(RUNNING);
|
|
|
+ video2image.setStartTime(new Date());
|
|
|
+ this.updateById(video2image);
|
|
|
+
|
|
|
+ System.out.println("开始截取图片子线程...");
|
|
|
+
|
|
|
+ new Thread(() -> {
|
|
|
+ String log = "开始截取图片...\n";
|
|
|
+ System.out.println("开始截取图片...");
|
|
|
+ try {
|
|
|
+ VideoCapture.startCaputre(videoPath, outPath, fps);
|
|
|
+ System.out.println("视频转图片结束...");
|
|
|
+ log += "视频转图片结束...\n";
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ log += "视频转图片出现位置错误...\n";
|
|
|
+ log += e.getMessage();
|
|
|
+ }
|
|
|
+ updateStatusToEnd(id, log);
|
|
|
+ System.out.println("视频转图片子线程结束...");
|
|
|
+ }).start();
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|