gao.qiang 1 год назад
Родитель
Сommit
ad4d0fdc34

+ 6 - 28
business-service/src/main/java/com/ozs/utils/CameraUtil.java

@@ -741,32 +741,6 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
     }
 
 
-    /**
-     * RTSP流下载
-     */
-    public  void streamUrlDownload(String url, String code) {
-        ExecutorService executor = Executors.newSingleThreadExecutor();
-        Callable<String> task = new Callable<String>() {
-            @Override
-            public String call() throws Exception {
-                // 执行网络请求...
-                log.info(ffmpegPath + " -loglevel debug -i " + url + " -codec copy /opt/streams/map/" + code+".mp4");
-                cmdCameraUtil.cmd(ffmpegPath + " -i " + url + " -codec copy /opt/streams/map/" + code+".mp4");                return "Response";
-            }
-        };
-
-        try {
-            String result = executor.submit(task).get(1, TimeUnit.SECONDS); // 设置5秒超时时间
-            System.out.println("Response: " + result);
-        } catch (InterruptedException | ExecutionException | TimeoutException e) {
-            // 请求超时处理逻辑
-            System.out.println("Request timeout");
-        }
-
-        executor.shutdown();
-    }
-
-
     public static List<Map<String, Object>> filterRecordList(String channel,
                                                              Date startTm,
                                                              Date endTm,
@@ -980,8 +954,12 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
 //                    log.info("outJson----->" + outJson);
 //                    JSONObject data = outJson.getJSONObject("data");
 //                    String urls = data.getString("url");
-                log.info("--------------->code::"+code);
-                streamUrlDownload("rtsp://124.70.58.209:8554/42010001541320000024/42010001541320000024", code);
+                log.info("--------------->code::" + code);
+                FfmpegUtil recordVideoThread = new FfmpegUtil();
+                recordVideoThread.out_file_path = "/opt/streams/map/"+code+".mp4";
+                recordVideoThread.times_sec = 30L;// 最好设置结束时长 如直接停止程序会造成输出文件的损坏无法正常播放
+                recordVideoThread.is_audio = true;
+                new Thread(recordVideoThread).start();
 //                }
             }
             return 1;

+ 4 - 6
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -27,7 +27,6 @@ import com.ozs.system.service.DataScoreUtil;
 import com.ozs.system.service.ISysDeptService;
 import com.ozs.utils.CameraUtil;
 import com.ozs.utils.CaneraConfig;
-import com.ozs.utils.FfmpegUtil;
 import com.ozs.web.core.config.GetCameraPreviewURL;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -1036,11 +1035,10 @@ public class BaseCameraManagementController extends BaseController {
     @ApiOperation("报警回放本地测试")
     @Log(title = "相机台账管理", businessType = BusinessType.MESSAGE)
     public AjaxResult getAlarmRecord() {
-        FfmpegUtil recordVideoThread = new FfmpegUtil();
-        recordVideoThread.out_file_path = "/opt/streams/map/42010001541320000024.mp4";
-        recordVideoThread.times_sec = 10L;// 最好设置结束时长 如直接停止程序会造成输出文件的损坏无法正常播放
-        recordVideoThread.is_audio = true;
-        new Thread(recordVideoThread).start();        return AjaxResult.success("ok");
+        List<BaseCameraManagement> list = baseCameraManagementService.list(new QueryWrapper<BaseCameraManagement>().eq("line_dir",2));
+        List<String> collect = list.stream().map(BaseCameraManagement::getCameraCode).collect(Collectors.toList());
+        CompletableFuture.runAsync(() -> cameraUtil.playbackURLs(collect));
+        return AjaxResult.success("ok");
     }
 
 }