private void batchConvert() { if (!File.Exists(Directory.GetCurrentDirectory() + @"\ffmpeg.exe")) { MissingFFmpeg dlffmpeg = new MissingFFmpeg(); dlffmpeg.ShowDialog(); } if (_conversionFiles.Any()) { //get our file location from the queue var file = _conversionFiles.Dequeue(); //get the new filename string FileName = file.Substring(file.LastIndexOf("\\") + 1, (file.Length - file.LastIndexOf("\\") - 1)); string fileExt = FileName.Substring(FileName.IndexOf('.'), 4); //convert in queue Process proc = new Process(); ProcessStartInfo PSI = new ProcessStartInfo(); PSI.FileName = Directory.GetCurrentDirectory() + @"\ffmpeg.exe"; PSI.Arguments = "-i \"" + file + "\" -vcodec copy -acodec copy \"" + textBox4.Text + "\\" + FileName.Replace(fileExt, ".mp4"); proc.StartInfo = PSI; proc.Start(); proc.WaitForExit(); if (proc.HasExited) { //add number completed++; progressBar1.Value = completed; //redo batchConvert(); } } //download complete! completed = total; }
private void button1_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(textBox1.Text) || String.IsNullOrEmpty(textBox2.Text)) { MessageBox.Show("You forgot to fill out one of the fields!"); return; } if (radioButton1.Checked == true) { if (!textBox1.Text.Contains(".mkv")) { MessageBox.Show("That input file is not an MKV file!"); return; } if (!textBox2.Text.Contains(".mp4")) { MessageBox.Show("That output extension is incorrect! Please save the file as an MP4 Container!"); return; } } else if (radioButton2.Checked == true) { if (!textBox1.Text.Contains(".mp4")) { MessageBox.Show("That input file is not an MP4 file!"); return; } if (!textBox2.Text.Contains(".mkv")) { MessageBox.Show("That output extension is incorrect! Please save the file as an MKV Container!"); return; } } if (!File.Exists(Directory.GetCurrentDirectory() + @"\ffmpeg.exe")) { MissingFFmpeg dlffmpeg = new MissingFFmpeg(); dlffmpeg.ShowDialog(); } MessageBox.Show("Preparing to convert.... Do not close any Command windows that may pop up or conversion will fail!..."); button2.Enabled = true; button1.Enabled = false; button3.Enabled = false; button4.Enabled = false; textBox1.Enabled = true; textBox2.Enabled = true; if (radioButton1.Checked == true) { convertToMp4(textBox1.Text, textBox2.Text); } else if (radioButton2.Checked == true) { convertToMkv(textBox1.Text, textBox2.Text); } button2.Enabled = false; button1.Enabled = true; button3.Enabled = true; button4.Enabled = true; textBox1.Enabled = true; textBox2.Enabled = true; }