|
@@ -63,7 +63,7 @@ public class CameraUtil {
|
|
|
* @return
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
- public static String historyPlay(List<String> fromVideoFileList, String ph) {
|
|
|
+ public static String historyPlay(List<String> fromVideoFileList, String ph, String uuid) {
|
|
|
// 视频服务映射路径
|
|
|
String NewfilePath = BaseConfig.getProfile() + "/" + ph;
|
|
|
log.info("NewfilePath:{}", NewfilePath);
|
|
@@ -73,7 +73,7 @@ public class CameraUtil {
|
|
|
}
|
|
|
new Thread(() -> {
|
|
|
try {
|
|
|
- myConvetor(fromVideoFileList, NewfilePath);
|
|
|
+ myConvetor(fromVideoFileList, NewfilePath, uuid);
|
|
|
} catch (IOException e) {
|
|
|
log.error(e.getMessage());
|
|
|
e.printStackTrace();
|
|
@@ -132,12 +132,13 @@ public class CameraUtil {
|
|
|
*/
|
|
|
public static String historyPlayListStr(String channel, Date startTm, Date endTm) {
|
|
|
List<String> list = filterPlayList(channel, startTm, endTm, filePath);
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
String ph = "flv/" + DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, new Date())
|
|
|
+ "/" + channel + "/"
|
|
|
- + UUID.randomUUID().toString() + ".flv";
|
|
|
+ + uuid + ".flv";
|
|
|
if (!ObjectUtils.isEmpty(list)) {
|
|
|
try {
|
|
|
- return historyPlay(list, ph);
|
|
|
+ return historyPlay(list, ph, uuid);
|
|
|
} catch (Exception e) {
|
|
|
log.error(e.getMessage());
|
|
|
e.printStackTrace();
|
|
@@ -233,7 +234,8 @@ public class CameraUtil {
|
|
|
* @throws IOException
|
|
|
*/
|
|
|
public static void myConvetor(List<String> fromVideoFileList,
|
|
|
- String newfilePath) throws IOException {
|
|
|
+ String newfilePath,
|
|
|
+ String uuid) throws IOException {
|
|
|
/*
|
|
|
* for f in *.flv; do echo "file '$f'" >> mylist.txt; done
|
|
|
ffmpeg -f concat -i mylist.txt -c copy output.flv
|
|
@@ -251,18 +253,24 @@ public class CameraUtil {
|
|
|
|
|
|
|
|
|
StringBuffer sm = new StringBuffer("for f in ");
|
|
|
+ String pathStr = null;
|
|
|
for (int t = 0; t < fromVideoFileList.size(); t++) {
|
|
|
File ft = new File(fromVideoFileList.get(t));
|
|
|
if (ft.exists()) {
|
|
|
if (t != fromVideoFileList.size() - 1) {
|
|
|
- sm.append(fromVideoFileList.get(t) + " ");
|
|
|
+// sm.append(fromVideoFileList.get(t) + " ");
|
|
|
+ sm.append(fromVideoFileList.get(t).substring(fromVideoFileList.get(t).lastIndexOf("/") + 1, fromVideoFileList.get(t).length()) + " ");
|
|
|
} else {
|
|
|
- sm.append(fromVideoFileList.get(t));
|
|
|
+// sm.append(fromVideoFileList.get(t));
|
|
|
+ sm.append(fromVideoFileList.get(t).substring(fromVideoFileList.get(t).lastIndexOf("/") + 1, fromVideoFileList.get(t).length()));
|
|
|
+ pathStr = fromVideoFileList.get(t).substring(0, fromVideoFileList.get(t).lastIndexOf("/"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- String substring = newfilePath.substring(0, newfilePath.lastIndexOf("."));
|
|
|
- substring = substring + ".txt";
|
|
|
+// String substring = newfilePath.substring(0, newfilePath.lastIndexOf("."));
|
|
|
+// substring = substring + ".txt";
|
|
|
+
|
|
|
+ String substring = uuid + ".txt";
|
|
|
log.info("临时转化的文件:{}", substring);
|
|
|
|
|
|
|
|
@@ -275,14 +283,20 @@ public class CameraUtil {
|
|
|
|
|
|
try {
|
|
|
String commit1 = ffmpegPath + " -f concat -safe 0 -i " + substring + " -c copy " + newfilePath;
|
|
|
+
|
|
|
+ log.info("合并转化文件的命令:{}", commit1);
|
|
|
List<String> commands = new ArrayList<>();
|
|
|
if (flay) {
|
|
|
commands.add("chomd -R 777 " + file.getParentFile().getPath());
|
|
|
}
|
|
|
+ //
|
|
|
+ commands.add("cd " + pathStr);
|
|
|
// 合并成一个临时文件
|
|
|
commands.add(commit);
|
|
|
// 临时文件转化为 flv
|
|
|
commands.add(commit1);
|
|
|
+
|
|
|
+ commands.add("rm -rf " + pathStr + "/" + substring);
|
|
|
for (String line : commands) {
|
|
|
out.println(line);
|
|
|
}
|
|
@@ -523,7 +537,12 @@ public class CameraUtil {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) throws InterruptedException, ParseException, IOException {
|
|
|
- CameraUtil cameraUtil = new CameraUtil();
|
|
|
- cameraUtil.closeRecording();
|
|
|
+// CameraUtil cameraUtil = new CameraUtil();
|
|
|
+// cameraUtil.closeRecording();
|
|
|
+ String s = "/opt/streams/record/flv/42010001541320001116/20230403_235506_000506-22e1523b-d170-11ed-8a42-fa163e4e1e9f.flv";
|
|
|
+ String fileStr = s.substring(s.lastIndexOf("/") + 1, s.length());
|
|
|
+ String pathStr = s.substring(0, s.lastIndexOf("/"));
|
|
|
+ System.out.println(fileStr);
|
|
|
+ System.out.println(pathStr);
|
|
|
}
|
|
|
}
|