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
155 // Audio Settings Tab
\r
156 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
157 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
158 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
161 if (Properties.Settings.Default.CRF == "Checked")
\r
163 CheckCRF.CheckState = CheckState.Checked;
\r
165 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
167 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.selectedPreset + ")";
\r
171 // Load the default preset on lauch
\r
172 ListBox_Presets.SelectedItem = "Normal";
\r
177 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
181 private Boolean updateCheck()
\r
185 if (Properties.Settings.Default.updateStatus == "Checked")
\r
187 String updateFile = Properties.Settings.Default.updateFile;
\r
188 WebClient client = new WebClient();
\r
189 String data = client.DownloadString(updateFile);
\r
190 String[] versionData = data.Split('\n');
\r
192 int verdata = int.Parse(versionData[0].Replace(".", ""));
\r
193 int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));
\r
194 int verd1 = int.Parse(versionData[1].Replace(".", ""));
\r
195 int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));
\r
197 Boolean update = ((verdata > vergui) || (verd1 > cliversion));
\r
199 lbl_update.Visible = update;
\r
210 // Silently ignore the error
\r
215 private void tooltip()
\r
217 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
219 ToolTip.Active = true;
\r
223 private void showPresets()
\r
225 if (Properties.Settings.Default.showPresets == "Checked")
\r
227 btn_presets.Visible = false;
\r
235 // --------------------------------------------------------------
\r
236 // The main Menu bar.
\r
237 // --------------------------------------------------------------
\r
241 private void mnu_exit_Click(object sender, EventArgs e)
\r
243 Application.Exit();
\r
250 private void mnu_encode_Click(object sender, EventArgs e)
\r
255 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
257 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
258 dvdInfoWindow.Show();
\r
261 private void mnu_options_Click(object sender, EventArgs e)
\r
263 Form Options = new frmOptions();
\r
264 Options.ShowDialog();
\r
269 #region Presets Menu
\r
271 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
273 ListBox_Presets.Items.Clear();
\r
274 ListBox_Presets.Items.Add("Animation");
\r
275 ListBox_Presets.Items.Add("AppleTV");
\r
276 ListBox_Presets.Items.Add("Bedlam");
\r
277 ListBox_Presets.Items.Add("Blind");
\r
278 ListBox_Presets.Items.Add("Broke");
\r
279 ListBox_Presets.Items.Add("Classic");
\r
280 ListBox_Presets.Items.Add("Constant Quality Rate");
\r
281 ListBox_Presets.Items.Add("Deux Six Quatre");
\r
282 ListBox_Presets.Items.Add("Film");
\r
283 ListBox_Presets.Items.Add("iPhone");
\r
284 ListBox_Presets.Items.Add("iPod High-Rez");
\r
285 ListBox_Presets.Items.Add("iPod Low-Rez");
\r
286 ListBox_Presets.Items.Add("Normal");
\r
287 ListBox_Presets.Items.Add("PS3");
\r
288 ListBox_Presets.Items.Add("PSP");
\r
289 ListBox_Presets.Items.Add("QuickTime");
\r
290 ListBox_Presets.Items.Add("Television");
\r
292 if (presetStatus == false)
\r
295 presetStatus = true;
\r
296 btn_presets.Text = "Hide Presets";
\r
300 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
302 ListBox_Presets.SelectedItem = "Normal";
\r
303 if (presetStatus == false)
\r
306 presetStatus = true;
\r
307 btn_presets.Text = "Hide Presets";
\r
316 private void mnu_quickStart_Click(object sender, EventArgs e)
\r
318 Form QuickStart = new frmQuickStart();
\r
319 QuickStart.ShowDialog();
\r
322 private void mnu_wiki_Click(object sender, EventArgs e)
\r
324 Process.Start("http://handbrake.m0k.org/trac");
\r
327 private void mnu_faq_Click(object sender, EventArgs e)
\r
329 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
332 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
334 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
337 private void mnu_homepage_Click(object sender, EventArgs e)
\r
339 Process.Start("http://handbrake.m0k.org");
\r
342 private void mnu_forum_Click(object sender, EventArgs e)
\r
344 Process.Start("http://handbrake.m0k.org/forum");
\r
347 private void mnu_UpdateCheck_Click(object sender, EventArgs e)
\r
349 Boolean update = updateCheck();
\r
350 if (update == true)
\r
352 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
356 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
360 private void mnu_about_Click(object sender, EventArgs e)
\r
362 Form About = new frmAbout();
\r
363 About.ShowDialog();
\r
368 // --------------------------------------------------------------
\r
369 // Buttons on the main Window
\r
370 // --------------------------------------------------------------
\r
374 private void btn_Browse_Click(object sender, EventArgs e)
\r
376 String filename = "";
\r
377 text_source.Text = "";
\r
378 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
379 if (RadioDVD.Checked)
\r
381 DVD_Open.ShowDialog();
\r
382 filename = DVD_Open.SelectedPath;
\r
383 if (filename != "")
\r
385 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
386 text_source.Text = filename;
\r
387 frmRD.ShowDialog();
\r
392 ISO_Open.ShowDialog();
\r
393 filename = ISO_Open.FileName;
\r
394 if (filename != "")
\r
396 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
397 text_source.Text = filename;
\r
398 frmRD.ShowDialog();
\r
402 // Check if there was titles in the dvd title dropdown
\r
403 if (filename == "")
\r
405 text_source.Text = "Click 'Browse' to continue";
\r
408 // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.
\r
409 if (drp_dvdtitle.Items.Count == 0)
\r
411 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
415 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
417 DVD_Save.ShowDialog();
\r
418 text_destination.Text = DVD_Save.FileName;
\r
420 if (Check_ChapterMarkers.Checked)
\r
422 string destination = text_destination.Text;
\r
423 destination = destination.Replace(".mp4", ".m4v");
\r
424 text_destination.Text = destination;
\r
428 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
430 rtf_h264advanced.Text = "";
\r
433 private void GenerateQuery_Click(object sender, EventArgs e)
\r
435 String query = GenerateTheQuery();
\r
436 QueryEditorText.Text = query;
\r
439 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
441 QueryEditorText.Text = "";
\r
444 private void btn_queue_Click(object sender, EventArgs e)
\r
446 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
447 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
451 if (QueryEditorText.Text == "")
\r
453 query = GenerateTheQuery();
\r
457 query = QueryEditorText.Text;
\r
459 queueWindow.list_queue.Items.Add(query);
\r
460 queueWindow.Show();
\r
464 private void btn_copy_Click(object sender, EventArgs e)
\r
466 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);
\r
469 private void showQueue()
\r
471 queueWindow.Show();
\r
476 // --------------------------------------------------------------
\r
477 // Main Window Preset System
\r
478 // --------------------------------------------------------------
\r
480 #region Preset System
\r
483 private Boolean presetStatus = false;
\r
486 private void btn_presets_Click(object sender, EventArgs e)
\r
488 if (presetStatus == false)
\r
491 presetStatus = true;
\r
492 btn_presets.Text = "Hide Presets";
\r
497 presetStatus = false;
\r
498 btn_presets.Text = "Show Presets";
\r
503 private void btn_addPreset_Click(object sender, EventArgs e)
\r
506 File_Open.ShowDialog();
\r
507 filename = File_Open.FileName;
\r
508 if (filename != "")
\r
512 // Create StreamReader & open file
\r
513 StreamReader line = new StreamReader(filename);
\r
514 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
516 // Read in the data and set the correct GUI component with the setting.
\r
517 text_source.Text = line.ReadLine();
\r
518 drp_dvdtitle.Text = line.ReadLine();
\r
519 drop_chapterStart.Text = line.ReadLine();
\r
520 drop_chapterFinish.Text = line.ReadLine();
\r
521 text_destination.Text = line.ReadLine();
\r
522 drp_videoEncoder.Text = line.ReadLine();
\r
523 drp_audioCodec.Text = line.ReadLine();
\r
524 text_width.Text = line.ReadLine();
\r
525 text_height.Text = line.ReadLine();
\r
526 text_top.Text = line.ReadLine();
\r
527 text_bottom.Text = line.ReadLine();
\r
528 text_left.Text = line.ReadLine();
\r
529 text_right.Text = line.ReadLine();
\r
530 drp_subtitle.Text = line.ReadLine();
\r
531 text_bitrate.Text = line.ReadLine();
\r
532 text_filesize.Text = line.ReadLine();
\r
533 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
535 temporyLine = line.ReadLine();
\r
536 if (temporyLine == "Checked")
\r
538 check_2PassEncode.CheckState = CheckState.Checked;
\r
541 drp_deInterlace_option.Text = line.ReadLine();
\r
543 temporyLine = line.ReadLine();
\r
544 if (temporyLine == "Checked")
\r
546 check_grayscale.CheckState = CheckState.Checked;
\r
549 drp_videoFramerate.Text = line.ReadLine();
\r
551 temporyLine = line.ReadLine();
\r
552 if (temporyLine == "Checked")
\r
554 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
557 temporyLine = line.ReadLine();
\r
558 if (temporyLine == "Checked")
\r
560 CheckPixelRatio.CheckState = CheckState.Checked;
\r
563 temporyLine = line.ReadLine();
\r
564 if (temporyLine == "Checked")
\r
566 check_turbo.CheckState = CheckState.Checked;
\r
569 temporyLine = line.ReadLine();
\r
570 if (temporyLine == "Checked")
\r
572 check_largeFile.CheckState = CheckState.Checked;
\r
575 drp_audioBitrate.Text = line.ReadLine();
\r
576 drp_audioSampleRate.Text = line.ReadLine();
\r
577 drp_audioChannels.Text = line.ReadLine();
\r
578 drp_audioMixDown.Text = line.ReadLine();
\r
580 // Advanced H264 Options
\r
581 temporyLine = line.ReadLine();
\r
582 if (temporyLine == "Checked")
\r
584 CheckCRF.CheckState = CheckState.Checked;
\r
586 rtf_h264advanced.Text = line.ReadLine();
\r
588 // Close the stream
\r
592 // Fix for SliderValue not appearing when Opening saved file
\r
593 SliderValue.Text = slider_videoQuality.Value + "%";
\r
598 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
603 private void btn_removePreset_Click(object sender, EventArgs e)
\r
606 File_Save.ShowDialog();
\r
607 filename = File_Save.FileName;
\r
608 if (filename != "")
\r
612 // Create a StreamWriter and open the file
\r
613 StreamWriter line = new StreamWriter(filename);
\r
616 line.WriteLine(text_source.Text);
\r
617 line.WriteLine(drp_dvdtitle.Text);
\r
618 line.WriteLine(drop_chapterStart.Text);
\r
619 line.WriteLine(drop_chapterFinish.Text);
\r
621 line.WriteLine(text_destination.Text);
\r
622 line.WriteLine(drp_videoEncoder.Text);
\r
623 line.WriteLine(drp_audioCodec.Text);
\r
624 line.WriteLine(text_width.Text);
\r
625 line.WriteLine(text_height.Text);
\r
626 //Picture Settings Tab
\r
627 line.WriteLine(text_top.Text);
\r
628 line.WriteLine(text_bottom.Text);
\r
629 line.WriteLine(text_left.Text);
\r
630 line.WriteLine(text_right.Text);
\r
631 line.WriteLine(drp_subtitle.Text);
\r
632 //Video Settings Tab
\r
633 line.WriteLine(text_bitrate.Text);
\r
634 line.WriteLine(text_filesize.Text);
\r
635 line.WriteLine(slider_videoQuality.Value.ToString());
\r
636 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
637 line.WriteLine(drp_deInterlace_option.Text);
\r
638 line.WriteLine(check_grayscale.CheckState.ToString());
\r
639 line.WriteLine(drp_videoFramerate.Text);
\r
640 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
641 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
642 line.WriteLine(check_turbo.CheckState.ToString());
\r
643 line.WriteLine(check_largeFile.CheckState.ToString());
\r
644 //Audio Settings Tab
\r
645 line.WriteLine(drp_audioBitrate.Text);
\r
646 line.WriteLine(drp_audioSampleRate.Text);
\r
647 line.WriteLine(drp_audioChannels.Text);
\r
648 line.WriteLine(drp_audioMixDown.Text);
\r
650 line.WriteLine(CheckCRF.CheckState.ToString());
\r
651 line.WriteLine(rtf_h264advanced.Text);
\r
652 // close the stream
\r
654 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
658 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
664 private void btn_setDefault_Click(object sender, EventArgs e)
\r
667 Properties.Settings.Default.DVDSource = text_source.Text;
\r
668 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
669 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
670 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
672 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
673 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
674 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
675 Properties.Settings.Default.Width = text_width.Text;
\r
676 Properties.Settings.Default.Height = text_height.Text;
\r
677 //Picture Settings Tab
\r
678 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
679 Properties.Settings.Default.CropTop = text_top.Text;
\r
680 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
681 Properties.Settings.Default.CropLeft = text_left.Text;
\r
682 Properties.Settings.Default.CropRight = text_right.Text;
\r
683 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
684 //Video Settings Tab
\r
685 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
686 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
687 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
688 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
689 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
690 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
691 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
692 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
693 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
694 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
695 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
696 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
697 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
698 //Audio Settings Tab
\r
699 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
700 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
701 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
703 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
704 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
707 Properties.Settings.Default.selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
709 catch (Exception exc)
\r
711 // If the user has not selected an item, then an exception may be thrown. Catch and ignore.
\r
713 Properties.Settings.Default.Save();
\r
716 // Preset Seleciton
\r
717 private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)
\r
719 string selectedPreset = null;
\r
720 if (ListBox_Presets.SelectedItem != null)
\r
722 selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
726 selectedPreset = "";
\r
729 switch (selectedPreset)
\r
732 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
736 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
739 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
743 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
746 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
749 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
751 case "Constant Quality Rate":
\r
752 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
755 case "Deux Six Quatre":
\r
756 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
760 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
764 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
766 case "iPod High-Rez":
\r
767 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
769 case "iPod Low-Rez":
\r
770 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
773 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
776 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
779 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
782 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
785 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
793 // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.
\r
794 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
796 CheckPixelRatio.CheckState = anamorphic;
\r
797 text_width.Text = width;
\r
798 text_height.Text = height;
\r
799 drp_videoEncoder.Text = vencoder;
\r
800 text_bitrate.Text = bitrate;
\r
801 text_filesize.Text = filesize;
\r
802 slider_videoQuality.Value = quality;
\r
803 SliderValue.Text = qpercent;
\r
804 drp_audioBitrate.Text = audioBit;
\r
805 Check_ChapterMarkers.CheckState = chpt;
\r
806 drp_audioSampleRate.Text = audioSample;
\r
807 rtf_h264advanced.Text = h264;
\r
808 drp_deInterlace_option.Text = deinterlace;
\r
809 check_2PassEncode.CheckState = twopass;
\r
810 drp_crop.Text = crop;
\r
811 check_turbo.CheckState = turbo;
\r
812 drp_audioCodec.Text = audioCodec;
\r
814 groupBox_output.Text = preset;
\r
817 private void setMkv()
\r
819 // Set file extension to MKV
\r
820 string destination = text_destination.Text;
\r
821 destination = destination.Replace(".mp4", ".mkv");
\r
822 destination = destination.Replace(".avi", ".mkv");
\r
823 destination = destination.Replace(".m4v", ".mkv");
\r
824 destination = destination.Replace(".ogm", ".mkv");
\r
825 text_destination.Text = destination;
\r
830 //---------------------------------------------------
\r
831 // Encode / Cancel Buttons
\r
832 // Encode Progress Text Handler
\r
833 //---------------------------------------------------
\r
837 Functions.CLI process = new Functions.CLI();
\r
839 private void btn_encode_Click(object sender, EventArgs e)
\r
841 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
842 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
845 btn_eCancel.Enabled = true;
\r
847 if (QueryEditorText.Text == "")
\r
849 query = GenerateTheQuery();
\r
853 query = QueryEditorText.Text;
\r
856 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
857 lbl_encode.Visible = true;
\r
858 lbl_encode.Text = "Encoding in Progress";
\r
862 private void btn_eCancel_Click(object sender, EventArgs e)
\r
866 lbl_encode.Text = "Encoding Canceled";
\r
869 [DllImport("user32.dll")]
\r
870 public static extern void LockWorkStation();
\r
871 [DllImport("user32.dll")]
\r
872 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
874 private void procMonitor(object state)
\r
876 // Make sure we are not already encoding and if we are then display an error.
\r
877 if (hbProc != null)
\r
879 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
883 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
884 hbProc.WaitForExit();
\r
889 //*****************************************************************************************
\r
891 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
892 // video stream which has mild corruption issues every few seconds.
\r
893 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
894 //*****************************************************************************************
\r
897 Parsing.Parser encode = new Parsing.Parser(hbProc.StandardOutput.BaseStream);
\r
898 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
899 while (!encode.EndOfStream)
\r
904 hbProc.WaitForExit();
\r
905 process.closeCLI();
\r
909 catch (Exception exc)
\r
912 MessageBox.Show(exc.ToString());
\r
919 // Do something whent he encode ends.
\r
920 switch (Properties.Settings.Default.CompletionOption)
\r
923 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
926 ExitWindowsEx(0, 0);
\r
929 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
932 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
934 case "Lock System":
\r
937 case "Quit HandBrake":
\r
938 Application.Exit();
\r
946 private delegate void UpdateUIHandler();
\r
948 private void setEncodeLabel()
\r
950 if (this.InvokeRequired)
\r
952 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
955 lbl_encode.Text = "Encoding Finished";
\r
958 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
961 if (this.InvokeRequired)
\r
963 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
964 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
967 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
972 //---------------------------------------------------
\r
973 // Items that require actions on frmMain
\r
974 //---------------------------------------------------
\r
976 #region frmMain Actions
\r
978 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
980 drop_chapterStart.BackColor = Color.White;
\r
981 QueryEditorText.Text = "";
\r
982 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
986 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
987 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
989 if (chapterFinish < chapterStart)
\r
991 drop_chapterStart.BackColor = Color.LightCoral;
\r
996 drop_chapterStart.BackColor = Color.LightCoral;
\r
1003 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1005 drop_chapterFinish.BackColor = Color.White;
\r
1006 QueryEditorText.Text = "";
\r
1007 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1011 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1012 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1014 if (chapterFinish < chapterStart)
\r
1016 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1021 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1026 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1028 text_filesize.Text = "";
\r
1029 slider_videoQuality.Value = 0;
\r
1030 SliderValue.Text = "0%";
\r
1031 CheckCRF.CheckState = CheckState.Unchecked;
\r
1032 CheckCRF.Enabled = false;
\r
1035 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1037 text_bitrate.Text = "";
\r
1038 slider_videoQuality.Value = 0;
\r
1039 SliderValue.Text = "0%";
\r
1040 CheckCRF.CheckState = CheckState.Unchecked;
\r
1041 CheckCRF.Enabled = false;
\r
1044 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1046 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1047 text_bitrate.Text = "";
\r
1048 text_filesize.Text = "";
\r
1049 CheckCRF.Enabled = true;
\r
1052 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1054 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1057 private void text_width_TextChanged(object sender, EventArgs e)
\r
1062 if (CheckPixelRatio.Checked)
\r
1064 text_width.Text = "";
\r
1065 text_width.BackColor = Color.White;
\r
1069 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1071 text_width.BackColor = Color.LightCoral;
\r
1075 text_width.BackColor = Color.LightGreen;
\r
1079 if (lbl_Aspect.Text != "Select a Title")
\r
1081 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1082 double mod16 = height % 16;
\r
1083 height = height - mod16;
\r
1085 if (text_width.Text == "")
\r
1087 text_height.Text = "";
\r
1088 text_width.BackColor = Color.White;
\r
1092 text_height.Text = height.ToString();
\r
1098 // No need to throw an error here.
\r
1099 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1105 private void text_height_TextChanged(object sender, EventArgs e)
\r
1109 if (text_height.Text != "Auto")
\r
1111 if (CheckPixelRatio.Checked)
\r
1113 text_height.Text = "";
\r
1114 text_width.BackColor = Color.White;
\r
1118 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1120 text_height.BackColor = Color.LightCoral;
\r
1124 text_height.BackColor = Color.LightGreen;
\r
1128 } catch(Exception){
\r
1129 // No need to alert the user.
\r
1133 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1135 if ((string)drp_crop.SelectedItem == "Manual")
\r
1137 text_left.Enabled = true;
\r
1138 text_right.Enabled = true;
\r
1139 text_top.Enabled = true;
\r
1140 text_bottom.Enabled = true;
\r
1143 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1145 text_left.Enabled = false;
\r
1146 text_right.Enabled = false;
\r
1147 text_top.Enabled = false;
\r
1148 text_bottom.Enabled = false;
\r
1149 text_left.Text = "";
\r
1150 text_right.Text = "";
\r
1151 text_top.Text = "";
\r
1152 text_bottom.Text = "";
\r
1154 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1156 string[] temp = new string[4];
\r
1157 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1158 text_left.Text = temp[2];
\r
1159 text_right.Text = temp[3];
\r
1160 text_top.Text = temp[0];
\r
1161 text_bottom.Text = temp[1];
\r
1165 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1167 text_left.Enabled = false;
\r
1168 text_right.Enabled = false;
\r
1169 text_top.Enabled = false;
\r
1170 text_bottom.Enabled = false;
\r
1171 text_left.Text = "0";
\r
1172 text_right.Text = "0";
\r
1173 text_top.Text = "0";
\r
1174 text_bottom.Text = "0";
\r
1179 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1181 text_width.Text = "";
\r
1182 text_height.Text = "";
\r
1183 text_width.BackColor = Color.White;
\r
1184 text_height.BackColor = Color.White;
\r
1187 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1189 if (drp_dvdtitle.Items.Count == 0)
\r
1191 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
1195 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1198 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1200 drp_audioMixDown.Items.Clear();
\r
1202 if (drp_audioCodec.Text == "AAC")
\r
1204 drp_audioMixDown.Items.Clear();
\r
1205 drp_audioMixDown.Items.Add("Mono");
\r
1206 drp_audioMixDown.Items.Add("Stereo");
\r
1207 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1208 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1209 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1211 drp_audioBitrate.Items.Clear();
\r
1212 drp_audioBitrate.Items.Add("32");
\r
1213 drp_audioBitrate.Items.Add("40");
\r
1214 drp_audioBitrate.Items.Add("48");
\r
1215 drp_audioBitrate.Items.Add("56");
\r
1216 drp_audioBitrate.Items.Add("64");
\r
1217 drp_audioBitrate.Items.Add("80");
\r
1218 drp_audioBitrate.Items.Add("86");
\r
1219 drp_audioBitrate.Items.Add("112");
\r
1220 drp_audioBitrate.Items.Add("128");
\r
1221 drp_audioBitrate.Items.Add("160");
\r
1226 drp_audioMixDown.Items.Clear();
\r
1227 drp_audioMixDown.Items.Add("Stereo");
\r
1228 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1229 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1231 drp_audioBitrate.Items.Clear();
\r
1232 drp_audioBitrate.Items.Add("32");
\r
1233 drp_audioBitrate.Items.Add("40");
\r
1234 drp_audioBitrate.Items.Add("48");
\r
1235 drp_audioBitrate.Items.Add("56");
\r
1236 drp_audioBitrate.Items.Add("64");
\r
1237 drp_audioBitrate.Items.Add("80");
\r
1238 drp_audioBitrate.Items.Add("86");
\r
1239 drp_audioBitrate.Items.Add("112");
\r
1240 drp_audioBitrate.Items.Add("128");
\r
1241 drp_audioBitrate.Items.Add("160");
\r
1242 drp_audioBitrate.Items.Add("192");
\r
1243 drp_audioBitrate.Items.Add("224");
\r
1244 drp_audioBitrate.Items.Add("256");
\r
1245 drp_audioBitrate.Items.Add("320");
\r
1249 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1251 if (drp_audioCodec.Text == "AAC")
\r
1253 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1256 drp_audioBitrate.Items.Clear();
\r
1257 drp_audioBitrate.Items.Add("32");
\r
1258 drp_audioBitrate.Items.Add("40");
\r
1259 drp_audioBitrate.Items.Add("48");
\r
1260 drp_audioBitrate.Items.Add("56");
\r
1261 drp_audioBitrate.Items.Add("64");
\r
1262 drp_audioBitrate.Items.Add("80");
\r
1263 drp_audioBitrate.Items.Add("86");
\r
1264 drp_audioBitrate.Items.Add("112");
\r
1265 drp_audioBitrate.Items.Add("128");
\r
1266 drp_audioBitrate.Items.Add("160");
\r
1267 drp_audioBitrate.Items.Add("192");
\r
1268 drp_audioBitrate.Items.Add("224");
\r
1269 drp_audioBitrate.Items.Add("256");
\r
1270 drp_audioBitrate.Items.Add("320");
\r
1271 drp_audioBitrate.Items.Add("384");
\r
1276 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1278 if (Check_ChapterMarkers.Checked)
\r
1280 string destination = text_destination.Text;
\r
1281 destination = destination.Replace(".mp4", ".m4v");
\r
1282 text_destination.Text = destination;
\r
1286 string destination = text_destination.Text;
\r
1287 destination = destination.Replace(".m4v", ".mp4");
\r
1288 text_destination.Text = destination;
\r
1292 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1294 if (!text_destination.Text.Contains(".mp4"))
\r
1296 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1297 check_largeFile.CheckState = CheckState.Unchecked;
\r
1301 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1303 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1304 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1306 check_turbo.CheckState = CheckState.Unchecked;
\r
1307 CheckCRF.CheckState = CheckState.Unchecked;
\r
1308 CheckCRF.Enabled = false;
\r
1309 check_turbo.Enabled = false;
\r
1310 h264Tab.Enabled = false;
\r
1311 rtf_h264advanced.Text = "";
\r
1315 CheckCRF.Enabled = true;
\r
1316 check_turbo.Enabled = true;
\r
1317 h264Tab.Enabled = true;
\r
1322 public void setStreamReader(Parsing.DVD dvd)
\r
1324 this.thisDVD = dvd;
\r
1327 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1329 // Reset some values on the form
\r
1330 lbl_Aspect.Text = "Select a Title";
\r
1331 lbl_RecomendedCrop.Text = "Select a Title";
\r
1332 drop_chapterStart.Items.Clear();
\r
1333 drop_chapterFinish.Items.Clear();
\r
1334 QueryEditorText.Text = "";
\r
1336 // If the dropdown is set to automatic nothing else needs to be done.
\r
1337 // Otheriwse if its not, title data has to be loased from parsing.
\r
1338 if (drp_dvdtitle.Text != "Automatic")
\r
1340 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1342 // Set the Aspect Ratio
\r
1343 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1345 // Set the Recommended Cropping values
\r
1346 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1348 // Populate the Start chapter Dropdown
\r
1349 drop_chapterStart.Items.Clear();
\r
1350 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1351 if (drop_chapterStart.Items.Count > 0)
\r
1353 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1356 // Populate the Final Chapter Dropdown
\r
1357 drop_chapterFinish.Items.Clear();
\r
1358 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1359 if (drop_chapterFinish.Items.Count > 0)
\r
1361 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1364 // Populate the Audio Channels Dropdown
\r
1365 drp_audioChannels.Items.Clear();
\r
1366 drp_audioChannels.Items.Add("Automatic");
\r
1367 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1368 if (drp_audioChannels.Items.Count > 0)
\r
1370 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1373 // Populate the Subtitles dropdown
\r
1374 drp_subtitle.Items.Clear();
\r
1375 drp_subtitle.Items.Add("None");
\r
1376 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1377 if (drp_subtitle.Items.Count > 0)
\r
1379 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1386 //---------------------------------------------------
\r
1388 // - Query Generation
\r
1389 //---------------------------------------------------
\r
1391 #region Program Functions
\r
1393 public string GenerateTheQuery()
\r
1395 string source = text_source.Text;
\r
1396 string dvdTitle = drp_dvdtitle.Text;
\r
1397 string chapterStart = drop_chapterStart.Text;
\r
1398 string chapterFinish = drop_chapterFinish.Text;
\r
1399 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1400 string dvdChapter = "";
\r
1402 source = " -i " + '"' + source+ '"';
\r
1404 if (dvdTitle == "Automatic")
\r
1408 string[] titleInfo = dvdTitle.Split(' ');
\r
1409 dvdTitle = " -t "+ titleInfo[0];
\r
1412 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1414 else if (chapterFinish == chapterStart)
\r
1415 dvdChapter = " -c " + chapterStart;
\r
1417 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1419 string querySource = source+ dvdTitle+ dvdChapter;
\r
1420 // ----------------------------------------------------------------------
\r
1424 string destination = text_destination.Text;
\r
1425 string videoEncoder = drp_videoEncoder.Text;
\r
1426 string audioEncoder = drp_audioCodec.Text;
\r
1427 string width = text_width.Text;
\r
1428 string height = text_height.Text;
\r
1430 if (destination == "")
\r
1431 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1433 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1436 switch (videoEncoder)
\r
1439 videoEncoder = " -e ffmpeg";
\r
1442 videoEncoder = " -e xvid";
\r
1445 videoEncoder = " -e x264";
\r
1447 case "H.264 Baseline 1.3":
\r
1448 videoEncoder = " -e x264b13";
\r
1450 case "H.264 (iPod)":
\r
1451 videoEncoder = " -e x264b30";
\r
1454 videoEncoder = " -e x264";
\r
1458 switch (audioEncoder)
\r
1461 audioEncoder = " -E faac";
\r
1464 audioEncoder = " -E lame";
\r
1467 audioEncoder = " -E vorbis";
\r
1470 audioEncoder = " -E ac3";
\r
1473 audioEncoder = " -E faac";
\r
1478 width = " -w "+ width;
\r
1481 if (height == "Auto")
\r
1485 else if (height != "")
\r
1487 height = " -l " + height;
\r
1491 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1492 // ----------------------------------------------------------------------
\r
1494 // Picture Settings Tab
\r
1496 string cropSetting = drp_crop.Text;
\r
1497 string cropTop = text_top.Text;
\r
1498 string cropBottom = text_bottom.Text;
\r
1499 string cropLeft = text_left.Text;
\r
1500 string cropRight = text_right.Text;
\r
1501 string subtitles = drp_subtitle.Text;
\r
1502 string cropOut = "";
\r
1503 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1504 string deinterlace = "";
\r
1505 string grayscale = "";
\r
1506 string pixelRatio = "";
\r
1507 string ChapterMarkers = "";
\r
1508 // Returns Crop Query
\r
1510 if (cropSetting == "Auto Crop")
\r
1512 else if (cropSetting == "No Crop")
\r
1513 cropOut = " --crop 0:0:0:0 ";
\r
1516 if (text_top.Text == "")
\r
1518 if (text_bottom.Text == "")
\r
1520 if (text_left.Text == "")
\r
1522 if (text_right.Text == "")
\r
1525 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1528 if (subtitles == "None")
\r
1530 else if (subtitles == "")
\r
1535 tempSub = subtitles.Split(' ');
\r
1536 subtitles = " -s "+ tempSub[0];
\r
1539 switch (deInterlace_Option)
\r
1544 case "Origional (Fast)":
\r
1545 deinterlace = " --deinterlace=1";
\r
1547 case "yadif (Slow)":
\r
1548 deinterlace = " --deinterlace=" + '"' + "0" + '"';
\r
1550 case "yadif + mcdeint (Slower)":
\r
1551 deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';
\r
1553 case "yadif + mcdeint (Slowest)":
\r
1554 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1561 if (check_grayscale.Checked)
\r
1562 grayscale = " -g ";
\r
1564 if (CheckPixelRatio.Checked)
\r
1565 pixelRatio = " -p ";
\r
1567 if (Check_ChapterMarkers.Checked)
\r
1568 ChapterMarkers = " -m ";
\r
1570 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1571 // ----------------------------------------------------------------------
\r
1573 // Video Settings Tab
\r
1575 string videoBitrate = text_bitrate.Text;
\r
1576 string videoFilesize = text_filesize.Text;
\r
1577 double videoQuality = slider_videoQuality.Value;
\r
1578 string vidQSetting = "";
\r
1579 string twoPassEncoding = "";
\r
1580 string videoFramerate = drp_videoFramerate.Text;
\r
1581 string turboH264 = "";
\r
1582 string largeFile = "";
\r
1583 string deblock = "";
\r
1584 string detelecine = "";
\r
1585 string denoise = "";
\r
1586 string CRF = CheckCRF.CheckState.ToString();
\r
1589 if ((CRF == "Checked"))
\r
1594 if (videoBitrate != "")
\r
1595 videoBitrate = " -b "+ videoBitrate;
\r
1597 if (videoFilesize != "")
\r
1598 videoFilesize = " -S "+ videoFilesize;
\r
1600 // Video Quality Setting
\r
1602 if ((videoQuality == 0))
\r
1606 videoQuality = videoQuality / 100;
\r
1607 if (videoQuality == 1)
\r
1609 vidQSetting = "1.0";
\r
1612 vidQSetting = " -q " + videoQuality.ToString();
\r
1615 if (check_2PassEncode.Checked)
\r
1616 twoPassEncoding = " -2 ";
\r
1618 if (videoFramerate == "Automatic")
\r
1619 videoFramerate = "";
\r
1621 videoFramerate = " -r "+ videoFramerate;
\r
1623 if (check_turbo.Checked)
\r
1624 turboH264 = " -T ";
\r
1626 if (check_largeFile.Checked)
\r
1627 largeFile = " -4 ";
\r
1629 if (check_deblock.Checked)
\r
1630 deblock = " --deblock";
\r
1632 if (check_detelecine.Checked)
\r
1633 detelecine = " --detelecine";
\r
1635 switch (drp_deNoise.Text)
\r
1641 denoise = " --denoise=2:1:2:3";
\r
1644 denoise = " --denoise=3:2:2:3";
\r
1647 denoise = " --denoise=7:7:5:5";
\r
1654 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1655 // ----------------------------------------------------------------------
\r
1657 // Audio Settings Tab
\r
1659 string audioBitrate = drp_audioBitrate.Text;
\r
1660 string audioSampleRate = drp_audioSampleRate.Text;
\r
1661 string audioChannels = drp_audioChannels.Text;
\r
1662 string Mixdown = drp_audioMixDown.Text;
\r
1663 string SixChannelAudio = "";
\r
1665 if (audioBitrate != "")
\r
1666 audioBitrate = " -B "+ audioBitrate;
\r
1668 if (audioSampleRate != "")
\r
1669 audioSampleRate = " -R "+ audioSampleRate;
\r
1671 if (audioChannels == "Automatic")
\r
1672 audioChannels = "";
\r
1673 else if (audioChannels == "")
\r
1674 audioChannels = "";
\r
1678 tempSub = audioChannels.Split(' ');
\r
1679 audioChannels = " -a "+ tempSub[0];
\r
1691 Mixdown = "stereo";
\r
1693 case "Dolby Surround":
\r
1696 case "Dolby Pro Logic II":
\r
1699 case "6 Channel Discrete":
\r
1703 Mixdown = "stero";
\r
1707 if (Mixdown != "")
\r
1708 SixChannelAudio = " -6 "+ Mixdown;
\r
1710 SixChannelAudio = "";
\r
1712 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1713 // ----------------------------------------------------------------------
\r
1718 string h264Advanced = rtf_h264advanced.Text;
\r
1720 if ((h264Advanced == ""))
\r
1721 h264Advanced = "";
\r
1723 h264Advanced = " -x "+ h264Advanced;
\r
1726 string h264Settings = h264Advanced;
\r
1727 // ----------------------------------------------------------------------
\r
1729 // Processors (Program Settings)
\r
1731 string processors = Properties.Settings.Default.Processors;
\r
1732 // Number of Processors Handler
\r
1734 if (processors == "Automatic")
\r
1737 processors = " -C "+ processors+ " ";
\r
1740 string queryAdvancedSettings = processors;
\r
1741 // ----------------------------------------------------------------------
\r
1743 // Verbose option (Program Settings)
\r
1745 string verbose = "";
\r
1746 if (Properties.Settings.Default.verbose == "Checked")
\r
1749 // ----------------------------------------------------------------------
\r
1751 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1756 // This is the END of the road ------------------------------------------------------------------------------
\r