From 3854dc5b7e498d8505657c755f76d6cf38d6e7fd Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Thu, 11 Feb 2021 00:08:22 +0100 Subject: [PATCH 1/2] Fixed dedupe cache check not running in every loop iteration --- Code/Magick/Dedupe.cs | 20 ++++++++++---------- Code/Main/Interpolate.cs | 1 - 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Code/Magick/Dedupe.cs b/Code/Magick/Dedupe.cs index cd0ccf2..639ef4c 100644 --- a/Code/Magick/Dedupe.cs +++ b/Code/Magick/Dedupe.cs @@ -127,18 +127,18 @@ namespace Flowframes.Magick currentDupeCount = 0; break; } - - if (sw.ElapsedMilliseconds >= 500 || (i+1) == framePaths.Length) // Print every 0.5s (or when done) - { - sw.Restart(); - Logger.Log($"[Deduplication] Running de-duplication ({i}/{framePaths.Length}), deleted {statsFramesDeleted} ({(((float)statsFramesDeleted / framePaths.Length) * 100f).ToString("0")}%) duplicate frames so far...", false, true); - Program.mainForm.SetProgress((int)Math.Round(((float)i / framePaths.Length) * 100f)); - if (imageCache.Count > bufferSize || (imageCache.Count > 50 && OSUtils.GetFreeRamMb() < 3500)) - ClearCache(); - } } } + if (sw.ElapsedMilliseconds >= 500 || (i + 1) == framePaths.Length) // Print every 0.5s (or when done) + { + sw.Restart(); + Logger.Log($"[Deduplication] Running de-duplication ({i}/{framePaths.Length}), deleted {statsFramesDeleted} ({(((float)statsFramesDeleted / framePaths.Length) * 100f).ToString("0")}%) duplicate frames so far...", false, true); + Program.mainForm.SetProgress((int)Math.Round(((float)i / framePaths.Length) * 100f)); + if (imageCache.Count > bufferSize || (imageCache.Count > 50 && OSUtils.GetFreeRamMb() < 3500)) + ClearCache(); + } + // int oldIndex = -1; // TODO: Compare with 1st to fix loops? // if (i >= framePaths.Length) // If this is the last frame, compare with 1st to avoid OutOfRange error // { @@ -146,7 +146,7 @@ namespace Flowframes.Magick // i = 0; // } - if(i % 3 == 0) + if (i % 3 == 0) await Task.Delay(1); if (Interpolate.canceled) return; diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index 0179edb..c8e3594 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -223,7 +223,6 @@ namespace Flowframes } else { - Logger.Log("Deleting temp folder because current.stepByStep = " + current.stepByStep); IOUtils.TryDeleteIfExists(current.tempFolder); } } From 538e0a9f49a5e23f81aaa2476b58448fc4f48f1a Mon Sep 17 00:00:00 2001 From: N00MKRAD Date: Thu, 11 Feb 2021 00:53:48 +0100 Subject: [PATCH 2/2] Extract alpha *after* frame postprocessing to avoid problems --- Code/Main/Interpolate.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index c8e3594..df22e74 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -77,15 +77,6 @@ namespace Flowframes await ExtractFrames(current.inPath, current.framesFolder, current.alpha, !stepByStep); else await FfmpegExtract.ImportImages(current.inPath, current.framesFolder, current.alpha, await Utils.GetOutputResolution(current.inPath, true)); - - if (current.alpha) - { - Program.mainForm.SetStatus("Extracting transparency..."); - Logger.Log("Extracting transparency... (1/2)"); - await FfmpegAlpha.ExtractAlphaDir(current.framesFolder, current.framesFolder + Paths.alphaSuffix); - Logger.Log("Extracting transparency... (2/2)", false, true); - await FfmpegAlpha.RemoveAlpha(current.framesFolder, current.framesFolder); - } } public static async Task ExtractFrames(string inPath, string outPath, bool alpha, bool sceneDetect) @@ -168,6 +159,15 @@ namespace Flowframes Logger.Log($"Error renaming frame files: {e.Message}"); Cancel("Error renaming frame files. Check the log for details."); } + + if (current.alpha) + { + Program.mainForm.SetStatus("Extracting transparency..."); + Logger.Log("Extracting transparency... (1/2)"); + await FfmpegAlpha.ExtractAlphaDir(current.framesFolder, current.framesFolder + Paths.alphaSuffix); + Logger.Log("Extracting transparency... (2/2)", false, true); + await FfmpegAlpha.RemoveAlpha(current.framesFolder, current.framesFolder); + } } public static async Task RunAi(string outpath, AI ai, bool stepByStep = false)