Exemplo n.º 1
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);
            }
        }
Exemplo n.º 2
0
        public static async Task ExtractSceneChanges()
        {
            string scenesPath = Path.Combine(current.tempFolder, Paths.scenesDir);

            if (!IOUtils.TryDeleteIfExists(scenesPath))
            {
                InterpolateUtils.ShowMessage("Failed to delete existing scenes folder - Make sure no file is opened in another program!", "Error");
                return;
            }

            Program.mainForm.SetStatus("Extracting scenes from video...");
            await FfmpegExtract.ExtractSceneChanges(current.inPath, scenesPath, current.inFps);

            await Task.Delay(10);
        }
Exemplo n.º 3
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));
            }
        }
Exemplo n.º 4
0
        public static async Task GetFrames()
        {
            current.RefreshAlpha();
            current.RefreshExtensions(InterpSettings.FrameType.Import);

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

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