|
@@ -50,6 +50,7 @@ public class CameraUtil {
|
|
|
private static CmdCameraUtil cUtil;
|
|
|
private static RedisCache rc;
|
|
|
private static ServerConfig sc;
|
|
|
+ private static String recordUrl;
|
|
|
|
|
|
@Autowired
|
|
|
private CaneraConfig caneraConfig;
|
|
@@ -468,6 +469,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
cUtil = cmdCameraUtil;
|
|
|
sc = serverConfig;
|
|
|
wsUrl = caneraConfig.getWsUrl();
|
|
|
+ recordUrl = caneraConfig.getRecordUrl();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -683,6 +685,98 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static List<Map<String, Object>> getRecordList(String channel, Date startTm, Date endTm) {
|
|
|
+ return filterRecordList(channel, startTm, endTm, filePath, recordUrl + "/profile/");
|
|
|
+ }
|
|
|
+
|
|
|
+ public static List<Map<String, Object>> filterRecordList(String channel,
|
|
|
+ Date startTm,
|
|
|
+ Date endTm,
|
|
|
+ String mappingUrl,
|
|
|
+ String wUrl) {
|
|
|
+ List<Map<String, Object>> rmaps = new ArrayList<>();
|
|
|
+
|
|
|
+ if (StringUtils.isBlank(channel)
|
|
|
+ || ObjectUtils.isEmpty(startTm)
|
|
|
+ || ObjectUtils.isEmpty(endTm)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<Date, Map<String, Object>> m = new HashMap<>();
|
|
|
+ // 调用视频服务返回参数
|
|
|
+ String startTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, startTm);
|
|
|
+ String endTime = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, endTm);
|
|
|
+
|
|
|
+ String param = "channel=" + channel + "&startTime=" + startTime + "&endTime=" + endTime;
|
|
|
+ // /api/record/flv/list
|
|
|
+ String s = HttpUtils.sendGet(webUrl + "/recordpro/api/list", param);
|
|
|
+ // 视频拼接
|
|
|
+ if (!StringUtils.isBlank(s) || "null".equals(s)) {
|
|
|
+ List<Map<String, Object>> maps = JSON.parseArray(s, Map.class);
|
|
|
+ if (ObjectUtils.isEmpty(maps)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ for (Map<String, Object> map : maps) {
|
|
|
+ Object path = map.get("Path");
|
|
|
+ Object size = map.get("Size");
|
|
|
+ Object duration = map.get("Duration");
|
|
|
+ if (!ObjectUtils.isEmpty(path)) {
|
|
|
+ String s1 = path.toString();
|
|
|
+ String substring = s1.substring(s1.lastIndexOf("/") + 1, s1.length());
|
|
|
+ String substring1 = substring.substring(0, substring.indexOf("-"));
|
|
|
+ String[] s2 = substring1.split("_");
|
|
|
+ if (!ObjectUtils.isEmpty(s2)) {
|
|
|
+ Map<String, Object> mo = new HashMap<>();
|
|
|
+
|
|
|
+ String s3 = s2[0] + s2[1];
|
|
|
+ String s4 = s2[0] + s2[2];
|
|
|
+ Date sdate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s3);
|
|
|
+ if (s2[1].startsWith("23") && s2[2].startsWith("00")) {
|
|
|
+ sdate = DateUtils.addDays(sdate, -1);
|
|
|
+ }
|
|
|
+ Date edate = DateUtils.dateTime(DateUtils.YYYYMMDDHHMMSS, s4);
|
|
|
+ mo.put("startTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, sdate));
|
|
|
+ mo.put("entTime", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, edate));
|
|
|
+ mo.put("url", wUrl + path.toString());
|
|
|
+ mo.put("path", mappingUrl + path.toString());
|
|
|
+ mo.put("fileName", substring);
|
|
|
+ mo.put("size", size);
|
|
|
+ mo.put("duration", duration);
|
|
|
+ /* sdate |startTm| edate |endTm| */
|
|
|
+ if (startTm.compareTo(sdate) >= 0
|
|
|
+ && startTm.compareTo(edate) <= 0
|
|
|
+ && endTm.compareTo(edate) >= 0) {
|
|
|
+ m.put(sdate, mo);
|
|
|
+ /* |startTm| sdate edate |endTm| */
|
|
|
+ } else if (startTm.compareTo(sdate) <= 0 && endTm.compareTo(edate) >= 0) {
|
|
|
+ m.put(sdate, mo);
|
|
|
+
|
|
|
+ /* |startTm| sdate |endTm| edate */
|
|
|
+ } else if (startTm.compareTo(sdate) <= 0
|
|
|
+ && endTm.compareTo(sdate) >= 0
|
|
|
+ && endTm.compareTo(edate) <= 0) {
|
|
|
+ m.put(sdate, mo);
|
|
|
+
|
|
|
+ /* sdate |startTm| |endTm| edate */
|
|
|
+ } else if (startTm.compareTo(sdate) >= 0 && endTm.compareTo(edate) <= 0) {
|
|
|
+ m.put(sdate, mo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!ObjectUtils.isEmpty(m) && m.size() > 0) {
|
|
|
+ Set<Date> dates = m.keySet();
|
|
|
+ // 排序
|
|
|
+ dates.stream().parallel().collect(Collectors.toList()).stream().sorted().forEach(d -> {
|
|
|
+
|
|
|
+ rmaps.add(m.get(d));
|
|
|
+ });
|
|
|
+ log.info("rmaps:{}", rmaps);
|
|
|
+ return rmaps;
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
public static void main(String[] args) throws InterruptedException, ParseException, IOException {
|
|
|
// CameraUtil cameraUtil = new CameraUtil();
|
|
|
// cameraUtil.closeRecording();
|