|
@@ -25,6 +25,7 @@ import com.iden.common.util.ByteUtil;
|
|
import com.iden.common.util.DateUtils;
|
|
import com.iden.common.util.DateUtils;
|
|
import com.iden.common.util.ImgUtil;
|
|
import com.iden.common.util.ImgUtil;
|
|
import com.iden.common.vo.*;
|
|
import com.iden.common.vo.*;
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -44,6 +45,7 @@ import java.util.*;
|
|
* @author makejava
|
|
* @author makejava
|
|
* @since 2021-05-21 00:08:38
|
|
* @since 2021-05-21 00:08:38
|
|
*/
|
|
*/
|
|
|
|
+@Slf4j
|
|
@Service
|
|
@Service
|
|
public class TraceService {
|
|
public class TraceService {
|
|
|
|
|
|
@@ -62,6 +64,9 @@ public class TraceService {
|
|
@Value("${file.url:#{null}}")
|
|
@Value("${file.url:#{null}}")
|
|
private String fileUrl;
|
|
private String fileUrl;
|
|
|
|
|
|
|
|
+ @Value("${ffmpeg.path:#{null}}")
|
|
|
|
+ private String ffmpegPath;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 上传图像
|
|
* 上传图像
|
|
* @param file
|
|
* @param file
|
|
@@ -266,4 +271,44 @@ public class TraceService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ public String cutVideo(Long videoId,String beginTime,String ednTime,UserLoginedConvertVO loginUser) {
|
|
|
|
+ String videoUrl = null;
|
|
|
|
+ try {
|
|
|
|
+ IdenCameraVideo idenCameraVideo = this.idenCameraVideoService.getById(videoId);
|
|
|
|
+ if(idenCameraVideo == null){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ IdenCamera idenCamera = this.idenCameraService.getById(idenCameraVideo.getCameraId());
|
|
|
|
+ if (idenCamera == null){
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ Long duration = DateUtils.betweenTimeSS(beginTime,ednTime); //s
|
|
|
|
+
|
|
|
|
+ String videoFileName = idenCameraVideo.getVideoUrl().substring(idenCameraVideo.getVideoUrl().lastIndexOf("/"));
|
|
|
|
+ String videoFileExt = videoFileName.substring(videoFileName.lastIndexOf("."));
|
|
|
|
+ String outFileName = UUID.randomUUID().toString() + "." + videoFileExt;
|
|
|
|
+
|
|
|
|
+ String videoFilepath = idenRoot + "data/final/camera/video/" + idenCamera.getCode() + "/" + videoFileName;
|
|
|
|
+ //String videoFilepath = "e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4";
|
|
|
|
+ String ountFilePath = idenRoot + "data/final/tmp/" + idenCamera.getCode() + "/" + outFileName;
|
|
|
|
+ //String ountFilePath = "e:/xx9.mp4";
|
|
|
|
+ videoUrl = fileUrl + "tmp/" + idenCamera.getCode() + "/" + outFileName;
|
|
|
|
+
|
|
|
|
+ String cmd = ffmpegPath + " -ss " + beginTime + " -i " + videoFilepath
|
|
|
|
+ + " -t " + duration + " -c:v copy -c:a copy " + ountFilePath;
|
|
|
|
+
|
|
|
|
+ log.info("开始运行视频剪辑命令:" + cmd);
|
|
|
|
+ Runtime.getRuntime().exec(cmd);
|
|
|
|
+ log.info("视频剪辑完成");
|
|
|
|
+
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return videoUrl;
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|