private Process GetFfmpegProcess(string inputVideoFileName, string outputVideoFileName, string assaTempFileName, int?passNumber = null, string twoPassBitRate = null) { var pass = string.Empty; if (passNumber.HasValue) { pass = passNumber.Value.ToString(CultureInfo.InvariantCulture); } return(VideoPreviewGenerator.GenerateHardcodedVideoFile( Path.GetFileName(inputVideoFileName), assaTempFileName, outputVideoFileName, (int)numericUpDownWidth.Value, (int)numericUpDownHeight.Value, comboBoxVideoEncoding.Text, comboBoxPreset.Text, comboBoxCrf.Text, comboBoxAudioEnc.Text, checkBoxMakeStereo.Checked, comboBoxAudioSampleRate.Text.Replace("Hz", string.Empty).Trim(), comboBoxTune.Text, comboBoxAudioBitRate.Text, pass, twoPassBitRate, OutputHandler)); }
private void buttonOK_Click(object sender, EventArgs e) { buttonOK.Enabled = false; using (var saveDialog = new SaveFileDialog { FileName = string.Empty, Filter = "MP4|*.mp4|Matroska|*.mkv|WebM|*.webm" }) { if (saveDialog.ShowDialog(this) != DialogResult.OK) { return; } VideoFileName = saveDialog.FileName; } if (File.Exists(VideoFileName)) { File.Delete(VideoFileName); } if (numericUpDownFontSize.Visible) { var fontSize = (int)numericUpDownFontSize.Value; var style = AdvancedSubStationAlpha.GetSsaStyle("Default", _assaSubtitle.Header); style.FontSize = fontSize; var styleLine = style.ToRawAss(); _assaSubtitle.Header = AdvancedSubStationAlpha.AddTagToHeader("Style", styleLine, "[V4+ Styles]", _assaSubtitle.Header); } if (Configuration.Settings.General.RightToLeftMode && LanguageAutoDetect.CouldBeRightToLeftLanguage(_assaSubtitle)) { for (var index = 0; index < _assaSubtitle.Paragraphs.Count; index++) { var paragraph = _assaSubtitle.Paragraphs[index]; if (LanguageAutoDetect.ContainsRightToLeftLetter(paragraph.Text)) { paragraph.Text = Utilities.FixRtlViaUnicodeChars(paragraph.Text); } } } SubtitleFormat format = new AdvancedSubStationAlpha(); var assaTempFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".ass"); File.WriteAllText(assaTempFileName, format.ToText(_assaSubtitle, null)); progressBar1.Style = ProgressBarStyle.Marquee; progressBar1.Visible = true; labelPleaseWait.Visible = true; var process = VideoPreviewGenerator.GenerateHardcodedVideoFile( _inputVideoFileName, assaTempFileName, VideoFileName); process.Start(); while (!process.HasExited) { System.Threading.Thread.Sleep(100); Application.DoEvents(); if (_abort) { process.Kill(); } } progressBar1.Visible = false; labelPleaseWait.Visible = false; try { File.Delete(assaTempFileName); } catch { // ignore } DialogResult = _abort ? DialogResult.Cancel : DialogResult.OK; }