Exemple #1
0
        /// <summary>
        ///     Audio Quality - Auto
        /// <summary>
        public static void QualityAuto(string input_Text,
                                       bool batch_IsChecked,
                                       string mediaType_SelectedItem,
                                       string stream_SelectedItem,
                                       string codec_SelectedItem,
                                       List <ViewModel.AudioQuality> quality_Items,
                                       string quality_SelectedItem,
                                       bool vbr_IsChecked
                                       )
        {
            // No Detectable BitRate Default
            aBitRateNA = quality_Items.FirstOrDefault(item => item.Name == quality_SelectedItem)?.NA;

            // --------------------------------------------------
            // Single
            // --------------------------------------------------
            if (batch_IsChecked == false)
            {
                // -------------------------
                // Input Has Audio
                // -------------------------
                if (!string.IsNullOrEmpty(FFprobe.inputAudioBitRate))
                {
                    //MessageBox.Show(FFprobe.inputAudioBitRate); //debug

                    // Input BitRate was detected
                    if (FFprobe.inputAudioBitRate != "N/A")
                    {
                        // CBR
                        if (vbr_IsChecked == false)
                        {
                            // aBitMode = "-b:a";
                            aBitRate = AudioBitRateCalculator(codec_SelectedItem,
                                                              FFprobe.aEntryType,

                                                                                   //FFprobe.inputAudioBitRate

                                                                                   // Limit FFprobe Input Audio BitRate if higher than Codec's maximum bit rate
                                                              AudioBitRateLimiter( //mediaType_SelectedItem,
                                                                                   //stream_SelectedItem,
                                                                  codec_SelectedItem,
                                                                  quality_SelectedItem,
                                                                  Convert.ToInt32(FFprobe.inputAudioBitRate)
                                                                  )
                                                              .ToString()
                                                              );
                        }

                        // VBR
                        else if (vbr_IsChecked == true)
                        {
                            //VBR does not have 'k'
                            // aBitMode = "-q:a";
                            aBitRate = AudioVBRCalculator(vbr_IsChecked,
                                                          codec_SelectedItem,
                                                          quality_Items,
                                                          quality_SelectedItem,
                                                          FFprobe.inputAudioBitRate // VBR Birate Limiter is handled in VBR Calculator
                                                          );
                        }
                    }

                    // -------------------------
                    // Input Does Not Have Audio Codec
                    // -------------------------
                    if (!string.IsNullOrEmpty(FFprobe.inputAudioCodec))
                    {
                        // Default to a new bitrate if Input & Output formats Do Not match
                        if (FFprobe.inputAudioBitRate == "N/A" &&
                            !string.Equals(MainWindow.inputExt, MainWindow.outputExt, StringComparison.CurrentCultureIgnoreCase))
                        {
                            // Default to NA value
                            if (!string.IsNullOrEmpty(aBitRateNA))
                            {
                                //aBitRate = aBitRateNA;

                                // CBR
                                if (vbr_IsChecked == false)
                                {
                                    aBitRate = AudioBitRateCalculator(codec_SelectedItem,
                                                                      FFprobe.aEntryType,
                                                                      aBitRateNA
                                                                      );
                                }

                                // VBR
                                else if (vbr_IsChecked == true)
                                {
                                    //VBR does not have 'k'
                                    aBitRate = AudioVBRCalculator(vbr_IsChecked,
                                                                  codec_SelectedItem,
                                                                  quality_Items,
                                                                  quality_SelectedItem,
                                                                  aBitRateNA
                                                                  );
                                }
                            }
                            // Default to 320k if NA value is empty
                            else
                            {
                                aBitRate = "320";
                            }
                        }
                    }
                }

                // -------------------------
                // Input No Audio
                // -------------------------
                else if (string.IsNullOrEmpty(FFprobe.inputAudioBitRate))
                {
                    aBitMode = string.Empty;
                    aBitRate = string.Empty;
                }

                // -------------------------
                // Input TextBox is Empty - Auto Value
                // -------------------------
                if (string.IsNullOrEmpty(input_Text))
                {
                    aBitMode = "-b:a";
                    //aBitRate = "320";
                    aBitRate = quality_Items.FirstOrDefault(item => item.Name == "Auto")?.NA;
                }

                // -------------------------
                // BitRate is 0 (Happens with NA)
                // -------------------------
                if (aBitRate == "0" &&
                    vbr_IsChecked == false) // Ignore VBR, Some Codecs use VBR 0
                {
                    aBitMode = string.Empty;
                    aBitRate = string.Empty;
                }

                // -------------------------
                // YouTube Download
                // -------------------------
                // Can't detect bitrate from URL
                if (MainWindow.IsWebURL(input_Text) == true)
                {
                    aBitMode = "-b:a";
                    aBitRate = "320";
                }

                // -------------------------
                // BitRate Returned Empty, Disable BitMode
                // -------------------------
                if (string.IsNullOrEmpty(aBitRate))
                {
                    aBitMode = string.Empty;
                }
            }

            // --------------------------------------------------
            // Batch
            // --------------------------------------------------
            else if (batch_IsChecked == true)
            {
                // Use the CMD Batch Audio Variable
                aBitRate = "%A";

                //MessageBox.Show(aBitRate); //debug
            }
        }