public static void EncSubtitles() { //Creates Subtitle Directory in the temp dir if (!Directory.Exists(Path.Combine(MainWindow.workingTempDirectory, "Subtitles"))) { Directory.CreateDirectory(Path.Combine(MainWindow.workingTempDirectory, "Subtitles")); } if (MainWindow.subtitleStreamCopy == true) { string subtitleCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.videoInput + '\u0022' + " -vn -an -dn -c copy " + '\u0022' + MainWindow.workingTempDirectory + "\\Subtitles\\subtitle.mkv" + '\u0022'; SmallScripts.ExecuteFfmpegTask(subtitleCommand); } if (MainWindow.subtitleCustom == true) { string subtitleMapping = ""; string subtitleInput = ""; int subtitleAmount = 0; foreach (var items in MainWindow.SubtitleChunks) { subtitleInput += " -i " + '\u0022' + items + '\u0022'; subtitleMapping += " -map " + subtitleAmount; subtitleAmount += 1; } string subtitleCommand = "/C ffmpeg.exe" + subtitleInput + " -vn -an -dn -c copy " + subtitleMapping + " " + '\u0022' + MainWindow.workingTempDirectory + "\\Subtitles\\subtitlecustom.mkv" + '\u0022'; SmallScripts.ExecuteFfmpegTask(subtitleCommand); } }
public static async Task Concat() { if (SmallScripts.Cancel.CancelAll == false) { string ffmpegCommand = "/C (for %i in (" + '\u0022' + MainWindow.chunksDir + "\\*.ivf" + '\u0022' + ") do @echo file '%i') > " + '\u0022' + MainWindow.chunksDir + "\\chunks.txt" + '\u0022'; await Task.Run(() => SmallScripts.ExecuteFfmpegTask(ffmpegCommand)); if (MainWindow.audioEncoding == false && MainWindow.subtitles == false) { ffmpegCommand = "/C ffmpeg.exe -f concat -safe 0 -i " + '\u0022' + MainWindow.chunksDir + "\\chunks.txt" + '\u0022' + " -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } else { ffmpegCommand = "/C ffmpeg.exe -f concat -safe 0 -i " + '\u0022' + MainWindow.chunksDir + "\\chunks.txt" + '\u0022' + " -c copy " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022'; } await Task.Run(() => SmallScripts.ExecuteFfmpegTask(ffmpegCommand)); if (MainWindow.audioEncoding != false || MainWindow.subtitles != false) { if (MainWindow.audioEncoding == true && MainWindow.subtitles == false) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022' + " -i " + '\u0022' + MainWindow.workingTempDirectory + "\\AudioEncoded\\audio.mkv" + '\u0022' + " -map_metadata -1 -map 0:v -map 1:a -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } else if (MainWindow.audioEncoding == true && MainWindow.subtitles == true && MainWindow.subtitleStreamCopy == true && MainWindow.subtitleCustom == false) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022' + " -i " + '\u0022' + MainWindow.workingTempDirectory + "\\AudioEncoded\\audio.mkv" + '\u0022' + " -i " + MainWindow.workingTempDirectory + "\\Subtitles\\subtitle.mkv" + " -map_metadata -1 -map 0:v -map 1:a -map 2:s -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } else if (MainWindow.audioEncoding == true && MainWindow.subtitles == true && MainWindow.subtitleStreamCopy == false && MainWindow.subtitleCustom == true) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022' + " -i " + '\u0022' + MainWindow.workingTempDirectory + "\\AudioEncoded\\audio.mkv" + '\u0022' + " -i " + MainWindow.workingTempDirectory + "\\Subtitles\\subtitlecustom.mkv" + " -map_metadata -1 -map 0:v -map 1:a -map 2:s -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } else if (MainWindow.audioEncoding == false && MainWindow.subtitles == true && MainWindow.subtitleStreamCopy == false && MainWindow.subtitleCustom == true) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022' + " -i " + MainWindow.workingTempDirectory + "\\Subtitles\\subtitlecustom.mkv" + " -map_metadata -1 -map 0:v -map 1:s -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } else if (MainWindow.audioEncoding == false && MainWindow.subtitles == true && MainWindow.subtitleStreamCopy == true && MainWindow.subtitleCustom == false) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.workingTempDirectory + "\\withoutaudio.mkv" + '\u0022' + " -i " + MainWindow.workingTempDirectory + "\\Subtitles\\subtitle.mkv" + " -map_metadata -1 -map 0:v -map 1:s -c copy " + '\u0022' + MainWindow.videoOutput + '\u0022'; } await Task.Run(() => SmallScripts.ExecuteFfmpegTask(ffmpegCommand)); SmallScripts.CheckSuccessfulEncode(); } } }
public static void StartSplitting(string videoInput, string tempFolderPath, int chunkLength, bool reencode, string ffmpegPath) { if (reencode == true) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -c:v utvideo -f segment -segment_time " + chunkLength + " -an " + '\u0022' + tempFolderPath + "\\Chunks\\out%0d.mkv" + '\u0022'; } else if (reencode == false) { ffmpegCommand = "/C ffmpeg.exe -i " + '\u0022' + videoInput + '\u0022' + " -vcodec copy -f segment -segment_time " + chunkLength + " -an " + '\u0022' + tempFolderPath + "\\Chunks\\out%0d.mkv" + '\u0022'; } SmallScripts.ExecuteFfmpegTask(ffmpegCommand); if (SmallScripts.Cancel.CancelAll == false) { SmallScripts.WriteToFileThreadSafe("True", "splitted.log"); } }
public static void AudioEncode() { if (MainWindow.audioEncoding == true) { string audioInput = ""; string audioMapping = ""; string audioCodec = ""; //Creates AudioEncoded Directory in the temp dir if (!Directory.Exists(Path.Combine(MainWindow.workingTempDirectory, "AudioEncoded"))) { Directory.CreateDirectory(Path.Combine(MainWindow.workingTempDirectory, "AudioEncoded")); } //Audio Encoder --------------------------------------------------------------------------|| if (MainWindow.audioCodec == "Opus") { audioCodec = "libopus"; } if (MainWindow.audioCodec == "Opus 5.1") { audioCodec = "libopus -af channelmap=channel_layout=5.1"; } if (MainWindow.audioCodec == "Opus Downmix") { audioCodec = "libopus -ac 2"; } if (MainWindow.audioCodec == "AC3") { audioCodec = "ac3"; } if (MainWindow.audioCodec == "AAC") { audioCodec = "aac"; } if (MainWindow.audioCodec == "MP3") { audioCodec = "libmp3lame"; } //----------------------------------------------------------------------------------------|| //Audio Mapping --------------------------------------------------------------------------|| if (MainWindow.trackOne == true && MainWindow.detectedTrackOne == true) { audioInput += " -c:a:0 " + audioCodec + " -b:a:0 " + MainWindow.audioBitrate + "k"; audioMapping += " -map 0:" + MainWindow.firstTrackIndex + " "; } if (MainWindow.trackTwo == true && MainWindow.detectedTrackTwo == true) { audioInput += " -c:a:1 " + audioCodec + " -b:a:1 " + MainWindow.audioBitrate + "k"; audioMapping += " -map 0:" + MainWindow.secondTrackIndex + " "; } if (MainWindow.trackThree == true && MainWindow.detectedTrackThree == true) { audioInput += " -c:a:2 " + audioCodec + " -b:a:2 " + MainWindow.audioBitrate + "k"; audioMapping += " -map 0:" + MainWindow.thirdTrackIndex + " "; } if (MainWindow.trackFour == true && MainWindow.detectedTrackFour == true) { audioInput += " -c:a:3 " + audioCodec + " -b:a:3 " + MainWindow.audioBitrate + "k"; audioMapping += " -map 0:" + MainWindow.fourthTrackIndex + " "; } //----------------------------------------------------------------------------------------|| //Audio Encoding -------------------------------------------------------------------------|| string ffmpegAudioCommands = "/C ffmpeg.exe -i " + '\u0022' + MainWindow.videoInput + '\u0022' + " -map_metadata -1 -vn -sn -dn" + audioInput + audioMapping + '\u0022' + MainWindow.workingTempDirectory + "\\AudioEncoded\\audio.mkv" + '\u0022'; SmallScripts.ExecuteFfmpegTask(ffmpegAudioCommands); //----------------------------------------------------------------------------------------|| } }