From 6f2661c3d1122f30919e34adecf1b35f9515fb2f Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 1 Jul 2026 08:02:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=8B=E5=8A=A8=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E5=BD=95=E5=88=B6=E6=97=B6=E8=B7=B3=E8=BF=87=E8=80=97=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E6=96=87=E4=BB=B6=E5=88=86=E6=9E=90=EF=BC=8C=E9=81=BF?= =?UTF-8?q?=E5=85=8D=20save=20dialog=20=E5=BB=B6=E8=BF=9F/=E5=8D=A1?= =?UTF-8?q?=E4=BD=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fragmented MP4 在 SIGINT 后可能导致 ffprobe/ffmpeg 分析卡住。 stopRequested 时直接返回基本文件信息,不跑 ffprobe 和音量检测。 --- .../StreamRecorderKit/FFmpegRecorder.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Sources/StreamRecorderKit/FFmpegRecorder.swift b/Sources/StreamRecorderKit/FFmpegRecorder.swift index 52e036d..63528ac 100644 --- a/Sources/StreamRecorderKit/FFmpegRecorder.swift +++ b/Sources/StreamRecorderKit/FFmpegRecorder.swift @@ -135,6 +135,25 @@ public final class FFmpegRecorder: StreamRecorderEngine { throw RecordingError.outputNotFound } + // 如果是手动停止,跳过耗时的分析(fragmented MP4 可能导致 ffprobe 卡住) + if stopRequested { + NSLog("[Recorder] Stop requested, skipping analysis") + let attrs = try? FileManager.default.attributesOfItem(atPath: outputPath) + let fileSize = attrs?[.size] as? Int64 ?? 0 + let result = RecordingResult( + outputPath: outputPath, + duration: duration, + fileSize: fileSize, + hasVideo: true, + hasAudio: true, + videoInfo: nil, + audioInfo: nil, + audioLevel: nil + ) + delegate?.recorder(self, didFinishWithResult: result) + return + } + NSLog("[Recorder] Analyzing output file...") // 分析输出文件 let ffprobePath = ffmpegPath.replacingOccurrences(of: "ffmpeg", with: "ffprobe")