static async Task AiFinished(string aiName) { if (Interpolate.canceled) { return; } Program.mainForm.SetProgress(100); AiProcessSuspend.SetRunning(false); int interpFramesFiles = IoUtils.GetAmountOfFiles(Interpolate.current.interpFolder, false, "*" + Interpolate.current.interpExt); int interpFramesCount = interpFramesFiles + InterpolationProgress.deletedFramesCount; InterpolationProgress.UpdateInterpProgress(interpFramesCount, InterpolationProgress.targetFrames); string logStr = $"Done running {aiName} - Interpolation took {FormatUtils.Time(processTime.Elapsed)}. Peak Output FPS: {InterpolationProgress.peakFpsOut.ToString("0.00")}"; if (Interpolate.currentlyUsingAutoEnc && AutoEncode.HasWorkToDo()) { logStr += " - Waiting for encoding to finish..."; Program.mainForm.SetStatus("Creating output video from frames..."); } Logger.Log(logStr); processTime.Stop(); if (interpFramesCount < 3) { string[] logLines = File.ReadAllLines(Path.Combine(Paths.GetLogPath(), lastLogName + ".txt")); string log = string.Join("\n", logLines.Reverse().Take(10).Reverse().Select(x => x.Split("]: ").Last()).ToList()); string amount = interpFramesCount > 0 ? $"Only {interpFramesCount}" : "No"; Interpolate.Cancel($"Interpolation failed - {amount} interpolated frames were created.\n\n\nLast 10 log lines:\n{log}\n\nCheck the log '{lastLogName}' for more details."); return; } try { while (Interpolate.currentlyUsingAutoEnc && Program.busy) { if (AvProcess.lastAvProcess != null && !AvProcess.lastAvProcess.HasExited) { if (Logger.LastLogLine.ToLower().Contains("frame: ")) { Logger.Log(FormatUtils.BeautifyFfmpegStats(Logger.LastLogLine), false, Logger.LastUiLine.ToLower().Contains("frame")); } } if (AvProcess.lastAvProcess.HasExited && !AutoEncode.HasWorkToDo()) // Stop logging if ffmpeg is not running & AE is done { break; } await Task.Delay(500); } } catch (Exception e) { Logger.Log($"AiFinished encoder logging error: {e.Message}\n{e.StackTrace}", true); } }
static void SetProgressCheck(string interpPath, float factor) { int frames = IoUtils.GetAmountOfFiles(lastInPath, false); int target = ((frames * factor) - (factor - 1)).RoundToInt(); InterpolationProgress.progressPaused = false; InterpolationProgress.currentFactor = factor; if (InterpolationProgress.progCheckRunning) { InterpolationProgress.targetFrames = target; } else { InterpolationProgress.GetProgressByFrameAmount(interpPath, target); } }
static void LogOutput(string line, string logFilename, bool err = false) { if (string.IsNullOrWhiteSpace(line) || line.Length < 6) { return; } Stopwatch sw = new Stopwatch(); sw.Restart(); //if (line.Contains("iVBOR")) //{ // try // { // string[] split = line.Split(':'); // //MemoryStream stream = new MemoryStream(Convert.FromBase64String(split[1])); // //Image img = Image.FromStream(stream); // Logger.Log($"Received image {split[0]} in {sw.ElapsedMilliseconds} ms", true); // } // catch (Exception e) // { // Logger.Log($"Failed to decode b64 string - {e}:"); // Logger.Log(line); // } // return; //} lastLogName = logFilename; Logger.Log(line, true, false, logFilename); if (line.Contains("ff:nocuda-cpu")) { Logger.Log("WARNING: CUDA-capable GPU device is not available, running on CPU instead!"); } if (!hasShownError && err && line.ToLower().Contains("out of memory")) { hasShownError = true; UiUtils.ShowMessageBox($"Your GPU ran out of VRAM! Please try a video with a lower resolution or use the Max Video Size option in the settings.\n\n{line}", UiUtils.MessageType.Error); } if (!hasShownError && err && line.ToLower().Contains("modulenotfounderror")) { hasShownError = true; UiUtils.ShowMessageBox($"A python module is missing.\nCheck {logFilename} for details.\n\n{line}", UiUtils.MessageType.Error); if (!Python.HasEmbeddedPyFolder()) { Process.Start("https://github.com/n00mkrad/flowframes/blob/main/PythonDependencies.md"); } } if (!hasShownError && line.ToLower().Contains("no longer supports this gpu")) { hasShownError = true; UiUtils.ShowMessageBox($"Your GPU seems to be outdated and is not supported!\n\n{line}", UiUtils.MessageType.Error); } if (!hasShownError && line.ToLower().Contains("illegal memory access")) { hasShownError = true; UiUtils.ShowMessageBox($"Your GPU appears to be unstable! If you have an overclock enabled, please disable it!\n\n{line}", UiUtils.MessageType.Error); } if (!hasShownError && line.ToLower().Contains("error(s) in loading state_dict")) { hasShownError = true; string msg = (Interpolate.current.ai.aiName == Implementations.flavrCuda.aiName) ? "\n\nFor FLAVR, you need to select the correct model for each scale!" : ""; UiUtils.ShowMessageBox($"Error loading the AI model!\n\n{line}{msg}", UiUtils.MessageType.Error); } if (!hasShownError && line.ToLower().Contains("unicodeencodeerror")) { hasShownError = true; UiUtils.ShowMessageBox($"It looks like your path contains invalid characters - remove them and try again!\n\n{line}", UiUtils.MessageType.Error); } if (!hasShownError && err && (line.Contains("RuntimeError") || line.Contains("ImportError") || line.Contains("OSError"))) { hasShownError = true; UiUtils.ShowMessageBox($"A python error occured during interpolation!\nCheck {logFilename} for details.\n\n{line}", UiUtils.MessageType.Error); } if (!hasShownError && err && line.MatchesWildcard("vk*Instance* failed")) { hasShownError = true; UiUtils.ShowMessageBox($"Vulkan failed to start up!\n\n{line}\n\nThis most likely means your GPU is not compatible.", UiUtils.MessageType.Error); } if (!hasShownError && err && line.Contains("vkAllocateMemory failed")) { hasShownError = true; bool usingDain = (Interpolate.current.ai.aiName == Implementations.dainNcnn.aiName); string msg = usingDain ? "\n\nTry reducing the tile size in the AI settings." : "\n\nTry a lower resolution (Settings -> Max Video Size)."; UiUtils.ShowMessageBox($"Vulkan ran out of memory!\n\n{line}{msg}", UiUtils.MessageType.Error); } if (!hasShownError && err && line.Contains("invalid gpu device")) { hasShownError = true; UiUtils.ShowMessageBox($"A Vulkan error occured during interpolation!\n\n{line}\n\nAre your GPU IDs set correctly?", UiUtils.MessageType.Error); } if (!hasShownError && err && line.MatchesWildcard("vk* failed")) { hasShownError = true; UiUtils.ShowMessageBox($"A Vulkan error occured during interpolation!\n\n{line}", UiUtils.MessageType.Error); } if (hasShownError) { Interpolate.Cancel(); } InterpolationProgress.UpdateLastFrameFromInterpOutput(line); }