public static void Check()
        {
            // Sets / Checks ffmpeg Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "ffmpeg.exe")))
            {
                MainWindow.FFmpegPath = Directory.GetCurrentDirectory();
            }
            else if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "ffmpeg", "ffmpeg.exe")))
            {
                MainWindow.FFmpegPath = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "ffmpeg");
            }
            else if (ExistsOnPath("ffmpeg.exe"))
            {
                MainWindow.FFmpegPath = GetFullPathWithOutName("ffmpeg.exe");
            }
            else
            {
                MainWindow.FFmpegPath = null;
            }
            SmallFunctions.Logging("FFmpeg Path: " + MainWindow.FFmpegPath);

            // Sets / Checks aomenc Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "aomenc.exe")))
            {
                MainWindow.AomencPath = Directory.GetCurrentDirectory();
            }
            else if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "aomenc", "aomenc.exe")))
            {
                MainWindow.AomencPath = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "aomenc");
            }
            else if (ExistsOnPath("aomenc.exe"))
            {
                MainWindow.AomencPath = GetFullPathWithOutName("aomenc.exe");
            }
            else
            {
                MainWindow.AomencPath = null;
            }
            SmallFunctions.Logging("Aomenc Path: " + MainWindow.AomencPath);

            // Sets / Checks rav1e Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "rav1e.exe")))
            {
                MainWindow.Rav1ePath = Directory.GetCurrentDirectory();
            }
            else if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "rav1e", "rav1e.exe")))
            {
                MainWindow.Rav1ePath = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "rav1e");
            }
            else if (ExistsOnPath("rav1e.exe"))
            {
                MainWindow.Rav1ePath = GetFullPathWithOutName("rav1e.exe");
            }
            else
            {
                MainWindow.Rav1ePath = null;
            }
            SmallFunctions.Logging("Rav1e Path: " + MainWindow.Rav1ePath);

            // Sets / Checks svt-av1 Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "SvtAv1EncApp.exe")))
            {
                MainWindow.SvtAV1Path = Directory.GetCurrentDirectory();
            }
            else if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "svt-av1", "SvtAv1EncApp.exe")))
            {
                MainWindow.SvtAV1Path = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "svt-av1");
            }
            else if (ExistsOnPath("SvtAv1EncApp.exe"))
            {
                MainWindow.SvtAV1Path = GetFullPathWithOutName("SvtAv1EncApp.exe");
            }
            else
            {
                MainWindow.SvtAV1Path = null;
            }
            SmallFunctions.Logging("SVT-AV1 Path: " + MainWindow.SvtAV1Path);

            // Sets / Checks mkvtoolnix Path
            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "mkvmerge.exe")))
            {
                MainWindow.MKVToolNixPath = Directory.GetCurrentDirectory();
            }
            else if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), "Apps", "mkvtoolnix", "mkvmerge.exe")))
            {
                MainWindow.MKVToolNixPath = Path.Combine(Directory.GetCurrentDirectory(), "Apps", "mkvtoolnix");
            }
            else if (ExistsOnPath("mkvmerge.exe"))
            {
                MainWindow.MKVToolNixPath = GetFullPathWithOutName("mkvmerge.exe");
            }
            else if (File.Exists(@"C:\Program Files\MKVToolNix\mkvmerge.exe"))
            {
                MainWindow.MKVToolNixPath = @"C:\Program Files\MKVToolNix\";
            }
            else
            {
                MainWindow.MKVToolNixPath = null;
            }
            SmallFunctions.Logging("MKVToolNix Path: " + MainWindow.MKVToolNixPath);

            // Checks if PySceneDetect is found in the Windows PATH environment
            if (ExistsOnPath("scenedetect.exe"))
            {
                MainWindow.PySceneFound = true;
            }
            SmallFunctions.Logging("PySceneDetect found: " + MainWindow.PySceneFound);

            NotifyUser();
        }
예제 #2
0
        public static void Encode()
        {
            // Skips Audio Encoding if the audio file already exist
            if (File.Exists(Path.Combine(MainWindow.TempPath, MainWindow.TempPathFileName, "Audio", "audio.mkv")) == false)
            {
                //Creates Audio Directory in the temp dir
                if (!Directory.Exists(Path.Combine(MainWindow.TempPath, MainWindow.TempPathFileName, "Audio")))
                {
                    Directory.CreateDirectory(Path.Combine(MainWindow.TempPath, MainWindow.TempPathFileName, "Audio"));
                }
                string audioCodec   = "";
                int    activeTracks = 0;

                //Counts the number of active audio tracks for audio mapping purposes
                if (MainWindow.trackOne)
                {
                    activeTracks += 1;
                }
                if (MainWindow.trackTwo)
                {
                    activeTracks += 1;
                }
                if (MainWindow.trackThree)
                {
                    activeTracks += 1;
                }
                if (MainWindow.trackFour)
                {
                    activeTracks += 1;
                }

                if (activeTracks == 1)
                {
                    audioCodec = OneTrackCommandGenerator(MainWindow.audioBitrateTrackOne, MainWindow.audioCodecTrackOne, MainWindow.audioChannelsTrackOne);
                }
                else if (activeTracks >= 2)
                {
                    if (MainWindow.trackOne == true)
                    {
                        audioCodec += MultipleTrackCommandGenerator(MainWindow.audioBitrateTrackOne, "0", MainWindow.audioCodecTrackOne, MainWindow.audioChannelsTrackOne, MainWindow.trackOneLanguage);
                    }
                    if (MainWindow.trackTwo == true)
                    {
                        audioCodec += MultipleTrackCommandGenerator(MainWindow.audioBitrateTrackTwo, "1", MainWindow.audioCodecTrackTwo, MainWindow.audioChannelsTrackTwo, MainWindow.trackTwoLanguage);
                    }
                    if (MainWindow.trackThree == true)
                    {
                        audioCodec += MultipleTrackCommandGenerator(MainWindow.audioBitrateTrackThree, "2", MainWindow.audioCodecTrackThree, MainWindow.audioChannelsTrackThree, MainWindow.trackThreeLanguage);
                    }
                    if (MainWindow.trackFour == true)
                    {
                        audioCodec += MultipleTrackCommandGenerator(MainWindow.audioBitrateTrackFour, "3", MainWindow.audioCodecTrackFour, MainWindow.audioChannelsTrackFour, MainWindow.trackFourLanguage);
                    }
                    if (MainWindow.audioCodecTrackOne != "Copy Audio" && MainWindow.audioCodecTrackTwo != "Copy Audio" && MainWindow.audioCodecTrackThree != "Copy Audio" && MainWindow.audioCodecTrackFour != "Copy Audio")
                    {
                        audioCodec += " -af aformat=channel_layouts=" + '\u0022' + "7.1|5.1|stereo|mono" + '\u0022' + " ";
                    }
                }

                // ══════════════════════════════════════ Audio Encoding ══════════════════════════════════════
                string ffmpegAudioCommands = "/C ffmpeg.exe -y -i " + '\u0022' + MainWindow.VideoInput + '\u0022' + " " + MainWindow.TrimCommand + " -map_metadata -1 -vn -sn -dn " + audioCodec + " " + '\u0022' + Path.Combine(MainWindow.TempPath, MainWindow.TempPathFileName, "Audio", "audio.mkv") + '\u0022';
                SmallFunctions.Logging("Encoding Audio: " + ffmpegAudioCommands);
                SmallFunctions.ExecuteFfmpegTask(ffmpegAudioCommands);
                // ════════════════════════════════════════════════════════════════════════════════════════════
            }
        }