Clean up intermediate render files during xfade

This commit is contained in:
Mikei386
2026-06-03 14:38:23 +02:00
parent 13169cac8e
commit 60fe54faa2
+20
View File
@@ -450,6 +450,11 @@ final class VideoProcessor: ObservableObject {
clipNumber: clipNumber, clipNumber: clipNumber,
totalClips: videos.count totalClips: videos.count
) )
if !settings.keepIntermediateClips {
removeTemporaryFile(segmentURL)
removeTemporaryFile(stabilizedURL)
removeTemporaryFile(tempDirectory.appendingPathComponent(String(format: "clip_%04d.trf", clipNumber)))
}
} else { } else {
try await normalizeSourceSegment( try await normalizeSourceSegment(
source: video.url, source: video.url,
@@ -808,6 +813,10 @@ final class VideoProcessor: ObservableObject {
throw VideoProcessingError.ffmpegFailed("Xfade Übergang \(index)", result.output) throw VideoProcessingError.ffmpegFailed("Xfade Übergang \(index)", result.output)
} }
if !settings.keepIntermediateClips {
removeTemporaryFile(current)
removeTemporaryFile(next)
}
current = out current = out
currentDuration += settings.targetClipLength - settings.transitionLength currentDuration += settings.targetClipLength - settings.transitionLength
progress = 0.75 + (Double(index) / Double(totalSteps)) * 0.25 progress = 0.75 + (Double(index) / Double(totalSteps)) * 0.25
@@ -834,6 +843,17 @@ final class VideoProcessor: ObservableObject {
try FileManager.default.copyItem(at: source, to: outputFile) try FileManager.default.copyItem(at: source, to: outputFile)
} }
private func removeTemporaryFile(_ url: URL) {
guard FileManager.default.fileExists(atPath: url.path) else {
return
}
do {
try FileManager.default.removeItem(at: url)
} catch {
appendLog("Warnung: Temporäre Datei konnte nicht gelöscht werden: \(url.lastPathComponent) (\(error.localizedDescription))")
}
}
private func escapeConcatPath(_ path: String) -> String { private func escapeConcatPath(_ path: String) -> String {
path.replacingOccurrences(of: "'", with: "'\\''") path.replacingOccurrences(of: "'", with: "'\\''")
} }