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 // Display the quick start window if required.
\r
57 // Enable or disable tooltips
\r
60 // Hide the presets part of the window
\r
66 * This code can be used for storing preset and preset name information in future versions.
\r
67 * Please ignore it for the moment.
\r
68 // Create and initialize a new StringCollection.
\r
69 StringCollection myCol = new StringCollection();
\r
70 // Add a range of elements from an array to the end of the StringCollection.
\r
71 String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" };
\r
72 myCol.AddRange(myArr);
\r
73 Properties.Settings.Default.BuiltInPresets = myCol;
\r
74 MessageBox.Show(Properties.Settings.Default.BuiltInPresets.ToString());
\r
78 private void showSplash(object sender)
\r
80 // Display splash screen for 1.5 Seconds
\r
81 Form splash = new frmSplashScreen();
\r
83 Thread.Sleep(1500);
\r
84 splash.Close(); // Then close.
\r
87 private void loadUserDefaults()
\r
91 // Load the users default settings or if the user has not got this option enabled, load the normal preset.
\r
92 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
95 text_source.Text = Properties.Settings.Default.DVDSource;
\r
96 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
97 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
98 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
101 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
102 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
103 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
104 text_width.Text = Properties.Settings.Default.Width;
\r
105 text_height.Text = Properties.Settings.Default.Height;
\r
107 // Picture Settings Tab
\r
108 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
109 text_top.Text = Properties.Settings.Default.CropTop;
\r
110 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
111 text_left.Text = Properties.Settings.Default.CropLeft;
\r
112 text_right.Text = Properties.Settings.Default.CropRight;
\r
113 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
115 // Video Settings Tab
\r
116 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
117 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
118 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
120 if (Properties.Settings.Default.TwoPass == "Checked")
\r
122 check_2PassEncode.CheckState = CheckState.Checked;
\r
125 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
126 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
128 if (Properties.Settings.Default.detelecine == "Checked")
\r
130 check_detelecine.CheckState = CheckState.Checked;
\r
133 if (Properties.Settings.Default.detelecine == "Checked")
\r
135 check_deblock.CheckState = CheckState.Checked;
\r
139 if (Properties.Settings.Default.Grayscale == "Checked")
\r
141 check_grayscale.CheckState = CheckState.Checked;
\r
144 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
146 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
148 CheckPixelRatio.CheckState = CheckState.Checked;
\r
150 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
152 check_turbo.CheckState = CheckState.Checked;
\r
154 if (Properties.Settings.Default.largeFile == "Checked")
\r
156 check_largeFile.CheckState = CheckState.Checked;
\r
158 // Audio Settings Tab
\r
159 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
160 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
161 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
164 if (Properties.Settings.Default.CRF == "Checked")
\r
166 CheckCRF.CheckState = CheckState.Checked;
\r
168 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
170 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.selectedPreset + ")";
\r
174 // Load the default preset on lauch
\r
175 ListBox_Presets.SelectedItem = "Normal";
\r
180 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
184 private Boolean updateCheck()
\r
188 if (Properties.Settings.Default.updateStatus == "Checked")
\r
190 String updateFile = Properties.Settings.Default.updateFile;
\r
191 WebClient client = new WebClient();
\r
192 String data = client.DownloadString(updateFile);
\r
193 String[] versionData = data.Split('\n');
\r
195 int verdata = int.Parse(versionData[0].Replace(".", ""));
\r
196 int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));
\r
197 int verd1 = int.Parse(versionData[1].Replace(".", ""));
\r
198 int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));
\r
200 Boolean update = ((verdata > vergui) || (verd1 > cliversion));
\r
202 lbl_update.Visible = update;
\r
213 // Silently ignore the error
\r
218 private void quickStart()
\r
220 if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))
\r
222 frmQuickStart quickstart = new frmQuickStart();
\r
223 quickstart.ShowDialog();
\r
227 private void tooltip()
\r
229 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
231 ToolTip.Active = true;
\r
235 private void showPresets()
\r
237 if (Properties.Settings.Default.showPresets == "Checked")
\r
239 btn_presets.Visible = false;
\r
247 // --------------------------------------------------------------
\r
248 // The main Menu bar.
\r
249 // --------------------------------------------------------------
\r
253 private void mnu_exit_Click(object sender, EventArgs e)
\r
255 Application.Exit();
\r
262 private void mnu_encode_Click(object sender, EventArgs e)
\r
267 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
269 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
270 dvdInfoWindow.Show();
\r
273 private void mnu_options_Click(object sender, EventArgs e)
\r
275 Form Options = new frmOptions();
\r
276 Options.ShowDialog();
\r
281 #region Presets Menu
\r
283 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
285 ListBox_Presets.Items.Clear();
\r
286 ListBox_Presets.Items.Add("Animation");
\r
287 ListBox_Presets.Items.Add("AppleTV");
\r
288 ListBox_Presets.Items.Add("Bedlam");
\r
289 ListBox_Presets.Items.Add("Blind");
\r
290 ListBox_Presets.Items.Add("Broke");
\r
291 ListBox_Presets.Items.Add("Classic");
\r
292 ListBox_Presets.Items.Add("Constant Quality Rate");
\r
293 ListBox_Presets.Items.Add("Deux Six Quatre");
\r
294 ListBox_Presets.Items.Add("Film");
\r
295 ListBox_Presets.Items.Add("iPhone");
\r
296 ListBox_Presets.Items.Add("iPod High-Rez");
\r
297 ListBox_Presets.Items.Add("iPod Low-Rez");
\r
298 ListBox_Presets.Items.Add("Normal");
\r
299 ListBox_Presets.Items.Add("PS3");
\r
300 ListBox_Presets.Items.Add("PSP");
\r
301 ListBox_Presets.Items.Add("QuickTime");
\r
302 ListBox_Presets.Items.Add("Television");
\r
304 if (presetStatus == false)
\r
307 presetStatus = true;
\r
308 btn_presets.Text = "Hide Presets";
\r
312 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
314 ListBox_Presets.SelectedItem = "Normal";
\r
315 if (presetStatus == false)
\r
318 presetStatus = true;
\r
319 btn_presets.Text = "Hide Presets";
\r
327 private void mnu_wiki_Click(object sender, EventArgs e)
\r
329 Process.Start("http://handbrake.m0k.org/trac");
\r
332 private void mnu_faq_Click(object sender, EventArgs e)
\r
334 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
337 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
339 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
342 private void mnu_homepage_Click(object sender, EventArgs e)
\r
344 Process.Start("http://handbrake.m0k.org");
\r
347 private void mnu_forum_Click(object sender, EventArgs e)
\r
349 Process.Start("http://handbrake.m0k.org/forum");
\r
352 private void mnu_UpdateCheck_Click(object sender, EventArgs e)
\r
354 Boolean update = updateCheck();
\r
355 if (update == true)
\r
357 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
361 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
365 private void mnu_about_Click(object sender, EventArgs e)
\r
367 Form About = new frmAbout();
\r
368 About.ShowDialog();
\r
373 // --------------------------------------------------------------
\r
374 // Buttons on the main Window
\r
375 // --------------------------------------------------------------
\r
379 private void btn_Browse_Click(object sender, EventArgs e)
\r
381 String filename = "";
\r
382 text_source.Text = "";
\r
383 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
384 if (RadioDVD.Checked)
\r
386 DVD_Open.ShowDialog();
\r
387 filename = DVD_Open.SelectedPath;
\r
388 if (filename != "")
\r
390 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
391 text_source.Text = filename;
\r
392 frmRD.ShowDialog();
\r
397 ISO_Open.ShowDialog();
\r
398 filename = ISO_Open.FileName;
\r
399 if (filename != "")
\r
401 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
402 text_source.Text = filename;
\r
403 frmRD.ShowDialog();
\r
407 // Check if there was titles in the dvd title dropdown
\r
408 if (filename == "")
\r
410 text_source.Text = "Click 'Browse' to continue";
\r
413 // If there are no titles in the dropdown menu then the scan has obviously failed. Display an error message explaining to the user.
\r
414 if (drp_dvdtitle.Items.Count == 0)
\r
416 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
420 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
422 DVD_Save.ShowDialog();
\r
423 text_destination.Text = DVD_Save.FileName;
\r
425 if (Check_ChapterMarkers.Checked)
\r
427 string destination = text_destination.Text;
\r
428 destination = destination.Replace(".mp4", ".m4v");
\r
429 text_destination.Text = destination;
\r
433 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
435 rtf_h264advanced.Text = "";
\r
438 private void GenerateQuery_Click(object sender, EventArgs e)
\r
440 String query = GenerateTheQuery();
\r
441 QueryEditorText.Text = query;
\r
444 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
446 QueryEditorText.Text = "";
\r
449 private void btn_queue_Click(object sender, EventArgs e)
\r
451 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
452 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
456 if (QueryEditorText.Text == "")
\r
458 query = GenerateTheQuery();
\r
462 query = QueryEditorText.Text;
\r
464 queueWindow.list_queue.Items.Add(query);
\r
465 queueWindow.Show();
\r
469 private void btn_copy_Click(object sender, EventArgs e)
\r
471 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);
\r
474 private void showQueue()
\r
476 queueWindow.Show();
\r
481 // --------------------------------------------------------------
\r
482 // Main Window Preset System
\r
483 // --------------------------------------------------------------
\r
485 #region Preset System
\r
488 private Boolean presetStatus = false;
\r
491 private void btn_presets_Click(object sender, EventArgs e)
\r
493 if (presetStatus == false)
\r
496 presetStatus = true;
\r
497 btn_presets.Text = "Hide Presets";
\r
502 presetStatus = false;
\r
503 btn_presets.Text = "Show Presets";
\r
508 private void btn_addPreset_Click(object sender, EventArgs e)
\r
511 File_Open.ShowDialog();
\r
512 filename = File_Open.FileName;
\r
513 if (filename != "")
\r
517 // Create StreamReader & open file
\r
518 StreamReader line = new StreamReader(filename);
\r
519 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
521 // Read in the data and set the correct GUI component with the setting.
\r
522 text_source.Text = line.ReadLine();
\r
523 drp_dvdtitle.Text = line.ReadLine();
\r
524 drop_chapterStart.Text = line.ReadLine();
\r
525 drop_chapterFinish.Text = line.ReadLine();
\r
526 text_destination.Text = line.ReadLine();
\r
527 drp_videoEncoder.Text = line.ReadLine();
\r
528 drp_audioCodec.Text = line.ReadLine();
\r
529 text_width.Text = line.ReadLine();
\r
530 text_height.Text = line.ReadLine();
\r
531 text_top.Text = line.ReadLine();
\r
532 text_bottom.Text = line.ReadLine();
\r
533 text_left.Text = line.ReadLine();
\r
534 text_right.Text = line.ReadLine();
\r
535 drp_subtitle.Text = line.ReadLine();
\r
536 text_bitrate.Text = line.ReadLine();
\r
537 text_filesize.Text = line.ReadLine();
\r
538 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
540 temporyLine = line.ReadLine();
\r
541 if (temporyLine == "Checked")
\r
543 check_2PassEncode.CheckState = CheckState.Checked;
\r
546 drp_deInterlace_option.Text = line.ReadLine();
\r
548 temporyLine = line.ReadLine();
\r
549 if (temporyLine == "Checked")
\r
551 check_grayscale.CheckState = CheckState.Checked;
\r
554 drp_videoFramerate.Text = line.ReadLine();
\r
556 temporyLine = line.ReadLine();
\r
557 if (temporyLine == "Checked")
\r
559 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
562 temporyLine = line.ReadLine();
\r
563 if (temporyLine == "Checked")
\r
565 CheckPixelRatio.CheckState = CheckState.Checked;
\r
568 temporyLine = line.ReadLine();
\r
569 if (temporyLine == "Checked")
\r
571 check_turbo.CheckState = CheckState.Checked;
\r
574 temporyLine = line.ReadLine();
\r
575 if (temporyLine == "Checked")
\r
577 check_largeFile.CheckState = CheckState.Checked;
\r
580 drp_audioBitrate.Text = line.ReadLine();
\r
581 drp_audioSampleRate.Text = line.ReadLine();
\r
582 drp_audioChannels.Text = line.ReadLine();
\r
583 drp_audioMixDown.Text = line.ReadLine();
\r
585 // Advanced H264 Options
\r
586 temporyLine = line.ReadLine();
\r
587 if (temporyLine == "Checked")
\r
589 CheckCRF.CheckState = CheckState.Checked;
\r
591 rtf_h264advanced.Text = line.ReadLine();
\r
593 // Close the stream
\r
597 // Fix for SliderValue not appearing when Opening saved file
\r
598 SliderValue.Text = slider_videoQuality.Value + "%";
\r
603 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
608 private void btn_removePreset_Click(object sender, EventArgs e)
\r
611 File_Save.ShowDialog();
\r
612 filename = File_Save.FileName;
\r
613 if (filename != "")
\r
617 // Create a StreamWriter and open the file
\r
618 StreamWriter line = new StreamWriter(filename);
\r
621 line.WriteLine(text_source.Text);
\r
622 line.WriteLine(drp_dvdtitle.Text);
\r
623 line.WriteLine(drop_chapterStart.Text);
\r
624 line.WriteLine(drop_chapterFinish.Text);
\r
626 line.WriteLine(text_destination.Text);
\r
627 line.WriteLine(drp_videoEncoder.Text);
\r
628 line.WriteLine(drp_audioCodec.Text);
\r
629 line.WriteLine(text_width.Text);
\r
630 line.WriteLine(text_height.Text);
\r
631 //Picture Settings Tab
\r
632 line.WriteLine(text_top.Text);
\r
633 line.WriteLine(text_bottom.Text);
\r
634 line.WriteLine(text_left.Text);
\r
635 line.WriteLine(text_right.Text);
\r
636 line.WriteLine(drp_subtitle.Text);
\r
637 //Video Settings Tab
\r
638 line.WriteLine(text_bitrate.Text);
\r
639 line.WriteLine(text_filesize.Text);
\r
640 line.WriteLine(slider_videoQuality.Value.ToString());
\r
641 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
642 line.WriteLine(drp_deInterlace_option.Text);
\r
643 line.WriteLine(check_grayscale.CheckState.ToString());
\r
644 line.WriteLine(drp_videoFramerate.Text);
\r
645 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
646 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
647 line.WriteLine(check_turbo.CheckState.ToString());
\r
648 line.WriteLine(check_largeFile.CheckState.ToString());
\r
649 //Audio Settings Tab
\r
650 line.WriteLine(drp_audioBitrate.Text);
\r
651 line.WriteLine(drp_audioSampleRate.Text);
\r
652 line.WriteLine(drp_audioChannels.Text);
\r
653 line.WriteLine(drp_audioMixDown.Text);
\r
655 line.WriteLine(CheckCRF.CheckState.ToString());
\r
656 line.WriteLine(rtf_h264advanced.Text);
\r
657 // close the stream
\r
659 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
663 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
669 private void btn_setDefault_Click(object sender, EventArgs e)
\r
672 Properties.Settings.Default.DVDSource = text_source.Text;
\r
673 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
674 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
675 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
677 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
678 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
679 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
680 Properties.Settings.Default.Width = text_width.Text;
\r
681 Properties.Settings.Default.Height = text_height.Text;
\r
682 //Picture Settings Tab
\r
683 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
684 Properties.Settings.Default.CropTop = text_top.Text;
\r
685 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
686 Properties.Settings.Default.CropLeft = text_left.Text;
\r
687 Properties.Settings.Default.CropRight = text_right.Text;
\r
688 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
689 //Video Settings Tab
\r
690 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
691 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
692 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
693 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
694 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
695 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
696 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
697 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
698 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
699 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
700 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
701 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
702 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
703 //Audio Settings Tab
\r
704 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
705 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
706 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
708 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
709 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
712 Properties.Settings.Default.selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
714 catch (Exception exc)
\r
716 // If the user has not selected an item, then an exception may be thrown. Catch and ignore.
\r
718 Properties.Settings.Default.Save();
\r
721 // Preset Seleciton
\r
722 private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)
\r
724 string selectedPreset = null;
\r
725 if (ListBox_Presets.SelectedItem != null)
\r
727 selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
731 selectedPreset = "";
\r
734 switch (selectedPreset)
\r
737 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
741 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
744 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
748 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
751 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
754 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
756 case "Constant Quality Rate":
\r
757 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
760 case "Deux Six Quatre":
\r
761 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
765 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
769 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
771 case "iPod High-Rez":
\r
772 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
774 case "iPod Low-Rez":
\r
775 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
778 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
781 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
784 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
787 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
790 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
798 // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.
\r
799 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
801 CheckPixelRatio.CheckState = anamorphic;
\r
802 text_width.Text = width;
\r
803 text_height.Text = height;
\r
804 drp_videoEncoder.Text = vencoder;
\r
805 text_bitrate.Text = bitrate;
\r
806 text_filesize.Text = filesize;
\r
807 slider_videoQuality.Value = quality;
\r
808 SliderValue.Text = qpercent;
\r
809 drp_audioBitrate.Text = audioBit;
\r
810 Check_ChapterMarkers.CheckState = chpt;
\r
811 drp_audioSampleRate.Text = audioSample;
\r
812 rtf_h264advanced.Text = h264;
\r
813 drp_deInterlace_option.Text = deinterlace;
\r
814 check_2PassEncode.CheckState = twopass;
\r
815 drp_crop.Text = crop;
\r
816 check_turbo.CheckState = turbo;
\r
817 drp_audioCodec.Text = audioCodec;
\r
819 groupBox_output.Text = preset;
\r
822 private void setMkv()
\r
824 // Set file extension to MKV
\r
825 string destination = text_destination.Text;
\r
826 destination = destination.Replace(".mp4", ".mkv");
\r
827 destination = destination.Replace(".avi", ".mkv");
\r
828 destination = destination.Replace(".m4v", ".mkv");
\r
829 destination = destination.Replace(".ogm", ".mkv");
\r
830 text_destination.Text = destination;
\r
835 //---------------------------------------------------
\r
836 // Encode / Cancel Buttons
\r
837 // Encode Progress Text Handler
\r
838 //---------------------------------------------------
\r
842 Functions.CLI process = new Functions.CLI();
\r
844 private void btn_encode_Click(object sender, EventArgs e)
\r
846 if (text_source.Text == "" || text_source.Text == "Click 'Browse' to continue" || text_destination.Text == "")
\r
847 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
850 btn_eCancel.Enabled = true;
\r
852 if (QueryEditorText.Text == "")
\r
854 query = GenerateTheQuery();
\r
858 query = QueryEditorText.Text;
\r
861 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
862 lbl_encode.Visible = true;
\r
863 lbl_encode.Text = "Encoding in Progress";
\r
867 private void btn_eCancel_Click(object sender, EventArgs e)
\r
871 lbl_encode.Text = "Encoding Canceled";
\r
874 [DllImport("user32.dll")]
\r
875 public static extern void LockWorkStation();
\r
876 [DllImport("user32.dll")]
\r
877 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
879 private void procMonitor(object state)
\r
881 // Make sure we are not already encoding and if we are then display an error.
\r
882 if (hbProc != null)
\r
884 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
888 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
889 hbProc.WaitForExit();
\r
894 //*****************************************************************************************
\r
896 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
897 // video stream which has mild corruption issues every few seconds.
\r
898 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
899 //*****************************************************************************************
\r
902 Parsing.Parser encode = new Parsing.Parser(hbProc.StandardOutput.BaseStream);
\r
903 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
904 while (!encode.EndOfStream)
\r
909 hbProc.WaitForExit();
\r
910 process.closeCLI();
\r
914 catch (Exception exc)
\r
917 MessageBox.Show(exc.ToString());
\r
924 // Do something whent he encode ends.
\r
925 switch (Properties.Settings.Default.CompletionOption)
\r
928 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
931 ExitWindowsEx(0, 0);
\r
934 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
937 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
939 case "Lock System":
\r
942 case "Quit HandBrake":
\r
943 Application.Exit();
\r
951 private delegate void UpdateUIHandler();
\r
953 private void setEncodeLabel()
\r
955 if (this.InvokeRequired)
\r
957 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
960 lbl_encode.Text = "Encoding Finished";
\r
963 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
966 if (this.InvokeRequired)
\r
968 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
969 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
972 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
977 //---------------------------------------------------
\r
978 // Items that require actions on frmMain
\r
979 //---------------------------------------------------
\r
981 #region frmMain Actions
\r
983 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
985 drop_chapterStart.BackColor = Color.White;
\r
986 QueryEditorText.Text = "";
\r
987 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
991 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
992 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
994 if (chapterFinish < chapterStart)
\r
996 drop_chapterStart.BackColor = Color.LightCoral;
\r
1001 drop_chapterStart.BackColor = Color.LightCoral;
\r
1008 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1010 drop_chapterFinish.BackColor = Color.White;
\r
1011 QueryEditorText.Text = "";
\r
1012 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1016 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1017 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1019 if (chapterFinish < chapterStart)
\r
1021 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1026 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1031 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1033 text_filesize.Text = "";
\r
1034 slider_videoQuality.Value = 0;
\r
1035 SliderValue.Text = "0%";
\r
1036 CheckCRF.CheckState = CheckState.Unchecked;
\r
1037 CheckCRF.Enabled = false;
\r
1040 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1042 text_bitrate.Text = "";
\r
1043 slider_videoQuality.Value = 0;
\r
1044 SliderValue.Text = "0%";
\r
1045 CheckCRF.CheckState = CheckState.Unchecked;
\r
1046 CheckCRF.Enabled = false;
\r
1049 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1051 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1052 text_bitrate.Text = "";
\r
1053 text_filesize.Text = "";
\r
1054 CheckCRF.Enabled = true;
\r
1057 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1059 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1062 private void text_width_TextChanged(object sender, EventArgs e)
\r
1067 if (CheckPixelRatio.Checked)
\r
1069 text_width.Text = "";
\r
1070 text_width.BackColor = Color.White;
\r
1074 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1076 text_width.BackColor = Color.LightCoral;
\r
1080 text_width.BackColor = Color.LightGreen;
\r
1084 if (lbl_Aspect.Text != "Select a Title")
\r
1086 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1087 double mod16 = height % 16;
\r
1088 height = height - mod16;
\r
1090 if (text_width.Text == "")
\r
1092 text_height.Text = "";
\r
1093 text_width.BackColor = Color.White;
\r
1097 text_height.Text = height.ToString();
\r
1103 // No need to throw an error here.
\r
1104 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1110 private void text_height_TextChanged(object sender, EventArgs e)
\r
1114 if (text_height.Text != "Auto")
\r
1116 if (CheckPixelRatio.Checked)
\r
1118 text_height.Text = "";
\r
1119 text_width.BackColor = Color.White;
\r
1123 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1125 text_height.BackColor = Color.LightCoral;
\r
1129 text_height.BackColor = Color.LightGreen;
\r
1133 } catch(Exception){
\r
1134 // No need to alert the user.
\r
1138 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1140 if ((string)drp_crop.SelectedItem == "Manual")
\r
1142 text_left.Enabled = true;
\r
1143 text_right.Enabled = true;
\r
1144 text_top.Enabled = true;
\r
1145 text_bottom.Enabled = true;
\r
1148 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1150 text_left.Enabled = false;
\r
1151 text_right.Enabled = false;
\r
1152 text_top.Enabled = false;
\r
1153 text_bottom.Enabled = false;
\r
1154 text_left.Text = "";
\r
1155 text_right.Text = "";
\r
1156 text_top.Text = "";
\r
1157 text_bottom.Text = "";
\r
1159 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1161 string[] temp = new string[4];
\r
1162 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1163 text_left.Text = temp[2];
\r
1164 text_right.Text = temp[3];
\r
1165 text_top.Text = temp[0];
\r
1166 text_bottom.Text = temp[1];
\r
1170 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1172 text_left.Enabled = false;
\r
1173 text_right.Enabled = false;
\r
1174 text_top.Enabled = false;
\r
1175 text_bottom.Enabled = false;
\r
1176 text_left.Text = "0";
\r
1177 text_right.Text = "0";
\r
1178 text_top.Text = "0";
\r
1179 text_bottom.Text = "0";
\r
1184 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1186 text_width.Text = "";
\r
1187 text_height.Text = "";
\r
1188 text_width.BackColor = Color.White;
\r
1189 text_height.BackColor = Color.White;
\r
1192 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1194 if (drp_dvdtitle.Items.Count == 0)
\r
1196 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
1200 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1203 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1205 drp_audioMixDown.Items.Clear();
\r
1207 if (drp_audioCodec.Text == "AAC")
\r
1209 drp_audioMixDown.Items.Clear();
\r
1210 drp_audioMixDown.Items.Add("Mono");
\r
1211 drp_audioMixDown.Items.Add("Stereo");
\r
1212 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1213 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1214 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1216 drp_audioBitrate.Items.Clear();
\r
1217 drp_audioBitrate.Items.Add("32");
\r
1218 drp_audioBitrate.Items.Add("40");
\r
1219 drp_audioBitrate.Items.Add("48");
\r
1220 drp_audioBitrate.Items.Add("56");
\r
1221 drp_audioBitrate.Items.Add("64");
\r
1222 drp_audioBitrate.Items.Add("80");
\r
1223 drp_audioBitrate.Items.Add("86");
\r
1224 drp_audioBitrate.Items.Add("112");
\r
1225 drp_audioBitrate.Items.Add("128");
\r
1226 drp_audioBitrate.Items.Add("160");
\r
1231 drp_audioMixDown.Items.Clear();
\r
1232 drp_audioMixDown.Items.Add("Stereo");
\r
1233 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1234 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1236 drp_audioBitrate.Items.Clear();
\r
1237 drp_audioBitrate.Items.Add("32");
\r
1238 drp_audioBitrate.Items.Add("40");
\r
1239 drp_audioBitrate.Items.Add("48");
\r
1240 drp_audioBitrate.Items.Add("56");
\r
1241 drp_audioBitrate.Items.Add("64");
\r
1242 drp_audioBitrate.Items.Add("80");
\r
1243 drp_audioBitrate.Items.Add("86");
\r
1244 drp_audioBitrate.Items.Add("112");
\r
1245 drp_audioBitrate.Items.Add("128");
\r
1246 drp_audioBitrate.Items.Add("160");
\r
1247 drp_audioBitrate.Items.Add("192");
\r
1248 drp_audioBitrate.Items.Add("224");
\r
1249 drp_audioBitrate.Items.Add("256");
\r
1250 drp_audioBitrate.Items.Add("320");
\r
1254 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1256 if (drp_audioCodec.Text == "AAC")
\r
1258 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1261 drp_audioBitrate.Items.Clear();
\r
1262 drp_audioBitrate.Items.Add("32");
\r
1263 drp_audioBitrate.Items.Add("40");
\r
1264 drp_audioBitrate.Items.Add("48");
\r
1265 drp_audioBitrate.Items.Add("56");
\r
1266 drp_audioBitrate.Items.Add("64");
\r
1267 drp_audioBitrate.Items.Add("80");
\r
1268 drp_audioBitrate.Items.Add("86");
\r
1269 drp_audioBitrate.Items.Add("112");
\r
1270 drp_audioBitrate.Items.Add("128");
\r
1271 drp_audioBitrate.Items.Add("160");
\r
1272 drp_audioBitrate.Items.Add("192");
\r
1273 drp_audioBitrate.Items.Add("224");
\r
1274 drp_audioBitrate.Items.Add("256");
\r
1275 drp_audioBitrate.Items.Add("320");
\r
1276 drp_audioBitrate.Items.Add("384");
\r
1281 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1283 if (Check_ChapterMarkers.Checked)
\r
1285 string destination = text_destination.Text;
\r
1286 destination = destination.Replace(".mp4", ".m4v");
\r
1287 text_destination.Text = destination;
\r
1291 string destination = text_destination.Text;
\r
1292 destination = destination.Replace(".m4v", ".mp4");
\r
1293 text_destination.Text = destination;
\r
1297 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1299 if (!text_destination.Text.Contains(".mp4"))
\r
1301 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1302 check_largeFile.CheckState = CheckState.Unchecked;
\r
1306 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1308 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1309 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1311 check_turbo.CheckState = CheckState.Unchecked;
\r
1312 CheckCRF.CheckState = CheckState.Unchecked;
\r
1313 CheckCRF.Enabled = false;
\r
1314 check_turbo.Enabled = false;
\r
1315 h264Tab.Enabled = false;
\r
1319 CheckCRF.Enabled = true;
\r
1320 check_turbo.Enabled = true;
\r
1321 h264Tab.Enabled = true;
\r
1326 public void setStreamReader(Parsing.DVD dvd)
\r
1328 this.thisDVD = dvd;
\r
1331 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1333 // Reset some values on the form
\r
1334 lbl_Aspect.Text = "Select a Title";
\r
1335 lbl_RecomendedCrop.Text = "Select a Title";
\r
1336 drop_chapterStart.Items.Clear();
\r
1337 drop_chapterFinish.Items.Clear();
\r
1338 QueryEditorText.Text = "";
\r
1340 // If the dropdown is set to automatic nothing else needs to be done.
\r
1341 // Otheriwse if its not, title data has to be loased from parsing.
\r
1342 if (drp_dvdtitle.Text != "Automatic")
\r
1344 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1346 // Set the Aspect Ratio
\r
1347 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1349 // Set the Recommended Cropping values
\r
1350 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1352 // Populate the Start chapter Dropdown
\r
1353 drop_chapterStart.Items.Clear();
\r
1354 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1355 if (drop_chapterStart.Items.Count > 0)
\r
1357 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1360 // Populate the Final Chapter Dropdown
\r
1361 drop_chapterFinish.Items.Clear();
\r
1362 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1363 if (drop_chapterFinish.Items.Count > 0)
\r
1365 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1368 // Populate the Audio Channels Dropdown
\r
1369 drp_audioChannels.Items.Clear();
\r
1370 drp_audioChannels.Items.Add("Automatic");
\r
1371 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1372 if (drp_audioChannels.Items.Count > 0)
\r
1374 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1377 // Populate the Subtitles dropdown
\r
1378 drp_subtitle.Items.Clear();
\r
1379 drp_subtitle.Items.Add("None");
\r
1380 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1381 if (drp_subtitle.Items.Count > 0)
\r
1383 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1390 //---------------------------------------------------
\r
1392 // - Query Generation
\r
1393 //---------------------------------------------------
\r
1395 #region Program Functions
\r
1397 public string GenerateTheQuery()
\r
1399 string source = text_source.Text;
\r
1400 string dvdTitle = drp_dvdtitle.Text;
\r
1401 string chapterStart = drop_chapterStart.Text;
\r
1402 string chapterFinish = drop_chapterFinish.Text;
\r
1403 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1404 string dvdChapter = "";
\r
1406 source = " -i " + '"' + source+ '"';
\r
1408 if (dvdTitle == "Automatic")
\r
1412 string[] titleInfo = dvdTitle.Split(' ');
\r
1413 dvdTitle = " -t "+ titleInfo[0];
\r
1416 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1418 else if (chapterFinish == chapterStart)
\r
1419 dvdChapter = " -c " + chapterStart;
\r
1421 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1423 string querySource = source+ dvdTitle+ dvdChapter;
\r
1424 // ----------------------------------------------------------------------
\r
1428 string destination = text_destination.Text;
\r
1429 string videoEncoder = drp_videoEncoder.Text;
\r
1430 string audioEncoder = drp_audioCodec.Text;
\r
1431 string width = text_width.Text;
\r
1432 string height = text_height.Text;
\r
1434 if (destination == "")
\r
1435 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1437 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1440 switch (videoEncoder)
\r
1443 videoEncoder = " -e ffmpeg";
\r
1446 videoEncoder = " -e xvid";
\r
1449 videoEncoder = " -e x264";
\r
1451 case "H.264 Baseline 1.3":
\r
1452 videoEncoder = " -e x264b13";
\r
1454 case "H.264 (iPod)":
\r
1455 videoEncoder = " -e x264b30";
\r
1458 videoEncoder = " -e x264";
\r
1462 switch (audioEncoder)
\r
1465 audioEncoder = " -E faac";
\r
1468 audioEncoder = " -E lame";
\r
1471 audioEncoder = " -E vorbis";
\r
1474 audioEncoder = " -E ac3";
\r
1477 audioEncoder = " -E faac";
\r
1482 width = " -w "+ width;
\r
1485 if (height == "Auto")
\r
1489 else if (height != "")
\r
1491 height = " -l " + height;
\r
1495 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1496 // ----------------------------------------------------------------------
\r
1498 // Picture Settings Tab
\r
1500 string cropSetting = drp_crop.Text;
\r
1501 string cropTop = text_top.Text;
\r
1502 string cropBottom = text_bottom.Text;
\r
1503 string cropLeft = text_left.Text;
\r
1504 string cropRight = text_right.Text;
\r
1505 string subtitles = drp_subtitle.Text;
\r
1506 string cropOut = "";
\r
1507 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1508 string deinterlace = "";
\r
1509 string grayscale = "";
\r
1510 string pixelRatio = "";
\r
1511 string ChapterMarkers = "";
\r
1512 // Returns Crop Query
\r
1514 if (cropSetting == "Auto Crop")
\r
1516 else if (cropSetting == "No Crop")
\r
1517 cropOut = " --crop 0:0:0:0 ";
\r
1520 if (text_top.Text == "")
\r
1522 if (text_bottom.Text == "")
\r
1524 if (text_left.Text == "")
\r
1526 if (text_right.Text == "")
\r
1529 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1532 if (subtitles == "None")
\r
1534 else if (subtitles == "")
\r
1539 tempSub = subtitles.Split(' ');
\r
1540 subtitles = " -s "+ tempSub[0];
\r
1543 switch (deInterlace_Option)
\r
1548 case "Origional (Fast)":
\r
1549 deinterlace = " --deinterlace=1";
\r
1551 case "yadif (Slow)":
\r
1552 deinterlace = " --deinterlace=" + '"' + "0" + '"';
\r
1554 case "yadif + mcdeint (Slower)":
\r
1555 deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';
\r
1557 case "yadif + mcdeint (Slowest)":
\r
1558 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1565 if (check_grayscale.Checked)
\r
1566 grayscale = " -g ";
\r
1568 if (CheckPixelRatio.Checked)
\r
1569 pixelRatio = " -p ";
\r
1571 if (Check_ChapterMarkers.Checked)
\r
1572 ChapterMarkers = " -m ";
\r
1574 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1575 // ----------------------------------------------------------------------
\r
1577 // Video Settings Tab
\r
1579 string videoBitrate = text_bitrate.Text;
\r
1580 string videoFilesize = text_filesize.Text;
\r
1581 double videoQuality = slider_videoQuality.Value;
\r
1582 string vidQSetting = "";
\r
1583 string twoPassEncoding = "";
\r
1584 string videoFramerate = drp_videoFramerate.Text;
\r
1585 string turboH264 = "";
\r
1586 string largeFile = "";
\r
1587 string deblock = "";
\r
1588 string detelecine = "";
\r
1589 string denoise = "";
\r
1590 string CRF = CheckCRF.CheckState.ToString();
\r
1593 if ((CRF == "Checked"))
\r
1598 if (videoBitrate != "")
\r
1599 videoBitrate = " -b "+ videoBitrate;
\r
1601 if (videoFilesize != "")
\r
1602 videoFilesize = " -S "+ videoFilesize;
\r
1604 // Video Quality Setting
\r
1606 if ((videoQuality == 0))
\r
1610 videoQuality = videoQuality / 100;
\r
1611 if (videoQuality == 1)
\r
1613 vidQSetting = "1.0";
\r
1616 vidQSetting = " -q " + videoQuality.ToString();
\r
1619 if (check_2PassEncode.Checked)
\r
1620 twoPassEncoding = " -2 ";
\r
1622 if (videoFramerate == "Automatic")
\r
1623 videoFramerate = "";
\r
1625 videoFramerate = " -r "+ videoFramerate;
\r
1627 if (check_turbo.Checked)
\r
1628 turboH264 = " -T ";
\r
1630 if (check_largeFile.Checked)
\r
1631 largeFile = " -4 ";
\r
1633 if (check_deblock.Checked)
\r
1634 deblock = " --deblock";
\r
1636 if (check_detelecine.Checked)
\r
1637 detelecine = " --detelecine";
\r
1639 switch (drp_deNoise.Text)
\r
1645 denoise = " --denoise=2:1:2:3";
\r
1648 denoise = " --denoise=3:2:2:3";
\r
1651 denoise = " --denoise=7:7:5:5";
\r
1658 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1659 // ----------------------------------------------------------------------
\r
1661 // Audio Settings Tab
\r
1663 string audioBitrate = drp_audioBitrate.Text;
\r
1664 string audioSampleRate = drp_audioSampleRate.Text;
\r
1665 string audioChannels = drp_audioChannels.Text;
\r
1666 string Mixdown = drp_audioMixDown.Text;
\r
1667 string SixChannelAudio = "";
\r
1669 if (audioBitrate != "")
\r
1670 audioBitrate = " -B "+ audioBitrate;
\r
1672 if (audioSampleRate != "")
\r
1673 audioSampleRate = " -R "+ audioSampleRate;
\r
1675 if (audioChannels == "Automatic")
\r
1676 audioChannels = "";
\r
1677 else if (audioChannels == "")
\r
1678 audioChannels = "";
\r
1682 tempSub = audioChannels.Split(' ');
\r
1683 audioChannels = " -a "+ tempSub[0];
\r
1695 Mixdown = "stereo";
\r
1697 case "Dolby Surround":
\r
1700 case "Dolby Pro Logic II":
\r
1703 case "6 Channel Discrete":
\r
1707 Mixdown = "stero";
\r
1711 if (Mixdown != "")
\r
1712 SixChannelAudio = " -6 "+ Mixdown;
\r
1714 SixChannelAudio = "";
\r
1716 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1717 // ----------------------------------------------------------------------
\r
1722 string h264Advanced = rtf_h264advanced.Text;
\r
1724 if ((h264Advanced == ""))
\r
1725 h264Advanced = "";
\r
1727 h264Advanced = " -x "+ h264Advanced;
\r
1730 string h264Settings = h264Advanced;
\r
1731 // ----------------------------------------------------------------------
\r
1733 // Processors (Program Settings)
\r
1735 string processors = Properties.Settings.Default.Processors;
\r
1736 // Number of Processors Handler
\r
1738 if (processors == "Automatic")
\r
1741 processors = " -C "+ processors+ " ";
\r
1744 string queryAdvancedSettings = processors;
\r
1745 // ----------------------------------------------------------------------
\r
1747 // Verbose option (Program Settings)
\r
1749 string verbose = "";
\r
1750 if (Properties.Settings.Default.verbose == "Checked")
\r
1753 // ----------------------------------------------------------------------
\r
1755 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1760 // This is the END of the road ------------------------------------------------------------------------------
\r