2 using System.Collections.Generic;
\r
3 using System.Collections.Specialized;
\r
4 using System.ComponentModel;
\r
6 using System.Drawing;
\r
8 using System.Windows.Forms;
\r
11 using System.Diagnostics;
\r
12 using System.Threading;
\r
13 using System.Runtime.InteropServices;
\r
14 using System.Globalization;
\r
15 using System.Text.RegularExpressions;
\r
20 public partial class frmMain : Form
\r
22 // --------------------------------------------------------------
\r
23 // Applicaiton Startup Stuff
\r
24 // --------------------------------------------------------------
\r
26 #region Application Startup
\r
28 // Some stuff that needs to be Initialized.
\r
29 private Process hbProc;
\r
30 private Parsing.DVD thisDVD;
\r
31 private frmQueue queueWindow = new frmQueue();
\r
33 // The main window beings here...
\r
36 // Load the splash screen in this thread
\r
37 Form splash = new frmSplashScreen();
\r
40 //Create a label that can be updated from the parent thread.
\r
41 Label lblStatus = new Label();
\r
44 lblStatus.Size = new Size(250, 20);
\r
46 //Position the label
\r
47 lblStatus.Location = new Point(10, 280);
\r
49 //Put the label on the splash form
\r
50 splash.Controls.Add(lblStatus);
\r
52 //Fire a thread to wait for 2 seconds. The splash screen will exit when the time expires
\r
53 Thread timer = new Thread(splashTimer);
\r
56 InitializeComponent();
\r
58 // show the form, but leave disabled until preloading is complete
\r
59 this.Enabled = false;
\r
61 // Show the main form
\r
64 // Forces frmMain to draw
\r
65 Application.DoEvents();
\r
67 // Set the Version number lable to the corect version.
\r
68 Version.Text = "Version " + Properties.Settings.Default.CliVersion;
\r
70 // update the status
\r
71 lblStatus.Text = "Checking for updates ...";
\r
72 // redraw the splash screen
\r
73 Application.DoEvents();
\r
74 // Run the update checker.
\r
78 // Update the presets
\r
79 lblStatus.Text = "Updaing Presets ...";
\r
80 Application.DoEvents();
\r
84 // Now load the users default if required. (Will overide the above setting)
\r
85 lblStatus.Text = "Loading User Default Settings...";
\r
86 Application.DoEvents();
\r
91 // Enable or disable tooltips
\r
92 lblStatus.Text = "Loading Tooltips ...";
\r
93 Application.DoEvents();
\r
97 // Hide the preset bar if required.
\r
101 lblStatus.Text = "Loading Complete!";
\r
102 Application.DoEvents();
\r
105 // Wait until splash screen is done
\r
106 while (timer.IsAlive)
\r
107 { Thread.Sleep(100); }
\r
109 //Close the splash screen
\r
113 // Turn the interface back to the user
\r
114 this.Enabled = true;
\r
117 private void splashTimer(object sender)
\r
119 Thread.Sleep(2000); //sit for 2 seconds then exit
\r
122 private void showSplash(object sender)
\r
124 // Display splash screen for 1.5 Seconds
\r
125 Form splash = new frmSplashScreen();
\r
127 Thread.Sleep(1500);
\r
128 splash.Close(); // Then close.
\r
131 private void loadNormalPreset()
\r
133 ListViewItem item = listview_presets.FindItemWithText("Normal");
\r
137 listview_presets.SelectedItems.Clear();
\r
138 item.Selected = true;
\r
142 private void loadUserDefaults()
\r
146 // Load the users default settings or if the user has not got this option enabled, load the normal preset.
\r
147 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
150 text_source.Text = Properties.Settings.Default.DVDSource;
\r
151 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
152 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
153 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
156 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
157 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
158 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
159 text_width.Text = Properties.Settings.Default.Width;
\r
160 text_height.Text = Properties.Settings.Default.Height;
\r
162 // Picture Settings Tab
\r
163 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
164 text_top.Text = Properties.Settings.Default.CropTop;
\r
165 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
166 text_left.Text = Properties.Settings.Default.CropLeft;
\r
167 text_right.Text = Properties.Settings.Default.CropRight;
\r
168 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
170 // Video Settings Tab
\r
171 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
172 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
173 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
175 if (Properties.Settings.Default.TwoPass == "Checked")
\r
177 check_2PassEncode.CheckState = CheckState.Checked;
\r
180 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
181 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
183 if (Properties.Settings.Default.detelecine == "Checked")
\r
185 check_detelecine.CheckState = CheckState.Checked;
\r
188 if (Properties.Settings.Default.detelecine == "Checked")
\r
190 check_deblock.CheckState = CheckState.Checked;
\r
194 if (Properties.Settings.Default.Grayscale == "Checked")
\r
196 check_grayscale.CheckState = CheckState.Checked;
\r
199 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
201 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
203 CheckPixelRatio.CheckState = CheckState.Checked;
\r
205 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
207 check_turbo.CheckState = CheckState.Checked;
\r
209 if (Properties.Settings.Default.largeFile == "Checked")
\r
211 check_largeFile.CheckState = CheckState.Checked;
\r
214 if (Properties.Settings.Default.chapterMarker == "Checked")
\r
216 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
219 // Audio Settings Tab
\r
220 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
221 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
222 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
225 if (Properties.Settings.Default.CRF == "Checked")
\r
227 CheckCRF.CheckState = CheckState.Checked;
\r
229 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
231 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.selectedPreset + ")";
\r
236 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
240 private Boolean updateCheck()
\r
244 if (Properties.Settings.Default.updateStatus == "Checked")
\r
246 String updateFile = Properties.Settings.Default.updateFile;
\r
247 WebClient client = new WebClient();
\r
248 String data = client.DownloadString(updateFile);
\r
249 String[] versionData = data.Split('\n');
\r
251 int verdata = int.Parse(versionData[0].Replace(".", ""));
\r
252 int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));
\r
253 int verd1 = int.Parse(versionData[1].Replace(".", ""));
\r
254 int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));
\r
256 Boolean update = ((verdata > vergui) || (verd1 > cliversion));
\r
258 lbl_update.Visible = update;
\r
269 // Silently ignore the error
\r
274 private void tooltip()
\r
276 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
278 ToolTip.Active = true;
\r
282 private void hidePresetBar()
\r
284 if (Properties.Settings.Default.hidePresets == "Checked")
\r
286 btn_presets.Visible = true;
\r
294 // --------------------------------------------------------------
\r
295 // The main Menu bar.
\r
296 // --------------------------------------------------------------
\r
299 private void mnu_open_Click(object sender, EventArgs e)
\r
302 File_Open.ShowDialog();
\r
303 filename = File_Open.FileName;
\r
305 if (filename != "")
\r
309 // Some things that need to be done to reset some gui components:
\r
310 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
312 //---------------------------
\r
314 // ---------------------------
\r
316 // Create StreamReader & open file
\r
317 StreamReader line = new StreamReader(filename);
\r
319 // Send the query from the file to the Query Parser class
\r
320 Functions.QueryParser presetQuery = Functions.QueryParser.Parse(line.ReadLine());
\r
322 // Now load the preset
\r
323 presetLoader(presetQuery, filename);
\r
325 // Close the stream
\r
328 catch (Exception exc)
\r
330 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
331 MessageBox.Show(exc.ToString());
\r
336 private void mnu_save_Click(object sender, EventArgs e)
\r
339 File_Save.ShowDialog();
\r
340 filename = File_Save.FileName;
\r
341 if (filename != "")
\r
345 // Create a StreamWriter and open the file
\r
346 StreamWriter line = new StreamWriter(filename);
\r
348 // Generate and write the query string to the file
\r
349 String query = GenerateTheQuery();
\r
350 line.WriteLine(query);
\r
352 // close the stream
\r
354 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
358 MessageBox.Show("Unable to write to the file. Please make sure the location has the correct permissions for file writing.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
364 private void mnu_exit_Click(object sender, EventArgs e)
\r
366 Application.Exit();
\r
373 private void mnu_encode_Click(object sender, EventArgs e)
\r
378 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
380 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
381 dvdInfoWindow.Show();
\r
384 private void mnu_options_Click(object sender, EventArgs e)
\r
386 Form Options = new frmOptions();
\r
387 Options.ShowDialog();
\r
392 #region Presets Menu
\r
394 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
396 listview_presets.Items.Clear();
\r
398 MessageBox.Show("Presets have been updated", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
401 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
403 ListViewItem item = listview_presets.FindItemWithText("Normal");
\r
407 listview_presets.SelectedItems.Clear();
\r
408 item.Selected = true;
\r
411 if (presetStatus == false)
\r
414 presetStatus = true;
\r
415 btn_presets.Text = "Hide Presets";
\r
424 private void mnu_quickStart_Click(object sender, EventArgs e)
\r
426 Form QuickStart = new frmQuickStart();
\r
427 QuickStart.ShowDialog();
\r
430 private void mnu_wiki_Click(object sender, EventArgs e)
\r
432 Process.Start("http://handbrake.m0k.org/trac");
\r
435 private void mnu_faq_Click(object sender, EventArgs e)
\r
437 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
440 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
442 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
445 private void mnu_homepage_Click(object sender, EventArgs e)
\r
447 Process.Start("http://handbrake.m0k.org");
\r
450 private void mnu_forum_Click(object sender, EventArgs e)
\r
452 Process.Start("http://handbrake.m0k.org/forum");
\r
455 private void mnu_UpdateCheck_Click(object sender, EventArgs e)
\r
457 Boolean update = updateCheck();
\r
458 if (update == true)
\r
460 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
464 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
468 private void mnu_about_Click(object sender, EventArgs e)
\r
470 Form About = new frmAbout();
\r
471 About.ShowDialog();
\r
476 // --------------------------------------------------------------
\r
477 // Buttons on the main Window
\r
478 // --------------------------------------------------------------
\r
482 private void btn_Browse_Click(object sender, EventArgs e)
\r
484 String filename = "";
\r
485 text_source.Text = "";
\r
486 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
488 if (RadioDVD.Checked)
\r
490 DVD_Open.ShowDialog();
\r
491 filename = DVD_Open.SelectedPath;
\r
492 if (filename != "")
\r
494 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
495 text_source.Text = filename;
\r
496 frmRD.ShowDialog();
\r
501 ISO_Open.ShowDialog();
\r
502 filename = ISO_Open.FileName;
\r
503 if (filename != "")
\r
505 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
506 text_source.Text = filename;
\r
507 frmRD.ShowDialog();
\r
511 // Check if there was titles in the dvd title dropdown
\r
512 if (filename == "")
\r
514 text_source.Text = "Click 'Browse' to continue";
\r
517 // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.
\r
518 if (drp_dvdtitle.Items.Count == 0)
\r
520 MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source. Please refer to the FAQ (see Help Menu).", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
524 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
526 // This removes the file extension from the filename box on the save file dialog.
\r
527 // It's daft but some users don't realise that typing an extension overrides the dropdown extension selected.
\r
528 // Should be a nicer way to do this.
\r
529 DVD_Save.FileName = DVD_Save.FileName.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "").Replace(".ogm", "").Replace(".avi", "");
\r
531 // Show the dialog and set the main form file path
\r
532 DVD_Save.ShowDialog();
\r
533 text_destination.Text = DVD_Save.FileName;
\r
535 // Quicktime requires .m4v file for chapter markers to work. If checked, change the extension to .m4v (mp4 and m4v are the same thing)
\r
536 if (Check_ChapterMarkers.Checked)
\r
538 string destination = text_destination.Text;
\r
539 destination = destination.Replace(".mp4", ".m4v");
\r
540 text_destination.Text = destination;
\r
544 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
546 rtf_h264advanced.Text = "";
\r
549 private void GenerateQuery_Click(object sender, EventArgs e)
\r
551 String query = GenerateTheQuery();
\r
552 QueryEditorText.Text = query;
\r
555 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
557 QueryEditorText.Text = "";
\r
560 private void btn_queue_Click(object sender, EventArgs e)
\r
563 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
564 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
568 if (QueryEditorText.Text == "")
\r
570 query = GenerateTheQuery();
\r
574 query = QueryEditorText.Text;
\r
576 queueWindow.list_queue.Items.Add(query);
\r
577 queueWindow.Show();
\r
581 private void btn_copy_Click(object sender, EventArgs e)
\r
583 if (QueryEditorText.Text != "")
\r
584 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);
\r
587 private void showQueue()
\r
589 queueWindow.Show();
\r
594 // --------------------------------------------------------------
\r
595 // Main Window Preset System
\r
596 // --------------------------------------------------------------
\r
598 #region Preset System
\r
600 // Import Current Presets
\r
601 private void updatePresets()
\r
603 string[] presets = new string[17];
\r
604 presets[0] = "Animation";
\r
605 presets[1] = "AppleTV";
\r
606 presets[2] = "Bedlam";
\r
607 presets[3] = "Blind";
\r
608 presets[4] = "Broke";
\r
609 presets[5] = "Classic";
\r
610 presets[6] = "Constant Quality Rate";
\r
611 presets[7] = "Deux Six Quatre";
\r
612 presets[8] = "Film";
\r
613 presets[9] = "iPhone / iPod Touch";
\r
614 presets[10] = "iPod High-Rez";
\r
615 presets[11] = "iPod Low-Rez";
\r
616 presets[12] = "Normal";
\r
617 presets[13] = "PS3";
\r
618 presets[14] = "PSP";
\r
619 presets[15] = "QuickTime";
\r
620 presets[16] = "Television";
\r
622 ListViewItem preset_listview = new ListViewItem();
\r
623 string[] presetList = new string[1];
\r
625 foreach (string preset in presets)
\r
627 presetList[0] = preset;
\r
628 preset_listview = new ListViewItem(presetList);
\r
630 // Now Fill Out List View with Items
\r
631 listview_presets.Items.Add(preset_listview);
\r
634 string appPath = Application.StartupPath.ToString() + "\\";
\r
635 string strCmdLine = "cmd /c " + '"' + '"' + appPath + "HandBrakeCLI.exe" + '"' + " --preset-list >" + '"' + appPath + "presets.dat" + '"' + " 2>&1" + '"';
\r
636 Process hbproc = Process.Start("CMD.exe", strCmdLine);
\r
637 hbproc.WaitForExit();
\r
644 private Boolean presetStatus = false;
\r
647 private void btn_presets_Click(object sender, EventArgs e)
\r
649 if (presetStatus == false)
\r
652 presetStatus = true;
\r
653 btn_presets.Text = "Hide Presets";
\r
658 presetStatus = false;
\r
659 btn_presets.Text = "Show Presets";
\r
664 private void btn_setDefault_Click(object sender, EventArgs e)
\r
667 Properties.Settings.Default.DVDSource = text_source.Text;
\r
668 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
669 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
670 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
672 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
673 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
674 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
675 Properties.Settings.Default.Width = text_width.Text;
\r
676 Properties.Settings.Default.Height = text_height.Text;
\r
677 //Picture Settings Tab
\r
678 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
679 Properties.Settings.Default.CropTop = text_top.Text;
\r
680 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
681 Properties.Settings.Default.CropLeft = text_left.Text;
\r
682 Properties.Settings.Default.CropRight = text_right.Text;
\r
683 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
684 //Video Settings Tab
\r
685 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
686 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
687 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
688 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
689 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
690 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
691 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
692 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
693 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
694 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
695 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
696 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
697 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
698 Properties.Settings.Default.chapterMarker = Check_ChapterMarkers.CheckState.ToString();
\r
699 //Audio Settings Tab
\r
700 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
701 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
702 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
704 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
705 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
707 Properties.Settings.Default.selectedPreset = groupBox_output.Text.Replace("Output Settings (Preset: ", "").Replace("\"", "").Replace(")", "");
\r
708 // Save the new default Settings
\r
709 Properties.Settings.Default.Save();
\r
710 MessageBox.Show("New default settings saved.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
713 // Preset Selection
\r
714 private void listview_presets_SelectedIndexChanged(object sender, EventArgs e)
\r
717 string selectedPreset = null;
\r
718 ListView.SelectedListViewItemCollection name = null;
\r
719 name = listview_presets.SelectedItems;
\r
721 if (listview_presets.SelectedItems.Count != 0)
\r
722 selectedPreset = name[0].SubItems[0].Text;
\r
726 string appPath = Application.StartupPath.ToString() + "\\";
\r
727 StreamReader presetInput = new StreamReader(appPath + "presets.dat");
\r
729 while (!presetInput.EndOfStream)
\r
731 if ((char)presetInput.Peek() == '+')
\r
733 string preset = presetInput.ReadLine().Replace("+ ", "");
\r
734 Regex r = new Regex("(: )"); // Split on hyphens.
\r
735 string[] presetName = r.Split(preset);
\r
737 if (selectedPreset == "iPhone / iPod Touch")
\r
739 selectedPreset = "iPhone";
\r
742 if (selectedPreset == presetName[0])
\r
744 // Need to disable anamorphic now, otherwise it may overide the width / height values later.
\r
745 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
747 // Send the query from the file to the Query Parser class
\r
748 Functions.QueryParser presetQuery = Functions.QueryParser.Parse(preset);
\r
750 // Now load the preset
\r
751 presetLoader(presetQuery, selectedPreset);
\r
757 presetInput.ReadLine();
\r
761 catch (Exception exc)
\r
763 MessageBox.Show(exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
770 //---------------------------------------------------
\r
771 // Encode / Cancel Buttons
\r
772 // Encode Progress Text Handler
\r
773 //---------------------------------------------------
\r
777 Functions.CLI process = new Functions.CLI();
\r
779 private void btn_encode_Click(object sender, EventArgs e)
\r
781 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
782 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
785 btn_eCancel.Enabled = true;
\r
787 if (QueryEditorText.Text == "")
\r
789 query = GenerateTheQuery();
\r
793 query = QueryEditorText.Text;
\r
796 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
797 lbl_encode.Visible = true;
\r
798 lbl_encode.Text = "Encoding in Progress";
\r
802 private void btn_eCancel_Click(object sender, EventArgs e)
\r
806 lbl_encode.Text = "Encoding Canceled";
\r
809 [DllImport("user32.dll")]
\r
810 public static extern void LockWorkStation();
\r
811 [DllImport("user32.dll")]
\r
812 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
814 private void procMonitor(object state)
\r
816 // Make sure we are not already encoding and if we are then display an error.
\r
817 if (hbProc != null)
\r
819 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
823 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
824 hbProc.WaitForExit();
\r
829 //*****************************************************************************************
\r
831 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
832 // video stream which has mild corruption issues every few seconds.
\r
833 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
834 //*****************************************************************************************
\r
837 Parsing.Parser encode = new Parsing.Parser(hbProc.StandardOutput.BaseStream);
\r
838 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
839 while (!encode.EndOfStream)
\r
844 hbProc.WaitForExit();
\r
845 process.closeCLI();
\r
849 catch (Exception exc)
\r
852 MessageBox.Show(exc.ToString());
\r
859 // Do something whent he encode ends.
\r
860 switch (Properties.Settings.Default.CompletionOption)
\r
863 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
866 ExitWindowsEx(0, 0);
\r
869 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
872 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
874 case "Lock System":
\r
877 case "Quit HandBrake":
\r
878 Application.Exit();
\r
886 private delegate void UpdateUIHandler();
\r
888 private void setEncodeLabel()
\r
890 if (this.InvokeRequired)
\r
892 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
895 lbl_encode.Text = "Encoding Finished";
\r
898 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
901 if (this.InvokeRequired)
\r
903 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
904 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
907 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
912 //---------------------------------------------------
\r
913 // Items that require actions on frmMain
\r
914 //---------------------------------------------------
\r
916 #region frmMain Actions
\r
918 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
920 drop_chapterStart.BackColor = Color.White;
\r
921 QueryEditorText.Text = "";
\r
922 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
926 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
927 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
929 if (chapterFinish < chapterStart)
\r
931 drop_chapterStart.BackColor = Color.LightCoral;
\r
936 drop_chapterStart.BackColor = Color.LightCoral;
\r
943 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
945 drop_chapterFinish.BackColor = Color.White;
\r
946 QueryEditorText.Text = "";
\r
947 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
951 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
952 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
954 if (chapterFinish < chapterStart)
\r
956 drop_chapterFinish.BackColor = Color.LightCoral;
\r
961 drop_chapterFinish.BackColor = Color.LightCoral;
\r
966 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
968 text_filesize.Text = "";
\r
969 slider_videoQuality.Value = 0;
\r
970 SliderValue.Text = "0%";
\r
971 CheckCRF.CheckState = CheckState.Unchecked;
\r
972 CheckCRF.Enabled = false;
\r
975 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
977 text_bitrate.Text = "";
\r
978 slider_videoQuality.Value = 0;
\r
979 SliderValue.Text = "0%";
\r
980 CheckCRF.CheckState = CheckState.Unchecked;
\r
981 CheckCRF.Enabled = false;
\r
984 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
986 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
987 text_bitrate.Text = "";
\r
988 text_filesize.Text = "";
\r
989 CheckCRF.Enabled = true;
\r
992 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
994 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
997 private void text_width_TextChanged(object sender, EventArgs e)
\r
1001 if (CheckPixelRatio.Checked)
\r
1003 text_width.Text = "";
\r
1004 text_width.BackColor = Color.LightCoral;
\r
1005 CheckPixelRatio.BackColor = Color.LightCoral;
\r
1009 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1011 text_width.BackColor = Color.LightCoral;
\r
1015 text_width.BackColor = Color.LightGreen;
\r
1019 if (lbl_Aspect.Text != "Select a Title")
\r
1021 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1022 double mod16 = height % 16;
\r
1023 height = height - mod16;
\r
1025 if (text_width.Text == "")
\r
1027 text_height.Text = "";
\r
1028 text_width.BackColor = Color.White;
\r
1032 text_height.Text = height.ToString();
\r
1033 text_width.BackColor = Color.LightGreen;
\r
1039 // No need to throw an error here.
\r
1040 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1046 private void text_height_TextChanged(object sender, EventArgs e)
\r
1050 if (CheckPixelRatio.Checked)
\r
1052 text_height.Text = "";
\r
1053 text_height.BackColor = Color.LightCoral;
\r
1054 CheckPixelRatio.BackColor = Color.LightCoral;
\r
1058 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1060 text_height.BackColor = Color.LightCoral;
\r
1064 text_height.BackColor = Color.LightGreen;
\r
1071 // No need to alert the user.
\r
1075 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1077 if ((string)drp_crop.SelectedItem == "Manual")
\r
1079 text_left.Enabled = true;
\r
1080 text_right.Enabled = true;
\r
1081 text_top.Enabled = true;
\r
1082 text_bottom.Enabled = true;
\r
1085 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1087 text_left.Enabled = false;
\r
1088 text_right.Enabled = false;
\r
1089 text_top.Enabled = false;
\r
1090 text_bottom.Enabled = false;
\r
1091 text_left.Text = "";
\r
1092 text_right.Text = "";
\r
1093 text_top.Text = "";
\r
1094 text_bottom.Text = "";
\r
1096 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1098 string[] temp = new string[4];
\r
1099 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1100 text_left.Text = temp[2];
\r
1101 text_right.Text = temp[3];
\r
1102 text_top.Text = temp[0];
\r
1103 text_bottom.Text = temp[1];
\r
1107 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1109 text_left.Enabled = false;
\r
1110 text_right.Enabled = false;
\r
1111 text_top.Enabled = false;
\r
1112 text_bottom.Enabled = false;
\r
1113 text_left.Text = "0";
\r
1114 text_right.Text = "0";
\r
1115 text_top.Text = "0";
\r
1116 text_bottom.Text = "0";
\r
1121 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1123 text_width.Text = "";
\r
1124 text_height.Text = "";
\r
1125 text_width.BackColor = Color.White;
\r
1126 text_height.BackColor = Color.White;
\r
1127 CheckPixelRatio.BackColor = TabPage1.BackColor;
\r
1130 private void check_2PassEncode_CheckedChanged(object sender, EventArgs e)
\r
1132 if (check_2PassEncode.CheckState.ToString() == "Checked")
\r
1134 if (drp_videoEncoder.Text.Contains("H.264"))
\r
1136 check_turbo.Enabled = true;
\r
1141 check_turbo.Enabled = false;
\r
1142 check_turbo.CheckState = CheckState.Unchecked;
\r
1146 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1148 if (!text_destination.Text.Contains(".mp4"))
\r
1150 lbl_largeMp4Warning.Text = "Warning: Only mp4 files are supported";
\r
1151 lbl_largeMp4Warning.ForeColor = Color.Red;
\r
1152 check_largeFile.CheckState = CheckState.Unchecked;
\r
1156 lbl_largeMp4Warning.Text = "Warning: Breaks iPod, @TV, PS3 compatibility.";
\r
1157 lbl_largeMp4Warning.ForeColor = Color.Black;
\r
1161 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1163 if (drp_dvdtitle.Items.Count == 0)
\r
1165 MessageBox.Show("There are no titles to select. Please scan the DVD by clicking the 'browse' button above before trying to select a title.", "Alert", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
1169 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1172 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1174 drp_audioMixDown.Items.Clear();
\r
1176 if (drp_audioCodec.Text == "AAC")
\r
1178 drp_audioMixDown.Items.Clear();
\r
1179 drp_audioMixDown.Items.Add("Mono");
\r
1180 drp_audioMixDown.Items.Add("Stereo");
\r
1181 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1182 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1183 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1185 drp_audioBitrate.Items.Clear();
\r
1186 drp_audioBitrate.Items.Add("32");
\r
1187 drp_audioBitrate.Items.Add("40");
\r
1188 drp_audioBitrate.Items.Add("48");
\r
1189 drp_audioBitrate.Items.Add("56");
\r
1190 drp_audioBitrate.Items.Add("64");
\r
1191 drp_audioBitrate.Items.Add("80");
\r
1192 drp_audioBitrate.Items.Add("86");
\r
1193 drp_audioBitrate.Items.Add("112");
\r
1194 drp_audioBitrate.Items.Add("128");
\r
1195 drp_audioBitrate.Items.Add("160");
\r
1200 drp_audioMixDown.Items.Clear();
\r
1201 drp_audioMixDown.Items.Add("Stereo");
\r
1202 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1203 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1205 drp_audioBitrate.Items.Clear();
\r
1206 drp_audioBitrate.Items.Add("32");
\r
1207 drp_audioBitrate.Items.Add("40");
\r
1208 drp_audioBitrate.Items.Add("48");
\r
1209 drp_audioBitrate.Items.Add("56");
\r
1210 drp_audioBitrate.Items.Add("64");
\r
1211 drp_audioBitrate.Items.Add("80");
\r
1212 drp_audioBitrate.Items.Add("86");
\r
1213 drp_audioBitrate.Items.Add("112");
\r
1214 drp_audioBitrate.Items.Add("128");
\r
1215 drp_audioBitrate.Items.Add("160");
\r
1216 drp_audioBitrate.Items.Add("192");
\r
1217 drp_audioBitrate.Items.Add("224");
\r
1218 drp_audioBitrate.Items.Add("256");
\r
1219 drp_audioBitrate.Items.Add("320");
\r
1223 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1225 if (drp_audioCodec.Text == "AAC")
\r
1227 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1230 drp_audioBitrate.Items.Clear();
\r
1231 drp_audioBitrate.Items.Add("32");
\r
1232 drp_audioBitrate.Items.Add("40");
\r
1233 drp_audioBitrate.Items.Add("48");
\r
1234 drp_audioBitrate.Items.Add("56");
\r
1235 drp_audioBitrate.Items.Add("64");
\r
1236 drp_audioBitrate.Items.Add("80");
\r
1237 drp_audioBitrate.Items.Add("86");
\r
1238 drp_audioBitrate.Items.Add("112");
\r
1239 drp_audioBitrate.Items.Add("128");
\r
1240 drp_audioBitrate.Items.Add("160");
\r
1241 drp_audioBitrate.Items.Add("192");
\r
1242 drp_audioBitrate.Items.Add("224");
\r
1243 drp_audioBitrate.Items.Add("256");
\r
1244 drp_audioBitrate.Items.Add("320");
\r
1245 drp_audioBitrate.Items.Add("384");
\r
1250 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1252 if (Check_ChapterMarkers.Checked)
\r
1254 string destination = text_destination.Text;
\r
1255 destination = destination.Replace(".mp4", ".m4v");
\r
1256 text_destination.Text = destination;
\r
1260 string destination = text_destination.Text;
\r
1261 destination = destination.Replace(".m4v", ".mp4");
\r
1262 text_destination.Text = destination;
\r
1266 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1268 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1269 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1271 check_turbo.CheckState = CheckState.Unchecked;
\r
1272 CheckCRF.CheckState = CheckState.Unchecked;
\r
1273 CheckCRF.Enabled = false;
\r
1274 check_turbo.Enabled = false;
\r
1275 h264Tab.Enabled = false;
\r
1276 rtf_h264advanced.Text = "";
\r
1280 CheckCRF.Enabled = true;
\r
1281 if (check_2PassEncode.CheckState.ToString() == "Checked")
\r
1283 check_turbo.Enabled = true;
\r
1285 h264Tab.Enabled = true;
\r
1290 public void setStreamReader(Parsing.DVD dvd)
\r
1292 this.thisDVD = dvd;
\r
1295 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1297 // Reset some values on the form
\r
1298 lbl_Aspect.Text = "Select a Title";
\r
1299 lbl_RecomendedCrop.Text = "Select a Title";
\r
1300 drop_chapterStart.Items.Clear();
\r
1301 drop_chapterFinish.Items.Clear();
\r
1302 QueryEditorText.Text = "";
\r
1304 // If the dropdown is set to automatic nothing else needs to be done.
\r
1305 // Otheriwse if its not, title data has to be loased from parsing.
\r
1306 if (drp_dvdtitle.Text != "Automatic")
\r
1308 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1310 // Set the Aspect Ratio
\r
1311 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1313 // Set the Recommended Cropping values
\r
1314 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1316 // Populate the Start chapter Dropdown
\r
1317 drop_chapterStart.Items.Clear();
\r
1318 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1319 if (drop_chapterStart.Items.Count > 0)
\r
1321 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1324 // Populate the Final Chapter Dropdown
\r
1325 drop_chapterFinish.Items.Clear();
\r
1326 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1327 if (drop_chapterFinish.Items.Count > 0)
\r
1329 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1332 // Populate the Audio Channels Dropdown
\r
1333 drp_audioChannels.Items.Clear();
\r
1334 drp_audioChannels.Items.Add("Automatic");
\r
1335 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1336 if (drp_audioChannels.Items.Count > 0)
\r
1338 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1341 // Populate the Subtitles dropdown
\r
1342 drp_subtitle.Items.Clear();
\r
1343 drp_subtitle.Items.Add("None");
\r
1344 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1345 if (drp_subtitle.Items.Count > 0)
\r
1347 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1354 //---------------------------------------------------
\r
1356 // - Query Generation
\r
1357 //---------------------------------------------------
\r
1359 #region Program Functions
\r
1361 // Generate a CLI Query String
\r
1362 public string GenerateTheQuery()
\r
1364 string source = text_source.Text;
\r
1365 string dvdTitle = drp_dvdtitle.Text;
\r
1366 string chapterStart = drop_chapterStart.Text;
\r
1367 string chapterFinish = drop_chapterFinish.Text;
\r
1368 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1369 string dvdChapter = "";
\r
1371 source = " -i " + '"' + source + '"';
\r
1373 if (dvdTitle == "Automatic")
\r
1377 string[] titleInfo = dvdTitle.Split(' ');
\r
1378 dvdTitle = " -t " + titleInfo[0];
\r
1381 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1383 else if (chapterFinish == chapterStart)
\r
1384 dvdChapter = " -c " + chapterStart;
\r
1386 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1388 string querySource = source + dvdTitle + dvdChapter;
\r
1389 // ----------------------------------------------------------------------
\r
1393 string destination = text_destination.Text;
\r
1394 string videoEncoder = drp_videoEncoder.Text;
\r
1395 string audioEncoder = drp_audioCodec.Text;
\r
1396 string width = text_width.Text;
\r
1397 string height = text_height.Text;
\r
1399 if (destination == "")
\r
1400 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1402 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1405 switch (videoEncoder)
\r
1408 videoEncoder = " -e ffmpeg";
\r
1411 videoEncoder = " -e xvid";
\r
1414 videoEncoder = " -e x264";
\r
1416 case "H.264 Baseline 1.3":
\r
1417 videoEncoder = " -e x264b13";
\r
1419 case "H.264 (iPod)":
\r
1420 videoEncoder = " -e x264b30";
\r
1423 videoEncoder = " -e x264";
\r
1427 switch (audioEncoder)
\r
1430 audioEncoder = " -E faac";
\r
1433 audioEncoder = " -E lame";
\r
1436 audioEncoder = " -E vorbis";
\r
1439 audioEncoder = " -E ac3";
\r
1442 audioEncoder = " -E faac";
\r
1447 width = " -w " + width;
\r
1450 if (height == "Auto")
\r
1454 else if (height != "")
\r
1456 height = " -l " + height;
\r
1460 string queryDestination = destination + videoEncoder + audioEncoder + width + height;
\r
1461 // ----------------------------------------------------------------------
\r
1463 // Picture Settings Tab
\r
1465 string cropSetting = drp_crop.Text;
\r
1466 string cropTop = text_top.Text;
\r
1467 string cropBottom = text_bottom.Text;
\r
1468 string cropLeft = text_left.Text;
\r
1469 string cropRight = text_right.Text;
\r
1470 string subtitles = drp_subtitle.Text;
\r
1471 string cropOut = "";
\r
1472 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1473 string deinterlace = "";
\r
1474 string grayscale = "";
\r
1475 string pixelRatio = "";
\r
1476 string ChapterMarkers = "";
\r
1477 // Returns Crop Query
\r
1479 if (cropSetting == "Auto Crop")
\r
1481 else if (cropSetting == "No Crop")
\r
1482 cropOut = " --crop 0:0:0:0 ";
\r
1485 if (text_top.Text == "")
\r
1487 if (text_bottom.Text == "")
\r
1489 if (text_left.Text == "")
\r
1491 if (text_right.Text == "")
\r
1494 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1497 if (subtitles == "None")
\r
1499 else if (subtitles == "")
\r
1504 tempSub = subtitles.Split(' ');
\r
1505 subtitles = " -s " + tempSub[0];
\r
1508 switch (deInterlace_Option)
\r
1513 case "Original (Fast)":
\r
1514 deinterlace = " --deinterlace=fast";
\r
1516 case "yadif (Slow)":
\r
1517 deinterlace = " --deinterlace=slow";
\r
1519 case "yadif + mcdeint (Slower)":
\r
1520 deinterlace = " --deinterlace=slower";
\r
1522 case "yadif + mcdeint (Slowest)":
\r
1523 deinterlace = " --deinterlace=slowest";
\r
1530 if (check_grayscale.Checked)
\r
1531 grayscale = " -g ";
\r
1533 if (CheckPixelRatio.Checked)
\r
1534 pixelRatio = " -p ";
\r
1536 if (Check_ChapterMarkers.Checked)
\r
1537 ChapterMarkers = " -m ";
\r
1539 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1540 // ----------------------------------------------------------------------
\r
1542 // Video Settings Tab
\r
1544 string videoBitrate = text_bitrate.Text;
\r
1545 string videoFilesize = text_filesize.Text;
\r
1546 double videoQuality = slider_videoQuality.Value;
\r
1547 string vidQSetting = "";
\r
1548 string twoPassEncoding = "";
\r
1549 string videoFramerate = drp_videoFramerate.Text;
\r
1550 string turboH264 = "";
\r
1551 string largeFile = "";
\r
1552 string deblock = "";
\r
1553 string detelecine = "";
\r
1554 string denoise = "";
\r
1555 string CRF = CheckCRF.CheckState.ToString();
\r
1557 if (CRF == "Checked")
\r
1562 if (videoBitrate != "")
\r
1563 videoBitrate = " -b " + videoBitrate;
\r
1565 if (videoFilesize != "")
\r
1566 videoFilesize = " -S " + videoFilesize;
\r
1568 // Video Quality Setting
\r
1570 if ((videoQuality == 0))
\r
1574 videoQuality = videoQuality / 100;
\r
1575 if (videoQuality == 1)
\r
1577 vidQSetting = "1.0";
\r
1579 vidQSetting = " -q " + videoQuality.ToString(new CultureInfo("en-US"));
\r
1582 if (check_2PassEncode.Checked)
\r
1583 twoPassEncoding = " -2 ";
\r
1585 if (videoFramerate == "Automatic")
\r
1586 videoFramerate = "";
\r
1588 videoFramerate = " -r " + videoFramerate;
\r
1590 if (check_turbo.Checked)
\r
1591 turboH264 = " -T ";
\r
1593 if (check_largeFile.Checked)
\r
1594 largeFile = " -4 ";
\r
1596 if (check_deblock.Checked)
\r
1597 deblock = " --deblock";
\r
1599 if (check_detelecine.Checked)
\r
1600 detelecine = " --detelecine";
\r
1602 switch (drp_deNoise.Text)
\r
1608 denoise = " --denoise=weak";
\r
1611 denoise = " --denoise=medium";
\r
1614 denoise = " --denoise=strong";
\r
1621 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + CRF + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1622 // ----------------------------------------------------------------------
\r
1624 // Audio Settings Tab
\r
1626 string audioBitrate = drp_audioBitrate.Text;
\r
1627 string audioSampleRate = drp_audioSampleRate.Text;
\r
1628 string audioChannels = drp_audioChannels.Text;
\r
1629 string Mixdown = drp_audioMixDown.Text;
\r
1630 string SixChannelAudio = "";
\r
1632 if (audioBitrate != "")
\r
1633 audioBitrate = " -B " + audioBitrate;
\r
1635 if (audioSampleRate != "")
\r
1636 audioSampleRate = " -R " + audioSampleRate;
\r
1638 if (audioChannels == "Automatic")
\r
1639 audioChannels = "";
\r
1640 else if (audioChannels == "")
\r
1641 audioChannels = "";
\r
1645 tempSub = audioChannels.Split(' ');
\r
1646 audioChannels = " -a " + tempSub[0];
\r
1658 Mixdown = "stereo";
\r
1660 case "Dolby Surround":
\r
1663 case "Dolby Pro Logic II":
\r
1666 case "6 Channel Discrete":
\r
1674 if (Mixdown != "")
\r
1675 SixChannelAudio = " -6 " + Mixdown;
\r
1677 SixChannelAudio = "";
\r
1679 string queryAudioSettings = audioBitrate + audioSampleRate + audioChannels + SixChannelAudio;
\r
1680 // ----------------------------------------------------------------------
\r
1685 string h264Advanced = rtf_h264advanced.Text;
\r
1687 if ((h264Advanced == ""))
\r
1688 h264Advanced = "";
\r
1690 h264Advanced = " -x " + h264Advanced;
\r
1693 string h264Settings = h264Advanced;
\r
1694 // ----------------------------------------------------------------------
\r
1696 // Processors (Program Settings)
\r
1698 string processors = Properties.Settings.Default.Processors;
\r
1699 // Number of Processors Handler
\r
1701 if (processors == "Automatic")
\r
1704 processors = " -C " + processors + " ";
\r
1707 string queryAdvancedSettings = processors;
\r
1708 // ----------------------------------------------------------------------
\r
1710 // Verbose option (Program Settings)
\r
1712 string verbose = "";
\r
1713 if (Properties.Settings.Default.verbose == "Checked")
\r
1716 // ----------------------------------------------------------------------
\r
1718 return querySource + queryDestination + queryPictureSettings + queryVideoSettings + h264Settings + queryAudioSettings + queryAdvancedSettings + verbose;
\r
1722 private void presetLoader(Functions.QueryParser presetQuery, string name)
\r
1724 // ---------------------------
\r
1726 // ---------------------------
\r
1730 if (presetQuery.Source != "")
\r
1731 text_source.Text = presetQuery.Source;
\r
1733 if (presetQuery.DVDTitle != 0)
\r
1734 drp_dvdtitle.Text = presetQuery.DVDTitle.ToString();
\r
1736 if (presetQuery.DVDChapterStart != 0)
\r
1737 drop_chapterStart.Text = presetQuery.DVDChapterStart.ToString();
\r
1739 if (presetQuery.DVDChapterFinish != 0)
\r
1740 drop_chapterFinish.Text = presetQuery.DVDChapterFinish.ToString();
\r
1742 if (presetQuery.Format != "")
\r
1744 string destination = text_destination.Text;
\r
1745 destination = destination.Replace(".mp4", "." + presetQuery.Format);
\r
1746 destination = destination.Replace(".m4v", "." + presetQuery.Format);
\r
1747 destination = destination.Replace(".avi", "." + presetQuery.Format);
\r
1748 destination = destination.Replace(".mkv", "." + presetQuery.Format);
\r
1749 destination = destination.Replace(".ogm", "." + presetQuery.Format);
\r
1750 text_destination.Text = destination;
\r
1755 // Destination tab
\r
1756 #region destination
\r
1758 if (presetQuery.Destination != "")
\r
1759 text_destination.Text = presetQuery.Destination;
\r
1761 drp_videoEncoder.Text = presetQuery.VideoEncoder;
\r
1762 drp_audioCodec.Text = presetQuery.AudioEncoder;
\r
1763 if (presetQuery.Width != 0)
\r
1765 text_width.Text = presetQuery.Width.ToString();
\r
1770 text_width.Text = "";
\r
1771 text_width.BackColor = Color.White;
\r
1774 if (presetQuery.Height != 0)
\r
1776 text_height.Text = presetQuery.Height.ToString();
\r
1780 text_height.Text = "";
\r
1781 text_height.BackColor = Color.White;
\r
1785 // Picture Settings Tab
\r
1787 drp_crop.Text = "Manual";
\r
1788 text_top.Text = presetQuery.CropTop;
\r
1789 text_bottom.Text = presetQuery.CropBottom;
\r
1790 text_left.Text = presetQuery.CropLeft;
\r
1791 text_right.Text = presetQuery.CropRight;
\r
1793 drp_deInterlace_option.Text = presetQuery.DeInterlace;
\r
1794 drp_deNoise.Text = presetQuery.DeNoise;
\r
1796 if (presetQuery.DeTelecine == true)
\r
1798 check_detelecine.CheckState = CheckState.Checked;
\r
1802 check_detelecine.CheckState = CheckState.Unchecked;
\r
1806 if (presetQuery.DeBlock == true)
\r
1808 check_deblock.CheckState = CheckState.Checked;
\r
1812 check_deblock.CheckState = CheckState.Unchecked;
\r
1815 if (presetQuery.ChapterMarkers == true)
\r
1817 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
1821 Check_ChapterMarkers.CheckState = CheckState.Unchecked;
\r
1824 if (presetQuery.Anamorphic == true)
\r
1826 CheckPixelRatio.CheckState = CheckState.Checked;
\r
1830 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
1834 // Video Settings Tab
\r
1836 text_bitrate.Text = presetQuery.AverageVideoBitrate;
\r
1837 text_filesize.Text = presetQuery.VideoTargetSize;
\r
1838 slider_videoQuality.Value = presetQuery.VideoQuality;
\r
1839 if (slider_videoQuality.Value != 0)
\r
1841 CheckCRF.Enabled = true;
\r
1842 int ql = presetQuery.VideoQuality;
\r
1843 SliderValue.Text = ql.ToString() + "%";
\r
1846 if (presetQuery.TwoPass == true)
\r
1848 check_2PassEncode.CheckState = CheckState.Checked;
\r
1852 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
1855 if (presetQuery.Grayscale == true)
\r
1857 check_grayscale.CheckState = CheckState.Checked;
\r
1861 check_grayscale.CheckState = CheckState.Unchecked;
\r
1864 drp_videoFramerate.Text = presetQuery.VideoFramerate;
\r
1866 if (presetQuery.TurboFirstPass == true)
\r
1868 check_turbo.CheckState = CheckState.Checked;
\r
1872 check_turbo.CheckState = CheckState.Unchecked;
\r
1875 if (presetQuery.LargeMP4 == true)
\r
1877 check_largeFile.CheckState = CheckState.Checked;
\r
1881 check_largeFile.CheckState = CheckState.Unchecked;
\r
1883 if (presetQuery.CRF == true)
\r
1885 CheckCRF.CheckState = CheckState.Checked;
\r
1889 CheckCRF.CheckState = CheckState.Unchecked;
\r
1893 // Audio Settings Tab
\r
1895 drp_audioBitrate.Text = presetQuery.AudioBitrate;
\r
1896 drp_audioSampleRate.Text = presetQuery.AudioSampleBitrate;
\r
1897 drp_audioChannels.Text = presetQuery.AudioTrack1;
\r
1898 drp_audioMixDown.Text = presetQuery.AudioTrackMix;
\r
1899 drp_subtitle.Text = presetQuery.Subtitles;
\r
1902 // H264 Tab & Preset Name
\r
1904 rtf_h264advanced.Text = presetQuery.H264Query;
\r
1906 // Set the preset name
\r
1907 groupBox_output.Text = "Output Settings (Preset: " + name + ")";
\r
1913 // This is the END of the road ------------------------------------------------------------------------------
\r