|
@@ -260,6 +260,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
/**
|
|
|
* web页面实时流接口
|
|
|
+ *
|
|
|
* @param cameraCode
|
|
|
* @param channel
|
|
|
* @return
|
|
@@ -561,7 +562,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
host = caneraConfig.getHost();
|
|
|
appKey = caneraConfig.getAppKey();
|
|
|
appSecret = caneraConfig.getAppSecret();
|
|
|
- rtmpUrl=caneraConfig.getRtmpUrl();
|
|
|
+ rtmpUrl = caneraConfig.getRtmpUrl();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -704,6 +705,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
/**
|
|
|
* web页面视频回放接口
|
|
|
+ *
|
|
|
* @param code
|
|
|
* @param startTm
|
|
|
* @param endTm
|
|
@@ -744,8 +746,8 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
@Override
|
|
|
public String call() throws Exception {
|
|
|
// 执行网络请求...
|
|
|
- log.info(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv "+rtmpUrl+"/live/" + code);
|
|
|
- cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv "+rtmpUrl+"/live/" + code);
|
|
|
+ log.info(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv " + rtmpUrl + "/live/" + code);
|
|
|
+ cmdCameraUtil.cmd(ffmpegPath + " -re -i /opt/streams/compress/" + code + ".mp4 -c:v copy -c:a copy -f flv " + rtmpUrl + "/live/" + code);
|
|
|
return "Response";
|
|
|
}
|
|
|
};
|
|
@@ -759,7 +761,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
}
|
|
|
|
|
|
executor.shutdown();
|
|
|
- return bakUrlRtsp+"/live/"+code;
|
|
|
+ return bakUrlRtsp + "/live/" + code;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -767,9 +769,9 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* RTSP流视频压缩
|
|
|
*/
|
|
|
public void videoCompression(String code) {
|
|
|
- // 执行网络请求...
|
|
|
- log.info(ffmpegPath + " -i /opt/streams/map/"+code+".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code+".mp4");
|
|
|
- cmdCameraUtil.cmd(ffmpegPath + " -i /opt/streams/map/"+code+".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code+".mp4");
|
|
|
+ // 执行网络请求...
|
|
|
+ log.info(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code + ".mp4");
|
|
|
+ cmdCameraUtil.cmd(ffmpegPath + " -i /opt/streams/map/" + code + ".mp4 -c:v libx264 -s 640x480 -c:a adpcm_swf -ar 44100 /opt/streams/compress/" + code + ".mp4");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -940,10 +942,11 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
/**
|
|
|
* 车载终端实时流调用的远程天网接口
|
|
|
+ *
|
|
|
* @param camerasVo
|
|
|
* @param channel
|
|
|
*/
|
|
|
- public String apiPreviewURLs(CamerasVo camerasVo) {
|
|
|
+ public String apiPreviewURLs(CamerasVo camerasVo) {
|
|
|
/**
|
|
|
* jsonBody.put("cameraIndexCode", "01ea43e6676f4e47bd6c5cd9e02aa006");
|
|
|
* jsonBody.put("streamType", 0);
|
|
@@ -963,13 +966,14 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
JSONObject data = outJson.getJSONObject("data");
|
|
|
String urls = data.getString("url");
|
|
|
return urls;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return "1";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* web页面实时流调用的远程天网接口
|
|
|
+ *
|
|
|
* @param camerasVo
|
|
|
* @param channel
|
|
|
*/
|
|
@@ -1000,36 +1004,37 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
/**
|
|
|
* 报警回放本地测试
|
|
|
* 从天网拉回放流,然后根据url把流下载下来变成文件,然后进行视频压缩
|
|
|
+ *
|
|
|
* @param list
|
|
|
* @param alarmPlayTimeValue
|
|
|
*/
|
|
|
public void playbackURLs(List<String> list, String alarmPlayTimeValue) {
|
|
|
log.info("--------------->playbackURLs");
|
|
|
- CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
- log.info("异步任务开始-----》");
|
|
|
+// CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
+// log.info("异步任务开始-----》");
|
|
|
// for (String code : list) {
|
|
|
- String code="42010001541320000024";
|
|
|
- PlaybackVo playbackVo = new PlaybackVo();
|
|
|
- playbackVo.setCameraIndexCode(code);
|
|
|
- // 获取当前时间
|
|
|
- OffsetDateTime currentTime = OffsetDateTime.now();
|
|
|
- // 获取当前时间的前10分钟时间
|
|
|
- OffsetDateTime beforeTenMinutes = currentTime.minusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
- // 获取当前时间的后10分钟时间
|
|
|
- OffsetDateTime afterTenMinutes = currentTime.plusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
- // 格式化时间
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
|
|
- playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
|
|
|
- //现在当前时间:后续需要修改成报警时间的后几分钟
|
|
|
- playbackVo.setEndTime(currentTime.format(formatter));
|
|
|
- // jsonBody.put("protocol","rtsp");
|
|
|
- // jsonBody.put("expand","streamform=rtp");
|
|
|
- playbackVo.setProtocol("rtsp");
|
|
|
- playbackVo.setExpand("streamform=rtp");
|
|
|
- //对象转换json字符串
|
|
|
- String body = JSONObject.toJSONString(playbackVo);
|
|
|
- //调用天网接口
|
|
|
- log.info("body----->" + body);
|
|
|
+ String code = "42010001541320000024";
|
|
|
+// PlaybackVo playbackVo = new PlaybackVo();
|
|
|
+// playbackVo.setCameraIndexCode(code);
|
|
|
+// // 获取当前时间
|
|
|
+// OffsetDateTime currentTime = OffsetDateTime.now();
|
|
|
+// // 获取当前时间的前10分钟时间
|
|
|
+// OffsetDateTime beforeTenMinutes = currentTime.minusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
+// // 获取当前时间的后10分钟时间
|
|
|
+// OffsetDateTime afterTenMinutes = currentTime.plusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
+// // 格式化时间
|
|
|
+// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
|
|
+// playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
|
|
|
+// //现在当前时间:后续需要修改成报警时间的后几分钟
|
|
|
+// playbackVo.setEndTime(currentTime.format(formatter));
|
|
|
+// // jsonBody.put("protocol","rtsp");
|
|
|
+// // jsonBody.put("expand","streamform=rtp");
|
|
|
+// playbackVo.setProtocol("rtsp");
|
|
|
+// playbackVo.setExpand("streamform=rtp");
|
|
|
+// //对象转换json字符串
|
|
|
+// String body = JSONObject.toJSONString(playbackVo);
|
|
|
+// //调用天网接口
|
|
|
+// log.info("body----->" + body);
|
|
|
// String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
// log.info("playbackURLs----->" + playbackURLs);
|
|
|
// JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
|
|
@@ -1039,16 +1044,31 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
// String urls = data.getString("url");
|
|
|
// log.info("--------------->urls::" + urls);
|
|
|
|
|
|
- String FilePath = "/opt/streams/map/"+code+".mp4";
|
|
|
-// String FilePath = "/opt/streams/map/01ea43e6676f4e47bd6c5cd9e02aa006.mp4";
|
|
|
- Process process = rtspToMP4.StartRecord(ffmpegPath, "rtsp://124.70.58.209:8554/"+code+"/"+code, FilePath);
|
|
|
- log.info("------playbackURLs----->>>>:" + process);
|
|
|
- if (null != process) {
|
|
|
- map.put(code, process);
|
|
|
- }
|
|
|
- return 1;
|
|
|
+// String FilePath = "/opt/streams/map/"+code+".mp4";
|
|
|
+//// String FilePath = "/opt/streams/map/01ea43e6676f4e47bd6c5cd9e02aa006.mp4";
|
|
|
+// Process process = rtspToMP4.StartRecord(ffmpegPath, "rtsp://124.70.58.209:8554/"+code+"/"+code, FilePath);
|
|
|
+// log.info("------playbackURLs----->>>>:" + process);
|
|
|
+// if (null != process) {
|
|
|
+// map.put(code, process);
|
|
|
+// }
|
|
|
+// return 1;
|
|
|
+// });
|
|
|
+// future.join();
|
|
|
+
|
|
|
+
|
|
|
+ CompletableFuture<Void> recordFuture = CompletableFuture.runAsync(() -> {
|
|
|
+ log.info("异步任务开始-----》");
|
|
|
+ String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
+ rtspToMP4.StartRecord(ffmpegPath, "rtsp://124.70.58.209:8554/" + code + "/" + code, FilePath);
|
|
|
});
|
|
|
- future.join();
|
|
|
+
|
|
|
+ CompletableFuture<Integer> compressionFuture = recordFuture.thenApplyAsync(result ->
|
|
|
+ {
|
|
|
+ videoCompression(code);
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ compressionFuture.join();
|
|
|
}
|
|
|
|
|
|
public AjaxResult stop(String id) {
|