Bläddra i källkod

相机cardNo修改cardNum

hexiao 2 år sedan
förälder
incheckning
d67496997d

+ 53 - 12
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -7,6 +7,7 @@ import com.ozs.common.exception.base.BaseException;
 import com.ozs.common.utils.DateUtils;
 import com.ozs.common.utils.http.HttpUtils;
 import com.ozs.web.core.config.CaneraConfig;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -22,6 +23,7 @@ import java.util.regex.Pattern;
  * 相机工具
  */
 @Component
+@Slf4j
 public class CameraUtil {
 
     private static String url;
@@ -43,6 +45,8 @@ public class CameraUtil {
     public static String historyPlay(List<String> fromVideoFileList, String ph) throws IOException {
         // 视频服务映射路径
         String NewfilePath = BaseConfig.getProfile() + ph;
+        log.info("NewfilePath:{}", NewfilePath);
+        log.info("fromVideoFileList:{}", fromVideoFileList);
         convetor(fromVideoFileList, NewfilePath);
         return "/profile" + ph;
     }
@@ -67,7 +71,7 @@ public class CameraUtil {
     }
 
 
-    public static String historyPlayList(String channel, Date startTm, Date endTm) {
+    public static List<String> historyPlayList(String channel, Date startTm, Date endTm) {
         if (StringUtils.isBlank(channel)
                 || ObjectUtils.isEmpty(startTm)
                 || ObjectUtils.isEmpty(endTm)) {
@@ -77,14 +81,14 @@ public class CameraUtil {
         List<String> ls = new ArrayList<>();
         // 调用视频服务返回参数
         String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
-        String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
+        String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
         String ph = "/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
                 + "/" + channel + "/" + startTime + "/" + endTime + "/"
                 + UUID.randomUUID().toString() + ".flv";
         String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
         String s = HttpUtils.sendGet(historyUrl + "/api/record/flv/list", param);
         // 视频拼接
-        if (!StringUtils.isBlank(s)) {
+        if (!StringUtils.isBlank(s) || "null".equals(s)) {
             List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
             for (Map<String, Object> map : maps) {
                 Object path = map.get("Path");
@@ -99,19 +103,19 @@ public class CameraUtil {
                         Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
                         Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
                         /*     s | e     | */
-                        if (sdate.compareTo(startTm) <= 0 && edate.compareTo(startTm) > 0) {
+                        if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) > 0) {
                             ls.add(mappingUrl + path.toString());
 
                             /*  |   s    e    | */
-                        } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) <= 0) {
+                        } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) <= 0) {
                             ls.add(mappingUrl + path.toString());
 
                             /*  |   s     |  e  */
-                        } else if (sdate.compareTo(startTm) >= 0 && edate.compareTo(endTm) >= 0) {
+                        } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) >= 0) {
                             ls.add(mappingUrl + path.toString());
 
                             /*  s|      | e  */
-                        } else if (sdate.compareTo(startTm) <= 0 && edate.compareTo(endTm) >= 0) {
+                        } else if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) >= 0) {
                             ls.add(mappingUrl + path.toString());
                         }
                     }
@@ -119,11 +123,12 @@ public class CameraUtil {
             }
         }
         if (!ObjectUtils.isEmpty(ls)) {
-            try {
-                return historyPlay(ls, ph);
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
+            return ls;
+//            try {
+//                return historyPlay(ls, ph);
+//            } catch (IOException e) {
+//                e.printStackTrace();
+//            }
         }
         return null;
     }
@@ -144,6 +149,7 @@ public class CameraUtil {
      */
     public static void convetor(List<String> fromVideoFileList,
                                 String NewfilePath) throws IOException {
+
         new Thread(
                 () -> {
                     try {
@@ -255,4 +261,39 @@ public class CameraUtil {
     }
 
 
+    /**
+     * 合并多个视频文件
+     */
+    public static void mergeFile(List<String> fromVideoFileList, String NewfilePath) {
+        // 合并命令
+        String commit = "$0 -f concat -safe 0 -i $1 -c copy $2";
+
+        String str = commit.replace("$0", ffmpegPath);
+        if (!ObjectUtils.isEmpty(fromVideoFileList)) {
+            for (String s : fromVideoFileList) {
+                str = str.replace("$1", s);
+            }
+        }
+        str = str.replace("$2", NewfilePath);
+        System.out.println(str);
+        Runtime runtime = Runtime.getRuntime();
+        try {
+            Process proce = runtime.exec(str);
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    public static void main(String[] args) throws IOException {
+
+        List<String> fromVideoFileList = new ArrayList();
+        String p = "C:\\Users\\Administrator.DESKTOP-0NUUTMM\\Desktop\\work\\106\\流媒体\\";
+        String NewfilePath = p + "mergevideo.flv";
+        fromVideoFileList.add(p + "20230303_174931_175031-d6d56396-b9a8-11ed-aeb9-00163e06a5f3.flv");
+        fromVideoFileList.add(p + "20230303_175032_175132-fb32b9fe-b9a8-11ed-aeb9-00163e06a5f3.flv");
+        fromVideoFileList.add(p + "20230303_175133_175233-1f97af04-b9a9-11ed-aeb9-00163e06a5f3.flv");
+        fromVideoFileList.add(p + "20230303_175234_175334-43f4daf1-b9a9-11ed-aeb9-00163e06a5f3.flv");
+        convetor(fromVideoFileList, NewfilePath);
+
+    }
 }

+ 3 - 2
hazard-admin/src/main/resources/application.yml

@@ -9,12 +9,13 @@ base:
   # 实例演示开关
   demoEnabled: true
   # 文件路径 示例( Windows配置D:/ruoyi/uploadPath,Linux配置 /home/ruoyi/uploadPath)
-  profile: /data/service/hazard-admin/uploadPath
+  #  profile: /data/service/hazard-admin/uploadPath
+  profile: C:\base\uploadPath
   # 获取ip地址开关
   addressEnabled: false
   # 验证码类型 math 数组计算 char 字符验证
   captchaType: math
-#  path: http://47.106.159.135:8554
+  #  path: http://47.106.159.135:8554
   path: http://47.106.159.135:8554
   ffmpegPath: /usr/local/ffmpeg/bin/ffmpeg