/// <summary> /// Audio Filter Combine (Method) /// <summary> public static String AudioFilter() { // Audio BitRate None Check // Audio Codec None // Codec Copy Check // Mute Check // Stream None Check // Media Type Check if (VM.AudioView.Audio_Quality_SelectedItem != "None" && VM.AudioView.Audio_Codec_SelectedItem != "None" && VM.AudioView.Audio_Codec_SelectedItem != "Copy" && VM.AudioView.Audio_Quality_SelectedItem != "Mute" && VM.AudioView.Audio_Stream_SelectedItem != "none" && VM.FormatView.Format_MediaType_SelectedItem != "Image" && VM.FormatView.Format_MediaType_SelectedItem != "Sequence") { // -------------------------------------------------- // Filters // -------------------------------------------------- // ------------------------- // Volume // ------------------------- Audio.Volume(); // ------------------------- // Hard Limiter // ------------------------- Audio.HardLimiter(); // ------------------------- // Remove Click // ------------------------- //RemoveClick_Filter(mainwindow); // ------------------------- // Lowpass // ------------------------- Lowpass_Filter(); // ------------------------- // Highpass // ------------------------- Highpass_Filter(); // ------------------------- // Contrast // ------------------------- Contrast_Filter(); // ------------------------- // Extra Stereo // ------------------------- ExtraStereo_Filter(); // ------------------------- // Headphones // ------------------------- Headphones_Filter(); // ------------------------- // Tempo // ------------------------- Tempo_Filter(); // ------------------------- // Filter Combine // ------------------------- if (VM.AudioView.Audio_Codec_SelectedItem != "None") // None Check { // ------------------------- // 1 Filter // ------------------------- if (aFiltersList.Count == 1) { // Always wrap in quotes aFilter = "-af \"" + string.Join(", \r\n\r\n", aFiltersList .Where(s => !string.IsNullOrEmpty(s))) + "\""; } // ------------------------- // Multiple Filters // ------------------------- else if (aFiltersList.Count > 1) { // Always wrap in quotes // Linebreak beginning and end aFilter = "-af \"\r\n" + string.Join(", \r\n\r\n", aFiltersList .Where(s => !string.IsNullOrEmpty(s))) + "\r\n\""; //System.Windows.MessageBox.Show(aFilter); //debug } // ------------------------- // Empty // ------------------------- else { aFilter = string.Empty; } } // Audio Codec None else { aFilter = string.Empty; } } // ------------------------- // Filter Clear // ------------------------- else { aFilter = string.Empty; if (aFiltersList != null) { aFiltersList.Clear(); aFiltersList.TrimExcess(); } } // Return Value return(aFilter); }
public static string ffplay; // ffplay.exe /// <summary> /// Preview FFplay /// </summary> public static void Preview(MainWindow mainwindow) { // ------------------------- // Clear Variables before Run // ------------------------- ffplay = string.Empty; MainWindow.ClearVariables(mainwindow); // Ignore if Batch if (mainwindow.tglBatch.IsChecked == false) { // ------------------------- // Set FFprobe Path // ------------------------- MainWindow.FFplayPath(); // ------------------------- // Arguments List // ------------------------- List <string> FFplayArgsList = new List <string>() { //ffplay, "-i " + "\"" + MainWindow.InputPath(mainwindow) + "\"", Video.Subtitles(mainwindow), //Video.VideoCodec(), //Video.Speed(mainwindow), //Video.VideoQuality(mainwindow), Video.FPS(mainwindow), VideoFilters.VideoFilter(mainwindow), Video.ScalingAlgorithm(mainwindow), Video.Images(mainwindow), //Video.Optimize(mainwindow), //Streams.VideoStreamMaps(mainwindow), //Video.SubtitleCodec(mainwindow), //"Streams.SubtitleMaps(mainwindow), //Audio.AudioCodec(mainwindow), //Audio.AudioQuality(mainwindow), Audio.SampleRate(mainwindow), Audio.BitDepth(mainwindow), Audio.Channel(mainwindow), AudioFilters.AudioFilter(mainwindow), //Streams.AudioStreamMaps(mainwindow), //Format.Cut(mainwindow), //Streams.FormatMaps(mainwindow), //Format.ForceFormat(mainwindow), //MainWindow.ThreadDetect(mainwindow), //"\"" + MainWindow.OutputPath(mainwindow) + "\"" }; // Join List with Spaces // Remove: Empty, Null, Standalone LineBreak string ffplayArgs = MainWindow.ReplaceLineBreaksWithSpaces( string.Join(" ", FFplayArgsList) ); //string ffplayArgs = string.Join(" ", FFplayArgsList // .Where(s => !string.IsNullOrEmpty(s))) // .Replace("\r\n", " ") //Remove Linebreaks // .Replace(Environment.NewLine, " "); //MessageBox.Show(ffplayArgs); //debug // Start FFplay System.Diagnostics.Process.Start( ffplay, //"/c " //always close cmd //FFmpeg.KeepWindow(mainwindow) ffplayArgs ); } // Batch Warning else { MessageBox.Show("Cannot Preview Batch.", "Notice", MessageBoxButton.OK, MessageBoxImage.Information); } }
// -------------------------------------------------------------------------------------------------------- /// <summary> /// FFmpeg Batch - Generate Args /// </summary> public static void FFmpegBatchGenerateArgs(MainWindow mainwindow) { if (mainwindow.tglBatch.IsChecked == true) { // Replace ( with ^( to avoid Windows 7 CMD Error //important! // This is only used in select areas //MainWindow.batchInputAuto = mainwindow.textBoxBrowse.Text.Replace(@"(", "^("); //MainWindow.batchInputAuto = MainWindow.batchInputAuto.Replace(@")", "^)"); // Log Console Message ///////// Log.WriteAction = () => { Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new Bold(new Run("Batch: ")) { Foreground = Log.ConsoleDefault }); Log.logParagraph.Inlines.Add(new Run(Convert.ToString(mainwindow.tglBatch.IsChecked)) { Foreground = Log.ConsoleDefault }); Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new Bold(new Run("Generating Batch Script...")) { Foreground = Log.ConsoleTitle }); Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new LineBreak()); Log.logParagraph.Inlines.Add(new Bold(new Run("Running Batch Convert...")) { Foreground = Log.ConsoleAction }); }; Log.LogActions.Add(Log.WriteAction); // ------------------------- // Batch Arguments Full // ------------------------- // Make List // List<string> FFmpegBatchArgsList = new List<string>() { "cd /d", "\"" + MainWindow.BatchInputDirectory(mainwindow) + "\"", "\r\n\r\n" + "&& for %f in", "(*" + MainWindow.batchExt + ")", "do (echo)", "\r\n\r\n" + Video.BatchVideoQualityAuto(mainwindow), "\r\n\r\n" + Audio.BatchAudioQualityAuto(mainwindow), "\r\n\r\n" + Audio.BatchAudioBitrateLimiter(mainwindow), "\r\n\r\n" + "&&", "\r\n\r\n" + MainWindow.FFmpegPath(), "\r\n\r\n" + Video.HWAcceleration(mainwindow), "-y", //%~f added in InputPath() FFmpeg.OnePassArgs(mainwindow), //disabled if 2-Pass FFmpeg.TwoPassArgs(mainwindow) //disabled if 1-Pass }; // Join List with Spaces // Remove: Empty, Null, Standalone LineBreak ffmpegArgsSort = string.Join(" ", FFmpegBatchArgsList .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.Equals(Environment.NewLine)) .Where(s => !s.Equals("\r\n\r\n")) .Where(s => !s.Equals("\r\n")) ); // Inline ffmpegArgs = MainWindow.RemoveLineBreaks( string.Join(" ", FFmpegBatchArgsList .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.Equals(Environment.NewLine)) .Where(s => !s.Equals("\r\n\r\n")) .Where(s => !s.Equals("\r\n")) ) ); //.Replace("\r\n", " ") // Replace Linebreaks with Spaces to avoid arguments touching //.Replace(Environment.NewLine, ""); } }
/// <summary> /// OnePassArgs /// </summary> // 1-Pass, CRF, & Auto public static String OnePassArgs(MainWindow mainwindow) { // ------------------------- // Single Pass // ------------------------- if ((string)mainwindow.cboPass.SelectedItem == "1 Pass" || (string)mainwindow.cboPass.SelectedItem == "CRF" || (string)mainwindow.cboPass.SelectedItem == "auto" || (string)mainwindow.cboFormat.SelectedItem == "ogv" //ogv (special rule) ) { // ------------------------- // Arguments List // ------------------------- List<string> FFmpegArgsSinglePassList = new List<string>() { "\r\n\r\n" + "-i "+ "\"" + MainWindow.InputPath(mainwindow) + "\"", "\r\n\r\n" + Video.Subtitles(mainwindow), "\r\n\r\n" + Video.VideoCodec(mainwindow), "\r\n" + Video.Speed(mainwindow, "pass single"), Video.VideoQuality(mainwindow), "\r\n" + Video.FPS(mainwindow), "\r\n" + VideoFilters.VideoFilter(mainwindow), "\r\n" + Video.ScalingAlgorithm(mainwindow), "\r\n" + Video.Images(mainwindow), "\r\n" + Video.Optimize(mainwindow), "\r\n" + Streams.VideoStreamMaps(mainwindow), "\r\n\r\n" + Video.SubtitleCodec(mainwindow), "\r\n" + Streams.SubtitleMaps(mainwindow), "\r\n\r\n" + Audio.AudioCodec(mainwindow), "\r\n" + Audio.AudioQuality(mainwindow), Audio.SampleRate(mainwindow), Audio.BitDepth(mainwindow), Audio.Channel(mainwindow), "\r\n" + AudioFilters.AudioFilter(mainwindow), "\r\n" + Streams.AudioStreamMaps(mainwindow), "\r\n\r\n" + Format.Cut(mainwindow), "\r\n\r\n" + Streams.FormatMaps(mainwindow), "\r\n\r\n" + Format.ForceFormat(mainwindow), "\r\n\r\n" + MainWindow.ThreadDetect(mainwindow), "\r\n\r\n" + "\"" + MainWindow.OutputPath(mainwindow) + "\"" }; // Join List with Spaces // Remove: Empty, Null, Standalone LineBreak Video.passSingle = string.Join(" ", FFmpegArgsSinglePassList .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.Equals(Environment.NewLine)) .Where(s => !s.Equals("\r\n\r\n")) .Where(s => !s.Equals("\r\n")) ); } // Return Value return Video.passSingle; }
/// <summary> /// Batch 2Pass Args /// </summary> public static String TwoPassArgs(MainWindow mainwindow) { // ------------------------- // 2-Pass Auto Quality // ------------------------- // Enabled // if ((string)mainwindow.cboPass.SelectedItem == "2 Pass" && (string)mainwindow.cboMediaType.SelectedItem == "Video" // video only && (string)mainwindow.cboVideoCodec.SelectedItem != "Copy" // exclude copy && (string)mainwindow.cboFormat.SelectedItem != "ogv" // exclude ogv (special rule) ) { // ------------------------- // Pass 1 // ------------------------- List<string> FFmpegArgsPass1List = new List<string>() { "\r\n\r\n" + "-i "+ "\"" + MainWindow.InputPath(mainwindow) + "\"", //"\r\n\r\n" + //Video.Subtitles(mainwindow), "\r\n\r\n" + Video.VideoCodec(mainwindow), "\r\n" + Video.Speed(mainwindow, "pass 1"), Video.VideoQuality(mainwindow), "\r\n" + Video.FPS(mainwindow), "\r\n" + VideoFilters.VideoFilter(mainwindow), "\r\n" + Video.ScalingAlgorithm(mainwindow), "\r\n" + Video.Images(mainwindow), "\r\n" + Video.Optimize(mainwindow), "\r\n" + Video.Pass1Modifier(mainwindow), // -pass 1, -x265-params pass=2 "\r\n\r\n" + "-sn -an", // Disable Audio & Subtitles for Pass 1 to speed up encoding "\r\n\r\n" + Format.Cut(mainwindow), "\r\n\r\n" + Format.ForceFormat(mainwindow), "\r\n\r\n" + MainWindow.ThreadDetect(mainwindow), //"\r\n\r\n" + "\"" + MainWindow.OutputPath(mainwindow) + "\"" "\r\n\r\n" + "NUL" }; // Join List with Spaces // Remove: Empty, Null, Standalone LineBreak Video.pass1Args = string.Join(" ", FFmpegArgsPass1List .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.Equals(Environment.NewLine)) .Where(s => !s.Equals("\r\n\r\n")) .Where(s => !s.Equals("\r\n")) ); // ------------------------- // Pass 2 // ------------------------- List<string> FFmpegArgsPass2List = new List<string>() { // Video Methods have already defined Global Strings in Pass 1 // Use Strings instead of Methods // "\r\n\r\n" + "&&", "\r\n\r\n" + MainWindow.FFmpegPath(), "-y", "\r\n\r\n" + Video.HWAcceleration(mainwindow), "\r\n\r\n" + "-i " + "\"" + MainWindow.InputPath(mainwindow) + "\"", "\r\n\r\n" + Video.Subtitles(mainwindow), "\r\n\r\n" + Video.vCodec, "\r\n" + Video.Speed(mainwindow, "pass 2"), Video.vQuality, "\r\n" + Video.fps, "\r\n" + VideoFilters.vFilter, "\r\n" + Video.ScalingAlgorithm(mainwindow), "\r\n" + Video.image, "\r\n" + Video.optimize, "\r\n" + Streams.VideoStreamMaps(mainwindow), "\r\n" + Video.Pass2Modifier(mainwindow), // -pass 2, -x265-params pass=2 "\r\n\r\n" + Video.SubtitleCodec(mainwindow), "\r\n" + Streams.SubtitleMaps(mainwindow), "\r\n\r\n" + Audio.AudioCodec(mainwindow), "\r\n" + Audio.AudioQuality(mainwindow), Audio.SampleRate(mainwindow), Audio.BitDepth(mainwindow), Audio.Channel(mainwindow), "\r\n" + AudioFilters.AudioFilter(mainwindow), "\r\n" + Streams.AudioStreamMaps(mainwindow), "\r\n\r\n" + Format.trim, "\r\n\r\n" + Streams.FormatMaps(mainwindow), "\r\n\r\n" + Format.ForceFormat(mainwindow), "\r\n\r\n" + Configure.threads, "\r\n\r\n" + "\"" + MainWindow.OutputPath(mainwindow) + "\"" }; // Join List with Spaces // Remove: Empty, Null, Standalone LineBreak Video.pass2Args = string.Join(" ", FFmpegArgsPass2List .Where(s => !string.IsNullOrEmpty(s)) .Where(s => !s.Equals(Environment.NewLine)) .Where(s => !s.Equals("\r\n\r\n")) .Where(s => !s.Equals("\r\n")) ); // Combine Pass 1 & Pass 2 Args // Video.v2PassArgs = Video.pass1Args + " " + Video.pass2Args; } // Return Value return Video.v2PassArgs; }