Преглед на файлове

替换合并视频代码

hexiao преди 1 година
родител
ревизия
d026620d3f
променени са 1 файла, в които са добавени 15 реда и са изтрити 7 реда
  1. 15 7
      hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

+ 15 - 7
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -13,6 +13,7 @@ import com.ozs.service.entity.BaseCameraManagement;
 import com.ozs.service.service.BaseCameraManagementService;
 import com.ozs.system.mapper.SysDictDataMapper;
 import com.ozs.web.core.config.CaneraConfig;
+import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -44,7 +45,7 @@ import java.util.stream.Collectors;
 @Component
 public class CameraUtil {
 
-   private static final ExecutorService executor = Executors.newFixedThreadPool(10);
+    private static final ExecutorService executor = Executors.newFixedThreadPool(20);
     private static String historyUrl;
     private static String ffmpegPath;
     private static String filePath;
@@ -359,6 +360,7 @@ public class CameraUtil {
     }
 
 
+    @SneakyThrows
     public static void txConvetor(List<String> fromVideoFileList,
                                   String newfilePath,
                                   String uuid) throws IOException {
@@ -385,6 +387,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
                 // ffmpeg -i 20230411_155948_160048-f91fea03-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 2.ts
                 log.info("file:{}", fromVideoFileList.get(t));
                 String substring = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("."));
+                int x;//定义两变量
+                Random ne = new Random();//实例化一个random的对象ne
+                x = ne.nextInt(9999 - 1000 + 1) + 1000;//为变量赋随机值1000-9999
+                substring = substring + x;//定义两变量
+
                 String cmdstr = ffmpegPath + " -i " + fromVideoFileList.get(t) + " -c:v copy " + substring + ".ts";
                 log.info("转换命令:{}", cmdstr);
                 cUtil.cmd(cmdstr);
@@ -402,12 +409,13 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
             log.info("合并命令:{}", sm.toString());
             cUtil.cmd(sm.toString());
         }
-//        for (String fileT : fileTs) {
-//            File ft = new File(fileT);
-//            if (ft.exists()) {
-//                ft.delete();
-//            }
-//        }
+        Thread.sleep(2000L);
+        for (String fileT : fileTs) {
+            File ft = new File(fileT);
+            if (ft.exists()) {
+                ft.delete();
+            }
+        }
     }
 
     @PostConstruct