fix: log ffmpeg stderr on outputNotFound too, include in error message

This commit is contained in:
yumoqing 2026-07-17 20:40:05 +08:00
parent fa38caa5a5
commit 14b68e419f
2 changed files with 10 additions and 3 deletions

View File

@ -139,7 +139,9 @@ public final class FFmpegRecorder: StreamRecorderEngine {
} }
guard FileManager.default.fileExists(atPath: outputPath) else { guard FileManager.default.fileExists(atPath: outputPath) else {
throw RecordingError.outputNotFound let lastStderr = String(stderrAccumulator.suffix(2000))
NSLog("[Recorder] ffmpeg stderr (last 2000 chars):\n%@", lastStderr)
throw RecordingError.outputNotFound(lastStderr)
} }
// fragmented MP4 ffprobe // fragmented MP4 ffprobe

View File

@ -58,7 +58,7 @@ public enum RecordingError: Error, LocalizedError {
case noFFmpeg case noFFmpeg
case noMediaTracks case noMediaTracks
case processFailed(Int, String? = nil) case processFailed(Int, String? = nil)
case outputNotFound case outputNotFound(String? = nil)
case unknown(String) case unknown(String)
public var errorDescription: String? { public var errorDescription: String? {
@ -72,7 +72,12 @@ public enum RecordingError: Error, LocalizedError {
return "录制失败 (exit code: \(code)):\n\(preview)" return "录制失败 (exit code: \(code)):\n\(preview)"
} }
return "录制失败 (exit code: \(code))" return "录制失败 (exit code: \(code))"
case .outputNotFound: return "输出文件不存在" case .outputNotFound(let stderr):
if let s = stderr, !s.isEmpty {
let preview = String(s.prefix(300))
return "输出文件不存在\n\(preview)"
}
return "输出文件不存在"
case .unknown(let msg): return msg case .unknown(let msg): return msg
} }
} }