|
@@ -91,7 +91,7 @@ public class CameraUtil {
|
|
* @return
|
|
* @return
|
|
* @throws IOException
|
|
* @throws IOException
|
|
*/
|
|
*/
|
|
- public static String historyPlay(List<String> fromVideoFileList, String ph, String uuid) {
|
|
|
|
|
|
+ public static String historyPlay(List<String> fromVideoFileList, String ph, boolean flay) {
|
|
// 视频服务映射路径
|
|
// 视频服务映射路径
|
|
String NewfilePath = BaseConfig.getProfile() + "/" + ph;
|
|
String NewfilePath = BaseConfig.getProfile() + "/" + ph;
|
|
log.info("NewfilePath:{}", NewfilePath);
|
|
log.info("NewfilePath:{}", NewfilePath);
|
|
@@ -103,7 +103,7 @@ public class CameraUtil {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
try {
|
|
- txConvetor(fromVideoFileList, NewfilePath, uuid);
|
|
|
|
|
|
+ txConvetor(fromVideoFileList, NewfilePath, flay);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -169,7 +169,7 @@ public class CameraUtil {
|
|
* @param endTm 结束时间
|
|
* @param endTm 结束时间
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- public static String historyPlayListStr(String channel, Date startTm, Date endTm) {
|
|
|
|
|
|
+ public static String historyPlayListStr(String channel, Date startTm, Date endTm, boolean flay) {
|
|
List<String> list = filterPlayList(channel, startTm, endTm, filePath);
|
|
List<String> list = filterPlayList(channel, startTm, endTm, filePath);
|
|
String uuid = UUID.randomUUID().toString();
|
|
String uuid = UUID.randomUUID().toString();
|
|
String ph = "record/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
String ph = "record/flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
@@ -177,7 +177,7 @@ public class CameraUtil {
|
|
+ uuid + ".mp4";
|
|
+ uuid + ".mp4";
|
|
if (!ObjectUtils.isEmpty(list)) {
|
|
if (!ObjectUtils.isEmpty(list)) {
|
|
try {
|
|
try {
|
|
- return historyPlay(list, ph, uuid);
|
|
|
|
|
|
+ return historyPlay(list, ph, flay);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage());
|
|
log.error(e.getMessage());
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -371,11 +371,11 @@ public class CameraUtil {
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
public static void txConvetor(List<String> fromVideoFileList,
|
|
public static void txConvetor(List<String> fromVideoFileList,
|
|
String newfilePath,
|
|
String newfilePath,
|
|
- String uuid) throws IOException {
|
|
|
|
|
|
+ boolean fly) throws IOException {
|
|
/*
|
|
/*
|
|
* ffmpeg -i 20230411_155847_155947-d4c2265d-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 1.ts
|
|
* ffmpeg -i 20230411_155847_155947-d4c2265d-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 1.ts
|
|
ffmpeg -i 20230411_155948_160048-f91fea03-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 2.ts
|
|
ffmpeg -i 20230411_155948_160048-f91fea03-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 2.ts
|
|
-ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
|
|
|
+ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
|
|
* */
|
|
* */
|
|
|
|
|
|
File file = new File(newfilePath);
|
|
File file = new File(newfilePath);
|
|
@@ -393,8 +393,6 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
for (int t = 0; t < fromVideoFileList.size(); t++) {
|
|
for (int t = 0; t < fromVideoFileList.size(); t++) {
|
|
File ft = new File(fromVideoFileList.get(t));
|
|
File ft = new File(fromVideoFileList.get(t));
|
|
if (ft.exists()) {
|
|
if (ft.exists()) {
|
|
- // ffmpeg -i 20230411_155847_155947-d4c2265d-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 1.ts
|
|
|
|
- // ffmpeg -i 20230411_155948_160048-f91fea03-d83e-11ed-8e7f-fa163e4e1e9f.flv -c:v copy 2.ts
|
|
|
|
log.info("file:{}", fromVideoFileList.get(t));
|
|
log.info("file:{}", fromVideoFileList.get(t));
|
|
String substring = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("."));
|
|
String substring = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("."));
|
|
int x;//定义两变量
|
|
int x;//定义两变量
|
|
@@ -419,21 +417,21 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
if (ObjectUtils.isEmpty(mergeVideoTsFile)) {
|
|
if (ObjectUtils.isEmpty(mergeVideoTsFile)) {
|
|
mergeVideoTsFile = new HashMap<>();
|
|
mergeVideoTsFile = new HashMap<>();
|
|
}
|
|
}
|
|
|
|
+ if (!flay) {
|
|
|
|
+ // 如果没有解除,把生成的文件放入要删除的定时任务 redis key 中
|
|
|
|
+ fileTs.add(newfilePath);
|
|
|
|
+ }
|
|
mergeVideoTsFile.put(new Date().getTime() + "", fileTs);
|
|
mergeVideoTsFile.put(new Date().getTime() + "", fileTs);
|
|
rc.deleteObject(tsFilekey);
|
|
rc.deleteObject(tsFilekey);
|
|
- rc.setCacheMap(tsFilekey, mergeVideoTsFile);
|
|
|
|
|
|
+ if (mergeVideoTsFile.size() > 0) {
|
|
|
|
+ rc.setCacheMap(tsFilekey, mergeVideoTsFile);
|
|
|
|
+ }
|
|
|
|
|
|
sm.append("-c copy " + newfilePath);
|
|
sm.append("-c copy " + newfilePath);
|
|
log.info("合并命令:{}", sm.toString());
|
|
log.info("合并命令:{}", sm.toString());
|
|
cUtil.cmd(sm.toString());
|
|
cUtil.cmd(sm.toString());
|
|
}
|
|
}
|
|
|
|
|
|
-// 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) {
|
|
public static List<Map<String, Object>> getRecordList(String channel, Date startTm, Date endTm) {
|
|
@@ -442,6 +440,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
|
|
|
/**
|
|
/**
|
|
* 定时任务参数flv文件
|
|
* 定时任务参数flv文件
|
|
|
|
+ * -----------------------------废弃
|
|
*
|
|
*
|
|
* @throws IOException
|
|
* @throws IOException
|
|
* @throws InterruptedException
|
|
* @throws InterruptedException
|
|
@@ -569,15 +568,6 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
return listFiles;
|
|
return listFiles;
|
|
}
|
|
}
|
|
|
|
|
|
- public static void execute(String command) {
|
|
|
|
- try {
|
|
|
|
- ProcessBuilder process = new ProcessBuilder(command);
|
|
|
|
- process.inheritIO().start().waitFor();
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- e.printStackTrace();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 定时任务:关闭录制视频
|
|
* 定时任务:关闭录制视频
|
|
@@ -773,6 +763,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
|
|
|
|
/**
|
|
/**
|
|
* 定时合成视频
|
|
* 定时合成视频
|
|
|
|
+ * ----------------------------废弃
|
|
*/
|
|
*/
|
|
public void mergeVideo() {
|
|
public void mergeVideo() {
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
@@ -793,10 +784,10 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
alarmTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
alarmTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
if (date.compareTo(alarmTime) > 0) {
|
|
if (date.compareTo(alarmTime) > 0) {
|
|
// 表示已经超过报警时间20分钟,可以合成视频
|
|
// 表示已经超过报警时间20分钟,可以合成视频
|
|
- String cameraChannelByAlarmId = baseCameraManagementService.getCameraChannelByAlarmId(alarmId);
|
|
|
|
- if (!StringUtils.isBlank(cameraChannelByAlarmId)) {
|
|
|
|
- log.info("报警UUID:{},相机通道:{},开始时间:{},结束时间:{}", alarmId, cameraChannelByAlarmId, (Date) oTime, date);
|
|
|
|
- String url = historyPlayListStr(cameraChannelByAlarmId, (Date) oTime, date);
|
|
|
|
|
|
+ Map<String, Object> map = baseCameraManagementService.getCameraChannelByAlarmId(alarmId);
|
|
|
|
+ if (!StringUtils.isBlank(map.get("channel").toString())) {
|
|
|
|
+ log.info("报警UUID:{},相机通道:{},开始时间:{},结束时间:{}", alarmId, map.get("channel").toString(), (Date) oTime, date);
|
|
|
|
+ String url = historyPlayListStr(map.get("channel").toString(), (Date) oTime, date, false);
|
|
|
|
|
|
redisCache.setCacheObject("STREAMING_ALARM_VIDEO:" + alarmId, url);
|
|
redisCache.setCacheObject("STREAMING_ALARM_VIDEO:" + alarmId, url);
|
|
redisCache.expire("STREAMING_ALARM_VIDEO:" + alarmId, 365L, TimeUnit.DAYS);
|
|
redisCache.expire("STREAMING_ALARM_VIDEO:" + alarmId, 365L, TimeUnit.DAYS);
|
|
@@ -818,6 +809,9 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 删除生成的临时文件 30分钟后
|
|
|
|
+ */
|
|
public void deleteTsFile() {
|
|
public void deleteTsFile() {
|
|
Date date = new Date();
|
|
Date date = new Date();
|
|
List<String> keys = new ArrayList<>();
|
|
List<String> keys = new ArrayList<>();
|
|
@@ -828,7 +822,7 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
Object o = mergeVideoTsFile.get(s);
|
|
Object o = mergeVideoTsFile.get(s);
|
|
Date fileTime = new Date(Long.parseLong(s));
|
|
Date fileTime = new Date(Long.parseLong(s));
|
|
calendar.setTime(fileTime);
|
|
calendar.setTime(fileTime);
|
|
- calendar.add(calendar.MINUTE, 30); //把日期往后增加10分钟,整数 往后推,负数往前移动
|
|
|
|
|
|
+ calendar.add(calendar.MINUTE, 30); //把日期往后增加30分钟,整数 往后推,负数往前移动
|
|
fileTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
fileTime = calendar.getTime(); //这个时间就是日期往后推一天的结果
|
|
if (date.compareTo(fileTime) > 0) {
|
|
if (date.compareTo(fileTime) > 0) {
|
|
List<String> list = (List<String>) o;
|
|
List<String> list = (List<String>) o;
|
|
@@ -851,6 +845,9 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.flv
|
|
}
|
|
}
|
|
log.info("mergeVideoTsFile:{}", mergeVideoTsFile);
|
|
log.info("mergeVideoTsFile:{}", mergeVideoTsFile);
|
|
redisCache.deleteObject("mergeVideoTsFile");
|
|
redisCache.deleteObject("mergeVideoTsFile");
|
|
- redisCache.setCacheMap("mergeVideoTsFile", mergeVideoTsFile);
|
|
|
|
|
|
+ if (mergeVideoTsFile.size() > 0) {
|
|
|
|
+ redisCache.setCacheMap("mergeVideoTsFile", mergeVideoTsFile);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|