예제 #1
0
        public static async Task MuxOutputVideo(string inputPath, string outVideo)
        {
            if (!Config.GetBool("keepAudio") && !Config.GetBool("keepAudio"))
            {
                return;
            }

            Program.mainForm.SetStatus("Muxing audio/subtitles into video...");

            bool muxFromInput = Config.GetInt("audioSubTransferMode") == 0;

            try
            {
                if (muxFromInput)
                {
                    await FfmpegAudioAndMetadata.MergeStreamsFromInput(inputPath, outVideo, I.current.tempFolder);
                }
                else
                {
                    await FfmpegAudioAndMetadata.MergeAudioAndSubs(outVideo, I.current.tempFolder);        // Merge from audioFile into outVideo
                }
            }
            catch (Exception e)
            {
                Logger.Log("Failed to merge audio/subtitles with output video!");
                Logger.Log("MergeAudio() Exception: " + e.Message, true);
            }
        }
예제 #2
0
        public static async Task MuxOutputVideo(string inputPath, string outVideo, bool shortest = false, bool showLog = true)
        {
            if (!File.Exists(outVideo))
            {
                I.Cancel($"No video was encoded!\n\nFFmpeg Output:\n{AvProcess.lastOutputFfmpeg}");
                return;
            }

            if (!Config.GetBool(Config.Key.keepAudio) && !Config.GetBool(Config.Key.keepAudio))
            {
                return;
            }

            if (showLog)
            {
                Program.mainForm.SetStatus("Muxing audio/subtitles into video...");
            }

            if (I.current.inputIsFrames)
            {
                Logger.Log("Skipping muxing from input step as there is no input video, only frames.", true);
                return;
            }

            try
            {
                await FfmpegAudioAndMetadata.MergeStreamsFromInput(inputPath, outVideo, I.current.tempFolder, shortest);
            }
            catch (Exception e)
            {
                Logger.Log("Failed to merge audio/subtitles with output video!", !showLog);
                Logger.Log("MergeAudio() Exception: " + e.Message, true);
            }
        }
예제 #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);
            }
        }
예제 #4
0
 public static async Task MergeAudio(string inputPath, string outVideo)
 {
     try
     {
         await FfmpegAudioAndMetadata.MergeAudioAndSubs(outVideo, I.current.tempFolder);        // Merge from audioFile into outVideo
     }
     catch (Exception e)
     {
         Logger.Log("Failed to merge audio/subtitles with output video!");
         Logger.Log("MergeAudio() Exception: " + e.Message, true);
     }
 }