public static string ExtractMp3(string input, string output, BitrateMp3 br = BitrateMp3.Standard, SamplingRate sr = SamplingRate.AudioCD) {
			if(string.IsNullOrWhiteSpace(input))
				throw new ArgumentNullException("input");
			if(string.IsNullOrWhiteSpace(output))
				throw new ArgumentNullException("output");
			
			return new CommandLineBuilder()
				.AddEntry(input)
				.VideoCodec(VideoEncoding.NOVIDEO)
				.AudioCodec(AudioEncoding.MP3)
				.Param(Parameter.A_BITRATE, ((int)br).ToString())
				.Param(Parameter.A_SAMPLE, ((int)sr).ToString())
				.Param(Parameter.MISC_OVERWRITE_YES)
				.Output(output);
		}
Esempio n. 2
0
        public static string ExtractMp3(string input, string output, BitrateMp3 br = BitrateMp3.Standard, SamplingRate sr = SamplingRate.AudioCD)
        {
            if (string.IsNullOrWhiteSpace(input))
            {
                throw new ArgumentNullException("input");
            }
            if (string.IsNullOrWhiteSpace(output))
            {
                throw new ArgumentNullException("output");
            }

            return(new CommandLineBuilder()
                   .AddEntry(input)
                   .VideoCodec(VideoEncoding.NOVIDEO)
                   .AudioCodec(AudioEncoding.MP3)
                   .Param(Parameter.A_BITRATE, ((int)br).ToString())
                   .Param(Parameter.A_SAMPLE, ((int)sr).ToString())
                   .Param(Parameter.MISC_OVERWRITE_YES)
                   .Output(output));
        }
Esempio n. 3
0
        private void Validate(object sender, EventArgs e)
        {
            int tmp;

            if (gbVideo.Enabled)
            {
                // Vérification CRF
                if (tbCRF.Text.Length != 0)
                {
                    if (!int.TryParse(tbCRF.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        return;
                    }
                    if (tmp < Common.CRF_MIN || tmp > Common.CRF_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_CRF, tbCRF.Text);
                }

                // Vérification Qscale
                if (tbQscale.Text.Length != 0)
                {
                    if (!int.TryParse(tbQscale.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        return;
                    }
                    if (tmp < Common.QSCALE_MIN || tmp > Common.QSCALE_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QSCALE, tbQscale.Text);
                }

                // Vérification Qmin
                int qmin = 4;
                if (tbQmin.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmin.Text, out qmin))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        return;
                    }
                    if (qmin < Common.QMIN_MIN || qmin > Common.QMIN_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QMIN, tbQmin.Text);
                }

                // Vérification Qmax
                if (tbQmax.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmax.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        return;
                    }
                    if (tmp < qmin || tmp > Common.QMAX_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        return;
                    }
                    _builder.Param(Parameter.V_QMAX, tbQmax.Text);
                }

                // Vérification Bitrate
                if (tbBV.Text.Length != 0)
                {
                    bool unit = tbBV.Text.EndsWith("k", StringComparison.CurrentCultureIgnoreCase) || tbBV.Text.EndsWith("m", StringComparison.CurrentCultureIgnoreCase);
                    if (!int.TryParse(unit ? tbBV.Text.Substring(0, tbBV.Text.Length - 1) : tbBV.Text, out tmp))
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        return;
                    }
                    if (tmp <= 0)
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        return;
                    }
                    _builder.Param(Parameter.V_BITRATE, tbBV.Text);
                }

                _builder.VideoCodec((VideoEncoding)cbCV.SelectedValue);
            }

            if (gbAudio.Enabled)
            {
                _builder.AudioCodec((AudioEncoding)cbCA.SelectedValue);
                BitrateMp3 br = (BitrateMp3)Enum.Parse(typeof(BitrateMp3), cbBA.SelectedValue.ToString());
                if (br != BitrateMp3.Defaut)
                {
                    _builder.Param(Parameter.A_BITRATE, ((int)br).ToString());
                }
                SamplingRate sr = (SamplingRate)Enum.Parse(typeof(SamplingRate), cbSR.SelectedValue.ToString());
                if (sr != SamplingRate.Defaut)
                {
                    _builder.Param(Parameter.A_SAMPLE, ((int)sr).ToString());
                }
            }

            _builder.Param(Parameter.NONE, cbFormat.SelectedValue.ToString());

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 4
0
        private void Validate(object sender, EventArgs e)
        {
            if (_media == null)
            {
                MessageBox.Show("Aucun fichier valable en entrée.");
                return;
            }

            if (tbOut.Text.Length == 0)
            {
                MessageBox.Show("Choisissez un fichier de sortie.");
                return;
            }

            if (tbFile.Text.Equals(tbOut.Text))
            {
                MessageBox.Show(I18n.Get("ErrorSameInputOutput"));
                return;
            }

            _builder = new CommandLineBuilder();
            _builder.AddEntry(tbFile.Text);

            int tmp;

            if (gbVideo.Enabled)
            {
                // Vérification CRF
                if (tbCRF.Text.Length != 0)
                {
                    if (!int.TryParse(tbCRF.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < Common.CRF_MIN || tmp > Common.CRF_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatCrf"), Common.CRF_MIN, Common.CRF_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_CRF, tbCRF.Text);
                }

                // Vérification Qscale
                if (tbQscale.Text.Length != 0)
                {
                    if (!int.TryParse(tbQscale.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < Common.QSCALE_MIN || tmp > Common.QSCALE_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQscale"), Common.QSCALE_MIN, Common.QSCALE_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QSCALE, tbQscale.Text);
                }

                // Vérification Qmin
                int qmin = 4;
                if (tbQmin.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmin.Text, out qmin))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        _builder = null;
                        return;
                    }
                    if (qmin < Common.QMIN_MIN || qmin > Common.QMIN_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmin"), Common.QMIN_MIN, Common.QMIN_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QMIN, tbQmin.Text);
                }

                // Vérification Qmax
                if (tbQmax.Text.Length != 0)
                {
                    if (!int.TryParse(tbQmax.Text, out tmp))
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        _builder = null;
                        return;
                    }
                    if (tmp < qmin || tmp > Common.QMAX_MAX)
                    {
                        MessageBox.Show(string.Format(I18n.Get("FormatQmax"), qmin, Common.QMAX_MAX));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_QMAX, tbQmax.Text);
                }

                // Vérification Bitrate
                if (tbBV.Text.Length != 0)
                {
                    bool unit = tbBV.Text.EndsWith("k", StringComparison.CurrentCultureIgnoreCase) || tbBV.Text.EndsWith("m", StringComparison.CurrentCultureIgnoreCase);
                    if (!int.TryParse(unit ? tbBV.Text.Substring(0, tbBV.Text.Length - 1) : tbBV.Text, out tmp))
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        _builder = null;
                        return;
                    }
                    if (tmp <= 0)
                    {
                        MessageBox.Show(I18n.Get("FormatBitrate"));
                        _builder = null;
                        return;
                    }
                    _builder.Param(Parameter.V_BITRATE, tbBV.Text);
                }

                _builder.VideoCodec((VideoEncoding)cbCV.SelectedValue);
            }
            else
            {
                _builder.VideoCodec(VideoEncoding.NOVIDEO);
            }

            if (gbAudio.Enabled)
            {
                _builder.AudioCodec((AudioEncoding)cbCA.SelectedValue);
                BitrateMp3 br = (BitrateMp3)Enum.Parse(typeof(BitrateMp3), cbBA.SelectedValue.ToString());
                if (br != BitrateMp3.Defaut)
                {
                    _builder.Param(Parameter.A_BITRATE, ((int)br).ToString());
                }
                SamplingRate sr = (SamplingRate)Enum.Parse(typeof(SamplingRate), cbSR.SelectedValue.ToString());
                if (sr != SamplingRate.Defaut)
                {
                    _builder.Param(Parameter.A_SAMPLE, ((int)sr).ToString());
                }
            }
            else
            {
                _builder.AudioCodec(AudioEncoding.NOAUDIO);
            }

            _builder.Param(Parameter.NONE, cbFormat.SelectedValue.ToString()).Param(Parameter.MISC_OVERWRITE_YES);

            this.DialogResult = DialogResult.OK;
        }
Esempio n. 5
0
 public static string Value(this BitrateMp3 value)
 {
     return(((int)value).ToString());
 }