From ebf3e79411c5f4d3ba4aac745108ffb1b2522600 Mon Sep 17 00:00:00 2001 From: n00mkrad Date: Mon, 30 Aug 2021 16:58:19 +0200 Subject: [PATCH] Better warning for multi-pass interpolations, warning when using cmd debug mode --- Code/Form1.cs | 3 --- Code/Main/AutoEncode.cs | 2 +- Code/Main/Interpolate.cs | 1 + Code/Main/InterpolateUtils.cs | 14 ++++++++++++++ Code/Os/OsUtils.cs | 28 ++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 4 deletions(-) diff --git a/Code/Form1.cs b/Code/Form1.cs index 7b9355d..a9ca6c8 100644 --- a/Code/Form1.cs +++ b/Code/Form1.cs @@ -411,9 +411,6 @@ namespace Flowframes return; string aiName = GetAi().aiName.Replace("_", "-"); - - if (!Program.busy && guiFactor > 2 && GetAi().multiPass && Config.GetInt(Config.Key.autoEncMode) > 0 && !Logger.GetLastLine().Contains(aiName)) - Logger.Log($"Warning: {aiName} doesn't natively support 4x/8x and will run multiple times for {guiFactor}x. Auto-Encode will only work on the last run."); } public void ValidateFactor () diff --git a/Code/Main/AutoEncode.cs b/Code/Main/AutoEncode.cs index ce9fb3c..8295df9 100644 --- a/Code/Main/AutoEncode.cs +++ b/Code/Main/AutoEncode.cs @@ -99,7 +99,7 @@ namespace Flowframes.Main int maxFrames = chunkSize + (0.5f * chunkSize).RoundToInt() + safetyBufferFrames; bool overwhelmed = unencodedFrameLines.Count > maxFrames; - if(overwhelmed && !AiProcessSuspend.aiProcFrozen) + if(overwhelmed && !AiProcessSuspend.aiProcFrozen && OsUtils.IsProcessHidden(AiProcess.lastAiProcess)) { string dirSize = FormatUtils.Bytes(IoUtils.GetDirSize(Interpolate.current.interpFolder, true)); Logger.Log($"AutoEnc is overwhelmed! ({unencodedFrameLines.Count} unencoded frames > {maxFrames}) - Pausing.", true); diff --git a/Code/Main/Interpolate.cs b/Code/Main/Interpolate.cs index d1c48bf..16f4c8f 100644 --- a/Code/Main/Interpolate.cs +++ b/Code/Main/Interpolate.cs @@ -41,6 +41,7 @@ namespace Flowframes if (!ResumeUtils.resumeNextRun && !Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists if (!Utils.CheckPathValid(current.inPath)) return; // Check if input path/file is valid if (!(await Utils.CheckEncoderValid())) return; // Check NVENC compat + Utils.ShowWarnings(current.interpFactor, current.ai); currentInputFrameCount = await GetFrameCountCached.GetFrameCountAsync(current.inPath); current.stepByStep = false; Program.mainForm.SetStatus("Starting..."); diff --git a/Code/Main/InterpolateUtils.cs b/Code/Main/InterpolateUtils.cs index c07e70a..6ff9055 100644 --- a/Code/Main/InterpolateUtils.cs +++ b/Code/Main/InterpolateUtils.cs @@ -172,6 +172,20 @@ namespace Flowframes.Main return true; } + public static void ShowWarnings (float factor, AI ai) + { + string aiName = ai.aiName.Replace("_", "-"); + + if (factor > 2 && ai.multiPass && Config.GetInt(Config.Key.autoEncMode) > 0) + { + int times = (int)Math.Log(factor, 2); + Logger.Log($"Warning: {aiName} can only do 2x at a time and will run {times} times for {factor}x. Auto-Encode will only work on the last run."); + } + + if (Config.GetInt(Config.Key.cmdDebugMode) > 0) + Logger.Log($"Warning: The CMD window for interpolation is enabled. This will disable Auto-Encode and the progress bar!"); + } + public static bool CheckPathValid(string path) { if (IoUtils.IsPathDirectory(path)) diff --git a/Code/Os/OsUtils.cs b/Code/Os/OsUtils.cs index c6789ed..cbb8879 100644 --- a/Code/Os/OsUtils.cs +++ b/Code/Os/OsUtils.cs @@ -53,6 +53,34 @@ namespace Flowframes.Os return proc; } + public static bool IsProcessHidden(Process proc) + { + bool defaultVal = true; + + try + { + if(proc == null) + { + Logger.Log($"IsProcessHidden was called but proc is null, defaulting to {defaultVal}", true); + return defaultVal; + } + + if (proc.HasExited) + { + Logger.Log($"IsProcessHidden was called but proc has already exited, defaulting to {defaultVal}", true); + return defaultVal; + } + + ProcessStartInfo si = proc.StartInfo; + return !si.UseShellExecute && si.CreateNoWindow; + } + catch (Exception e) + { + Logger.Log($"IsProcessHidden errored, defaulting to {defaultVal}: {e.Message}", true); + return defaultVal; + } + } + public static Process NewProcess(bool hidden, string filename = "cmd.exe") { Process proc = new Process();