|
@@ -55,7 +55,7 @@ public class CameraUtil {
|
|
|
private static String webUrl;
|
|
|
private static String bakUrl;
|
|
|
private static CmdCameraUtil cUtil;
|
|
|
-
|
|
|
+ private static RedisCache rc;
|
|
|
@Autowired
|
|
|
private CaneraConfig caneraConfig;
|
|
|
|
|
@@ -414,13 +414,19 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
log.info("合并命令:{}", sm.toString());
|
|
|
cUtil.cmd(sm.toString());
|
|
|
}
|
|
|
- Thread.sleep(2000L);
|
|
|
- for (String fileT : fileTs) {
|
|
|
- File ft = new File(fileT);
|
|
|
- if (ft.exists()) {
|
|
|
- ft.delete();
|
|
|
- }
|
|
|
+ Map<String, Object> mergeVideoTsFile = rc.getCacheMap("mergeVideoTsFile");
|
|
|
+ if (ObjectUtils.isEmpty(mergeVideoTsFile)) {
|
|
|
+ mergeVideoTsFile = new HashMap<>();
|
|
|
}
|
|
|
+ Map<Date, List<String>> objectObjectHashMap = new HashMap<>();
|
|
|
+ objectObjectHashMap.put(new Date(), fileTs);
|
|
|
+ mergeVideoTsFile.put(newfilePath, objectObjectHashMap);
|
|
|
+// for (String fileT : fileTs) {
|
|
|
+// File ft = new File(fileT);
|
|
|
+// if (ft.exists()) {
|
|
|
+// ft.delete();
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
public static List<Map<String, Object>> getRecordList(String channel, Date startTm, Date endTm) {
|
|
@@ -684,6 +690,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
bakUrl = caneraConfig.getBakUrl();
|
|
|
recordUrl = caneraConfig.getRecordUrl();
|
|
|
cUtil = cmdCameraUtil;
|
|
|
+ rc = redisCache;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -812,4 +819,47 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
redisCache.setCacheMap("WAIT_MERGE_VIDEO_ALARM_ID", alarmIdMap);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public void deleteTsFile() {
|
|
|
+ Date date = new Date();
|
|
|
+ Set<String> keys = new HashSet<>();
|
|
|
+ Calendar calendar = new GregorianCalendar();
|
|
|
+ Map<String, Object> mergeVideoTsFile = redisCache.getCacheMap("mergeVideoTsFile");
|
|
|
+ if (!ObjectUtils.isEmpty(mergeVideoTsFile) && mergeVideoTsFile.size() > 0) {
|
|
|
+ mergeVideoTsFile.keySet().forEach(s -> {
|
|
|
+ Object o = mergeVideoTsFile.get(s);
|
|
|
+ if (!ObjectUtils.isEmpty(o)) {
|
|
|
+ Map<Date, List<String>> m = (Map<Date, List<String>>) o;
|
|
|
+ if (!ObjectUtils.isEmpty(m) && m.size() > 0) {
|
|
|
+ m.keySet().forEach(md -> {
|
|
|
+ Date fileTime = (Date) md;
|
|
|
+ // 判断当前时间是否超过报警时间 20分钟
|
|
|
+ calendar.setTime(fileTime);
|
|
|
+ calendar.add(calendar.MINUTE, 10); //把日期往后增加一天,整数 往后推,负数往前移动
|
|
|
+ fileTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
|
+ if (date.compareTo(fileTime) > 0) {
|
|
|
+ List<String> list = m.get(md);
|
|
|
+ for (String s1 : list) {
|
|
|
+ File ft = new File(s1);
|
|
|
+ if (ft.exists()) {
|
|
|
+ ft.delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //
|
|
|
+ m.remove(md);
|
|
|
+ keys.add(s);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 删除key
|
|
|
+ if (keys.size() > 0) {
|
|
|
+ for (String s : mergeVideoTsFile.keySet()) {
|
|
|
+ mergeVideoTsFile.remove(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|