Beispiel #1
0
        // --------------------------------------------------------------------------------------------------------


        /// <summary>
        /// FFmpeg Single File - Generate Args
        /// </summary>
        public static String FFmpegSingleGenerateArgs(MainWindow mainwindow)
        {
            if (mainwindow.tglBatch.IsChecked == false)
            {
                // Make Arugments List
                List<string> FFmpegArgsList = new List<string>()
                {
                    //MainWindow.YouTubeDownload(MainWindow.InputPath(mainwindow)),
                    MainWindow.FFmpegPath(),
                    "-y",
                    "\r\n\r\n" + Video.HWAcceleration(mainwindow),
                    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(" ", FFmpegArgsList
                                                  .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(" ", FFmpegArgsList
                                                             .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", "") //Remove Linebreaks
                                   //.Replace(Environment.NewLine, "")
            }


            // Log Console Message /////////
            Log.WriteAction = () =>
            {
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new Bold(new Run("FFmpeg Arguments")) { Foreground = Log.ConsoleTitle });
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new Run(ffmpegArgs) { Foreground = Log.ConsoleDefault });
            };
            Log.LogActions.Add(Log.WriteAction);


            // Return Value
            return ffmpegArgs;
        }
Beispiel #2
0
        /// <summary>
        /// FFprobe Detect Metadata (Method)
        /// </summary>
        public static void Metadata()
        {
            // --------------------------------------------------------------------
            // Section: FFprobe
            // --------------------------------------------------------------------

            // 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("FFprobe"))
                {
                    Foreground = Log.ConsoleTitle
                });
            };
            Log.LogActions.Add(Log.WriteAction);


            // Only Run FFprobe if Input File is Not Null
            // Strange FFprobe Class problem - methods halting after InputFileInfo()
            // unless Null Check is put here instead of inside the Class.
            if (!string.IsNullOrEmpty(VM.MainView.Input_Text) &&
                !string.IsNullOrEmpty(ffprobe))
            {
                // -------------------------
                //    FFprobe Video Entry Type Containers
                // -------------------------
                VideoEntryType();

                // -------------------------
                //    FFprobe Audio Entry Type Containers
                // -------------------------
                AudioEntryType();

                // -------------------------
                //    FFprobe File Info
                // -------------------------
                argsFrameRate    = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams v:0 -show_entries stream=r_frame_rate -v quiet -of csv=\"p=0\"";
                argsSize         = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams v:0 -show_entries format=scale -v quiet -of csv=\"p=0\"";
                argsDuration     = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams v:0 -show_entries format=duration -v quiet -of csv=\"p=0\"";
                argsVideoCodec   = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams v:0 -show_entries stream=codec_name -v quiet -of csv=\"p=0\"";
                argsVideoBitRate = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams v:0 -show_entries " + vEntryType + " -v quiet -of csv=\"p=0\"";
                argsAudioCodec   = " -i " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams a:0 -show_entries stream=codec_name -v quiet -of csv=\"p=0\"";
                argsAudioBitRate = " -i" + " " + "\"" + VM.MainView.Input_Text + "\"" + " -select_streams a:0 -show_entries " + aEntryType + " -v quiet -of csv=\"p=0\"";

                inputFrameRate    = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsFrameRate));
                inputSize         = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsSize));
                inputDuration     = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsDuration));
                inputVideoCodec   = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsVideoCodec));
                inputVideoBitRate = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsVideoBitRate));
                inputAudioCodec   = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsAudioCodec));
                inputAudioBitRate = MainWindow.RemoveLineBreaks(InputFileInfo(VM.MainView.Input_Text, VM.MainView.Batch_IsChecked, argsAudioBitRate));

                // Log won't write the input data unless we pass it to a new string
                string logInputFrameRate    = inputFrameRate;
                string logInputSize         = inputSize;
                string logInputDuration     = inputDuration;
                string logInputVideoCodec   = inputVideoCodec;
                string logInputVideoBitRate = inputVideoBitRate;
                string logInputAudioCodec   = inputAudioCodec;
                string logInputAudioBitRate = inputAudioBitRate;

                // --------------------------------------------------------------------
                // Section: Input
                // --------------------------------------------------------------------
                Log.WriteAction = () =>
                {
                    // Log Console Message /////////
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Input File Details"))
                    {
                        Foreground = Log.ConsoleTitle
                    });

                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Directory: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(MainWindow.inputDir)
                    {
                        Foreground = Log.ConsoleDefault
                    });

                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("General"))
                    {
                        Foreground = Log.ConsoleAction
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());

                    Log.logParagraph.Inlines.Add(new Bold(new Run("Container: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    // Single File
                    if (!string.IsNullOrEmpty(MainWindow.inputExt))
                    {
                        Log.logParagraph.Inlines.Add(new Run(MainWindow.inputExt)
                        {
                            Foreground = Log.ConsoleDefault
                        });
                    }
                    // Batch
                    //if (!string.IsNullOrEmpty(MainWindow.inputExt) &&
                    //    MainWindow.inputExt != "extension")
                    //{
                    //    Log.logParagraph.Inlines.Add(new Run(MainWindow.inputExt) { Foreground = Log.ConsoleDefault });
                    //}

                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Size: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputSize)
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Duration: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputDuration)
                    {
                        Foreground = Log.ConsoleDefault
                    });

                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Video"))
                    {
                        Foreground = Log.ConsoleAction
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Codec: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputVideoCodec)
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("BitRate: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputVideoBitRate)
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("FPS: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputFrameRate)
                    {
                        Foreground = Log.ConsoleDefault
                    });

                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Audio"))
                    {
                        Foreground = Log.ConsoleAction
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("Codec: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(logInputAudioCodec)
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new LineBreak());
                    Log.logParagraph.Inlines.Add(new Bold(new Run("BitRate: "))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                    Log.logParagraph.Inlines.Add(new Run(Convert.ToString(logInputAudioBitRate))
                    {
                        Foreground = Log.ConsoleDefault
                    });
                };
                Log.LogActions.Add(Log.WriteAction);
            }
            else
            {
                // 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("Input File Not Found"))
                    {
                        Foreground = Log.ConsoleWarning
                    });
                };
                Log.LogActions.Add(Log.WriteAction);
            }


            // --------------------------------------------------------------------
            // Section: Output
            // --------------------------------------------------------------------
            // Log Console Message /////////
            Log.WriteAction = () =>
            {
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new Bold(new Run("Output File Settings"))
                {
                    Foreground = Log.ConsoleTitle
                });
            };
            Log.LogActions.Add(Log.WriteAction);

            // 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("Directory: "))
                {
                    Foreground = Log.ConsoleDefault
                });
                Log.logParagraph.Inlines.Add(new Run(MainWindow.outputDir)
                {
                    Foreground = Log.ConsoleDefault
                });
            };
            Log.LogActions.Add(Log.WriteAction);

            // --------------------------------------------------
            // Category: General
            // --------------------------------------------------
            // 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("General"))
                {
                    Foreground = Log.ConsoleAction
                });
            };
            Log.LogActions.Add(Log.WriteAction);


            // -------------------------
            //    Format
            // -------------------------
            // OutputFormat() is not called because it is instead used in Controls
            // Use a Message for Log Console

            // Log Console Message /////////
            Log.WriteAction = () =>
            {
                Log.logParagraph.Inlines.Add(new LineBreak());
                Log.logParagraph.Inlines.Add(new Bold(new Run("Format: "))
                {
                    Foreground = Log.ConsoleDefault
                });
                Log.logParagraph.Inlines.Add(new Run(MainWindow.outputExt)
                {
                    Foreground = Log.ConsoleDefault
                });
            };
            Log.LogActions.Add(Log.WriteAction);
        }
Beispiel #3
0
        // --------------------------------------------------------------------------------------------------------


        /// <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, "");
            }
        }