浏览代码

相机文件修改权限

hexiao 2 年之前
父节点
当前提交
d8f980f9a2
共有 1 个文件被更改,包括 9 次插入8 次删除
  1. 9 8
      hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

+ 9 - 8
hazard-admin/src/main/java/com/ozs/web/core/util/CameraUtil.java

@@ -167,13 +167,14 @@ public class CameraUtil {
      * **String NewfilePath 合并后的视频存放地址,如:E:/mergevideo.mp4***
      */
     public static void convetor(List<String> fromVideoFileList,
-                                String NewfilePath) throws IOException {
-        File file = new File(NewfilePath);
+                                String newfilePath) throws IOException {
+        File file = new File(newfilePath);
         if (!file.getParentFile().exists()) {
             file.getParentFile().mkdirs();
             log.info("创建文件夹:{}", file.getParentFile().getPath());
-            Runtime.getRuntime().exec("chmod 777 " + file.getParentFile().getPath());
         }
+        log.info("newfilePath:{}", newfilePath);
+        Runtime.getRuntime().exec("chmod 777 " + file.getParentFile().getPath());
         List<String> voidTS = new ArrayList<>();
         Process process = null;
         ProcessBuilder builder = null;
@@ -224,6 +225,7 @@ public class CameraUtil {
                     inputStreamReader.close();
                     errorStream.close();
                 } catch (IOException e) {
+                    log.error(e.getMessage());
                     e.printStackTrace();
                 }
             } else {
@@ -248,7 +250,7 @@ public class CameraUtil {
         tsPath.append(" aac_adtstoasc ");
         tsPath.append(" -movflags ");
         tsPath.append(" +faststart ");
-        tsPath.append(NewfilePath);
+        tsPath.append(newfilePath);
         Process pr = Runtime.getRuntime().exec(
                 tsPath.toString());
         process.getInputStream();
@@ -257,17 +259,16 @@ public class CameraUtil {
         pr.getErrorStream().close();
         try {
             pr.waitFor();
-            Thread.sleep(1000);
-            pr.destroy();
         } catch (InterruptedException e) {
-            // TODO Auto-generated catch block
+            log.error(e.getMessage());
             e.printStackTrace();
+        } finally {
+            pr.destroy();
         }
         //删除生成的ts文件
         for (String filePath : voidTS) {
             File filet = new File(filePath);
             filet.delete();
-            pr.destroy();
         }
     }