Ejemplo n.º 1
0
        public void Convert()
        {
            var ffMpeg = new FFMpegConverter();

            comboBox1.InvokeIfRequired(GetComboBoxItem);
            ConvertSettings setting = new ConvertSettings();
            //string sTargetType = (string)comboBox1.SelectedItem;
            string    sTargetType = Combox1SelectItem;
            FieldInfo Info        = VideoTypes.Where(x => x.Name == sTargetType).Select(y => y).FirstOrDefault();

            setting.AudioSampleRate = 44100;
            label4.InvokeIfRequired(() =>
            {
                label4.ForeColor = Color.Red;
                label4.Text      = "轉檔中 請稍後";
            });
            try
            {
                ffMpeg.ConvertMedia(sSourceFile, null, sTargetFile + "." + Info.Name, Info.GetValue(null).ToString(), setting);
            }
            catch (Exception)
            {
                MessageBox.Show("轉檔失敗");
            }


            Console.WriteLine("Finish");

            //lambda非同步UI更新
            btnConvert.InvokeIfRequired(() =>
            {
                btnConvert.Enabled = true;
            });
            TargetFile.InvokeIfRequired(() =>
            {
                TargetFile.Enabled = false;
            });

            label4.InvokeIfRequired(() =>
            {
                label4.Text = "轉檔完畢,可以繼續進行下個轉換";
            });
        }