Example #1
0
        public static async Task ExtractFrames(string inPath, string outPath, bool alpha)
        {
            if (canceled)
            {
                return;
            }
            Program.mainForm.SetStatus("Extracting frames from video...");
            current.RefreshExtensions(InterpSettings.FrameType.Import);
            bool mpdecimate = Config.GetInt(Config.Key.dedupMode) == 2;
            Size res        = await Utils.GetOutputResolution(inPath, true, true);

            await FfmpegExtract.VideoToFrames(inPath, outPath, alpha, current.inFpsDetected, mpdecimate, false, res, current.framesExt);

            if (mpdecimate)
            {
                int    framesLeft     = IoUtils.GetAmountOfFiles(outPath, false, "*" + current.framesExt);
                int    framesDeleted  = currentInputFrameCount - framesLeft;
                float  percentDeleted = ((float)framesDeleted / currentInputFrameCount) * 100f;
                string keptPercent    = $"{(100f - percentDeleted).ToString("0.0")}%";

                if (QuickSettingsTab.trimEnabled)
                {
                    Logger.Log($"Deduplication: Kept {framesLeft} frames.");
                }
                else
                {
                    Logger.Log($"Deduplication: Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.");
                }
            }

            if (!Config.GetBool("allowConsecutiveSceneChanges", true))
            {
                Utils.FixConsecutiveSceneFrames(Path.Combine(current.tempFolder, Paths.scenesDir), current.framesFolder);
            }
        }
Example #2
0
        public static async Task GetFrames(bool stepByStep = false)
        {
            current.RefreshAlpha();

            if (!current.inputIsFrames)        // Extract if input is video, import if image sequence
            {
                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));
            }
        }
Example #3
0
        public static async Task ExtractFrames(string inPath, string outPath, bool alpha, bool sceneDetect)
        {
            if (sceneDetect && Config.GetBool("scnDetect"))
            {
                Program.mainForm.SetStatus("Extracting scenes from video...");
                await FfmpegExtract.ExtractSceneChanges(inPath, Path.Combine(current.tempFolder, Paths.scenesDir), current.inFps);

                await Task.Delay(10);
            }

            if (canceled)
            {
                return;
            }
            Program.mainForm.SetStatus("Extracting frames from video...");
            bool mpdecimate = Config.GetInt("dedupMode") == 2;
            await FfmpegExtract.VideoToFrames(inPath, outPath, alpha, current.inFps, mpdecimate, false, await Utils.GetOutputResolution(inPath, true, true));

            if (mpdecimate)
            {
                int    framesLeft     = IOUtils.GetAmountOfFiles(outPath, false, $"*.png");
                int    framesDeleted  = currentInputFrameCount - framesLeft;
                float  percentDeleted = ((float)framesDeleted / currentInputFrameCount) * 100f;
                string keptPercent    = $"{(100f - percentDeleted).ToString("0.0")}%";
                Logger.Log($"[Deduplication] Kept {framesLeft} ({keptPercent}) frames, deleted {framesDeleted} frames.");
            }

            if (!Config.GetBool("allowConsecutiveSceneChanges", true))
            {
                Utils.FixConsecutiveSceneFrames(Path.Combine(current.tempFolder, Paths.scenesDir), current.framesFolder);
            }

            if (canceled)
            {
                return;
            }

            if (Config.GetBool("keepAudio"))
            {
                Program.mainForm.SetStatus("Extracting audio from video...");
                await FfmpegAudioAndMetadata.ExtractAudioTracks(inPath, current.tempFolder);
            }

            if (canceled)
            {
                return;
            }

            if (Config.GetBool("keepSubs"))
            {
                Program.mainForm.SetStatus("Extracting subtitles from video...");
                await FfmpegAudioAndMetadata.ExtractSubtitles(inPath, current.tempFolder, current.outMode);
            }
        }
Example #4
0
        public static async Task GetFrames()
        {
            current.RefreshAlpha();

            if (Config.GetBool("scnDetect"))
            {
                Program.mainForm.SetStatus("Extracting scenes from video...");
                await FfmpegExtract.ExtractSceneChanges(current.inPath, Path.Combine(current.tempFolder, Paths.scenesDir), current.inFps, current.inputIsFrames);
            }

            if (!current.inputIsFrames)        // Extract if input is video, import if image sequence
            {
                await ExtractFrames(current.inPath, current.framesFolder, current.alpha);
            }
            else
            {
                await FfmpegExtract.ImportImages(current.inPath, current.framesFolder, current.alpha, await Utils.GetOutputResolution(current.inPath, true));
            }
        }