You've already forked FrameTour-BE
fix(video): 解决并发环境下视频片段处理的文件名冲突问题
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
All checks were successful
ZhenTu-BE/pipeline/head This commit looks good
- 为输出文件名添加时间戳和线程ID后缀,确保唯一性 -为临时文件名添加时间戳和线程ID后缀,防止并发冲突 - 避免因文件名重复导致的视频处理错误
This commit is contained in:
@@ -299,7 +299,9 @@ public class VideoPieceGetter {
|
||||
ffmpegTask.setFileList(listByDtRange);
|
||||
ffmpegTask.setDuration(duration);
|
||||
ffmpegTask.setOffsetStart(BigDecimal.valueOf(offset, 3));
|
||||
File outFile = new File(deviceId.toString() + "_" + faceSampleId + ".mp4");
|
||||
// 使用时间戳和线程ID确保输出文件名唯一性,避免并发冲突
|
||||
String uniqueSuffix = System.currentTimeMillis() + "_" + Thread.currentThread().getId();
|
||||
File outFile = new File(deviceId.toString() + "_" + faceSampleId + "_" + uniqueSuffix + ".mp4");
|
||||
ffmpegTask.setOutputFile(outFile.getAbsolutePath());
|
||||
boolean result = startFfmpegTask(ffmpegTask);
|
||||
if (!result) {
|
||||
@@ -437,7 +439,9 @@ public class VideoPieceGetter {
|
||||
boolean notOk = task.getFileList().stream().map(file -> {
|
||||
try {
|
||||
if (file.isNeedDownload() || (!file.getName().endsWith(".ts"))) {
|
||||
String tmpFile = file.getName() + ".ts";
|
||||
// 使用时间戳和线程ID确保临时文件名唯一性,避免并发冲突
|
||||
String uniqueSuffix = System.currentTimeMillis() + "_" + Thread.currentThread().getId();
|
||||
String tmpFile = file.getName() + "_" + uniqueSuffix + ".ts";
|
||||
boolean result = convertMp4ToTs(file, tmpFile);
|
||||
// 因为是并行转换,没法保证顺序,就直接存里面
|
||||
if (result) {
|
||||
|
Reference in New Issue
Block a user