suntianwu %!s(int64=3) %!d(string=hai) anos
pai
achega
8b66779789

+ 4 - 4
src/main/java/com/iden/bms/controller/TraceController.java

@@ -70,8 +70,8 @@ public class TraceController {
     @ApiOperation(value = "使用上传图像获取目标轨迹列表(地图打点划线) ")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(paramType = "query", name = "imageNames", value = "图像名称,多个用逗号分割"),
-            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间(yyyyMMdd HH:mm:ss)"),
-            @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间(yyyyMMdd HH:mm:ss)")
+            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间(yyyy-MM-dd HH:mm:ss)"),
+            @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间(yyyy-MM-dd HH:mm:ss)")
 
     })
     public Result<List<TraceVO>> listUploadImagesTrace(HttpServletRequest request, @RequestHeader(value = "token") String token,
@@ -93,8 +93,8 @@ public class TraceController {
     @ApiOperation(value = "获取摄像机视频列表")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(paramType = "query", name = "cameraId", value = "摄像机ID"),
-            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间(yyyyMMdd HH:mm:ss)"),
-            @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间(yyyyMMdd HH:mm:ss)")
+            @ApiImplicitParam(paramType = "query", name = "beginTime", value = "开始时间(yyyy-MM-dd HH:mm:ss"),
+            @ApiImplicitParam(paramType = "query", name = "endTime", value = "结束时间(yyyy-MM-dd HH:mm:ss)")
 
     })
     public Result<CameraVideoVO> getCameraVideoList(HttpServletRequest request, @RequestHeader("token") String token,

+ 12 - 4
src/main/java/com/iden/bms/service/TraceService.java

@@ -107,11 +107,11 @@ public class TraceService {
         List<TraceVO> result = new ArrayList<>();
         Date dateBegin = null;
         if(StringUtils.isNotEmpty(beginTime)){
-            dateBegin  = DateUtils.strToDate(beginTime,"yyyyMMdd HH:mm:ss");
+            dateBegin  = DateUtils.strToDate(beginTime,"yyyy-MM-dd HH:mm:ss");
         }
         Date dateEnd = null;
         if(StringUtils.isNotEmpty(endTime)){
-            dateEnd  = DateUtils.strToDate(endTime,"yyyyMMdd HH:mm:ss");
+            dateEnd  = DateUtils.strToDate(endTime,"yyyy-MM-dd HH:mm:ss");
         }
 
         if(imageNames.endsWith(",")) {
@@ -183,11 +183,19 @@ public class TraceService {
 
 
     public  List<CameraVideoVO> getCameraVideoList(Long cameraId, String beginTime,String endTime) {
+        Date dateBegin = null;
+        if(StringUtils.isNotEmpty(beginTime)){
+            dateBegin  = DateUtils.strToDate(beginTime,"yyyy-MM-dd HH:mm:ss");
+        }
+        Date dateEnd = null;
+        if(StringUtils.isNotEmpty(endTime)){
+            dateEnd  = DateUtils.strToDate(endTime,"yyyy-MM-dd HH:mm:ss");
+        }
         List<CameraVideoVO> vos = new ArrayList<>();
         QueryWrapper<IdenCameraVideo> queryWrapper = new QueryWrapper<>();
         queryWrapper.lambda().eq(IdenCameraVideo::getCameraId,cameraId)
-                .le(StringUtils.isNotEmpty(endTime),IdenCameraVideo::getPhotographBeginTime,endTime)
-                .ge(StringUtils.isNotEmpty(beginTime),IdenCameraVideo::getPhotographEndTime,beginTime)
+                .le(dateEnd != null,IdenCameraVideo::getPhotographBeginTime,dateEnd)
+                .ge(dateBegin != null,IdenCameraVideo::getPhotographEndTime,dateBegin)
                 .orderByAsc(IdenCameraVideo::getPhotographEndTime);
 
         List<IdenCameraVideo> idenCameraVideos = this.idenCameraVideoService.list(queryWrapper);

+ 10 - 3
src/test/java/com/face/video/VideoTest.java

@@ -207,6 +207,9 @@ public class VideoTest {
         return times;
     }
 
+
+
+/**********=======================================================以下实验没成功===============================***************/
     /**
      * 视频截取
      * @param videoFile
@@ -333,6 +336,10 @@ public class VideoTest {
 // Or run a two-pass encode (which is better quality at the cost of being slower)
         executor.createTwoPassJob(builder).run();
     }
+
+    /**********=======================================================以上实验没成功===============================***************/
+
+
     public static void main(String[] args) {
         try {
             //getList(10,113);
@@ -342,10 +349,10 @@ public class VideoTest {
 //            System.out.println(files.get(0).getName());
 //            System.out.println(VideoUtil.getVideoTime(file));
 
- //           Date shootEndTime = DateUtils.strToDate("20211223123223","yyyyMMddHHmmss");
- //          fetchAllPic(file,"E:/223",shootEndTime);
+         Date shootEndTime = DateUtils.strToDate("20211223123223","yyyyMMddHHmmss");
+         fetchAllPic(file,"E:/223",shootEndTime);
 //            cut3(file,new File("e:/a.mp4"));
-            cut3();
+   //         cut3();
         } catch (Exception e) {
             e.printStackTrace();
         }

+ 9 - 3
src/test/java/com/face/video/CmdExecuter.java

@@ -1,4 +1,4 @@
-package com.face.video;
+package com.face.video.cmd;
 
 import java.io.BufferedReader;
 import java.io.InputStreamReader;
@@ -39,8 +39,14 @@ public class CmdExecuter {
             e.printStackTrace();
         }finally{
             try {
-                proc.waitFor();
-                stdout.close();
+                if(proc != null){
+                    proc.waitFor();
+                }
+
+                if(stdout != null){
+                    stdout.close();
+                }
+
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 64 - 11
src/test/java/com/face/video/FFMPEG.java

@@ -1,4 +1,4 @@
-package com.face.video;
+package com.face.video.cmd;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -83,7 +83,7 @@ public class FFMPEG {
         // String ffmpeg_path,String input_path,String video_converted_path,String
         // logo,String screen_size,String xaxis,String yaxis,String vb,String ab
         List<String> cmd = new ArrayList<String>();
-        cmd.add("ffmpeg");
+        cmd.add(dto.get("ffmpeg_path"));
         cmd.add("-i");
         cmd.add(dto.get("input_path"));
 
@@ -106,17 +106,70 @@ public class FFMPEG {
         return returnSecond(converted_time);// 获取转换时间
     }
 
+    public String videoCut(HashMap<String, String> dto) {
+
+        List<String> cmd = new ArrayList<String>();
+        cmd.add(dto.get("ffmpeg_path"));
+
+        cmd.add("-ss");
+        cmd.add(dto.get("start"));
+
+        cmd.add("-i");
+        cmd.add(dto.get("input_path"));
+        cmd.add("-t");
+        cmd.add(dto.get("duration"));
+
+        cmd.add("-c:v copy");
+        cmd.add("-c:a copy");
+
+       // String xaxis = dto.get("xaxis");
+        //String yaxis = dto.get("yaxis");
+        //xaxis = xaxis != null && !xaxis.equals("") ? xaxis : "0";
+        //yaxis = yaxis != null && !yaxis.equals("") ? yaxis : "0";
+
+        //String cropString = "crop=" + width + ":" + height + ":" + xaxis + ":" + yaxis;
+        //String cropString = "crop=" + xaxis + ":" + yaxis;
+       // String cropString = "crop=" + width + ":" + height ;
+
+     //   cmd.add(cropString);
+
+        cmd.add(dto.get("video_converted_path"));
+        String converted_time = CmdExecuter.exec(cmd);
+        return returnSecond(converted_time);// 获取转换时间
+    }
+
+
+    public static String cut() {
+      String cmd0 = "D:\\program\\ffmpeg\\ffmpeg-4.3.1-2021-01-01-essentials_build\\bin\\ffmpeg.exe -ss 0:05 -i e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4" +
+              " -t 10 -c:v copy -c:a copy e:/output.mp4";
+        List<String> cmd = new ArrayList<String>();
+        cmd.add(cmd0);
+        String converted_time = CmdExecuter.exec(cmd);
+        return converted_time;
+    }
+
     public static void main(String[] arg) {
-        HashMap<String, String> dto = new HashMap<String, String>();
-        dto.put("ffmpeg_path", "D:\\program\\ffmpeg\\ffmpeg.exe");// 必填
+//        HashMap<String, String> dto = new HashMap<String, String>();
+//        dto.put("ffmpeg_path", "D:\\program\\ffmpeg\\ffmpeg-4.3.1-2021-01-01-essentials_build\\bin\\ffmpeg.exe");// 必填
+//        dto.put("input_path", "e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4");// 必填
+//        //dto.put("width", "720");// 必填
+//        //dto.put("height", "1280");
+//        dto.put("width", "640");
+//        dto.put("height", "368");
+//        dto.put("video_converted_path", "e:\\b2.mp4");
+//        String secondsString = new FFMPEG().videoTransfer(dto);
+
+         HashMap<String, String> dto = new HashMap<String, String>();
+        dto.put("ffmpeg_path", "D:\\program\\ffmpeg\\ffmpeg-4.3.1-2021-01-01-essentials_build\\bin\\ffmpeg.exe");// 必填
         dto.put("input_path", "e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4");// 必填
-        //dto.put("width", "720");// 必填
-        //dto.put("height", "1280");
-        dto.put("width", "540");
-        dto.put("height", "796");
-        dto.put("video_converted_path", "e:\\b3.mp4");
-        String secondsString = new FFMPEG().videoTransfer(dto);
-        System.out.println("转换共用:" + secondsString + "秒");
+        dto.put("start", "0:05");// 必填
+        dto.put("duration", "10");
+        //dto.put("width", "640");
+        //dto.put("height", "368");
+        dto.put("video_converted_path", "e:\\b0.mp4");
+        String secondsString = new FFMPEG().videoCut(dto);
+
+        System.out.println("转换共用:" +  cut() + "秒");
     }
 
 }

+ 1 - 1
src/test/java/com/face/video/VideoThumbTaker.java

@@ -1,4 +1,4 @@
-package com.face.video;
+package com.face.video.cmd;
 
 import java.io.BufferedReader;
 import java.io.IOException;

+ 76 - 0
src/test/java/com/face/videoCmd.java

@@ -0,0 +1,76 @@
+package com.face;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+public class videoCmd {
+    private BufferedReader reader;
+    public void exe(){
+        try {
+            String ffmpegPath = "D:\\program\\ffmpeg\\ffmpeg-4.3.1-2021-01-01-essentials_build\\bin\\ffmpeg.exe";
+            // 执行tail -f命令
+            Process process = Runtime.getRuntime().exec( ffmpegPath + " -ss 0:05 -i e:/20211223123223_76639ced-6400-11ec-b8f9-fa163e4e1e9f.mp4 -t 10 -c:v copy -c:a copy e:/555.mp4 ");
+            InputStream inputStream = process.getInputStream();
+            this.reader = new BufferedReader(new InputStreamReader(inputStream));
+            String line;
+            try {
+                while((line = reader.readLine()) != null) {
+                    System.out.println(line);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                if(reader != null){
+                    try {
+                        reader.close();
+                    } catch (Exception e){
+                        e.printStackTrace();
+                    }
+
+                }
+            }
+//            // 一定要启动新的线程,防止InputStream阻塞处理WebSocket的线程
+//            TailLogThread thread = new TailLogThread(inputStream);
+//            thread.start();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+
+        }
+    }
+    public static void main(String[] args) {
+       new videoCmd().exe();
+    }
+
+    class  TailLogThread extends Thread {
+        private BufferedReader reader;
+
+        public TailLogThread(InputStream in) {
+            this.reader = new BufferedReader(new InputStreamReader(in));
+        }
+
+        @Override
+        public void run() {
+            String line;
+            try {
+                while((line = reader.readLine()) != null) {
+                    System.out.println(line);
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            } finally {
+                if(reader != null){
+                    try {
+                        reader.close();
+                    } catch (Exception e){
+                        e.printStackTrace();
+                    }
+
+                }
+            }
+        }
+    }
+}