From b02d75edcdde0fa4fad0cc8cc30340c4027a50e5 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sun, 16 Mar 2025 18:02:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/task.go | 8 ++++++++ util/ffmpeg.go | 6 +----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/core/task.go b/core/task.go index 8f886de..79afb22 100644 --- a/core/task.go +++ b/core/task.go @@ -6,6 +6,7 @@ import ( "ZhenTuLocalPassiveAdapter/fs" "ZhenTuLocalPassiveAdapter/util" "fmt" + "os" "path" ) @@ -30,6 +31,13 @@ func HandleTask(device config.DeviceMapping, task dto.Task) (*dto.FileObject, er if !ok { return nil, fmt.Errorf("ffmpeg任务执行失败") } + outfile, err := os.Stat(constructTask.OutputFile) + if err != nil { + return nil, fmt.Errorf("文件不存在:%s", constructTask.OutputFile) + } + if outfile.Size() < 4096 { + return nil, fmt.Errorf("文件大小过小:%s", constructTask.OutputFile) + } return &dto.FileObject{ CreateTime: task.EndTime, EndTime: task.EndTime, diff --git a/util/ffmpeg.go b/util/ffmpeg.go index 9135b03..83cc309 100644 --- a/util/ffmpeg.go +++ b/util/ffmpeg.go @@ -102,15 +102,11 @@ func runFfmpegForSingleFile(task *dto.FfmpegTask) bool { if err != nil { return false } - outfile, err := os.Stat(task.OutputFile) + _, err = os.Stat(task.OutputFile) if err != nil { log.Printf("文件不存在:%s", task.OutputFile) return false } - if outfile.Size() < 4096 { - log.Printf("文件大小过小:%s", task.OutputFile) - return false - } return result }