Exemple #1
0
        public static async Task CreateOutputVid()
        {
            if (!Directory.Exists(current.interpFolder) || IOUtils.GetAmountOfFiles(current.interpFolder, false) < 2)
            {
                Cancel($"There are no interpolated frames to encode!\n\nDid you delete the folder?");
                return;
            }

            if (!(await InterpolateUtils.CheckEncoderValid()))
            {
                return;
            }

            string[] outFrames = IOUtils.GetFilesSorted(current.interpFolder, $"*.{InterpolateUtils.GetOutExt()}");

            if (outFrames.Length > 0 && !IOUtils.CheckImageValid(outFrames[0]))
            {
                InterpolateUtils.ShowMessage("Invalid frame files detected!\n\nIf you used Auto-Encode, this is normal, and you don't need to run " +
                                             "this step as the video was already created in the \"Interpolate\" step.", "Error");
                return;
            }

            string outPath = Path.Combine(current.outPath, Path.GetFileNameWithoutExtension(current.inPath) + IOUtils.GetCurrentExportSuffix() + FFmpegUtils.GetExt(current.outMode));
            await CreateVideo.Export(current.interpFolder, outPath, current.outMode, true);
        }
        public static async Task CreateOutputVid()
        {
            if (IoUtils.GetAmountOfFiles(current.interpFolder, false) < 2)
            {
                if (Config.GetBool(Config.Key.sbsRunPreviousStepIfNeeded))
                {
                    Logger.Log($"There are no interpolated frames to export - Running interpolation step first...");
                    await InterpolateStep();
                }

                if (IoUtils.GetAmountOfFiles(current.interpFolder, false) < 2)
                {
                    Cancel($"There are no interpolated frames to encode!\n\nDid you delete the folder?");
                    return;
                }
            }

            if (!(await InterpolateUtils.CheckEncoderValid()))
            {
                return;
            }

            string[] outFrames = IoUtils.GetFilesSorted(current.interpFolder, current.interpExt);

            if (outFrames.Length > 0 && !IoUtils.CheckImageValid(outFrames[0]))
            {
                UiUtils.ShowMessageBox("Invalid frame files detected!\n\nIf you used Auto-Encode, this is normal, and you don't need to run " +
                                       "this step as the video was already created in the \"Interpolate\" step.", UiUtils.MessageType.Error);
                return;
            }

            await Export.ExportFrames(current.interpFolder, current.outPath, current.outMode, 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);
        }
Exemple #4
0
        public static async Task DoInterpolate()
        {
            if (!InterpolateUtils.CheckAiAvailable(current.ai))
            {
                return;
            }

            current.framesFolder = Path.Combine(current.tempFolder, Paths.framesDir);

            if (!Directory.Exists(current.framesFolder) || IOUtils.GetAmountOfFiles(current.framesFolder, false, "*.png") < 2)
            {
                InterpolateUtils.ShowMessage("There are no extracted frames that can be interpolated!\nDid you run the extraction step?", "Error");
                return;
            }
            if (!IOUtils.TryDeleteIfExists(current.interpFolder))
            {
                InterpolateUtils.ShowMessage("Failed to delete existing frames folder - Make sure no file is opened in another program!", "Error");
                return;
            }

            currentInputFrameCount = await InterpolateUtils.GetInputFrameCountAsync(current.inPath);

            // TODO: Check if this works lol, remove if it does
            //if (Config.GetBool("sbsAllowAutoEnc"))
            //    nextOutPath = Path.Combine(currentOutPath, Path.GetFileNameWithoutExtension(current.inPath) + IOUtils.GetAiSuffix(current.ai, current.interpFactor) + InterpolateUtils.GetExt(current.outMode));

            if (Config.GetBool("sbsAllowAutoEnc") && !(await InterpolateUtils.CheckEncoderValid()))
            {
                return;
            }

            if (canceled)
            {
                return;
            }
            Program.mainForm.SetStatus("Running AI...");
            await RunAi(current.interpFolder, current.ai, true);

            await IOUtils.ReverseRenaming(current.framesFolder, AiProcess.filenameMap);   // Get timestamps back

            AiProcess.filenameMap.Clear();
            Program.mainForm.SetProgress(0);
        }
Exemple #5
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();
        }
Exemple #6
0
        public static async Task Start()
        {
            if (!BatchProcessing.busy && Program.busy)
            {
                return;
            }
            canceled = false;
            Program.mainForm.SetWorking(true);
            if (!Utils.InputIsValid(current.inPath, current.outPath, current.outFps, current.interpFactor, current.outMode))
            {
                return;                                                                                                                  // General input checks
            }
            if (!Utils.CheckAiAvailable(current.ai))
            {
                return;                                                 // Check if selected AI pkg is installed
            }
            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.PathAsciiCheck(current.outPath, "output path");
            currentInputFrameCount = await Utils.GetInputFrameCountAsync(current.inPath);

            current.stepByStep = false;
            Program.mainForm.SetStatus("Starting...");

            if (!ResumeUtils.resumeNextRun)
            {
                await GetFrames();

                if (canceled)
                {
                    return;
                }
                sw.Restart();
                await PostProcessFrames(false);
            }

            if (canceled)
            {
                return;
            }
            await ResumeUtils.PrepareResumedRun();

            //Task.Run(() => Utils.DeleteInterpolatedInputFrames());
            await RunAi(current.interpFolder, current.ai);

            if (canceled)
            {
                return;
            }
            Program.mainForm.SetProgress(100);
            if (!currentlyUsingAutoEnc)
            {
                await CreateVideo.Export(current.interpFolder, current.outFilename, current.outMode, false);
            }
            await IOUtils.ReverseRenaming(current.framesFolder, AiProcess.filenameMap);   // Get timestamps back

            AiProcess.filenameMap.Clear();
            await Cleanup();

            Program.mainForm.SetWorking(false);
            Logger.Log("Total processing time: " + FormatUtils.Time(sw.Elapsed));
            sw.Stop();
            Program.mainForm.SetStatus("Done interpolating!");
        }