public static async Task <int> GetCurrentInputFrameCount() { if (currentInputFrameCount < 2) { currentInputFrameCount = await GetFrameCountCached.GetFrameCountAsync(current.inPath); } return(currentInputFrameCount); }
public static async Task ExtractFramesStep() { if (!(await IoUtils.TryDeleteIfExistsAsync(current.framesFolder))) { UiUtils.ShowMessageBox("Failed to delete existing frames folder - Make sure no file is opened in another program!", UiUtils.MessageType.Error); return; } currentInputFrameCount = await GetFrameCountCached.GetFrameCountAsync(current.inPath); await GetFrames(); await PostProcessFrames(true); }
public static async Task InterpolateStep() { if (!InterpolateUtils.CheckAiAvailable(current.ai, current.model)) { return; } current.framesFolder = Path.Combine(current.tempFolder, Paths.framesDir); if (IoUtils.GetAmountOfFiles(current.framesFolder, false, "*") < 2) { if (Config.GetBool(Config.Key.sbsRunPreviousStepIfNeeded)) { Logger.Log($"There are no extracted frames to interpolate - Running extract step first..."); await ExtractFramesStep(); } if (IoUtils.GetAmountOfFiles(current.framesFolder, false, "*") < 2) { UiUtils.ShowMessageBox("There are no extracted frames that can be interpolated!\nDid you run the extraction step?", UiUtils.MessageType.Error); return; } } if (!(await IoUtils.TryDeleteIfExistsAsync(current.interpFolder))) { UiUtils.ShowMessageBox("Failed to delete existing frames folder - Make sure no file is opened in another program!", UiUtils.MessageType.Error); return; } currentInputFrameCount = await GetFrameCountCached.GetFrameCountAsync(current.inPath); if (Config.GetBool(Config.Key.sbsAllowAutoEnc) && !(await InterpolateUtils.CheckEncoderValid())) { return; } if (canceled) { return; } Program.mainForm.SetStatus("Running AI..."); await RunAi(current.interpFolder, current.ai, true); await Task.Run(async() => { await FrameRename.Unrename(); }); // Get timestamps back Program.mainForm.SetProgress(0); }
public static async Task Start() { if (!BatchProcessing.busy && Program.busy) { return; } canceled = false; Program.initialRun = false; Program.mainForm.SetWorking(true); if (!Utils.InputIsValid(current.inPath, current.outPath, current.inFps, current.interpFactor, current.outMode)) { return; // General input checks } if (!Utils.CheckAiAvailable(current.ai, current.model)) { return; // Check if selected AI pkg is installed } if (!AutoEncodeResume.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..."); sw.Restart(); if (!AutoEncodeResume.resumeNextRun) { await GetFrames(); if (canceled) { return; } await PostProcessFrames(false); } if (canceled) { return; } bool skip = await AutoEncodeResume.PrepareResumedRun(); if (skip || canceled) { return; } //Task.Run(() => Utils.DeleteInterpolatedInputFrames()); await RunAi(current.interpFolder, current.ai); if (canceled) { return; } Program.mainForm.SetProgress(100); if (!currentlyUsingAutoEnc) { await Export.ExportFrames(current.interpFolder, current.outPath, current.outMode, false); } if (!AutoEncodeResume.resumeNextRun && Config.GetBool(Config.Key.keepTempFolder)) { await Task.Run(async() => { await FrameRename.Unrename(); }); } await Done(); }
public static async Task InitInput(TextBox outputTbox, TextBox inputTbox, TextBox fpsInTbox, bool start = false) { Program.mainForm.SetTab("interpolate"); Program.mainForm.ResetInputInfo(); string path = inputTbox.Text.Trim(); GetFrameCountCached.Clear(); GetMediaResolutionCached.Clear(); if (Config.GetBool(Config.Key.clearLogOnInput)) { Logger.ClearLogBox(); } SetOutPath(outputTbox, inputTbox.Text.Trim().GetParentDir()); Program.lastInputPath = path; Program.lastInputPathIsSsd = OsUtils.DriveIsSSD(path); if (!Program.lastInputPathIsSsd) { Logger.Log("Your file seems to be on an HDD or USB device. It is recommended to interpolate videos on an SSD drive for best performance."); } Logger.Log("Loading metadata..."); Program.mainForm.currInDuration = FfmpegCommands.GetDuration(path); Program.mainForm.currInDurationCut = Program.mainForm.currInDuration; int frameCount = await GetFrameCountCached.GetFrameCountAsync(path); string fpsStr = "Not Found"; Fraction fps = (await IoUtils.GetFpsFolderOrVideo(path)); Program.mainForm.currInFpsDetected = fps; fpsInTbox.Text = fps.GetString(); if (fps.GetFloat() > 0) { fpsStr = $"{fps} (~{fps.GetFloat()})"; } Logger.Log($"Video FPS: {fpsStr} - Total Number Of Frames: {frameCount}", false, true); Program.mainForm.GetInputFpsTextbox().ReadOnly = (fps.GetFloat() > 0 && !Config.GetBool("allowCustomInputRate", false)); Program.mainForm.currInFps = fps; Program.mainForm.currInFrames = frameCount; Program.mainForm.UpdateInputInfo(); CheckExistingFolder(path, outputTbox.Text.Trim()); await Task.Delay(10); await PrintResolution(path); Dedupe.ClearCache(); await Task.Delay(10); InterpolationProgress.SetPreviewImg(await GetThumbnail(path)); if (AutoEncodeResume.resumeNextRun) { Logger.Log($"Incomplete interpolation detected. Flowframes will resume the interpolation."); } if (start) { Program.mainForm.runBtn_Click(null, null); } }