添加时间判断,避免切出过小的视频

This commit is contained in:
Jerry Yan 2025-04-13 14:53:18 +08:00
parent 37da5abad0
commit adf4186156

View File

@ -35,13 +35,11 @@ func RunFfmpegTask(ctx context.Context, task *dto.FfmpegTask) bool {
result = runFfmpegForMultipleFile1(subCtx, task) result = runFfmpegForMultipleFile1(subCtx, task)
} }
// 先尝试方法1 // 先尝试方法1
if result { if !result {
span.SetStatus(codes.Ok, "FFMPEG简易方法成功") log.Printf("FFMPEG简易方法失败尝试复杂方法转码")
return true // 不行再尝试方法二
result = runFfmpegForMultipleFile2(subCtx, task)
} }
log.Printf("FFMPEG简易方法失败尝试复杂方法转码")
// 不行再尝试方法二
result = runFfmpegForMultipleFile2(subCtx, task)
duration, err := GetVideoDuration(subCtx, task.OutputFile) duration, err := GetVideoDuration(subCtx, task.OutputFile)
if err != nil { if err != nil {
span.SetAttributes(attribute.String("error", err.Error())) span.SetAttributes(attribute.String("error", err.Error()))
@ -53,10 +51,10 @@ func RunFfmpegTask(ctx context.Context, task *dto.FfmpegTask) bool {
return false return false
} }
if result { if result {
span.SetStatus(codes.Ok, "FFMPEG复杂方法成功") span.SetStatus(codes.Ok, "成功")
return true return true
} }
span.SetStatus(codes.Error, "FFMPEG复杂方法失败") span.SetStatus(codes.Error, "失败")
return result return result
} }