|
@@ -271,6 +271,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
/**
|
|
|
* 点播的时候使用
|
|
|
+ *
|
|
|
* @param cameraCode
|
|
|
* @param channel
|
|
|
* @param flay
|
|
@@ -279,10 +280,10 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
public static String getPlayFlvRtsps(String cameraCode, String channel, boolean flay) {
|
|
|
if (!flay) {
|
|
|
log.info("-----getPlayFlvRtsps------11------>" + bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv");
|
|
|
- return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel+".flv";
|
|
|
+ return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv";
|
|
|
}
|
|
|
log.info("-------getPlayFlvRtsps----22------>" + bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv");
|
|
|
- return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel+".flv";
|
|
|
+ return bakUrlRtsp + "/hdl/" + cameraCode + "/" + channel + ".flv";
|
|
|
|
|
|
|
|
|
// if (!flay) {
|
|
@@ -386,7 +387,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- public String heartbeatgetUrl(String cameraCode, String channel, boolean type) throws Exception{
|
|
|
+ public String heartbeatgetUrl(String cameraCode, String channel, boolean type) throws Exception {
|
|
|
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
@@ -400,7 +401,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
return future.get();
|
|
|
}
|
|
|
|
|
|
- public String heartbeatgetUrls(String cameraCode, String channel, boolean type) throws Exception{
|
|
|
+ public String heartbeatgetUrls(String cameraCode, String channel, boolean type) throws Exception {
|
|
|
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
|
|
|
CamerasVo camerasVo = new CamerasVo();
|
|
|
camerasVo.setCameraIndexCode(cameraCode);
|
|
@@ -1080,7 +1081,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
log.info("GetCameraPreviewURL----->" + result);
|
|
|
long end = System.currentTimeMillis();
|
|
|
log.info("接受天网接口相应时间: " + sdf.format(new Date(end)));
|
|
|
- log.info("天网接口请求用时时间:" + (begin - end) / 1000+"秒");
|
|
|
+ log.info("天网接口请求用时时间:" + (begin - end) / 1000 + "秒");
|
|
|
return result;
|
|
|
}
|
|
|
|
|
@@ -1195,36 +1196,39 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
* @param list
|
|
|
* @param alarmPlayTimeValue
|
|
|
*/
|
|
|
- public void playbackURLs(List<String> list, String alarmPlayTimeValue) {
|
|
|
- log.info("--------------->playbackURLs");
|
|
|
- log.info("alarmPlayTimeValue------------->" + alarmPlayTimeValue);
|
|
|
- for (String code : list) {
|
|
|
+ public String playbackURLs(String code, String frontValue, String laterValue) {
|
|
|
+
|
|
|
+ try {
|
|
|
+ TimeUnit.SECONDS.sleep(65 * Integer.parseInt(laterValue));
|
|
|
+ log.info("--------------->playbackURLs");
|
|
|
+ log.info("frontValue------------->" + frontValue);
|
|
|
+ log.info("laterValue------------->" + laterValue);
|
|
|
PlaybackVo playbackVo = new PlaybackVo();
|
|
|
playbackVo.setCameraIndexCode(code);
|
|
|
// 获取当前时间
|
|
|
OffsetDateTime currentTime = OffsetDateTime.now();
|
|
|
log.info("currentTime------------->" + currentTime);
|
|
|
- // 获取当前时间的前10分钟时间
|
|
|
- OffsetDateTime beforeTenMinutes = currentTime.minusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
+ // 获取报警前的时间
|
|
|
+ OffsetDateTime beforeTenMinutes = currentTime.minusMinutes(Long.parseLong(frontValue));
|
|
|
log.info("beforeTenMinutes------------->" + beforeTenMinutes);
|
|
|
- // 获取当前时间的后10分钟时间
|
|
|
- OffsetDateTime afterTenMinutes = currentTime.plusMinutes(Long.parseLong(alarmPlayTimeValue));
|
|
|
+ // 获取报警后的时间
|
|
|
+ OffsetDateTime afterTenMinutes = currentTime.plusMinutes(Long.parseLong(laterValue));
|
|
|
log.info("afterTenMinutes------------->" + afterTenMinutes);
|
|
|
// 格式化时间
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
|
|
|
playbackVo.setBeginTime(beforeTenMinutes.format(formatter));
|
|
|
log.info("playbackVo.getBeginTime()------------->" + playbackVo.getBeginTime());
|
|
|
- //现在当前时间:后续需要修改成报警时间的后几分钟
|
|
|
- playbackVo.setEndTime(currentTime.format(formatter));
|
|
|
+ playbackVo.setEndTime(afterTenMinutes.format(formatter));
|
|
|
log.info("playbackVo.getEndTime()------------->" + playbackVo.getEndTime());
|
|
|
// jsonBody.put("protocol","rtsp");
|
|
|
- // jsonBody.put("expand","streamform=rtp");
|
|
|
+ // jsonBody.put("expand","streamform=rtp");
|
|
|
playbackVo.setProtocol("rtsp");
|
|
|
playbackVo.setExpand("streamform=rtp");
|
|
|
//对象转换json字符串
|
|
|
String body = JSONObject.toJSONString(playbackVo);
|
|
|
//调用天网接口
|
|
|
log.info("body----->" + body);
|
|
|
+ //获取回放视频的url
|
|
|
String playbackURLs = getPreviewURLs("/api/video/v1/cameras/playbackURLs", body);
|
|
|
log.info("playbackURLs----->" + playbackURLs);
|
|
|
JSONObject outJson = (JSONObject) JSONObject.parse(playbackURLs);
|
|
@@ -1233,19 +1237,19 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
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);
|
|
|
+ //向流媒体推报警回放视频
|
|
|
+ log.info("msg---------->" + httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
|
|
|
+ String msg = HttpUtils.sendGet(httpUrl + "/rtsp/api/pull?target=" + urls + "&streamPath=" + code + "/playback&save=0");
|
|
|
+ log.info("msg---------->" + msg);
|
|
|
+ if (!msg.equals("ok")) {
|
|
|
+ return "暂无视频-" + code;
|
|
|
}
|
|
|
+// String FilePath = "/opt/streams/map/" + code + ".mp4";
|
|
|
+// Process process = rtspToMP4.StartRecord(ffmpegPath, urls, FilePath);
|
|
|
+// log.info("------playbackURLs----->>>>:" + process);
|
|
|
+// if (null != process) {
|
|
|
+// map.put(code, process);
|
|
|
+// }
|
|
|
// try {
|
|
|
// TimeUnit.SECONDS.sleep(204 * Integer.parseInt(alarmPlayTimeValue));
|
|
|
// } catch (InterruptedException e) {
|
|
@@ -1253,8 +1257,13 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
// }
|
|
|
// log.info("------videoCompression----->>>>:");
|
|
|
// videoCompression(code);
|
|
|
+ } else {
|
|
|
+ return "天网无视频-" + code;
|
|
|
}
|
|
|
+ } catch (InterruptedException e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
public AjaxResult stop(String id) {
|