|
@@ -261,7 +261,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
// return webUrl + "/ws/" + channel + "/" + cameraCode + ".flv";
|
|
|
}
|
|
|
|
|
|
- public String heartbeatgetPlayFlv(String cameraCode, String channel) {
|
|
|
+ public String heartbeatgetPlayFlv(String cameraCode, String channel) {
|
|
|
List<String> pathList = new ArrayList<>();
|
|
|
String data = HttpUtils.sendGet(webUrl + "/rtsp/api/list");
|
|
|
if (StringUtils.isNotEmpty(data)) {
|
|
@@ -274,20 +274,20 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
boolean contains = pathList.contains(cameraCode + "/" + channel);
|
|
|
if (!contains) {
|
|
|
return null;
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
return getPlayFlv(cameraCode, channel, true);
|
|
|
}
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public String heartbeatgetUrl(String cameraCode, String channel) {
|
|
|
+ public String heartbeatgetUrl(String cameraCode, String channel) {
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
|
previewURLs(camerasVo, channel);
|
|
|
return getPlayFlv(cameraCode, channel, true);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
/**
|
|
|
* web页面实时流接口
|
|
|
*
|
|
@@ -741,7 +741,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @param endTm
|
|
|
* @return
|
|
|
*/
|
|
|
- public static String getRecordList(String code, Date startTm, Date endTm,String channel) {
|
|
|
+ public static String getRecordList(String code, Date startTm, Date endTm, String channel) {
|
|
|
PlaybackVo playbackVo = new PlaybackVo();
|
|
|
playbackVo.setCameraIndexCode(code);
|
|
|
|
|
@@ -772,7 +772,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
if ("0".equals(outJson.getString("code"))) {
|
|
|
JSONObject data = outJson.getJSONObject("data");
|
|
|
String urls = data.getString("url");
|
|
|
- log.info("urls----------->"+urls);
|
|
|
+ log.info("urls----------->" + urls);
|
|
|
try {
|
|
|
TimeUnit.SECONDS.sleep(3);
|
|
|
String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/" + channel + "&save=0");
|
|
@@ -1076,57 +1076,57 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
log.info("--------------->playbackURLs");
|
|
|
CompletableFuture future = CompletableFuture.supplyAsync(() -> {
|
|
|
log.info("异步任务开始-----》");
|
|
|
-// for (String code : list) {
|
|
|
- String code = "70b0bd685b0d4df1b4faf74ff5c1e7fd";
|
|
|
- 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";
|
|
|
+ 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";
|
|
|
// 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(70 * 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(70 * Integer.parseInt(alarmPlayTimeValue));
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ log.info("------videoCompression----->>>>:");
|
|
|
+ videoCompression(code);
|
|
|
}
|
|
|
- log.info("------videoCompression----->>>>:");
|
|
|
- videoCompression(code);
|
|
|
}
|
|
|
return 1;
|
|
|
});
|