From ae34cfe5f2466850d41953ff172a4c4e7f5fd8a4 Mon Sep 17 00:00:00 2001 From: n00mkrad Date: Thu, 30 Sep 2021 00:33:19 +0200 Subject: [PATCH] Fixed invalid chunk deletion & freeze after merging chunks after resume --- Code/Main/AutoEncode.cs | 4 ++-- Code/Main/AutoEncodeResume.cs | 4 ++-- Code/Main/Export.cs | 2 +- Code/Main/Interpolate.cs | 3 ++- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Code/Main/AutoEncode.cs b/Code/Main/AutoEncode.cs index 569c392..aec4eac 100644 --- a/Code/Main/AutoEncode.cs +++ b/Code/Main/AutoEncode.cs @@ -153,7 +153,7 @@ namespace Flowframes.Main if(!imgSeq && Config.GetInt(Config.Key.autoEncBackupMode) > 0) { if (aiRunning && (currentMuxTask == null || (currentMuxTask != null && currentMuxTask.IsCompleted))) - currentMuxTask = Task.Run(() => Export.ChunksToVideos(Interpolate.current.tempFolder, videoChunksFolder, Interpolate.current.outPath, true)); + currentMuxTask = Task.Run(() => Export.ChunksToVideo(Interpolate.current.tempFolder, videoChunksFolder, Interpolate.current.outPath, true)); else Logger.Log($"[AE] Skipping backup because {(!aiRunning ? "this is the final chunk" : "previous mux task has not finished yet")}!", true, false, "ffmpeg"); } @@ -178,7 +178,7 @@ namespace Flowframes.Main if (imgSeq) return; - await Export.ChunksToVideos(Interpolate.current.tempFolder, videoChunksFolder, Interpolate.current.outPath); + await Export.ChunksToVideo(Interpolate.current.tempFolder, videoChunksFolder, Interpolate.current.outPath); } catch (Exception e) { diff --git a/Code/Main/AutoEncodeResume.cs b/Code/Main/AutoEncodeResume.cs index c295c09..072fa81 100644 --- a/Code/Main/AutoEncodeResume.cs +++ b/Code/Main/AutoEncodeResume.cs @@ -94,7 +94,7 @@ namespace Flowframes.Main string videoChunksFolder = Path.Combine(I.current.tempFolder, Paths.chunksDir); - FileInfo[] invalidChunks = IoUtils.GetFileInfosSorted(videoChunksFolder, false, "????.*").Skip(encodedChunks).ToArray(); + FileInfo[] invalidChunks = IoUtils.GetFileInfosSorted(videoChunksFolder, true, "????.*").Skip(encodedChunks).ToArray(); foreach (FileInfo chunk in invalidChunks) chunk.Delete(); @@ -108,7 +108,7 @@ namespace Flowframes.Main if(IoUtils.GetAmountOfFiles(videoChunksFolder, true, "*.*") > 0) { Logger.Log($"No more frames left to interpolate - Merging existing video chunks instead."); - await Export.ChunksToVideos(I.current.tempFolder, videoChunksFolder, I.current.outPath); + await Export.ChunksToVideo(I.current.tempFolder, videoChunksFolder, I.current.outPath); await I.Done(); } else diff --git a/Code/Main/Export.cs b/Code/Main/Export.cs index 47a6ac8..4903fa0 100644 --- a/Code/Main/Export.cs +++ b/Code/Main/Export.cs @@ -189,7 +189,7 @@ namespace Flowframes.Main } } - public static async Task ChunksToVideos(string tempFolder, string chunksFolder, string baseOutPath, bool isBackup = false) + public static async Task ChunksToVideo(string tempFolder, string chunksFolder, string baseOutPath, bool isBackup = false) { if (IoUtils.GetAmountOfFiles(chunksFolder, true, "*" + FfmpegUtils.GetExt(I.current.outMode)) < 1) { diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index dec99d3..63412b9 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -65,7 +65,7 @@ namespace Flowframes if(!currentlyUsingAutoEnc) await Export.ExportFrames(current.interpFolder, current.outPath, current.outMode, false); - if (Config.GetBool(Config.Key.keepTempFolder)) + if (!AutoEncodeResume.resumeNextRun && Config.GetBool(Config.Key.keepTempFolder)) await Task.Run(async () => { await FrameRename.Unrename(); }); await Done(); @@ -74,6 +74,7 @@ namespace Flowframes public static async Task Done () { await Cleanup(); + Logger.Log($"after cleanup in done", true); Program.mainForm.SetWorking(false); Logger.Log("Total processing time: " + FormatUtils.Time(sw.Elapsed)); sw.Stop();