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
34 // Load the splash screen on another thread. Once completed wait for 1 second.
\r
35 ThreadPool.QueueUserWorkItem(showSplash);
\r
38 InitializeComponent();
\r
40 // This is a quick Hack fix for the cross-thread problem with frmDvdIndo ************************
\r
41 //dvdInfoWindow.Show();
\r
42 //dvdInfoWindow.Hide();
\r
43 // **********************************************************************************************
\r
45 // Set the Version number lable to the corect version.
\r
46 Version.Text = "Version " + Properties.Settings.Default.CliVersion;
\r
48 // Run the update checker.
\r
51 // Now load the users default if required. (Will overide the above setting)
\r
54 // Enable or disable tooltips
\r
57 // Hide the presets part of the window
\r
63 * This code can be used for storing preset and preset name information in future versions.
\r
64 * Please ignore it for the moment.
\r
65 // Create and initialize a new StringCollection.
\r
66 StringCollection myCol = new StringCollection();
\r
67 // Add a range of elements from an array to the end of the StringCollection.
\r
68 String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" };
\r
69 myCol.AddRange(myArr);
\r
70 Properties.Settings.Default.BuiltInPresets = myCol;
\r
71 MessageBox.Show(Properties.Settings.Default.BuiltInPresets.ToString());
\r
75 private void showSplash(object sender)
\r
77 // Display splash screen for 1.5 Seconds
\r
78 Form splash = new frmSplashScreen();
\r
80 Thread.Sleep(1500);
\r
81 splash.Close(); // Then close.
\r
84 private void loadUserDefaults()
\r
88 // Load the users default settings or if the user has not got this option enabled, load the normal preset.
\r
89 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
92 text_source.Text = Properties.Settings.Default.DVDSource;
\r
93 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
94 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
95 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
98 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
99 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
100 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
101 text_width.Text = Properties.Settings.Default.Width;
\r
102 text_height.Text = Properties.Settings.Default.Height;
\r
104 // Picture Settings Tab
\r
105 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
106 text_top.Text = Properties.Settings.Default.CropTop;
\r
107 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
108 text_left.Text = Properties.Settings.Default.CropLeft;
\r
109 text_right.Text = Properties.Settings.Default.CropRight;
\r
110 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
112 // Video Settings Tab
\r
113 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
114 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
115 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
117 if (Properties.Settings.Default.TwoPass == "Checked")
\r
119 check_2PassEncode.CheckState = CheckState.Checked;
\r
122 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
123 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
125 if (Properties.Settings.Default.detelecine == "Checked")
\r
127 check_detelecine.CheckState = CheckState.Checked;
\r
130 if (Properties.Settings.Default.detelecine == "Checked")
\r
132 check_deblock.CheckState = CheckState.Checked;
\r
136 if (Properties.Settings.Default.Grayscale == "Checked")
\r
138 check_grayscale.CheckState = CheckState.Checked;
\r
141 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
143 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
145 CheckPixelRatio.CheckState = CheckState.Checked;
\r
147 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
149 check_turbo.CheckState = CheckState.Checked;
\r
151 if (Properties.Settings.Default.largeFile == "Checked")
\r
153 check_largeFile.CheckState = CheckState.Checked;
\r
156 if (Properties.Settings.Default.chapterMarker == "Checked")
\r
158 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
161 // Audio Settings Tab
\r
162 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
163 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
164 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
167 if (Properties.Settings.Default.CRF == "Checked")
\r
169 CheckCRF.CheckState = CheckState.Checked;
\r
171 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
173 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.selectedPreset + ")";
\r
177 // Load the default preset on lauch
\r
178 ListBox_Presets.SelectedItem = "Normal";
\r
183 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
187 private Boolean updateCheck()
\r
191 if (Properties.Settings.Default.updateStatus == "Checked")
\r
193 String updateFile = Properties.Settings.Default.updateFile;
\r
194 WebClient client = new WebClient();
\r
195 String data = client.DownloadString(updateFile);
\r
196 String[] versionData = data.Split('\n');
\r
198 int verdata = int.Parse(versionData[0].Replace(".", ""));
\r
199 int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));
\r
200 int verd1 = int.Parse(versionData[1].Replace(".", ""));
\r
201 int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));
\r
203 Boolean update = ((verdata > vergui) || (verd1 > cliversion));
\r
205 lbl_update.Visible = update;
\r
216 // Silently ignore the error
\r
221 private void tooltip()
\r
223 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
225 ToolTip.Active = true;
\r
229 private void showPresets()
\r
231 if (Properties.Settings.Default.showPresets == "Checked")
\r
233 btn_presets.Visible = false;
\r
241 // --------------------------------------------------------------
\r
242 // The main Menu bar.
\r
243 // --------------------------------------------------------------
\r
247 private void mnu_exit_Click(object sender, EventArgs e)
\r
249 Application.Exit();
\r
256 private void mnu_encode_Click(object sender, EventArgs e)
\r
261 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
263 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
264 dvdInfoWindow.Show();
\r
267 private void mnu_options_Click(object sender, EventArgs e)
\r
269 Form Options = new frmOptions();
\r
270 Options.ShowDialog();
\r
275 #region Presets Menu
\r
277 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
279 ListBox_Presets.Items.Clear();
\r
280 ListBox_Presets.Items.Add("Animation");
\r
281 ListBox_Presets.Items.Add("AppleTV");
\r
282 ListBox_Presets.Items.Add("Bedlam");
\r
283 ListBox_Presets.Items.Add("Blind");
\r
284 ListBox_Presets.Items.Add("Broke");
\r
285 ListBox_Presets.Items.Add("Classic");
\r
286 ListBox_Presets.Items.Add("Constant Quality Rate");
\r
287 ListBox_Presets.Items.Add("Deux Six Quatre");
\r
288 ListBox_Presets.Items.Add("Film");
\r
289 ListBox_Presets.Items.Add("iPhone");
\r
290 ListBox_Presets.Items.Add("iPod High-Rez");
\r
291 ListBox_Presets.Items.Add("iPod Low-Rez");
\r
292 ListBox_Presets.Items.Add("Normal");
\r
293 ListBox_Presets.Items.Add("PS3");
\r
294 ListBox_Presets.Items.Add("PSP");
\r
295 ListBox_Presets.Items.Add("QuickTime");
\r
296 ListBox_Presets.Items.Add("Television");
\r
298 if (presetStatus == false)
\r
301 presetStatus = true;
\r
302 btn_presets.Text = "Hide Presets";
\r
306 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
308 ListBox_Presets.SelectedItem = "Normal";
\r
309 if (presetStatus == false)
\r
312 presetStatus = true;
\r
313 btn_presets.Text = "Hide Presets";
\r
322 private void mnu_quickStart_Click(object sender, EventArgs e)
\r
324 Form QuickStart = new frmQuickStart();
\r
325 QuickStart.ShowDialog();
\r
328 private void mnu_wiki_Click(object sender, EventArgs e)
\r
330 Process.Start("http://handbrake.m0k.org/trac");
\r
333 private void mnu_faq_Click(object sender, EventArgs e)
\r
335 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
338 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
340 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
343 private void mnu_homepage_Click(object sender, EventArgs e)
\r
345 Process.Start("http://handbrake.m0k.org");
\r
348 private void mnu_forum_Click(object sender, EventArgs e)
\r
350 Process.Start("http://handbrake.m0k.org/forum");
\r
353 private void mnu_UpdateCheck_Click(object sender, EventArgs e)
\r
355 Boolean update = updateCheck();
\r
356 if (update == true)
\r
358 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
362 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
366 private void mnu_about_Click(object sender, EventArgs e)
\r
368 Form About = new frmAbout();
\r
369 About.ShowDialog();
\r
374 // --------------------------------------------------------------
\r
375 // Buttons on the main Window
\r
376 // --------------------------------------------------------------
\r
380 private void btn_Browse_Click(object sender, EventArgs e)
\r
382 String filename = "";
\r
383 text_source.Text = "";
\r
384 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
385 if (RadioDVD.Checked)
\r
387 DVD_Open.ShowDialog();
\r
388 filename = DVD_Open.SelectedPath;
\r
389 if (filename != "")
\r
391 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
392 text_source.Text = filename;
\r
393 frmRD.ShowDialog();
\r
398 ISO_Open.ShowDialog();
\r
399 filename = ISO_Open.FileName;
\r
400 if (filename != "")
\r
402 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
403 text_source.Text = filename;
\r
404 frmRD.ShowDialog();
\r
408 // Check if there was titles in the dvd title dropdown
\r
409 if (filename == "")
\r
411 text_source.Text = "Click 'Browse' to continue";
\r
414 // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.
\r
415 if (drp_dvdtitle.Items.Count == 0)
\r
417 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
421 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
423 DVD_Save.ShowDialog();
\r
424 text_destination.Text = DVD_Save.FileName;
\r
426 if (Check_ChapterMarkers.Checked)
\r
428 string destination = text_destination.Text;
\r
429 destination = destination.Replace(".mp4", ".m4v");
\r
430 text_destination.Text = destination;
\r
434 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
436 rtf_h264advanced.Text = "";
\r
439 private void GenerateQuery_Click(object sender, EventArgs e)
\r
441 String query = GenerateTheQuery();
\r
442 QueryEditorText.Text = query;
\r
445 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
447 QueryEditorText.Text = "";
\r
450 private void btn_queue_Click(object sender, EventArgs e)
\r
452 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
453 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
457 if (QueryEditorText.Text == "")
\r
459 query = GenerateTheQuery();
\r
463 query = QueryEditorText.Text;
\r
465 queueWindow.list_queue.Items.Add(query);
\r
466 queueWindow.Show();
\r
470 private void btn_copy_Click(object sender, EventArgs e)
\r
472 if (QueryEditorText.Text != "")
\r
473 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);
\r
476 private void showQueue()
\r
478 queueWindow.Show();
\r
483 // --------------------------------------------------------------
\r
484 // Main Window Preset System
\r
485 // --------------------------------------------------------------
\r
487 #region Preset System
\r
490 private Boolean presetStatus = false;
\r
493 private void btn_presets_Click(object sender, EventArgs e)
\r
495 if (presetStatus == false)
\r
498 presetStatus = true;
\r
499 btn_presets.Text = "Hide Presets";
\r
504 presetStatus = false;
\r
505 btn_presets.Text = "Show Presets";
\r
510 private void btn_addPreset_Click(object sender, EventArgs e)
\r
513 File_Open.ShowDialog();
\r
514 filename = File_Open.FileName;
\r
515 if (filename != "")
\r
519 // Create StreamReader & open file
\r
520 StreamReader line = new StreamReader(filename);
\r
521 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
523 // Read in the data and set the correct GUI component with the setting.
\r
524 text_source.Text = line.ReadLine();
\r
525 drp_dvdtitle.Text = line.ReadLine();
\r
526 drop_chapterStart.Text = line.ReadLine();
\r
527 drop_chapterFinish.Text = line.ReadLine();
\r
528 text_destination.Text = line.ReadLine();
\r
529 drp_videoEncoder.Text = line.ReadLine();
\r
530 drp_audioCodec.Text = line.ReadLine();
\r
531 text_width.Text = line.ReadLine();
\r
532 text_height.Text = line.ReadLine();
\r
533 text_top.Text = line.ReadLine();
\r
534 text_bottom.Text = line.ReadLine();
\r
535 text_left.Text = line.ReadLine();
\r
536 text_right.Text = line.ReadLine();
\r
537 drp_subtitle.Text = line.ReadLine();
\r
538 text_bitrate.Text = line.ReadLine();
\r
539 text_filesize.Text = line.ReadLine();
\r
540 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
542 temporyLine = line.ReadLine();
\r
543 if (temporyLine == "Checked")
\r
545 check_2PassEncode.CheckState = CheckState.Checked;
\r
548 drp_deInterlace_option.Text = line.ReadLine();
\r
550 temporyLine = line.ReadLine();
\r
551 if (temporyLine == "Checked")
\r
553 check_grayscale.CheckState = CheckState.Checked;
\r
556 drp_videoFramerate.Text = line.ReadLine();
\r
558 temporyLine = line.ReadLine();
\r
559 if (temporyLine == "Checked")
\r
561 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
564 temporyLine = line.ReadLine();
\r
565 if (temporyLine == "Checked")
\r
567 CheckPixelRatio.CheckState = CheckState.Checked;
\r
570 temporyLine = line.ReadLine();
\r
571 if (temporyLine == "Checked")
\r
573 check_turbo.CheckState = CheckState.Checked;
\r
576 temporyLine = line.ReadLine();
\r
577 if (temporyLine == "Checked")
\r
579 check_largeFile.CheckState = CheckState.Checked;
\r
582 drp_audioBitrate.Text = line.ReadLine();
\r
583 drp_audioSampleRate.Text = line.ReadLine();
\r
584 drp_audioChannels.Text = line.ReadLine();
\r
585 drp_audioMixDown.Text = line.ReadLine();
\r
587 // Advanced H264 Options
\r
588 temporyLine = line.ReadLine();
\r
589 if (temporyLine == "Checked")
\r
591 CheckCRF.CheckState = CheckState.Checked;
\r
593 rtf_h264advanced.Text = line.ReadLine();
\r
595 // Close the stream
\r
599 // Fix for SliderValue not appearing when Opening saved file
\r
600 SliderValue.Text = slider_videoQuality.Value + "%";
\r
605 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
610 private void btn_removePreset_Click(object sender, EventArgs e)
\r
613 File_Save.ShowDialog();
\r
614 filename = File_Save.FileName;
\r
615 if (filename != "")
\r
619 // Create a StreamWriter and open the file
\r
620 StreamWriter line = new StreamWriter(filename);
\r
623 line.WriteLine(text_source.Text);
\r
624 line.WriteLine(drp_dvdtitle.Text);
\r
625 line.WriteLine(drop_chapterStart.Text);
\r
626 line.WriteLine(drop_chapterFinish.Text);
\r
628 line.WriteLine(text_destination.Text);
\r
629 line.WriteLine(drp_videoEncoder.Text);
\r
630 line.WriteLine(drp_audioCodec.Text);
\r
631 line.WriteLine(text_width.Text);
\r
632 line.WriteLine(text_height.Text);
\r
633 //Picture Settings Tab
\r
634 line.WriteLine(text_top.Text);
\r
635 line.WriteLine(text_bottom.Text);
\r
636 line.WriteLine(text_left.Text);
\r
637 line.WriteLine(text_right.Text);
\r
638 line.WriteLine(drp_subtitle.Text);
\r
639 //Video Settings Tab
\r
640 line.WriteLine(text_bitrate.Text);
\r
641 line.WriteLine(text_filesize.Text);
\r
642 line.WriteLine(slider_videoQuality.Value.ToString());
\r
643 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
644 line.WriteLine(drp_deInterlace_option.Text);
\r
645 line.WriteLine(check_grayscale.CheckState.ToString());
\r
646 line.WriteLine(drp_videoFramerate.Text);
\r
647 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
648 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
649 line.WriteLine(check_turbo.CheckState.ToString());
\r
650 line.WriteLine(check_largeFile.CheckState.ToString());
\r
651 //Audio Settings Tab
\r
652 line.WriteLine(drp_audioBitrate.Text);
\r
653 line.WriteLine(drp_audioSampleRate.Text);
\r
654 line.WriteLine(drp_audioChannels.Text);
\r
655 line.WriteLine(drp_audioMixDown.Text);
\r
657 line.WriteLine(CheckCRF.CheckState.ToString());
\r
658 line.WriteLine(rtf_h264advanced.Text);
\r
659 // close the stream
\r
661 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
665 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
671 private void btn_setDefault_Click(object sender, EventArgs e)
\r
674 Properties.Settings.Default.DVDSource = text_source.Text;
\r
675 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
676 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
677 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
679 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
680 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
681 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
682 Properties.Settings.Default.Width = text_width.Text;
\r
683 Properties.Settings.Default.Height = text_height.Text;
\r
684 //Picture Settings Tab
\r
685 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
686 Properties.Settings.Default.CropTop = text_top.Text;
\r
687 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
688 Properties.Settings.Default.CropLeft = text_left.Text;
\r
689 Properties.Settings.Default.CropRight = text_right.Text;
\r
690 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
691 //Video Settings Tab
\r
692 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
693 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
694 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
695 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
696 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
697 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
698 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
699 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
700 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
701 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
702 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
703 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
704 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
705 Properties.Settings.Default.chapterMarker = Check_ChapterMarkers.CheckState.ToString();
\r
706 //Audio Settings Tab
\r
707 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
708 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
709 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
711 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
712 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
715 Properties.Settings.Default.selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
717 catch (Exception exc)
\r
719 // If the user has not selected an item, then an exception may be thrown. Catch and ignore.
\r
721 Properties.Settings.Default.Save();
\r
724 // Preset Seleciton
\r
725 private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)
\r
727 string selectedPreset = null;
\r
728 if (ListBox_Presets.SelectedItem != null)
\r
730 selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
734 selectedPreset = "";
\r
737 switch (selectedPreset)
\r
740 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
744 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
747 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
751 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
754 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
757 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
759 case "Constant Quality Rate":
\r
760 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
763 case "Deux Six Quatre":
\r
764 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
768 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
771 case "iPhone / iPod Touch":
\r
772 setGuiSetttings(CheckState.Unchecked, "480", "", "H.264 (iPod)", "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
774 case "iPod High-Rez":
\r
775 setGuiSetttings(CheckState.Unchecked, "640", "", "H.264 (iPod)", "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
777 case "iPod Low-Rez":
\r
778 setGuiSetttings(CheckState.Unchecked, "320", "", "H.264 (iPod)", "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
781 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
784 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
787 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
790 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
793 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
801 // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.
\r
802 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
804 CheckPixelRatio.CheckState = anamorphic;
\r
805 text_width.Text = width;
\r
806 text_height.Text = height;
\r
807 drp_videoEncoder.Text = vencoder;
\r
808 text_bitrate.Text = bitrate;
\r
809 text_filesize.Text = filesize;
\r
810 slider_videoQuality.Value = quality;
\r
811 SliderValue.Text = qpercent;
\r
812 drp_audioBitrate.Text = audioBit;
\r
813 Check_ChapterMarkers.CheckState = chpt;
\r
814 drp_audioSampleRate.Text = audioSample;
\r
815 rtf_h264advanced.Text = h264;
\r
816 drp_deInterlace_option.Text = deinterlace;
\r
817 check_2PassEncode.CheckState = twopass;
\r
818 drp_crop.Text = crop;
\r
819 check_turbo.CheckState = turbo;
\r
820 drp_audioCodec.Text = audioCodec;
\r
822 groupBox_output.Text = preset;
\r
825 private void setMkv()
\r
827 // Set file extension to MKV
\r
828 string destination = text_destination.Text;
\r
829 destination = destination.Replace(".mp4", ".mkv");
\r
830 destination = destination.Replace(".avi", ".mkv");
\r
831 destination = destination.Replace(".m4v", ".mkv");
\r
832 destination = destination.Replace(".ogm", ".mkv");
\r
833 text_destination.Text = destination;
\r
838 //---------------------------------------------------
\r
839 // Encode / Cancel Buttons
\r
840 // Encode Progress Text Handler
\r
841 //---------------------------------------------------
\r
845 Functions.CLI process = new Functions.CLI();
\r
847 private void btn_encode_Click(object sender, EventArgs e)
\r
849 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
850 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
853 btn_eCancel.Enabled = true;
\r
855 if (QueryEditorText.Text == "")
\r
857 query = GenerateTheQuery();
\r
861 query = QueryEditorText.Text;
\r
864 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
865 lbl_encode.Visible = true;
\r
866 lbl_encode.Text = "Encoding in Progress";
\r
870 private void btn_eCancel_Click(object sender, EventArgs e)
\r
874 lbl_encode.Text = "Encoding Canceled";
\r
877 [DllImport("user32.dll")]
\r
878 public static extern void LockWorkStation();
\r
879 [DllImport("user32.dll")]
\r
880 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
882 private void procMonitor(object state)
\r
884 // Make sure we are not already encoding and if we are then display an error.
\r
885 if (hbProc != null)
\r
887 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
891 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
892 hbProc.WaitForExit();
\r
897 //*****************************************************************************************
\r
899 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
900 // video stream which has mild corruption issues every few seconds.
\r
901 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
902 //*****************************************************************************************
\r
905 Parsing.Parser encode = new Parsing.Parser(hbProc.StandardOutput.BaseStream);
\r
906 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
907 while (!encode.EndOfStream)
\r
912 hbProc.WaitForExit();
\r
913 process.closeCLI();
\r
917 catch (Exception exc)
\r
920 MessageBox.Show(exc.ToString());
\r
927 // Do something whent he encode ends.
\r
928 switch (Properties.Settings.Default.CompletionOption)
\r
931 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
934 ExitWindowsEx(0, 0);
\r
937 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
940 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
942 case "Lock System":
\r
945 case "Quit HandBrake":
\r
946 Application.Exit();
\r
954 private delegate void UpdateUIHandler();
\r
956 private void setEncodeLabel()
\r
958 if (this.InvokeRequired)
\r
960 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
963 lbl_encode.Text = "Encoding Finished";
\r
966 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
969 if (this.InvokeRequired)
\r
971 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
972 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
975 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
980 //---------------------------------------------------
\r
981 // Items that require actions on frmMain
\r
982 //---------------------------------------------------
\r
984 #region frmMain Actions
\r
986 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
988 drop_chapterStart.BackColor = Color.White;
\r
989 QueryEditorText.Text = "";
\r
990 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
994 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
995 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
997 if (chapterFinish < chapterStart)
\r
999 drop_chapterStart.BackColor = Color.LightCoral;
\r
1004 drop_chapterStart.BackColor = Color.LightCoral;
\r
1011 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1013 drop_chapterFinish.BackColor = Color.White;
\r
1014 QueryEditorText.Text = "";
\r
1015 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1019 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1020 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1022 if (chapterFinish < chapterStart)
\r
1024 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1029 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1034 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1036 text_filesize.Text = "";
\r
1037 slider_videoQuality.Value = 0;
\r
1038 SliderValue.Text = "0%";
\r
1039 CheckCRF.CheckState = CheckState.Unchecked;
\r
1040 CheckCRF.Enabled = false;
\r
1043 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1045 text_bitrate.Text = "";
\r
1046 slider_videoQuality.Value = 0;
\r
1047 SliderValue.Text = "0%";
\r
1048 CheckCRF.CheckState = CheckState.Unchecked;
\r
1049 CheckCRF.Enabled = false;
\r
1052 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1054 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1055 text_bitrate.Text = "";
\r
1056 text_filesize.Text = "";
\r
1057 CheckCRF.Enabled = true;
\r
1060 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1062 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1065 private void text_width_TextChanged(object sender, EventArgs e)
\r
1069 if (CheckPixelRatio.Checked)
\r
1071 text_width.Text = "";
\r
1072 text_width.BackColor = Color.LightCoral;
\r
1073 CheckPixelRatio.BackColor = Color.LightCoral;
\r
1074 lbl_anamorphicError.Visible = true;
\r
1078 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1080 text_width.BackColor = Color.LightCoral;
\r
1084 text_width.BackColor = Color.LightGreen;
\r
1088 if (lbl_Aspect.Text != "Select a Title")
\r
1090 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1091 double mod16 = height % 16;
\r
1092 height = height - mod16;
\r
1094 if (text_width.Text == "")
\r
1096 text_height.Text = "";
\r
1097 text_width.BackColor = Color.White;
\r
1101 text_height.Text = height.ToString();
\r
1107 // No need to throw an error here.
\r
1108 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1114 private void text_height_TextChanged(object sender, EventArgs e)
\r
1118 if (CheckPixelRatio.Checked)
\r
1120 text_height.Text = "";
\r
1121 text_height.BackColor = Color.LightCoral;
\r
1122 CheckPixelRatio.BackColor = Color.LightCoral;
\r
1123 lbl_anamorphicError.Visible = true;
\r
1127 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1129 text_height.BackColor = Color.LightCoral;
\r
1133 text_height.BackColor = Color.LightGreen;
\r
1137 } catch(Exception){
\r
1138 // No need to alert the user.
\r
1142 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1144 if ((string)drp_crop.SelectedItem == "Manual")
\r
1146 text_left.Enabled = true;
\r
1147 text_right.Enabled = true;
\r
1148 text_top.Enabled = true;
\r
1149 text_bottom.Enabled = true;
\r
1152 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1154 text_left.Enabled = false;
\r
1155 text_right.Enabled = false;
\r
1156 text_top.Enabled = false;
\r
1157 text_bottom.Enabled = false;
\r
1158 text_left.Text = "";
\r
1159 text_right.Text = "";
\r
1160 text_top.Text = "";
\r
1161 text_bottom.Text = "";
\r
1163 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1165 string[] temp = new string[4];
\r
1166 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1167 text_left.Text = temp[2];
\r
1168 text_right.Text = temp[3];
\r
1169 text_top.Text = temp[0];
\r
1170 text_bottom.Text = temp[1];
\r
1174 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1176 text_left.Enabled = false;
\r
1177 text_right.Enabled = false;
\r
1178 text_top.Enabled = false;
\r
1179 text_bottom.Enabled = false;
\r
1180 text_left.Text = "0";
\r
1181 text_right.Text = "0";
\r
1182 text_top.Text = "0";
\r
1183 text_bottom.Text = "0";
\r
1188 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1190 text_width.Text = "";
\r
1191 text_height.Text = "";
\r
1192 text_width.BackColor = Color.White;
\r
1193 text_height.BackColor = Color.White;
\r
1194 CheckPixelRatio.BackColor = frmMain.DefaultBackColor;
\r
1195 lbl_anamorphicError.Visible = false;
\r
1198 private void check_2PassEncode_CheckedChanged(object sender, EventArgs e)
\r
1200 if (check_2PassEncode.CheckState.ToString() == "Checked")
\r
1202 check_turbo.Enabled = true;
\r
1206 check_turbo.Enabled = false;
\r
1207 check_turbo.CheckState = CheckState.Unchecked;
\r
1211 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1213 if (!text_destination.Text.Contains(".mp4"))
\r
1215 lbl_largeMp4Warning.Text = "Warning: Only mp4 files are supported";
\r
1216 lbl_largeMp4Warning.ForeColor = Color.Red;
\r
1217 check_largeFile.CheckState = CheckState.Unchecked;
\r
1221 lbl_largeMp4Warning.Text = "Warning: Breaks iPod, @TV, PS3 compatibility.";
\r
1222 lbl_largeMp4Warning.ForeColor = Color.Black;
\r
1226 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1228 if (drp_dvdtitle.Items.Count == 0)
\r
1230 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
1234 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1237 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1239 drp_audioMixDown.Items.Clear();
\r
1241 if (drp_audioCodec.Text == "AAC")
\r
1243 drp_audioMixDown.Items.Clear();
\r
1244 drp_audioMixDown.Items.Add("Mono");
\r
1245 drp_audioMixDown.Items.Add("Stereo");
\r
1246 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1247 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1248 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1250 drp_audioBitrate.Items.Clear();
\r
1251 drp_audioBitrate.Items.Add("32");
\r
1252 drp_audioBitrate.Items.Add("40");
\r
1253 drp_audioBitrate.Items.Add("48");
\r
1254 drp_audioBitrate.Items.Add("56");
\r
1255 drp_audioBitrate.Items.Add("64");
\r
1256 drp_audioBitrate.Items.Add("80");
\r
1257 drp_audioBitrate.Items.Add("86");
\r
1258 drp_audioBitrate.Items.Add("112");
\r
1259 drp_audioBitrate.Items.Add("128");
\r
1260 drp_audioBitrate.Items.Add("160");
\r
1265 drp_audioMixDown.Items.Clear();
\r
1266 drp_audioMixDown.Items.Add("Stereo");
\r
1267 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1268 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1270 drp_audioBitrate.Items.Clear();
\r
1271 drp_audioBitrate.Items.Add("32");
\r
1272 drp_audioBitrate.Items.Add("40");
\r
1273 drp_audioBitrate.Items.Add("48");
\r
1274 drp_audioBitrate.Items.Add("56");
\r
1275 drp_audioBitrate.Items.Add("64");
\r
1276 drp_audioBitrate.Items.Add("80");
\r
1277 drp_audioBitrate.Items.Add("86");
\r
1278 drp_audioBitrate.Items.Add("112");
\r
1279 drp_audioBitrate.Items.Add("128");
\r
1280 drp_audioBitrate.Items.Add("160");
\r
1281 drp_audioBitrate.Items.Add("192");
\r
1282 drp_audioBitrate.Items.Add("224");
\r
1283 drp_audioBitrate.Items.Add("256");
\r
1284 drp_audioBitrate.Items.Add("320");
\r
1288 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1290 if (drp_audioCodec.Text == "AAC")
\r
1292 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1295 drp_audioBitrate.Items.Clear();
\r
1296 drp_audioBitrate.Items.Add("32");
\r
1297 drp_audioBitrate.Items.Add("40");
\r
1298 drp_audioBitrate.Items.Add("48");
\r
1299 drp_audioBitrate.Items.Add("56");
\r
1300 drp_audioBitrate.Items.Add("64");
\r
1301 drp_audioBitrate.Items.Add("80");
\r
1302 drp_audioBitrate.Items.Add("86");
\r
1303 drp_audioBitrate.Items.Add("112");
\r
1304 drp_audioBitrate.Items.Add("128");
\r
1305 drp_audioBitrate.Items.Add("160");
\r
1306 drp_audioBitrate.Items.Add("192");
\r
1307 drp_audioBitrate.Items.Add("224");
\r
1308 drp_audioBitrate.Items.Add("256");
\r
1309 drp_audioBitrate.Items.Add("320");
\r
1310 drp_audioBitrate.Items.Add("384");
\r
1315 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1317 if (Check_ChapterMarkers.Checked)
\r
1319 string destination = text_destination.Text;
\r
1320 destination = destination.Replace(".mp4", ".m4v");
\r
1321 text_destination.Text = destination;
\r
1325 string destination = text_destination.Text;
\r
1326 destination = destination.Replace(".m4v", ".mp4");
\r
1327 text_destination.Text = destination;
\r
1333 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1335 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1336 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1338 check_turbo.CheckState = CheckState.Unchecked;
\r
1339 CheckCRF.CheckState = CheckState.Unchecked;
\r
1340 CheckCRF.Enabled = false;
\r
1341 check_turbo.Enabled = false;
\r
1342 h264Tab.Enabled = false;
\r
1343 rtf_h264advanced.Text = "";
\r
1347 CheckCRF.Enabled = true;
\r
1348 check_turbo.Enabled = true;
\r
1349 h264Tab.Enabled = true;
\r
1354 public void setStreamReader(Parsing.DVD dvd)
\r
1356 this.thisDVD = dvd;
\r
1359 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1361 // Reset some values on the form
\r
1362 lbl_Aspect.Text = "Select a Title";
\r
1363 lbl_RecomendedCrop.Text = "Select a Title";
\r
1364 drop_chapterStart.Items.Clear();
\r
1365 drop_chapterFinish.Items.Clear();
\r
1366 QueryEditorText.Text = "";
\r
1368 // If the dropdown is set to automatic nothing else needs to be done.
\r
1369 // Otheriwse if its not, title data has to be loased from parsing.
\r
1370 if (drp_dvdtitle.Text != "Automatic")
\r
1372 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1374 // Set the Aspect Ratio
\r
1375 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1377 // Set the Recommended Cropping values
\r
1378 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1380 // Populate the Start chapter Dropdown
\r
1381 drop_chapterStart.Items.Clear();
\r
1382 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1383 if (drop_chapterStart.Items.Count > 0)
\r
1385 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1388 // Populate the Final Chapter Dropdown
\r
1389 drop_chapterFinish.Items.Clear();
\r
1390 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1391 if (drop_chapterFinish.Items.Count > 0)
\r
1393 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1396 // Populate the Audio Channels Dropdown
\r
1397 drp_audioChannels.Items.Clear();
\r
1398 drp_audioChannels.Items.Add("Automatic");
\r
1399 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1400 if (drp_audioChannels.Items.Count > 0)
\r
1402 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1405 // Populate the Subtitles dropdown
\r
1406 drp_subtitle.Items.Clear();
\r
1407 drp_subtitle.Items.Add("None");
\r
1408 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1409 if (drp_subtitle.Items.Count > 0)
\r
1411 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1418 //---------------------------------------------------
\r
1420 // - Query Generation
\r
1421 //---------------------------------------------------
\r
1423 #region Program Functions
\r
1425 public string GenerateTheQuery()
\r
1427 string source = text_source.Text;
\r
1428 string dvdTitle = drp_dvdtitle.Text;
\r
1429 string chapterStart = drop_chapterStart.Text;
\r
1430 string chapterFinish = drop_chapterFinish.Text;
\r
1431 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1432 string dvdChapter = "";
\r
1434 source = " -i " + '"' + source+ '"';
\r
1436 if (dvdTitle == "Automatic")
\r
1440 string[] titleInfo = dvdTitle.Split(' ');
\r
1441 dvdTitle = " -t "+ titleInfo[0];
\r
1444 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1446 else if (chapterFinish == chapterStart)
\r
1447 dvdChapter = " -c " + chapterStart;
\r
1449 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1451 string querySource = source+ dvdTitle+ dvdChapter;
\r
1452 // ----------------------------------------------------------------------
\r
1456 string destination = text_destination.Text;
\r
1457 string videoEncoder = drp_videoEncoder.Text;
\r
1458 string audioEncoder = drp_audioCodec.Text;
\r
1459 string width = text_width.Text;
\r
1460 string height = text_height.Text;
\r
1462 if (destination == "")
\r
1463 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1465 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1468 switch (videoEncoder)
\r
1471 videoEncoder = " -e ffmpeg";
\r
1474 videoEncoder = " -e xvid";
\r
1477 videoEncoder = " -e x264";
\r
1479 case "H.264 Baseline 1.3":
\r
1480 videoEncoder = " -e x264b13";
\r
1482 case "H.264 (iPod)":
\r
1483 videoEncoder = " -e x264b30";
\r
1486 videoEncoder = " -e x264";
\r
1490 switch (audioEncoder)
\r
1493 audioEncoder = " -E faac";
\r
1496 audioEncoder = " -E lame";
\r
1499 audioEncoder = " -E vorbis";
\r
1502 audioEncoder = " -E ac3";
\r
1505 audioEncoder = " -E faac";
\r
1510 width = " -w "+ width;
\r
1513 if (height == "Auto")
\r
1517 else if (height != "")
\r
1519 height = " -l " + height;
\r
1523 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1524 // ----------------------------------------------------------------------
\r
1526 // Picture Settings Tab
\r
1528 string cropSetting = drp_crop.Text;
\r
1529 string cropTop = text_top.Text;
\r
1530 string cropBottom = text_bottom.Text;
\r
1531 string cropLeft = text_left.Text;
\r
1532 string cropRight = text_right.Text;
\r
1533 string subtitles = drp_subtitle.Text;
\r
1534 string cropOut = "";
\r
1535 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1536 string deinterlace = "";
\r
1537 string grayscale = "";
\r
1538 string pixelRatio = "";
\r
1539 string ChapterMarkers = "";
\r
1540 // Returns Crop Query
\r
1542 if (cropSetting == "Auto Crop")
\r
1544 else if (cropSetting == "No Crop")
\r
1545 cropOut = " --crop 0:0:0:0 ";
\r
1548 if (text_top.Text == "")
\r
1550 if (text_bottom.Text == "")
\r
1552 if (text_left.Text == "")
\r
1554 if (text_right.Text == "")
\r
1557 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1560 if (subtitles == "None")
\r
1562 else if (subtitles == "")
\r
1567 tempSub = subtitles.Split(' ');
\r
1568 subtitles = " -s "+ tempSub[0];
\r
1571 switch (deInterlace_Option)
\r
1576 case "Original (Fast)":
\r
1577 deinterlace = " --deinterlace=" + '"' + "-1" + '"';
\r
1579 case "yadif (Slow)":
\r
1580 deinterlace = " --deinterlace=" + '"' + "0" + '"';
\r
1582 case "yadif + mcdeint (Slower)":
\r
1583 deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';
\r
1585 case "yadif + mcdeint (Slowest)":
\r
1586 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1593 if (check_grayscale.Checked)
\r
1594 grayscale = " -g ";
\r
1596 if (CheckPixelRatio.Checked)
\r
1597 pixelRatio = " -p ";
\r
1599 if (Check_ChapterMarkers.Checked)
\r
1600 ChapterMarkers = " -m ";
\r
1602 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1603 // ----------------------------------------------------------------------
\r
1605 // Video Settings Tab
\r
1607 string videoBitrate = text_bitrate.Text;
\r
1608 string videoFilesize = text_filesize.Text;
\r
1609 double videoQuality = slider_videoQuality.Value;
\r
1610 string vidQSetting = "";
\r
1611 string twoPassEncoding = "";
\r
1612 string videoFramerate = drp_videoFramerate.Text;
\r
1613 string turboH264 = "";
\r
1614 string largeFile = "";
\r
1615 string deblock = "";
\r
1616 string detelecine = "";
\r
1617 string denoise = "";
\r
1618 string CRF = CheckCRF.CheckState.ToString();
\r
1620 if (CRF == "Checked")
\r
1625 if (videoBitrate != "")
\r
1626 videoBitrate = " -b "+ videoBitrate;
\r
1628 if (videoFilesize != "")
\r
1629 videoFilesize = " -S "+ videoFilesize;
\r
1631 // Video Quality Setting
\r
1633 if ((videoQuality == 0))
\r
1637 videoQuality = videoQuality / 100;
\r
1638 if (videoQuality == 1)
\r
1640 vidQSetting = "1.0";
\r
1643 vidQSetting = " -q " + videoQuality.ToString();
\r
1646 if (check_2PassEncode.Checked)
\r
1647 twoPassEncoding = " -2 ";
\r
1649 if (videoFramerate == "Automatic")
\r
1650 videoFramerate = "";
\r
1652 videoFramerate = " -r "+ videoFramerate;
\r
1654 if (check_turbo.Checked)
\r
1655 turboH264 = " -T ";
\r
1657 if (check_largeFile.Checked)
\r
1658 largeFile = " -4 ";
\r
1660 if (check_deblock.Checked)
\r
1661 deblock = " --deblock";
\r
1663 if (check_detelecine.Checked)
\r
1664 detelecine = " --detelecine";
\r
1666 switch (drp_deNoise.Text)
\r
1672 denoise = " --denoise=2:1:2:3";
\r
1675 denoise = " --denoise=3:2:2:3";
\r
1678 denoise = " --denoise=7:7:5:5";
\r
1685 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + CRF + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1686 // ----------------------------------------------------------------------
\r
1688 // Audio Settings Tab
\r
1690 string audioBitrate = drp_audioBitrate.Text;
\r
1691 string audioSampleRate = drp_audioSampleRate.Text;
\r
1692 string audioChannels = drp_audioChannels.Text;
\r
1693 string Mixdown = drp_audioMixDown.Text;
\r
1694 string SixChannelAudio = "";
\r
1696 if (audioBitrate != "")
\r
1697 audioBitrate = " -B "+ audioBitrate;
\r
1699 if (audioSampleRate != "")
\r
1700 audioSampleRate = " -R "+ audioSampleRate;
\r
1702 if (audioChannels == "Automatic")
\r
1703 audioChannels = "";
\r
1704 else if (audioChannels == "")
\r
1705 audioChannels = "";
\r
1709 tempSub = audioChannels.Split(' ');
\r
1710 audioChannels = " -a "+ tempSub[0];
\r
1722 Mixdown = "stereo";
\r
1724 case "Dolby Surround":
\r
1727 case "Dolby Pro Logic II":
\r
1730 case "6 Channel Discrete":
\r
1738 if (Mixdown != "")
\r
1739 SixChannelAudio = " -6 "+ Mixdown;
\r
1741 SixChannelAudio = "";
\r
1743 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1744 // ----------------------------------------------------------------------
\r
1749 string h264Advanced = rtf_h264advanced.Text;
\r
1751 if ((h264Advanced == ""))
\r
1752 h264Advanced = "";
\r
1754 h264Advanced = " -x "+ h264Advanced;
\r
1757 string h264Settings = h264Advanced;
\r
1758 // ----------------------------------------------------------------------
\r
1760 // Processors (Program Settings)
\r
1762 string processors = Properties.Settings.Default.Processors;
\r
1763 // Number of Processors Handler
\r
1765 if (processors == "Automatic")
\r
1768 processors = " -C "+ processors+ " ";
\r
1771 string queryAdvancedSettings = processors;
\r
1772 // ----------------------------------------------------------------------
\r
1774 // Verbose option (Program Settings)
\r
1776 string verbose = "";
\r
1777 if (Properties.Settings.Default.verbose == "Checked")
\r
1780 // ----------------------------------------------------------------------
\r
1782 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1789 private Functions.QueryParser thisQuery;
\r
1790 private void button1_Click(object sender, EventArgs e)
\r
1792 String query = "";
\r
1793 if (QueryEditorText.Text == "")
\r
1795 query = GenerateTheQuery();
\r
1799 query = QueryEditorText.Text;
\r
1801 thisQuery = Functions.QueryParser.Parse(query);
\r
1802 MessageBox.Show(thisQuery.DeTelecine.ToString());
\r
1808 // This is the END of the road ------------------------------------------------------------------------------
\r