fix: log ffmpeg stderr on outputNotFound too, include in error message
This commit is contained in:
parent
fa38caa5a5
commit
14b68e419f
@ -139,7 +139,9 @@ public final class FFmpegRecorder: StreamRecorderEngine {
|
||||
}
|
||||
|
||||
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 卡住)
|
||||
|
||||
@ -58,7 +58,7 @@ public enum RecordingError: Error, LocalizedError {
|
||||
case noFFmpeg
|
||||
case noMediaTracks
|
||||
case processFailed(Int, String? = nil)
|
||||
case outputNotFound
|
||||
case outputNotFound(String? = nil)
|
||||
case unknown(String)
|
||||
|
||||
public var errorDescription: String? {
|
||||
@ -72,7 +72,12 @@ public enum RecordingError: Error, LocalizedError {
|
||||
return "录制失败 (exit code: \(code)):\n\(preview)"
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user