不修改原始数据避免失败
This commit is contained in:
parent
c6a6518248
commit
cdd1358d45
@ -66,8 +66,14 @@ func runFfmpegForMultipleFile1(ctx context.Context, task *dto.FfmpegTask) bool {
|
||||
var wg sync.WaitGroup
|
||||
var mu sync.Mutex
|
||||
var notOk bool
|
||||
var taskClone = dto.FfmpegTask{
|
||||
Files: task.Files,
|
||||
OutputFile: task.OutputFile,
|
||||
Offset: task.Offset,
|
||||
Length: task.Length,
|
||||
}
|
||||
|
||||
for i := range task.Files {
|
||||
for i := range taskClone.Files {
|
||||
wg.Add(1)
|
||||
go func(file *dto.File) {
|
||||
defer wg.Done()
|
||||
@ -88,7 +94,7 @@ func runFfmpegForMultipleFile1(ctx context.Context, task *dto.FfmpegTask) bool {
|
||||
// 失败了,务必删除临时文件
|
||||
os.Remove(tmpFile)
|
||||
}
|
||||
}(&task.Files[i])
|
||||
}(&taskClone.Files[i])
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
@ -99,7 +105,7 @@ func runFfmpegForMultipleFile1(ctx context.Context, task *dto.FfmpegTask) bool {
|
||||
}
|
||||
|
||||
// 步骤二:使用concat协议拼接裁切
|
||||
result, err := QuickConcatVideoCut(subCtx, task.Files, int64(task.Offset), int64(task.Length), task.OutputFile)
|
||||
result, err := QuickConcatVideoCut(subCtx, taskClone.Files, int64(taskClone.Offset), int64(taskClone.Length), taskClone.OutputFile)
|
||||
if err != nil {
|
||||
span.SetAttributes(attribute.String("error", err.Error()))
|
||||
span.SetStatus(codes.Error, "FFMPEG多文件concat协议转码失败")
|
||||
@ -107,13 +113,13 @@ func runFfmpegForMultipleFile1(ctx context.Context, task *dto.FfmpegTask) bool {
|
||||
}
|
||||
|
||||
// 步骤三:删除临时文件
|
||||
for _, file := range task.Files {
|
||||
for _, file := range taskClone.Files {
|
||||
if err := os.Remove(file.Url); err != nil {
|
||||
log.Printf("删除临时文件失败: %v", err)
|
||||
}
|
||||
}
|
||||
if result {
|
||||
outfile, err := os.Stat(task.OutputFile)
|
||||
outfile, err := os.Stat(taskClone.OutputFile)
|
||||
if err != nil {
|
||||
span.SetAttributes(attribute.String("error", err.Error()))
|
||||
span.SetStatus(codes.Error, "文件不存在")
|
||||
|
Loading…
x
Reference in New Issue
Block a user