|
@@ -744,9 +744,26 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
/**
|
|
|
* RTSP流下载
|
|
|
*/
|
|
|
- public static void streamUrlDownload(String url, String code) {
|
|
|
- log.info(ffmpegPath + " -i " + url + " -codec copy /opt/streams/map/" + code+".mp4");
|
|
|
- cUtil.cmd(ffmpegPath + " -i " + url + " -codec copy /opt/streams/map/" + code+".mp4");
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
|