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
19 public partial class frmMain : Form
\r
21 // --------------------------------------------------------------
\r
22 // Applicaiton Startup Stuff
\r
23 // --------------------------------------------------------------
\r
25 #region Application Startup
\r
27 private Process hbProc;
\r
28 private Parsing.DVD thisDVD;
\r
29 private frmQueue queueWindow = new frmQueue();
\r
30 //private frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
36 ThreadPool.QueueUserWorkItem(showSplash);
\r
39 InitializeComponent();
\r
41 // This is a quick Hack fix for the cross-thread problem with frmDvdIndo ************************
\r
42 //dvdInfoWindow.Show();
\r
43 //dvdInfoWindow.Hide();
\r
44 // **********************************************************************************************
\r
46 // System Requirements Check
\r
49 // Set the Version number lable to the corect version.
\r
50 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
52 // Run the update checker.
\r
55 // Now load the users default if required. (Will overide the above setting)
\r
58 // Display the quick start window if required.
\r
61 // Enable or disable tooltips
\r
65 // Hide the presets part of the window
\r
68 // Create and initializes a new StringCollection.
\r
69 StringCollection myCol = new StringCollection();
\r
70 // Add a range of elements from an array to the end of the StringCollection.
\r
71 String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" };
\r
72 myCol.AddRange(myArr);
\r
74 Properties.Settings.Default.BuiltInPresets = myCol;
\r
79 // Functions to preform tasks required on startup.
\r
80 #region Initializeation Functions
\r
82 private void showSplash(object sender)
\r
84 Form splash = new frmSplashScreen();
\r
86 Thread.Sleep(1500); // Display splash screen for 1.5 Seconds
\r
87 splash.Close(); // Then close.
\r
90 private void loadUserDefaults()
\r
94 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
97 text_source.Text = Properties.Settings.Default.DVDSource;
\r
98 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
99 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
100 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
103 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
104 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
105 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
106 text_width.Text = Properties.Settings.Default.Width;
\r
107 text_height.Text = Properties.Settings.Default.Height;
\r
109 // Picture Settings Tab
\r
110 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
111 text_top.Text = Properties.Settings.Default.CropTop;
\r
112 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
113 text_left.Text = Properties.Settings.Default.CropLeft;
\r
114 text_right.Text = Properties.Settings.Default.CropRight;
\r
115 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
117 // Video Settings Tab
\r
118 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
119 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
120 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
122 if (Properties.Settings.Default.TwoPass == "Checked")
\r
124 check_2PassEncode.CheckState = CheckState.Checked;
\r
127 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
128 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
130 if (Properties.Settings.Default.detelecine == "Checked")
\r
132 check_detelecine.CheckState = CheckState.Checked;
\r
135 if (Properties.Settings.Default.detelecine == "Checked")
\r
137 check_deblock.CheckState = CheckState.Checked;
\r
141 if (Properties.Settings.Default.Grayscale == "Checked")
\r
143 check_grayscale.CheckState = CheckState.Checked;
\r
146 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
148 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
150 CheckPixelRatio.CheckState = CheckState.Checked;
\r
152 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
154 check_turbo.CheckState = CheckState.Checked;
\r
156 if (Properties.Settings.Default.largeFile == "Checked")
\r
158 check_largeFile.CheckState = CheckState.Checked;
\r
160 // Audio Settings Tab
\r
161 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
162 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
163 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
166 if (Properties.Settings.Default.CRF == "Checked")
\r
168 CheckCRF.CheckState = CheckState.Checked;
\r
170 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
172 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.SelectedPreset + ")";
\r
176 // Load the default preset on lauch
\r
177 ListBox_Presets.SelectedItem = "Normal";
\r
182 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
186 private int updateCheck()
\r
190 String updateFile = Properties.Settings.Default.updateFile;
\r
191 WebClient client = new WebClient();
\r
192 String data = client.DownloadString(updateFile);
\r
193 String[] versionData = data.Split('\n');
\r
195 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
197 lbl_update.Visible = true;
\r
207 // Silently ignore the error
\r
212 private void quickStart()
\r
214 if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))
\r
216 frmQuickStart quickstart = new frmQuickStart();
\r
217 quickstart.ShowDialog();
\r
221 private void tooltip()
\r
223 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
225 ToolTip.Active = true;
\r
229 #region Memory Check
\r
231 public struct MEMORYSTATUS
\r
233 public UInt32 dwLength;
\r
234 public UInt32 dwMemoryLoad;
\r
235 public UInt32 dwTotalPhys; // Used
\r
236 public UInt32 dwAvailPhys;
\r
237 public UInt32 dwTotalPageFile;
\r
238 public UInt32 dwAvailPageFile;
\r
239 public UInt32 dwTotalVirtual;
\r
240 public UInt32 dwAvailVirtual;
\r
241 // Aditional Varibles left in for future usage (JIC)
\r
244 [DllImport("kernel32.dll")]
\r
245 public static extern void GlobalMemoryStatus
\r
247 ref MEMORYSTATUS lpBuffer
\r
250 public uint CheckMemeory()
\r
252 // Call the native GlobalMemoryStatus method
\r
253 // with the defined structure.
\r
254 MEMORYSTATUS memStatus = new MEMORYSTATUS();
\r
255 GlobalMemoryStatus(ref memStatus);
\r
257 // Use a StringBuilder for the message box string.
\r
258 uint MemoryInfo = memStatus.dwTotalPhys;
\r
260 // Return the Ram Information
\r
267 Boolean preventLaunch = false;
\r
268 private void systemCheck()
\r
272 // Make sure the screen resolution is not below 1024x768
\r
273 System.Windows.Forms.Screen scr = System.Windows.Forms.Screen.PrimaryScreen;
\r
274 if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 768))
\r
276 MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Screen resolution is too Low. Must be 1024x768 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
277 preventLaunch = true;
\r
280 // Make sure the system has enough RAM. 384MB or greater
\r
281 uint memory = CheckMemeory();
\r
283 if (memory < 319) // Set to 319 to allow for 64MB dedicated to video Memory and Windows returnig the memory figure slightly out.
\r
285 MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Insufficient Memory. 384MB or greater required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
286 preventLaunch = true;
\r
289 catch (Exception exc)
\r
291 if (Properties.Settings.Default.GuiDebug == "Checked")
\r
293 MessageBox.Show("frmMain.cs - systemCheck() " + exc.ToString());
\r
300 // Close the Application on main window load if required by the system Check
\r
302 private void frmMain_Load(object sender, EventArgs e)
\r
304 if (preventLaunch == true)
\r
306 Application.Exit();
\r
313 // --------------------------------------------------------------
\r
314 // The main Menu bar.
\r
315 // --------------------------------------------------------------
\r
319 private void mnu_open_Click(object sender, EventArgs e)
\r
322 File_Open.ShowDialog();
\r
323 filename = File_Open.FileName;
\r
324 if (filename != "")
\r
328 // Create StreamReader & open file
\r
329 StreamReader line = new StreamReader(filename);
\r
330 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
332 // Read in the data and set the correct GUI component with the setting.
\r
333 text_source.Text = line.ReadLine();
\r
334 drp_dvdtitle.Text = line.ReadLine();
\r
335 drop_chapterStart.Text = line.ReadLine();
\r
336 drop_chapterFinish.Text = line.ReadLine();
\r
337 text_destination.Text = line.ReadLine();
\r
338 drp_videoEncoder.Text = line.ReadLine();
\r
339 drp_audioCodec.Text = line.ReadLine();
\r
340 text_width.Text = line.ReadLine();
\r
341 text_height.Text = line.ReadLine();
\r
342 text_top.Text = line.ReadLine();
\r
343 text_bottom.Text = line.ReadLine();
\r
344 text_left.Text = line.ReadLine();
\r
345 text_right.Text = line.ReadLine();
\r
346 drp_subtitle.Text = line.ReadLine();
\r
347 text_bitrate.Text = line.ReadLine();
\r
348 text_filesize.Text = line.ReadLine();
\r
349 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
351 temporyLine = line.ReadLine();
\r
352 if (temporyLine == "Checked")
\r
354 check_2PassEncode.CheckState = CheckState.Checked;
\r
357 drp_deInterlace_option.Text = line.ReadLine();
\r
359 temporyLine = line.ReadLine();
\r
360 if (temporyLine == "Checked")
\r
362 check_grayscale.CheckState = CheckState.Checked;
\r
365 drp_videoFramerate.Text = line.ReadLine();
\r
367 temporyLine = line.ReadLine();
\r
368 if (temporyLine == "Checked")
\r
370 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
373 temporyLine = line.ReadLine();
\r
374 if (temporyLine == "Checked")
\r
376 CheckPixelRatio.CheckState = CheckState.Checked;
\r
379 temporyLine = line.ReadLine();
\r
380 if (temporyLine == "Checked")
\r
382 check_turbo.CheckState = CheckState.Checked;
\r
385 temporyLine = line.ReadLine();
\r
386 if (temporyLine == "Checked")
\r
388 check_largeFile.CheckState = CheckState.Checked;
\r
391 drp_audioBitrate.Text = line.ReadLine();
\r
392 drp_audioSampleRate.Text = line.ReadLine();
\r
393 drp_audioChannels.Text = line.ReadLine();
\r
394 drp_audioMixDown.Text = line.ReadLine();
\r
396 // Advanced H264 Options
\r
397 temporyLine = line.ReadLine();
\r
398 if (temporyLine == "Checked")
\r
400 CheckCRF.CheckState = CheckState.Checked;
\r
402 rtf_h264advanced.Text = line.ReadLine();
\r
404 // Close the stream
\r
408 // Fix for SliderValue not appearing when Opening saved file
\r
409 SliderValue.Text = slider_videoQuality.Value + "%";
\r
411 } catch (Exception){
\r
412 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
417 private void mnu_save_Click(object sender, EventArgs e)
\r
421 File_Save.ShowDialog();
\r
422 filename = File_Save.FileName;
\r
423 if (filename != "")
\r
427 // Create a StreamWriter and open the file
\r
428 StreamWriter line = new StreamWriter(filename);
\r
431 line.WriteLine(text_source.Text);
\r
432 line.WriteLine(drp_dvdtitle.Text);
\r
433 line.WriteLine(drop_chapterStart.Text);
\r
434 line.WriteLine(drop_chapterFinish.Text);
\r
436 line.WriteLine(text_destination.Text);
\r
437 line.WriteLine(drp_videoEncoder.Text);
\r
438 line.WriteLine(drp_audioCodec.Text);
\r
439 line.WriteLine(text_width.Text);
\r
440 line.WriteLine(text_height.Text);
\r
441 //Picture Settings Tab
\r
442 line.WriteLine(text_top.Text);
\r
443 line.WriteLine(text_bottom.Text);
\r
444 line.WriteLine(text_left.Text);
\r
445 line.WriteLine(text_right.Text);
\r
446 line.WriteLine(drp_subtitle.Text);
\r
447 //Video Settings Tab
\r
448 line.WriteLine(text_bitrate.Text);
\r
449 line.WriteLine(text_filesize.Text);
\r
450 line.WriteLine(slider_videoQuality.Value.ToString());
\r
451 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
452 line.WriteLine(drp_deInterlace_option.Text);
\r
453 line.WriteLine(check_grayscale.CheckState.ToString());
\r
454 line.WriteLine(drp_videoFramerate.Text);
\r
455 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
456 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
457 line.WriteLine(check_turbo.CheckState.ToString());
\r
458 line.WriteLine(check_largeFile.CheckState.ToString());
\r
459 //Audio Settings Tab
\r
460 line.WriteLine(drp_audioBitrate.Text);
\r
461 line.WriteLine(drp_audioSampleRate.Text);
\r
462 line.WriteLine(drp_audioChannels.Text);
\r
463 line.WriteLine(drp_audioMixDown.Text);
\r
465 line.WriteLine(CheckCRF.CheckState.ToString());
\r
466 line.WriteLine(rtf_h264advanced.Text);
\r
467 // close the stream
\r
469 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
473 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
479 private void mnu_update_Click(object sender, EventArgs e)
\r
481 int update = updateCheck();
\r
484 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
488 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
492 private void mnu_exit_Click(object sender, EventArgs e)
\r
494 Application.Exit();
\r
501 private void mnu_encode_Click(object sender, EventArgs e)
\r
506 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
508 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
509 dvdInfoWindow.Show();
\r
512 private void mnu_options_Click(object sender, EventArgs e)
\r
514 Form Options = new frmOptions();
\r
515 Options.ShowDialog();
\r
520 #region Presets Menu
\r
522 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
524 ListBox_Presets.Items.Clear();
\r
525 ListBox_Presets.Items.Add("Animation");
\r
526 ListBox_Presets.Items.Add("AppleTV");
\r
527 ListBox_Presets.Items.Add("Bedlam");
\r
528 ListBox_Presets.Items.Add("Blind");
\r
529 ListBox_Presets.Items.Add("Broke");
\r
530 ListBox_Presets.Items.Add("Classic");
\r
531 ListBox_Presets.Items.Add("Constant Quality Rate");
\r
532 ListBox_Presets.Items.Add("Deux Six Quatre");
\r
533 ListBox_Presets.Items.Add("Film");
\r
534 ListBox_Presets.Items.Add("iPhone");
\r
535 ListBox_Presets.Items.Add("iPod High-Rez");
\r
536 ListBox_Presets.Items.Add("iPod Low-Rez");
\r
537 ListBox_Presets.Items.Add("Normal");
\r
538 ListBox_Presets.Items.Add("PS3");
\r
539 ListBox_Presets.Items.Add("PSP");
\r
540 ListBox_Presets.Items.Add("QuickTime");
\r
541 ListBox_Presets.Items.Add("Television");
\r
543 if (presetStatus == false)
\r
546 presetStatus = true;
\r
547 btn_presets.Text = "Hide Presets";
\r
551 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
553 ListBox_Presets.SelectedItem = "Normal";
\r
554 if (presetStatus == false)
\r
557 presetStatus = true;
\r
558 btn_presets.Text = "Hide Presets";
\r
566 private void mnu_wiki_Click(object sender, EventArgs e)
\r
568 Process.Start("http://handbrake.m0k.org/trac");
\r
571 private void mnu_faq_Click(object sender, EventArgs e)
\r
573 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
576 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
578 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
581 private void mnu_homepage_Click(object sender, EventArgs e)
\r
583 Process.Start("http://handbrake.m0k.org");
\r
586 private void mnu_forum_Click(object sender, EventArgs e)
\r
588 Process.Start("http://handbrake.m0k.org/forum");
\r
591 private void mnu_about_Click(object sender, EventArgs e)
\r
593 Form About = new frmAbout();
\r
594 About.ShowDialog();
\r
599 // --------------------------------------------------------------
\r
600 // Buttons on the main Window
\r
601 // --------------------------------------------------------------
\r
604 private void btn_Browse_Click(object sender, EventArgs e)
\r
606 String filename ="";
\r
607 text_source.Text = "";
\r
608 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
609 if (RadioDVD.Checked)
\r
611 DVD_Open.ShowDialog();
\r
612 filename = DVD_Open.SelectedPath;
\r
613 if (filename != "")
\r
615 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
616 text_source.Text = filename;
\r
617 frmRD.ShowDialog();
\r
622 ISO_Open.ShowDialog();
\r
623 filename = ISO_Open.FileName;
\r
624 if (filename != "")
\r
626 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
627 text_source.Text = filename;
\r
628 frmRD.ShowDialog();
\r
632 // Check if there was titles in the dvd title dropdown
\r
633 if (filename == "")
\r
635 text_source.Text = "Click 'Browse' to continue";
\r
638 if (drp_dvdtitle.Items.Count == 0)
\r
640 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
644 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
646 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
648 DVD_Save.ShowDialog();
\r
649 text_destination.Text = DVD_Save.FileName;
\r
651 if (Check_ChapterMarkers.Checked)
\r
653 string destination = text_destination.Text;
\r
654 destination = destination.Replace(".mp4", ".m4v");
\r
655 text_destination.Text = destination;
\r
659 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
661 rtf_h264advanced.Text = "";
\r
664 private void GenerateQuery_Click(object sender, EventArgs e)
\r
666 String query = GenerateTheQuery();
\r
667 QueryEditorText.Text = query;
\r
670 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
672 QueryEditorText.Text = "";
\r
675 private void btn_queue_Click(object sender, EventArgs e)
\r
677 if (text_destination.Text != "" && text_source.Text != "")
\r
680 if (QueryEditorText.Text == "")
\r
682 query = GenerateTheQuery();
\r
686 query = QueryEditorText.Text;
\r
688 queueWindow.list_queue.Items.Add(query);
\r
689 queueWindow.Show();
\r
693 MessageBox.Show("No Source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
697 private void showQueue()
\r
699 queueWindow.Show();
\r
704 // --------------------------------------------------------------
\r
705 // Main Window Preset System
\r
706 // --------------------------------------------------------------
\r
708 #region Preset System
\r
711 private Boolean presetStatus = false;
\r
714 private void btn_presets_Click(object sender, EventArgs e)
\r
716 if (presetStatus == false)
\r
719 presetStatus = true;
\r
720 btn_presets.Text = "Hide Presets";
\r
725 presetStatus = false;
\r
726 btn_presets.Text = "Show Presets";
\r
731 private void btn_addPreset_Click(object sender, EventArgs e)
\r
736 private void btn_removePreset_Click(object sender, EventArgs e)
\r
738 ListBox_Presets.Items.Remove(ListBox_Presets.SelectedItem);
\r
741 private void btn_setDefault_Click(object sender, EventArgs e)
\r
744 Properties.Settings.Default.DVDSource = text_source.Text;
\r
745 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
746 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
747 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
749 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
750 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
751 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
752 Properties.Settings.Default.Width = text_width.Text;
\r
753 Properties.Settings.Default.Height = text_height.Text;
\r
754 //Picture Settings Tab
\r
755 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
756 Properties.Settings.Default.CropTop = text_top.Text;
\r
757 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
758 Properties.Settings.Default.CropLeft = text_left.Text;
\r
759 Properties.Settings.Default.CropRight = text_right.Text;
\r
760 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
761 //Video Settings Tab
\r
762 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
763 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
764 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
765 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
766 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
767 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
768 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
769 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
770 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
771 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
772 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
773 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
774 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
775 //Audio Settings Tab
\r
776 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
777 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
778 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
780 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
781 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
782 Properties.Settings.Default.SelectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
783 Properties.Settings.Default.Save();
\r
787 // Preset Seleciton
\r
788 private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)
\r
790 string selectedPreset = null;
\r
791 if (ListBox_Presets.SelectedItem != null)
\r
793 selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
797 selectedPreset = "";
\r
800 switch (selectedPreset)
\r
803 setGuiSetttings(CheckState.Checked, "", "", "H.264", "1000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=5:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=5:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip:filter=2,2", "Origional (Fast)", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Apple Animation)");
\r
807 setGuiSetttings(CheckState.Checked, "", "", "H.264", "2500", "", 0, "0%", "160", CheckState.Checked, "48", "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Apple TV)");
\r
810 setGuiSetttings(CheckState.Checked, "", "", "H.264", "1800", "", 0, "0%", "160", CheckState.Checked, "48", "ref=16:mixed-refs:bframes=6:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=7:me-range=64:analyse=all:8x8dct:trellis=2:no-fast-pskip:no-dct-decimate:filter=-2,-1", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Bedlam)");
\r
814 setGuiSetttings(CheckState.Unchecked, "512", "", "H.264", "512", "", 0, "0%", "128", CheckState.Checked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Blind)");
\r
817 setGuiSetttings(CheckState.Unchecked, "640", "", "H.264", "", "695", 0, "0%", "128", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=6:bime:weightb:b-rdo:b-pyramid::direct=auto:me=umh:subme=6:trellis=1:analyse=all:8x8dct:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Broke)");
\r
820 setGuiSetttings(CheckState.Unchecked, "", "", "H.264", "1000", "", 0, "0%", "160", CheckState.Unchecked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: Classic)");
\r
822 case "Constant Quality Rate":
\r
823 setGuiSetttings(CheckState.Checked, "", "", "H.264", "", "", 64, "64%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AC3", "Output Settings (Preset: CQR)");
\r
826 case "Deux Six Quatre":
\r
827 setGuiSetttings(CheckState.Checked, "", "", "H.264", "1600", "", 0, "0%", "160", CheckState.Checked, "48", "ref=5:mixed-refs:bframes=3:bime:weightb:b-rdo:b-pyramid:me=umh:subme=7:trellis=1:analyse=all:8x8dct:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AC3", "Output Settings (Preset: DSQ)");
\r
831 setGuiSetttings(CheckState.Checked, "", "", "H.264", "2000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AC3", "Output Settings (Preset: Film)");
\r
835 setGuiSetttings(CheckState.Unchecked, "480", "", "H.264", "960", "", 0, "0%", "128", CheckState.Checked, "48", "cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPhone)");
\r
837 case "iPod High-Rez":
\r
838 setGuiSetttings(CheckState.Unchecked, "640", "", "H.264", "1500", "", 0, "0%", "160", CheckState.Checked, "48", "keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=1500:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPod High Rez)");
\r
840 case "iPod Low-Rez":
\r
841 setGuiSetttings(CheckState.Unchecked, "320", "", "H.264", "700", "", 0, "0%", "160", CheckState.Checked, "48", "keyint=300:keyint-min=30:bframes=0:cabac=0:ref=1:vbv-maxrate=768:vbv-bufsize=2000:analyse=all:me=umh:subme=6:no-fast-pskip=1", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: iPod Low Rez)");
\r
844 setGuiSetttings(CheckState.Checked, "", "", "H.264", "1500", "", 0, "0%", "160", CheckState.Checked, "48", "ref=2:bframes=2:subme=5:me=umh", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Normal)");
\r
847 setGuiSetttings(CheckState.Checked, "", "", "H.264", "2500", "", 0, "0%", "160", CheckState.Checked, "48", "level=41:subme=5:me=umh", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: PS3)");
\r
850 setGuiSetttings(CheckState.Unchecked, "368", "208", "Mpeg 4", "1024", "", 0, "0%", "160", CheckState.Unchecked, "48", "", "None", CheckState.Unchecked, "No Crop", CheckState.Unchecked, "AAC", "Output Settings (Preset: PSP)");
\r
853 setGuiSetttings(CheckState.Checked, "", "", "H.264", "2000", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct-auto:me=umh:subme=5:analyse=all:8x8dct:trellis=1:no-fast-pskip", "None", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Quicktime)");
\r
856 setGuiSetttings(CheckState.Unchecked, "", "", "H.264", "1300", "", 0, "0%", "160", CheckState.Checked, "48", "ref=3:mixed-refs:bframes=6:bime:weightb:direct=auto:b-pyramid:me=umh:subme=6:analyse=all:8x8dct:trellis=1:nr=150:no-fast-pskip", "Origional (Fast)", CheckState.Checked, "No Crop", CheckState.Checked, "AAC", "Output Settings (Preset: Television)");
\r
868 // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.
\r
869 private void setGuiSetttings(CheckState anamorphic, string width, string height, string vencoder, string bitrate, string filesize, int quality, string qpercent, string audioBit, CheckState chpt, string audioSample, string h264, string deinterlace, CheckState twopass, string crop, CheckState turbo, string audioCodec, string preset)
\r
871 CheckPixelRatio.CheckState = anamorphic;
\r
872 text_width.Text = width;
\r
873 text_height.Text = height;
\r
874 drp_videoEncoder.Text = vencoder;
\r
875 text_bitrate.Text = bitrate;
\r
876 text_filesize.Text = filesize;
\r
877 slider_videoQuality.Value = quality;
\r
878 SliderValue.Text = qpercent;
\r
879 drp_audioBitrate.Text = audioBit;
\r
880 Check_ChapterMarkers.CheckState = chpt;
\r
881 drp_audioSampleRate.Text = audioSample;
\r
882 rtf_h264advanced.Text = h264;
\r
883 drp_deInterlace_option.Text = deinterlace;
\r
884 check_2PassEncode.CheckState = twopass;
\r
885 drp_crop.Text = crop;
\r
886 check_turbo.CheckState = turbo;
\r
887 drp_audioCodec.Text = audioCodec;
\r
889 groupBox_output.Text = preset;
\r
892 private void setMkv()
\r
894 // Set file extension to MKV
\r
895 string destination = text_destination.Text;
\r
896 destination = destination.Replace(".mp4", ".mkv");
\r
897 destination = destination.Replace(".avi", ".mkv");
\r
898 destination = destination.Replace(".m4v", ".mkv");
\r
899 destination = destination.Replace(".ogm", ".mkv");
\r
900 text_destination.Text = destination;
\r
905 //---------------------------------------------------
\r
906 // Encode / Cancel Buttons
\r
907 // Encode Progress Text Handler
\r
908 //---------------------------------------------------
\r
912 Functions.CLI process = new Functions.CLI();
\r
914 private void btn_encode_Click(object sender, EventArgs e)
\r
916 //btn_eCancel.Enabled = true;
\r
917 String query = "";
\r
918 if (QueryEditorText.Text == "")
\r
920 query = GenerateTheQuery();
\r
924 query = QueryEditorText.Text;
\r
927 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
928 lbl_encode.Visible = true;
\r
929 lbl_encode.Text = "Encoding in Progress";
\r
932 private void btn_eCancel_Click(object sender, EventArgs e)
\r
936 lbl_encode.Text = "Encoding Canceled";
\r
940 [DllImport("user32.dll")]
\r
941 public static extern void LockWorkStation();
\r
942 [DllImport("user32.dll")]
\r
943 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
945 private void procMonitor(object state)
\r
947 // Make sure we are not already encoding and if we are then display an error.
\r
948 if (hbProc != null)
\r
950 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
954 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
955 hbProc.WaitForExit();
\r
960 //*****************************************************************************************
\r
962 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
963 // video stream which has mild corruption issues every few seconds.
\r
964 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
965 //*****************************************************************************************
\r
968 /*Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
\r
969 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
970 while (!encode.EndOfStream)
\r
975 hbProc.WaitForExit();
\r
976 process.closeCLI();
\r
988 // Do something whent he encode ends.
\r
989 switch (Properties.Settings.Default.CompletionOption)
\r
992 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
995 ExitWindowsEx(0, 0);
\r
998 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
1001 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
1003 case "Lock System":
\r
1004 LockWorkStation();
\r
1006 case "Quit HandBrake":
\r
1007 Application.Exit();
\r
1015 private delegate void UpdateUIHandler();
\r
1017 private void setEncodeLabel()
\r
1019 if (this.InvokeRequired)
\r
1021 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
1024 lbl_encode.Text = "Encoding Finished";
\r
1027 /*private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
1030 if (this.InvokeRequired)
\r
1032 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
1033 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
1036 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
1041 //---------------------------------------------------
\r
1042 // Items that require actions on frmMain
\r
1043 //---------------------------------------------------
\r
1045 #region frmMain Actions
\r
1047 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
1049 drop_chapterStart.BackColor = Color.White;
\r
1050 QueryEditorText.Text = "";
\r
1051 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1055 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1056 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1058 if (chapterFinish < chapterStart)
\r
1060 drop_chapterStart.BackColor = Color.LightCoral;
\r
1065 drop_chapterStart.BackColor = Color.LightCoral;
\r
1072 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1074 drop_chapterFinish.BackColor = Color.White;
\r
1075 QueryEditorText.Text = "";
\r
1076 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1080 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1081 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1083 if (chapterFinish < chapterStart)
\r
1085 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1090 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1095 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1097 text_filesize.Text = "";
\r
1098 slider_videoQuality.Value = 0;
\r
1099 SliderValue.Text = "0%";
\r
1100 CheckCRF.CheckState = CheckState.Unchecked;
\r
1101 CheckCRF.Enabled = false;
\r
1104 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1106 text_bitrate.Text = "";
\r
1107 slider_videoQuality.Value = 0;
\r
1108 SliderValue.Text = "0%";
\r
1109 CheckCRF.CheckState = CheckState.Unchecked;
\r
1110 CheckCRF.Enabled = false;
\r
1113 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1115 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1116 text_bitrate.Text = "";
\r
1117 text_filesize.Text = "";
\r
1118 CheckCRF.Enabled = true;
\r
1121 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1123 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1126 private void text_width_TextChanged(object sender, EventArgs e)
\r
1131 if (CheckPixelRatio.Checked)
\r
1133 text_width.Text = "";
\r
1134 text_width.BackColor = Color.White;
\r
1138 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1140 text_width.BackColor = Color.LightCoral;
\r
1144 text_width.BackColor = Color.LightGreen;
\r
1148 if (lbl_Aspect.Text != "Select a Title")
\r
1150 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1151 double mod16 = height % 16;
\r
1152 height = height - mod16;
\r
1154 if (text_width.Text == "")
\r
1156 text_height.Text = "";
\r
1157 text_width.BackColor = Color.White;
\r
1161 text_height.Text = height.ToString();
\r
1167 // No need to throw an error here.
\r
1168 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1174 private void text_height_TextChanged(object sender, EventArgs e)
\r
1178 if (text_height.Text != "Auto")
\r
1180 if (CheckPixelRatio.Checked)
\r
1182 text_height.Text = "";
\r
1183 text_width.BackColor = Color.White;
\r
1187 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1189 text_height.BackColor = Color.LightCoral;
\r
1193 text_height.BackColor = Color.LightGreen;
\r
1197 } catch(Exception){
\r
1198 // No need to alert the user.
\r
1202 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1204 if ((string)drp_crop.SelectedItem == "Manual")
\r
1206 text_left.Enabled = true;
\r
1207 text_right.Enabled = true;
\r
1208 text_top.Enabled = true;
\r
1209 text_bottom.Enabled = true;
\r
1212 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1214 text_left.Enabled = false;
\r
1215 text_right.Enabled = false;
\r
1216 text_top.Enabled = false;
\r
1217 text_bottom.Enabled = false;
\r
1218 text_left.Text = "";
\r
1219 text_right.Text = "";
\r
1220 text_top.Text = "";
\r
1221 text_bottom.Text = "";
\r
1223 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1225 string[] temp = new string[4];
\r
1226 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1227 text_left.Text = temp[2];
\r
1228 text_right.Text = temp[3];
\r
1229 text_top.Text = temp[0];
\r
1230 text_bottom.Text = temp[1];
\r
1234 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1236 text_left.Enabled = false;
\r
1237 text_right.Enabled = false;
\r
1238 text_top.Enabled = false;
\r
1239 text_bottom.Enabled = false;
\r
1240 text_left.Text = "0";
\r
1241 text_right.Text = "0";
\r
1242 text_top.Text = "0";
\r
1243 text_bottom.Text = "0";
\r
1248 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1250 text_width.Text = "";
\r
1251 text_height.Text = "";
\r
1252 text_width.BackColor = Color.White;
\r
1253 text_height.BackColor = Color.White;
\r
1256 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1258 if (drp_dvdtitle.Items.Count == 0)
\r
1260 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
1264 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1267 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1269 drp_audioMixDown.Items.Clear();
\r
1271 if (drp_audioCodec.Text == "AAC")
\r
1273 drp_audioMixDown.Items.Clear();
\r
1274 drp_audioMixDown.Items.Add("Mono");
\r
1275 drp_audioMixDown.Items.Add("Stereo");
\r
1276 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1277 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1278 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1280 drp_audioBitrate.Items.Clear();
\r
1281 drp_audioBitrate.Items.Add("32");
\r
1282 drp_audioBitrate.Items.Add("40");
\r
1283 drp_audioBitrate.Items.Add("48");
\r
1284 drp_audioBitrate.Items.Add("56");
\r
1285 drp_audioBitrate.Items.Add("64");
\r
1286 drp_audioBitrate.Items.Add("80");
\r
1287 drp_audioBitrate.Items.Add("86");
\r
1288 drp_audioBitrate.Items.Add("112");
\r
1289 drp_audioBitrate.Items.Add("128");
\r
1290 drp_audioBitrate.Items.Add("160");
\r
1295 drp_audioMixDown.Items.Clear();
\r
1296 drp_audioMixDown.Items.Add("Stereo");
\r
1297 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1298 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1300 drp_audioBitrate.Items.Clear();
\r
1301 drp_audioBitrate.Items.Add("32");
\r
1302 drp_audioBitrate.Items.Add("40");
\r
1303 drp_audioBitrate.Items.Add("48");
\r
1304 drp_audioBitrate.Items.Add("56");
\r
1305 drp_audioBitrate.Items.Add("64");
\r
1306 drp_audioBitrate.Items.Add("80");
\r
1307 drp_audioBitrate.Items.Add("86");
\r
1308 drp_audioBitrate.Items.Add("112");
\r
1309 drp_audioBitrate.Items.Add("128");
\r
1310 drp_audioBitrate.Items.Add("160");
\r
1311 drp_audioBitrate.Items.Add("192");
\r
1312 drp_audioBitrate.Items.Add("224");
\r
1313 drp_audioBitrate.Items.Add("256");
\r
1314 drp_audioBitrate.Items.Add("320");
\r
1318 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1320 if (drp_audioCodec.Text == "AAC")
\r
1322 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1325 drp_audioBitrate.Items.Clear();
\r
1326 drp_audioBitrate.Items.Add("32");
\r
1327 drp_audioBitrate.Items.Add("40");
\r
1328 drp_audioBitrate.Items.Add("48");
\r
1329 drp_audioBitrate.Items.Add("56");
\r
1330 drp_audioBitrate.Items.Add("64");
\r
1331 drp_audioBitrate.Items.Add("80");
\r
1332 drp_audioBitrate.Items.Add("86");
\r
1333 drp_audioBitrate.Items.Add("112");
\r
1334 drp_audioBitrate.Items.Add("128");
\r
1335 drp_audioBitrate.Items.Add("160");
\r
1336 drp_audioBitrate.Items.Add("192");
\r
1337 drp_audioBitrate.Items.Add("224");
\r
1338 drp_audioBitrate.Items.Add("256");
\r
1339 drp_audioBitrate.Items.Add("320");
\r
1340 drp_audioBitrate.Items.Add("384");
\r
1345 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1347 if (Check_ChapterMarkers.Checked)
\r
1349 string destination = text_destination.Text;
\r
1350 destination = destination.Replace(".mp4", ".m4v");
\r
1351 text_destination.Text = destination;
\r
1355 string destination = text_destination.Text;
\r
1356 destination = destination.Replace(".m4v", ".mp4");
\r
1357 text_destination.Text = destination;
\r
1361 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1363 if (!text_destination.Text.Contains(".mp4"))
\r
1365 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1366 check_largeFile.CheckState = CheckState.Unchecked;
\r
1370 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1372 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1373 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1375 check_turbo.CheckState = CheckState.Unchecked;
\r
1376 CheckCRF.CheckState = CheckState.Unchecked;
\r
1377 CheckCRF.Enabled = false;
\r
1378 check_turbo.Enabled = false;
\r
1379 h264Tab.Enabled = false;
\r
1383 CheckCRF.Enabled = true;
\r
1384 check_turbo.Enabled = true;
\r
1385 h264Tab.Enabled = true;
\r
1390 public void setStreamReader(Parsing.DVD dvd)
\r
1392 this.thisDVD = dvd;
\r
1395 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1397 // Reset some values on the form
\r
1398 lbl_Aspect.Text = "Select a Title";
\r
1399 lbl_RecomendedCrop.Text = "Select a Title";
\r
1400 drop_chapterStart.Items.Clear();
\r
1401 drop_chapterFinish.Items.Clear();
\r
1402 QueryEditorText.Text = "";
\r
1404 // If the dropdown is set to automatic nothing else needs to be done.
\r
1405 // Otheriwse if its not, title data has to be loased from parsing.
\r
1406 if (drp_dvdtitle.Text != "Automatic")
\r
1408 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1410 // Set the Aspect Ratio
\r
1411 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1413 // Set the Recommended Cropping values
\r
1414 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1416 // Populate the Start chapter Dropdown
\r
1417 drop_chapterStart.Items.Clear();
\r
1418 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1419 if (drop_chapterStart.Items.Count > 0)
\r
1421 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1424 // Populate the Final Chapter Dropdown
\r
1425 drop_chapterFinish.Items.Clear();
\r
1426 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1427 if (drop_chapterFinish.Items.Count > 0)
\r
1429 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1432 // Populate the Audio Channels Dropdown
\r
1433 drp_audioChannels.Items.Clear();
\r
1434 drp_audioChannels.Items.Add("Automatic");
\r
1435 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1436 if (drp_audioChannels.Items.Count > 0)
\r
1438 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1441 // Populate the Subtitles dropdown
\r
1442 drp_subtitle.Items.Clear();
\r
1443 drp_subtitle.Items.Add("None");
\r
1444 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1445 if (drp_subtitle.Items.Count > 0)
\r
1447 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1454 //---------------------------------------------------
\r
1456 // - Query Generation
\r
1457 //---------------------------------------------------
\r
1459 #region Program Functions
\r
1461 public string GenerateTheQuery()
\r
1463 string source = text_source.Text;
\r
1464 string dvdTitle = drp_dvdtitle.Text;
\r
1465 string chapterStart = drop_chapterStart.Text;
\r
1466 string chapterFinish = drop_chapterFinish.Text;
\r
1467 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1468 string dvdChapter = "";
\r
1471 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1474 source = " -i " + '"' + source+ '"'; //'"'+
\r
1477 if (dvdTitle == "Automatic")
\r
1481 string[] titleInfo = dvdTitle.Split(' ');
\r
1482 dvdTitle = " -t "+ titleInfo[0];
\r
1485 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1487 else if (chapterFinish == chapterStart)
\r
1488 dvdChapter = " -c " + chapterStart;
\r
1490 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1492 string querySource = source+ dvdTitle+ dvdChapter;
\r
1493 // ----------------------------------------------------------------------
\r
1497 string destination = text_destination.Text;
\r
1498 string videoEncoder = drp_videoEncoder.Text;
\r
1499 string audioEncoder = drp_audioCodec.Text;
\r
1500 string width = text_width.Text;
\r
1501 string height = text_height.Text;
\r
1503 if (destination == "")
\r
1504 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1506 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1509 switch (videoEncoder)
\r
1512 videoEncoder = " -e ffmpeg";
\r
1515 videoEncoder = " -e xvid";
\r
1518 videoEncoder = " -e x264";
\r
1520 case "H.264 Baseline 1.3":
\r
1521 videoEncoder = " -e x264b13";
\r
1523 case "H.264 (iPod)":
\r
1524 videoEncoder = " -e x264b30";
\r
1527 videoEncoder = " -e x264";
\r
1531 switch (audioEncoder)
\r
1534 audioEncoder = " -E faac";
\r
1537 audioEncoder = " -E lame";
\r
1540 audioEncoder = " -E vorbis";
\r
1543 audioEncoder = " -E ac3";
\r
1546 audioEncoder = " -E faac";
\r
1551 width = " -w "+ width;
\r
1554 if (height == "Auto")
\r
1558 else if (height != "")
\r
1560 height = " -l " + height;
\r
1564 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1565 // ----------------------------------------------------------------------
\r
1567 // Picture Settings Tab
\r
1569 string cropSetting = drp_crop.Text;
\r
1570 string cropTop = text_top.Text;
\r
1571 string cropBottom = text_bottom.Text;
\r
1572 string cropLeft = text_left.Text;
\r
1573 string cropRight = text_right.Text;
\r
1574 string subtitles = drp_subtitle.Text;
\r
1575 string cropOut = "";
\r
1576 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1577 string deinterlace = "";
\r
1578 string grayscale = "";
\r
1579 string pixelRatio = "";
\r
1580 string ChapterMarkers = "";
\r
1581 // Returns Crop Query
\r
1583 if (cropSetting == "Auto Crop")
\r
1585 else if (cropSetting == "No Crop")
\r
1586 cropOut = " --crop 0:0:0:0 ";
\r
1589 if (text_top.Text == "")
\r
1591 if (text_bottom.Text == "")
\r
1593 if (text_left.Text == "")
\r
1595 if (text_right.Text == "")
\r
1598 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1601 if (subtitles == "None")
\r
1603 else if (subtitles == "")
\r
1608 tempSub = subtitles.Split(' ');
\r
1609 subtitles = " -s "+ tempSub[0];
\r
1612 switch (deInterlace_Option)
\r
1617 case "Origional (Fast)":
\r
1618 deinterlace = " --deinterlace=1";
\r
1620 case "yadif (Slow)":
\r
1621 deinterlace = " --deinterlace=" + '"' + "0" + '"';
\r
1623 case "yadif + mcdeint (Slower)":
\r
1624 deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';
\r
1626 case "yadif + mcdeint (Slowest)":
\r
1627 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1634 if (check_grayscale.Checked)
\r
1635 grayscale = " -g ";
\r
1637 if (CheckPixelRatio.Checked)
\r
1638 pixelRatio = " -p ";
\r
1640 if (Check_ChapterMarkers.Checked)
\r
1641 ChapterMarkers = " -m ";
\r
1643 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1644 // ----------------------------------------------------------------------
\r
1646 // Video Settings Tab
\r
1648 string videoBitrate = text_bitrate.Text;
\r
1649 string videoFilesize = text_filesize.Text;
\r
1650 double videoQuality = slider_videoQuality.Value;
\r
1651 string vidQSetting = "";
\r
1652 string twoPassEncoding = "";
\r
1653 string videoFramerate = drp_videoFramerate.Text;
\r
1654 string turboH264 = "";
\r
1655 string largeFile = "";
\r
1656 string deblock = "";
\r
1657 string detelecine = "";
\r
1658 string denoise = "";
\r
1659 string CRF = CheckCRF.CheckState.ToString();
\r
1662 if ((CRF == "Checked"))
\r
1667 if (videoBitrate != "")
\r
1668 videoBitrate = " -b "+ videoBitrate;
\r
1670 if (videoFilesize != "")
\r
1671 videoFilesize = " -S "+ videoFilesize;
\r
1673 // Video Quality Setting
\r
1675 if ((videoQuality == 0))
\r
1679 videoQuality = videoQuality / 100;
\r
1680 if (videoQuality == 1)
\r
1682 vidQSetting = "1.0";
\r
1685 vidQSetting = " -q " + videoQuality.ToString();
\r
1688 if (check_2PassEncode.Checked)
\r
1689 twoPassEncoding = " -2 ";
\r
1691 if (videoFramerate == "Automatic")
\r
1692 videoFramerate = "";
\r
1694 videoFramerate = " -r "+ videoFramerate;
\r
1696 if (check_turbo.Checked)
\r
1697 turboH264 = " -T ";
\r
1699 if (check_largeFile.Checked)
\r
1700 largeFile = " -4 ";
\r
1702 if (check_deblock.Checked)
\r
1703 deblock = " --deblock";
\r
1705 if (check_detelecine.Checked)
\r
1706 detelecine = " --detelecine";
\r
1708 switch (drp_deNoise.Text)
\r
1714 denoise = " --denoise=2:1:2:3";
\r
1717 denoise = " --denoise=3:2:2:3";
\r
1720 denoise = " --denoise=7:7:5:5";
\r
1727 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1728 // ----------------------------------------------------------------------
\r
1730 // Audio Settings Tab
\r
1732 string audioBitrate = drp_audioBitrate.Text;
\r
1733 string audioSampleRate = drp_audioSampleRate.Text;
\r
1734 string audioChannels = drp_audioChannels.Text;
\r
1735 string Mixdown = drp_audioMixDown.Text;
\r
1736 string SixChannelAudio = "";
\r
1738 if (audioBitrate != "")
\r
1739 audioBitrate = " -B "+ audioBitrate;
\r
1741 if (audioSampleRate != "")
\r
1742 audioSampleRate = " -R "+ audioSampleRate;
\r
1744 if (audioChannels == "Automatic")
\r
1745 audioChannels = "";
\r
1746 else if (audioChannels == "")
\r
1747 audioChannels = "";
\r
1751 tempSub = audioChannels.Split(' ');
\r
1752 audioChannels = " -a "+ tempSub[0];
\r
1764 Mixdown = "stereo";
\r
1766 case "Dolby Surround":
\r
1769 case "Dolby Pro Logic II":
\r
1772 case "6 Channel Discrete":
\r
1776 Mixdown = "stero";
\r
1780 if (Mixdown != "")
\r
1781 SixChannelAudio = " -6 "+ Mixdown;
\r
1783 SixChannelAudio = "";
\r
1785 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1786 // ----------------------------------------------------------------------
\r
1791 string h264Advanced = rtf_h264advanced.Text;
\r
1793 if ((h264Advanced == ""))
\r
1794 h264Advanced = "";
\r
1796 h264Advanced = " -x "+ h264Advanced;
\r
1799 string h264Settings = h264Advanced;
\r
1800 // ----------------------------------------------------------------------
\r
1802 // Processors (Program Settings)
\r
1804 string processors = Properties.Settings.Default.Processors;
\r
1805 // Number of Processors Handler
\r
1807 if (processors == "Automatic")
\r
1810 processors = " -C "+ processors+ " ";
\r
1813 string queryAdvancedSettings = processors;
\r
1814 // ----------------------------------------------------------------------
\r
1816 // Verbose option (Program Settings)
\r
1818 string verbose = "";
\r
1819 if (Properties.Settings.Default.verbose == "Checked")
\r
1822 // ----------------------------------------------------------------------
\r
1824 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1829 // This is the END of the road ------------------------------------------------------------------------------
\r