hexiao 2 anni fa
parent
commit
d5f5043ccb

+ 21 - 13
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -28,6 +28,8 @@ import java.io.*;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -77,22 +79,28 @@ public class CameraUtil {
         if (ObjectUtils.isEmpty(fromVideoFileList) || fromVideoFileList.size() <= 0) {
             throw new BaseException("当前相机无视频录像");
         }
-        new Thread(() -> {
-            try {
-                Map<String, String> map = myConvetor(fromVideoFileList, NewfilePath, uuid);
-                if (!ObjectUtils.isEmpty(map)) {
-                    cUtil.cmd(map.get("cmd"));
-                    //删除生成的ts文件
-                    File file1 = new File(map.get("path"));
-                    if (file1.exists()) {
-                        file1.delete();
+        ExecutorService executor = Executors.newFixedThreadPool(10);
+
+        executor.submit(new Runnable() {
+            @Override
+            public void run() {
+                try {
+                    Map<String, String> map = myConvetor(fromVideoFileList, NewfilePath, uuid);
+                    if (!ObjectUtils.isEmpty(map)) {
+                        cUtil.cmd(map.get("cmd"));
+                        //删除生成的ts文件
+                        File file1 = new File(map.get("path"));
+                        if (file1.exists()) {
+                            file1.delete();
+                        }
                     }
+                } catch (IOException e) {
+                    log.error(e.getMessage());
+                    e.printStackTrace();
                 }
-            } catch (IOException e) {
-                log.error(e.getMessage());
-                e.printStackTrace();
             }
-        }).start();
+        });
+        executor.shutdown();
 
         return Constants.RESOURCE_PREFIX + "/" + ph;
     }