|
@@ -275,7 +275,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
if (!contains) {
|
|
|
return null;
|
|
|
} else {
|
|
|
- return getPlayFlv(cameraCode, channel, true);
|
|
|
+ return getPlayFlvRtsp(cameraCode, channel, true);
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
@@ -285,7 +285,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
|
previewURLs(camerasVo, channel);
|
|
|
- return getPlayFlv(cameraCode, channel, true);
|
|
|
+ return getPlayFlvRtsp(cameraCode, channel, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1074,63 +1074,58 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
*/
|
|
|
public void playbackURLs(List<String> list, String alarmPlayTimeValue) {
|
|
|
log.info("--------------->playbackURLs");
|
|
|
- CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
- log.info("异步任务开始-----》");
|
|
|
- for (String code : list) {
|
|
|
- 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(afterTenMinutes.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);
|
|
|
- if ("0".equals(outJson.getString("code"))) {
|
|
|
- log.info("outJson----->" + outJson);
|
|
|
- JSONObject data = outJson.getJSONObject("data");
|
|
|
- String urls = data.getString("url");
|
|
|
- log.info("--------------->urls::" + urls);
|
|
|
-
|
|
|
- String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
+ for (String code : list) {
|
|
|
+ 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);
|
|
|
+ if ("0".equals(outJson.getString("code"))) {
|
|
|
+ log.info("outJson----->" + outJson);
|
|
|
+ JSONObject data = outJson.getJSONObject("data");
|
|
|
+ String urls = data.getString("url");
|
|
|
+ log.info("--------------->urls::" + urls);
|
|
|
+
|
|
|
+ String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
// String FilePath = "/opt/streams/map/01ea43e6676f4e47bd6c5cd9e02aa006.mp4";
|
|
|
// try {
|
|
|
// TimeUnit.SECONDS.sleep(62*Integer.parseInt(alarmPlayTimeValue));
|
|
|
// } catch (InterruptedException e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
- Process process = rtspToMP4.StartRecord(ffmpegPath, urls, FilePath);
|
|
|
- log.info("------playbackURLs----->>>>:" + process);
|
|
|
- if (null != process) {
|
|
|
- map.put(code, process);
|
|
|
- }
|
|
|
- try {
|
|
|
- TimeUnit.SECONDS.sleep(100 * Integer.parseInt(alarmPlayTimeValue));
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- log.info("------videoCompression----->>>>:");
|
|
|
- videoCompression(code);
|
|
|
+ Process process = rtspToMP4.StartRecord(ffmpegPath, urls, FilePath);
|
|
|
+ log.info("------playbackURLs----->>>>:" + process);
|
|
|
+ if (null != process) {
|
|
|
+ map.put(code, process);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ TimeUnit.SECONDS.sleep(70 * Integer.parseInt(alarmPlayTimeValue));
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ log.info("------videoCompression----->>>>:");
|
|
|
+ videoCompression(code);
|
|
|
}
|
|
|
- return 1;
|
|
|
- });
|
|
|
- future.join();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public AjaxResult stop(String id) {
|