/// <summary> /// Debug Test Button /// </summary> private void btnDebugTest_Click(object sender, RoutedEventArgs e) { // ------------------------- // Keep FFmpeg Window Toggle // ------------------------- //MainWindow.KeepWindow(mainwindow); // ------------------------- // Batch Extention Period Check // ------------------------- MainWindow.BatchExtCheck(mainwindow); // ------------------------- // Set FFprobe Path // ------------------------- MainWindow.FFprobePath(mainwindow); // ------------------------- // Ready Halts // ------------------------- MainWindow.ReadyHalts(mainwindow); // ------------------------- // Background Thread Worker // ------------------------- BackgroundWorker fileprocess = new BackgroundWorker(); fileprocess.WorkerSupportsCancellation = true; fileprocess.WorkerReportsProgress = true; fileprocess.DoWork += new DoWorkEventHandler(delegate(object o, DoWorkEventArgs args) { BackgroundWorker b = o as BackgroundWorker; // Cross-Thread Communication this.Dispatcher.Invoke(() => { // ------------------------- // Single // ------------------------- if (mainwindow.tglBatch.IsChecked == false) { // ------------------------- // FFprobe Detect Metadata // ------------------------- FFprobe.Metadata(mainwindow); // ------------------------- // FFmpeg Generate Arguments (Single) // ------------------------- //disabled if batch FFmpeg.FFmpegSingleGenerateArgs(mainwindow); } // ------------------------- // Batch // ------------------------- else if (mainwindow.tglBatch.IsChecked == true) { // ------------------------- // FFprobe Video Entry Type Containers // ------------------------- //FFprobe.VideoEntryTypeBatch(this); FFprobe.VideoEntryType(mainwindow); // ------------------------- // FFprobe Video Entry Type Containers // ------------------------- //FFprobe.AudioEntryTypeBatch(this); FFprobe.AudioEntryType(mainwindow); // ------------------------- // FFmpeg Generate Arguments (Batch) // ------------------------- //disabled if single file FFmpeg.FFmpegBatchGenerateArgs(mainwindow); } }); //end dispatcher }); //end thread // When background worker completes task fileprocess.RunWorkerCompleted += new RunWorkerCompletedEventHandler(delegate(object o, RunWorkerCompletedEventArgs args) { // ------------------------- // Write Variables to Debug Window // ------------------------- DebugWrite(this, mainwindow); // ------------------------- // Close the Background Worker // ------------------------- fileprocess.CancelAsync(); fileprocess.Dispose(); // ------------------------- // Clear Variables for next Run // ------------------------- MainWindow.ClearVariables(mainwindow); GC.Collect(); }); //end worker completed task // ------------------------- // Background Worker Run Async // ------------------------- fileprocess.RunWorkerAsync(); }
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); } }