feat(可回溯): 视频生成

修改生成命令
This commit is contained in:
BrandWang
2023-05-15 11:02:35 +08:00
parent fb2997aa2b
commit 48517f8953
@@ -113,7 +113,7 @@ public class RecallOrderApiServiceImpl implements RecallOrderApiService {
bw.flush(); bw.flush();
bw.close(); bw.close();
fw.close(); fw.close();
String[] command = {"ts-node", "/opt/review/index.ts"}; String[] command = {"ts-node", "/opt/rrvideo/src/cli.ts", "--input traces.json --output video.mp4"};
ProcessBuilder processBuilder = new ProcessBuilder(command); ProcessBuilder processBuilder = new ProcessBuilder(command);
processBuilder.directory(tempDir.toFile()); processBuilder.directory(tempDir.toFile());
// 在临时目录下执行命令 // 在临时目录下执行命令
@@ -138,40 +138,6 @@ public class RecallOrderApiServiceImpl implements RecallOrderApiService {
}); });
processThread.start(); processThread.start();
// Continue with other tasks here...
try {
processThread.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
String[] video = {"rrvideo", "--input unpack.json --config /opt/review/config.json --output video.mp4"};
ProcessBuilder videoBuilder = new ProcessBuilder(video);
videoBuilder.directory(tempDir.toFile());
Process p2 = videoBuilder.start();
Thread processThread2 = new Thread(() -> {
try {
// 读取命令输出
BufferedReader reader = new BufferedReader(new InputStreamReader(p2.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
reader.close();
// 等待命令执行完成
int exitCode = p2.waitFor();
System.out.println("Command exited with code " + exitCode);
} catch (InterruptedException | IOException e) {
e.printStackTrace();
}
});
processThread2.start();
File file = new File(tempDir.toFile(), "video.mp4"); File file = new File(tempDir.toFile(), "video.mp4");
if (file.exists()) { if (file.exists()) {
log.info(String.valueOf(file.length())); log.info(String.valueOf(file.length()));