2 using System.Collections.Generic;
\r
3 using System.Collections.Specialized;
\r
4 using System.ComponentModel;
\r
6 using System.Drawing;
\r
8 using System.Windows.Forms;
\r
11 using System.Diagnostics;
\r
12 using System.Threading;
\r
13 using System.Runtime.InteropServices;
\r
19 public partial class frmMain : Form
\r
21 // --------------------------------------------------------------
\r
22 // Applicaiton Startup Stuff
\r
23 // --------------------------------------------------------------
\r
25 #region Application Startup
\r
27 private Process hbProc;
\r
28 private Parsing.DVD thisDVD;
\r
29 private frmQueue queueWindow = new frmQueue();
\r
30 //private frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
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.GuiVersion;
\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
63 // Create and initializes a new StringCollection.
\r
64 StringCollection myCol = new StringCollection();
\r
65 // Add a range of elements from an array to the end of the StringCollection.
\r
66 String[] myArr = new String[] { "RED", "orange", "yellow", "RED", "green", "blue", "RED", "indigo", "violet", "RED" };
\r
67 myCol.AddRange(myArr);
\r
69 Properties.Settings.Default.BuiltInPresets = myCol;
\r
72 private void showSplash(object sender)
\r
74 Form splash = new frmSplashScreen();
\r
76 Thread.Sleep(1500); // Display splash screen for 1.5 Seconds
\r
77 splash.Close(); // Then close.
\r
80 private void loadUserDefaults()
\r
84 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
87 text_source.Text = Properties.Settings.Default.DVDSource;
\r
88 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
89 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
90 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
93 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
94 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
95 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
96 text_width.Text = Properties.Settings.Default.Width;
\r
97 text_height.Text = Properties.Settings.Default.Height;
\r
99 // Picture Settings Tab
\r
100 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
101 text_top.Text = Properties.Settings.Default.CropTop;
\r
102 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
103 text_left.Text = Properties.Settings.Default.CropLeft;
\r
104 text_right.Text = Properties.Settings.Default.CropRight;
\r
105 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
107 // Video Settings Tab
\r
108 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
109 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
110 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
112 if (Properties.Settings.Default.TwoPass == "Checked")
\r
114 check_2PassEncode.CheckState = CheckState.Checked;
\r
117 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
118 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
120 if (Properties.Settings.Default.detelecine == "Checked")
\r
122 check_detelecine.CheckState = CheckState.Checked;
\r
125 if (Properties.Settings.Default.detelecine == "Checked")
\r
127 check_deblock.CheckState = CheckState.Checked;
\r
131 if (Properties.Settings.Default.Grayscale == "Checked")
\r
133 check_grayscale.CheckState = CheckState.Checked;
\r
136 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
138 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
140 CheckPixelRatio.CheckState = CheckState.Checked;
\r
142 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
144 check_turbo.CheckState = CheckState.Checked;
\r
146 if (Properties.Settings.Default.largeFile == "Checked")
\r
148 check_largeFile.CheckState = CheckState.Checked;
\r
150 // Audio Settings Tab
\r
151 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
152 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
153 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
156 if (Properties.Settings.Default.CRF == "Checked")
\r
158 CheckCRF.CheckState = CheckState.Checked;
\r
160 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
162 groupBox_output.Text = "Output Settings (Preset: " + Properties.Settings.Default.SelectedPreset + ")";
\r
166 // Load the default preset on lauch
\r
167 ListBox_Presets.SelectedItem = "Normal";
\r
172 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
176 private Boolean updateCheck()
\r
180 if (Properties.Settings.Default.updateStatus == "Checked")
\r
182 String updateFile = Properties.Settings.Default.updateFile;
\r
183 WebClient client = new WebClient();
\r
184 String data = client.DownloadString(updateFile);
\r
185 String[] versionData = data.Split('\n');
\r
187 int verdata = int.Parse(versionData[0].Replace(".", ""));
\r
188 int vergui = int.Parse(Properties.Settings.Default.GuiVersion.Replace(".", ""));
\r
189 int verd1 = int.Parse(versionData[1].Replace(".", ""));
\r
190 int cliversion = int.Parse(Properties.Settings.Default.CliVersion.Replace(".", ""));
\r
192 Boolean update = ((verdata > vergui) || (verd1 > cliversion));
\r
194 lbl_update.Visible = update;
\r
205 // Silently ignore the error
\r
210 private void quickStart()
\r
212 if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))
\r
214 frmQuickStart quickstart = new frmQuickStart();
\r
215 quickstart.ShowDialog();
\r
219 private void tooltip()
\r
221 if (Properties.Settings.Default.tooltipEnable == "Checked")
\r
223 ToolTip.Active = true;
\r
229 // --------------------------------------------------------------
\r
230 // The main Menu bar.
\r
231 // --------------------------------------------------------------
\r
235 private void mnu_exit_Click(object sender, EventArgs e)
\r
237 Application.Exit();
\r
244 private void mnu_encode_Click(object sender, EventArgs e)
\r
249 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
251 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
252 dvdInfoWindow.Show();
\r
255 private void mnu_options_Click(object sender, EventArgs e)
\r
257 Form Options = new frmOptions();
\r
258 Options.ShowDialog();
\r
263 #region Presets Menu
\r
265 private void mnu_presetReset_Click(object sender, EventArgs e)
\r
267 ListBox_Presets.Items.Clear();
\r
268 ListBox_Presets.Items.Add("Animation");
\r
269 ListBox_Presets.Items.Add("AppleTV");
\r
270 ListBox_Presets.Items.Add("Bedlam");
\r
271 ListBox_Presets.Items.Add("Blind");
\r
272 ListBox_Presets.Items.Add("Broke");
\r
273 ListBox_Presets.Items.Add("Classic");
\r
274 ListBox_Presets.Items.Add("Constant Quality Rate");
\r
275 ListBox_Presets.Items.Add("Deux Six Quatre");
\r
276 ListBox_Presets.Items.Add("Film");
\r
277 ListBox_Presets.Items.Add("iPhone");
\r
278 ListBox_Presets.Items.Add("iPod High-Rez");
\r
279 ListBox_Presets.Items.Add("iPod Low-Rez");
\r
280 ListBox_Presets.Items.Add("Normal");
\r
281 ListBox_Presets.Items.Add("PS3");
\r
282 ListBox_Presets.Items.Add("PSP");
\r
283 ListBox_Presets.Items.Add("QuickTime");
\r
284 ListBox_Presets.Items.Add("Television");
\r
286 if (presetStatus == false)
\r
289 presetStatus = true;
\r
290 btn_presets.Text = "Hide Presets";
\r
294 private void mnu_SelectDefault_Click(object sender, EventArgs e)
\r
296 ListBox_Presets.SelectedItem = "Normal";
\r
297 if (presetStatus == false)
\r
300 presetStatus = true;
\r
301 btn_presets.Text = "Hide Presets";
\r
309 private void mnu_wiki_Click(object sender, EventArgs e)
\r
311 Process.Start("http://handbrake.m0k.org/trac");
\r
314 private void mnu_faq_Click(object sender, EventArgs e)
\r
316 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
319 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
321 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
324 private void mnu_homepage_Click(object sender, EventArgs e)
\r
326 Process.Start("http://handbrake.m0k.org");
\r
329 private void mnu_forum_Click(object sender, EventArgs e)
\r
331 Process.Start("http://handbrake.m0k.org/forum");
\r
334 private void mnu_UpdateCheck_Click(object sender, EventArgs e)
\r
336 Boolean update = updateCheck();
\r
337 if (update == true)
\r
339 MessageBox.Show("There is a new update available. Please visit http://handbrake.m0k.org for details!", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
343 MessageBox.Show("There are no new updates at this time.", "Update Check", MessageBoxButtons.OK, MessageBoxIcon.Information);
\r
347 private void mnu_about_Click(object sender, EventArgs e)
\r
349 Form About = new frmAbout();
\r
350 About.ShowDialog();
\r
355 // --------------------------------------------------------------
\r
356 // Buttons on the main Window
\r
357 // --------------------------------------------------------------
\r
361 private void btn_Browse_Click(object sender, EventArgs e)
\r
363 String filename ="";
\r
364 text_source.Text = "";
\r
365 frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
366 if (RadioDVD.Checked)
\r
368 DVD_Open.ShowDialog();
\r
369 filename = DVD_Open.SelectedPath;
\r
370 if (filename != "")
\r
372 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
373 text_source.Text = filename;
\r
374 frmRD.ShowDialog();
\r
379 ISO_Open.ShowDialog();
\r
380 filename = ISO_Open.FileName;
\r
381 if (filename != "")
\r
383 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
384 text_source.Text = filename;
\r
385 frmRD.ShowDialog();
\r
389 // Check if there was titles in the dvd title dropdown
\r
390 if (filename == "")
\r
392 text_source.Text = "Click 'Browse' to continue";
\r
395 if (drp_dvdtitle.Items.Count == 0)
\r
397 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
401 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
403 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
405 DVD_Save.ShowDialog();
\r
406 text_destination.Text = DVD_Save.FileName;
\r
408 if (Check_ChapterMarkers.Checked)
\r
410 string destination = text_destination.Text;
\r
411 destination = destination.Replace(".mp4", ".m4v");
\r
412 text_destination.Text = destination;
\r
416 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
418 rtf_h264advanced.Text = "";
\r
421 private void GenerateQuery_Click(object sender, EventArgs e)
\r
423 String query = GenerateTheQuery();
\r
424 QueryEditorText.Text = query;
\r
427 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
429 QueryEditorText.Text = "";
\r
432 private void btn_queue_Click(object sender, EventArgs e)
\r
434 if (text_destination.Text != "" && text_source.Text != "")
\r
437 if (QueryEditorText.Text == "")
\r
439 query = GenerateTheQuery();
\r
443 query = QueryEditorText.Text;
\r
445 queueWindow.list_queue.Items.Add(query);
\r
446 queueWindow.Show();
\r
450 MessageBox.Show("No Source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
454 private void btn_copy_Click(object sender, EventArgs e)
\r
456 Clipboard.SetText(QueryEditorText.Text, TextDataFormat.Text);
\r
459 private void showQueue()
\r
461 queueWindow.Show();
\r
466 // --------------------------------------------------------------
\r
467 // Main Window Preset System
\r
468 // --------------------------------------------------------------
\r
470 #region Preset System
\r
473 private Boolean presetStatus = false;
\r
476 private void btn_presets_Click(object sender, EventArgs e)
\r
478 if (presetStatus == false)
\r
481 presetStatus = true;
\r
482 btn_presets.Text = "Hide Presets";
\r
487 presetStatus = false;
\r
488 btn_presets.Text = "Show Presets";
\r
493 private void btn_addPreset_Click(object sender, EventArgs e)
\r
496 File_Open.ShowDialog();
\r
497 filename = File_Open.FileName;
\r
498 if (filename != "")
\r
502 // Create StreamReader & open file
\r
503 StreamReader line = new StreamReader(filename);
\r
504 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
506 // Read in the data and set the correct GUI component with the setting.
\r
507 text_source.Text = line.ReadLine();
\r
508 drp_dvdtitle.Text = line.ReadLine();
\r
509 drop_chapterStart.Text = line.ReadLine();
\r
510 drop_chapterFinish.Text = line.ReadLine();
\r
511 text_destination.Text = line.ReadLine();
\r
512 drp_videoEncoder.Text = line.ReadLine();
\r
513 drp_audioCodec.Text = line.ReadLine();
\r
514 text_width.Text = line.ReadLine();
\r
515 text_height.Text = line.ReadLine();
\r
516 text_top.Text = line.ReadLine();
\r
517 text_bottom.Text = line.ReadLine();
\r
518 text_left.Text = line.ReadLine();
\r
519 text_right.Text = line.ReadLine();
\r
520 drp_subtitle.Text = line.ReadLine();
\r
521 text_bitrate.Text = line.ReadLine();
\r
522 text_filesize.Text = line.ReadLine();
\r
523 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
525 temporyLine = line.ReadLine();
\r
526 if (temporyLine == "Checked")
\r
528 check_2PassEncode.CheckState = CheckState.Checked;
\r
531 drp_deInterlace_option.Text = line.ReadLine();
\r
533 temporyLine = line.ReadLine();
\r
534 if (temporyLine == "Checked")
\r
536 check_grayscale.CheckState = CheckState.Checked;
\r
539 drp_videoFramerate.Text = line.ReadLine();
\r
541 temporyLine = line.ReadLine();
\r
542 if (temporyLine == "Checked")
\r
544 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
547 temporyLine = line.ReadLine();
\r
548 if (temporyLine == "Checked")
\r
550 CheckPixelRatio.CheckState = CheckState.Checked;
\r
553 temporyLine = line.ReadLine();
\r
554 if (temporyLine == "Checked")
\r
556 check_turbo.CheckState = CheckState.Checked;
\r
559 temporyLine = line.ReadLine();
\r
560 if (temporyLine == "Checked")
\r
562 check_largeFile.CheckState = CheckState.Checked;
\r
565 drp_audioBitrate.Text = line.ReadLine();
\r
566 drp_audioSampleRate.Text = line.ReadLine();
\r
567 drp_audioChannels.Text = line.ReadLine();
\r
568 drp_audioMixDown.Text = line.ReadLine();
\r
570 // Advanced H264 Options
\r
571 temporyLine = line.ReadLine();
\r
572 if (temporyLine == "Checked")
\r
574 CheckCRF.CheckState = CheckState.Checked;
\r
576 rtf_h264advanced.Text = line.ReadLine();
\r
578 // Close the stream
\r
582 // Fix for SliderValue not appearing when Opening saved file
\r
583 SliderValue.Text = slider_videoQuality.Value + "%";
\r
588 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
593 private void btn_removePreset_Click(object sender, EventArgs e)
\r
596 File_Save.ShowDialog();
\r
597 filename = File_Save.FileName;
\r
598 if (filename != "")
\r
602 // Create a StreamWriter and open the file
\r
603 StreamWriter line = new StreamWriter(filename);
\r
606 line.WriteLine(text_source.Text);
\r
607 line.WriteLine(drp_dvdtitle.Text);
\r
608 line.WriteLine(drop_chapterStart.Text);
\r
609 line.WriteLine(drop_chapterFinish.Text);
\r
611 line.WriteLine(text_destination.Text);
\r
612 line.WriteLine(drp_videoEncoder.Text);
\r
613 line.WriteLine(drp_audioCodec.Text);
\r
614 line.WriteLine(text_width.Text);
\r
615 line.WriteLine(text_height.Text);
\r
616 //Picture Settings Tab
\r
617 line.WriteLine(text_top.Text);
\r
618 line.WriteLine(text_bottom.Text);
\r
619 line.WriteLine(text_left.Text);
\r
620 line.WriteLine(text_right.Text);
\r
621 line.WriteLine(drp_subtitle.Text);
\r
622 //Video Settings Tab
\r
623 line.WriteLine(text_bitrate.Text);
\r
624 line.WriteLine(text_filesize.Text);
\r
625 line.WriteLine(slider_videoQuality.Value.ToString());
\r
626 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
627 line.WriteLine(drp_deInterlace_option.Text);
\r
628 line.WriteLine(check_grayscale.CheckState.ToString());
\r
629 line.WriteLine(drp_videoFramerate.Text);
\r
630 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
631 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
632 line.WriteLine(check_turbo.CheckState.ToString());
\r
633 line.WriteLine(check_largeFile.CheckState.ToString());
\r
634 //Audio Settings Tab
\r
635 line.WriteLine(drp_audioBitrate.Text);
\r
636 line.WriteLine(drp_audioSampleRate.Text);
\r
637 line.WriteLine(drp_audioChannels.Text);
\r
638 line.WriteLine(drp_audioMixDown.Text);
\r
640 line.WriteLine(CheckCRF.CheckState.ToString());
\r
641 line.WriteLine(rtf_h264advanced.Text);
\r
642 // close the stream
\r
644 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
648 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
654 private void btn_setDefault_Click(object sender, EventArgs e)
\r
657 Properties.Settings.Default.DVDSource = text_source.Text;
\r
658 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
659 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
660 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
662 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
663 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
664 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
665 Properties.Settings.Default.Width = text_width.Text;
\r
666 Properties.Settings.Default.Height = text_height.Text;
\r
667 //Picture Settings Tab
\r
668 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
669 Properties.Settings.Default.CropTop = text_top.Text;
\r
670 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
671 Properties.Settings.Default.CropLeft = text_left.Text;
\r
672 Properties.Settings.Default.CropRight = text_right.Text;
\r
673 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
674 //Video Settings Tab
\r
675 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
676 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
677 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
678 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
679 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
680 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
681 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
682 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
683 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
684 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
685 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
686 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
687 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
688 //Audio Settings Tab
\r
689 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
690 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
691 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
693 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
694 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
695 Properties.Settings.Default.SelectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
696 Properties.Settings.Default.Save();
\r
700 // Preset Seleciton
\r
701 private void ListBox_Presets_SelectedIndexChanged(object sender, EventArgs e)
\r
703 string selectedPreset = null;
\r
704 if (ListBox_Presets.SelectedItem != null)
\r
706 selectedPreset = ListBox_Presets.SelectedItem.ToString();
\r
710 selectedPreset = "";
\r
713 switch (selectedPreset)
\r
716 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
720 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
723 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
727 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
730 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
733 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
735 case "Constant Quality Rate":
\r
736 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
739 case "Deux Six Quatre":
\r
740 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
744 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
748 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
750 case "iPod High-Rez":
\r
751 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
753 case "iPod Low-Rez":
\r
754 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
757 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
760 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
763 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
766 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
769 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
778 // Functions - It's a bit dirty but i'll sort this out later. Simply done to reduce the amount of code above.
\r
779 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
781 CheckPixelRatio.CheckState = anamorphic;
\r
782 text_width.Text = width;
\r
783 text_height.Text = height;
\r
784 drp_videoEncoder.Text = vencoder;
\r
785 text_bitrate.Text = bitrate;
\r
786 text_filesize.Text = filesize;
\r
787 slider_videoQuality.Value = quality;
\r
788 SliderValue.Text = qpercent;
\r
789 drp_audioBitrate.Text = audioBit;
\r
790 Check_ChapterMarkers.CheckState = chpt;
\r
791 drp_audioSampleRate.Text = audioSample;
\r
792 rtf_h264advanced.Text = h264;
\r
793 drp_deInterlace_option.Text = deinterlace;
\r
794 check_2PassEncode.CheckState = twopass;
\r
795 drp_crop.Text = crop;
\r
796 check_turbo.CheckState = turbo;
\r
797 drp_audioCodec.Text = audioCodec;
\r
799 groupBox_output.Text = preset;
\r
802 private void setMkv()
\r
804 // Set file extension to MKV
\r
805 string destination = text_destination.Text;
\r
806 destination = destination.Replace(".mp4", ".mkv");
\r
807 destination = destination.Replace(".avi", ".mkv");
\r
808 destination = destination.Replace(".m4v", ".mkv");
\r
809 destination = destination.Replace(".ogm", ".mkv");
\r
810 text_destination.Text = destination;
\r
815 //---------------------------------------------------
\r
816 // Encode / Cancel Buttons
\r
817 // Encode Progress Text Handler
\r
818 //---------------------------------------------------
\r
822 Functions.CLI process = new Functions.CLI();
\r
824 private void btn_encode_Click(object sender, EventArgs e)
\r
826 //btn_eCancel.Enabled = true;
\r
827 String query = "";
\r
828 if (QueryEditorText.Text == "")
\r
830 query = GenerateTheQuery();
\r
834 query = QueryEditorText.Text;
\r
837 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
838 lbl_encode.Visible = true;
\r
839 lbl_encode.Text = "Encoding in Progress";
\r
842 private void btn_eCancel_Click(object sender, EventArgs e)
\r
846 lbl_encode.Text = "Encoding Canceled";
\r
850 [DllImport("user32.dll")]
\r
851 public static extern void LockWorkStation();
\r
852 [DllImport("user32.dll")]
\r
853 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
855 private void procMonitor(object state)
\r
857 // Make sure we are not already encoding and if we are then display an error.
\r
858 if (hbProc != null)
\r
860 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
864 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
865 hbProc.WaitForExit();
\r
870 //*****************************************************************************************
\r
872 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
873 // video stream which has mild corruption issues every few seconds.
\r
874 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
875 //*****************************************************************************************
\r
878 /*Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
\r
879 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
880 while (!encode.EndOfStream)
\r
885 hbProc.WaitForExit();
\r
886 process.closeCLI();
\r
898 // Do something whent he encode ends.
\r
899 switch (Properties.Settings.Default.CompletionOption)
\r
902 System.Diagnostics.Process.Start("Shutdown", "-s -t 60");
\r
905 ExitWindowsEx(0, 0);
\r
908 Application.SetSuspendState(PowerState.Suspend, true, true);
\r
911 Application.SetSuspendState(PowerState.Hibernate, true, true);
\r
913 case "Lock System":
\r
916 case "Quit HandBrake":
\r
917 Application.Exit();
\r
925 private delegate void UpdateUIHandler();
\r
927 private void setEncodeLabel()
\r
929 if (this.InvokeRequired)
\r
931 this.BeginInvoke(new UpdateUIHandler(setEncodeLabel));
\r
934 lbl_encode.Text = "Encoding Finished";
\r
937 /*private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
940 if (this.InvokeRequired)
\r
942 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
943 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
946 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
951 //---------------------------------------------------
\r
952 // Items that require actions on frmMain
\r
953 //---------------------------------------------------
\r
955 #region frmMain Actions
\r
957 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
959 drop_chapterStart.BackColor = Color.White;
\r
960 QueryEditorText.Text = "";
\r
961 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
965 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
966 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
968 if (chapterFinish < chapterStart)
\r
970 drop_chapterStart.BackColor = Color.LightCoral;
\r
975 drop_chapterStart.BackColor = Color.LightCoral;
\r
982 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
984 drop_chapterFinish.BackColor = Color.White;
\r
985 QueryEditorText.Text = "";
\r
986 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
990 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
991 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
993 if (chapterFinish < chapterStart)
\r
995 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1000 drop_chapterFinish.BackColor = Color.LightCoral;
\r
1005 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1007 text_filesize.Text = "";
\r
1008 slider_videoQuality.Value = 0;
\r
1009 SliderValue.Text = "0%";
\r
1010 CheckCRF.CheckState = CheckState.Unchecked;
\r
1011 CheckCRF.Enabled = false;
\r
1014 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1016 text_bitrate.Text = "";
\r
1017 slider_videoQuality.Value = 0;
\r
1018 SliderValue.Text = "0%";
\r
1019 CheckCRF.CheckState = CheckState.Unchecked;
\r
1020 CheckCRF.Enabled = false;
\r
1023 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1025 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1026 text_bitrate.Text = "";
\r
1027 text_filesize.Text = "";
\r
1028 CheckCRF.Enabled = true;
\r
1031 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1033 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1036 private void text_width_TextChanged(object sender, EventArgs e)
\r
1041 if (CheckPixelRatio.Checked)
\r
1043 text_width.Text = "";
\r
1044 text_width.BackColor = Color.White;
\r
1048 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1050 text_width.BackColor = Color.LightCoral;
\r
1054 text_width.BackColor = Color.LightGreen;
\r
1058 if (lbl_Aspect.Text != "Select a Title")
\r
1060 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1061 double mod16 = height % 16;
\r
1062 height = height - mod16;
\r
1064 if (text_width.Text == "")
\r
1066 text_height.Text = "";
\r
1067 text_width.BackColor = Color.White;
\r
1071 text_height.Text = height.ToString();
\r
1077 // No need to throw an error here.
\r
1078 // Note on non english systems, this will throw an error because of double.Parse(lbl_Aspect.Text); not working.
\r
1084 private void text_height_TextChanged(object sender, EventArgs e)
\r
1088 if (text_height.Text != "Auto")
\r
1090 if (CheckPixelRatio.Checked)
\r
1092 text_height.Text = "";
\r
1093 text_width.BackColor = Color.White;
\r
1097 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1099 text_height.BackColor = Color.LightCoral;
\r
1103 text_height.BackColor = Color.LightGreen;
\r
1107 } catch(Exception){
\r
1108 // No need to alert the user.
\r
1112 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1114 if ((string)drp_crop.SelectedItem == "Manual")
\r
1116 text_left.Enabled = true;
\r
1117 text_right.Enabled = true;
\r
1118 text_top.Enabled = true;
\r
1119 text_bottom.Enabled = true;
\r
1122 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1124 text_left.Enabled = false;
\r
1125 text_right.Enabled = false;
\r
1126 text_top.Enabled = false;
\r
1127 text_bottom.Enabled = false;
\r
1128 text_left.Text = "";
\r
1129 text_right.Text = "";
\r
1130 text_top.Text = "";
\r
1131 text_bottom.Text = "";
\r
1133 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1135 string[] temp = new string[4];
\r
1136 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1137 text_left.Text = temp[2];
\r
1138 text_right.Text = temp[3];
\r
1139 text_top.Text = temp[0];
\r
1140 text_bottom.Text = temp[1];
\r
1144 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1146 text_left.Enabled = false;
\r
1147 text_right.Enabled = false;
\r
1148 text_top.Enabled = false;
\r
1149 text_bottom.Enabled = false;
\r
1150 text_left.Text = "0";
\r
1151 text_right.Text = "0";
\r
1152 text_top.Text = "0";
\r
1153 text_bottom.Text = "0";
\r
1158 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1160 text_width.Text = "";
\r
1161 text_height.Text = "";
\r
1162 text_width.BackColor = Color.White;
\r
1163 text_height.BackColor = Color.White;
\r
1166 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1168 if (drp_dvdtitle.Items.Count == 0)
\r
1170 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
1174 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1177 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1179 drp_audioMixDown.Items.Clear();
\r
1181 if (drp_audioCodec.Text == "AAC")
\r
1183 drp_audioMixDown.Items.Clear();
\r
1184 drp_audioMixDown.Items.Add("Mono");
\r
1185 drp_audioMixDown.Items.Add("Stereo");
\r
1186 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1187 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1188 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1190 drp_audioBitrate.Items.Clear();
\r
1191 drp_audioBitrate.Items.Add("32");
\r
1192 drp_audioBitrate.Items.Add("40");
\r
1193 drp_audioBitrate.Items.Add("48");
\r
1194 drp_audioBitrate.Items.Add("56");
\r
1195 drp_audioBitrate.Items.Add("64");
\r
1196 drp_audioBitrate.Items.Add("80");
\r
1197 drp_audioBitrate.Items.Add("86");
\r
1198 drp_audioBitrate.Items.Add("112");
\r
1199 drp_audioBitrate.Items.Add("128");
\r
1200 drp_audioBitrate.Items.Add("160");
\r
1205 drp_audioMixDown.Items.Clear();
\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
1210 drp_audioBitrate.Items.Clear();
\r
1211 drp_audioBitrate.Items.Add("32");
\r
1212 drp_audioBitrate.Items.Add("40");
\r
1213 drp_audioBitrate.Items.Add("48");
\r
1214 drp_audioBitrate.Items.Add("56");
\r
1215 drp_audioBitrate.Items.Add("64");
\r
1216 drp_audioBitrate.Items.Add("80");
\r
1217 drp_audioBitrate.Items.Add("86");
\r
1218 drp_audioBitrate.Items.Add("112");
\r
1219 drp_audioBitrate.Items.Add("128");
\r
1220 drp_audioBitrate.Items.Add("160");
\r
1221 drp_audioBitrate.Items.Add("192");
\r
1222 drp_audioBitrate.Items.Add("224");
\r
1223 drp_audioBitrate.Items.Add("256");
\r
1224 drp_audioBitrate.Items.Add("320");
\r
1228 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1230 if (drp_audioCodec.Text == "AAC")
\r
1232 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1235 drp_audioBitrate.Items.Clear();
\r
1236 drp_audioBitrate.Items.Add("32");
\r
1237 drp_audioBitrate.Items.Add("40");
\r
1238 drp_audioBitrate.Items.Add("48");
\r
1239 drp_audioBitrate.Items.Add("56");
\r
1240 drp_audioBitrate.Items.Add("64");
\r
1241 drp_audioBitrate.Items.Add("80");
\r
1242 drp_audioBitrate.Items.Add("86");
\r
1243 drp_audioBitrate.Items.Add("112");
\r
1244 drp_audioBitrate.Items.Add("128");
\r
1245 drp_audioBitrate.Items.Add("160");
\r
1246 drp_audioBitrate.Items.Add("192");
\r
1247 drp_audioBitrate.Items.Add("224");
\r
1248 drp_audioBitrate.Items.Add("256");
\r
1249 drp_audioBitrate.Items.Add("320");
\r
1250 drp_audioBitrate.Items.Add("384");
\r
1255 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1257 if (Check_ChapterMarkers.Checked)
\r
1259 string destination = text_destination.Text;
\r
1260 destination = destination.Replace(".mp4", ".m4v");
\r
1261 text_destination.Text = destination;
\r
1265 string destination = text_destination.Text;
\r
1266 destination = destination.Replace(".m4v", ".mp4");
\r
1267 text_destination.Text = destination;
\r
1271 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1273 if (!text_destination.Text.Contains(".mp4"))
\r
1275 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1276 check_largeFile.CheckState = CheckState.Unchecked;
\r
1280 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1282 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1283 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1285 check_turbo.CheckState = CheckState.Unchecked;
\r
1286 CheckCRF.CheckState = CheckState.Unchecked;
\r
1287 CheckCRF.Enabled = false;
\r
1288 check_turbo.Enabled = false;
\r
1289 h264Tab.Enabled = false;
\r
1293 CheckCRF.Enabled = true;
\r
1294 check_turbo.Enabled = true;
\r
1295 h264Tab.Enabled = true;
\r
1300 public void setStreamReader(Parsing.DVD dvd)
\r
1302 this.thisDVD = dvd;
\r
1305 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1307 // Reset some values on the form
\r
1308 lbl_Aspect.Text = "Select a Title";
\r
1309 lbl_RecomendedCrop.Text = "Select a Title";
\r
1310 drop_chapterStart.Items.Clear();
\r
1311 drop_chapterFinish.Items.Clear();
\r
1312 QueryEditorText.Text = "";
\r
1314 // If the dropdown is set to automatic nothing else needs to be done.
\r
1315 // Otheriwse if its not, title data has to be loased from parsing.
\r
1316 if (drp_dvdtitle.Text != "Automatic")
\r
1318 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1320 // Set the Aspect Ratio
\r
1321 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1323 // Set the Recommended Cropping values
\r
1324 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1326 // Populate the Start chapter Dropdown
\r
1327 drop_chapterStart.Items.Clear();
\r
1328 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1329 if (drop_chapterStart.Items.Count > 0)
\r
1331 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1334 // Populate the Final Chapter Dropdown
\r
1335 drop_chapterFinish.Items.Clear();
\r
1336 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1337 if (drop_chapterFinish.Items.Count > 0)
\r
1339 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1342 // Populate the Audio Channels Dropdown
\r
1343 drp_audioChannels.Items.Clear();
\r
1344 drp_audioChannels.Items.Add("Automatic");
\r
1345 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1346 if (drp_audioChannels.Items.Count > 0)
\r
1348 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1351 // Populate the Subtitles dropdown
\r
1352 drp_subtitle.Items.Clear();
\r
1353 drp_subtitle.Items.Add("None");
\r
1354 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1355 if (drp_subtitle.Items.Count > 0)
\r
1357 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1364 //---------------------------------------------------
\r
1366 // - Query Generation
\r
1367 //---------------------------------------------------
\r
1369 #region Program Functions
\r
1371 public string GenerateTheQuery()
\r
1373 string source = text_source.Text;
\r
1374 string dvdTitle = drp_dvdtitle.Text;
\r
1375 string chapterStart = drop_chapterStart.Text;
\r
1376 string chapterFinish = drop_chapterFinish.Text;
\r
1377 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1378 string dvdChapter = "";
\r
1381 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1384 source = " -i " + '"' + source+ '"'; //'"'+
\r
1387 if (dvdTitle == "Automatic")
\r
1391 string[] titleInfo = dvdTitle.Split(' ');
\r
1392 dvdTitle = " -t "+ titleInfo[0];
\r
1395 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1397 else if (chapterFinish == chapterStart)
\r
1398 dvdChapter = " -c " + chapterStart;
\r
1400 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1402 string querySource = source+ dvdTitle+ dvdChapter;
\r
1403 // ----------------------------------------------------------------------
\r
1407 string destination = text_destination.Text;
\r
1408 string videoEncoder = drp_videoEncoder.Text;
\r
1409 string audioEncoder = drp_audioCodec.Text;
\r
1410 string width = text_width.Text;
\r
1411 string height = text_height.Text;
\r
1413 if (destination == "")
\r
1414 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1416 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1419 switch (videoEncoder)
\r
1422 videoEncoder = " -e ffmpeg";
\r
1425 videoEncoder = " -e xvid";
\r
1428 videoEncoder = " -e x264";
\r
1430 case "H.264 Baseline 1.3":
\r
1431 videoEncoder = " -e x264b13";
\r
1433 case "H.264 (iPod)":
\r
1434 videoEncoder = " -e x264b30";
\r
1437 videoEncoder = " -e x264";
\r
1441 switch (audioEncoder)
\r
1444 audioEncoder = " -E faac";
\r
1447 audioEncoder = " -E lame";
\r
1450 audioEncoder = " -E vorbis";
\r
1453 audioEncoder = " -E ac3";
\r
1456 audioEncoder = " -E faac";
\r
1461 width = " -w "+ width;
\r
1464 if (height == "Auto")
\r
1468 else if (height != "")
\r
1470 height = " -l " + height;
\r
1474 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1475 // ----------------------------------------------------------------------
\r
1477 // Picture Settings Tab
\r
1479 string cropSetting = drp_crop.Text;
\r
1480 string cropTop = text_top.Text;
\r
1481 string cropBottom = text_bottom.Text;
\r
1482 string cropLeft = text_left.Text;
\r
1483 string cropRight = text_right.Text;
\r
1484 string subtitles = drp_subtitle.Text;
\r
1485 string cropOut = "";
\r
1486 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1487 string deinterlace = "";
\r
1488 string grayscale = "";
\r
1489 string pixelRatio = "";
\r
1490 string ChapterMarkers = "";
\r
1491 // Returns Crop Query
\r
1493 if (cropSetting == "Auto Crop")
\r
1495 else if (cropSetting == "No Crop")
\r
1496 cropOut = " --crop 0:0:0:0 ";
\r
1499 if (text_top.Text == "")
\r
1501 if (text_bottom.Text == "")
\r
1503 if (text_left.Text == "")
\r
1505 if (text_right.Text == "")
\r
1508 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1511 if (subtitles == "None")
\r
1513 else if (subtitles == "")
\r
1518 tempSub = subtitles.Split(' ');
\r
1519 subtitles = " -s "+ tempSub[0];
\r
1522 switch (deInterlace_Option)
\r
1527 case "Origional (Fast)":
\r
1528 deinterlace = " --deinterlace=1";
\r
1530 case "yadif (Slow)":
\r
1531 deinterlace = " --deinterlace=" + '"' + "0" + '"';
\r
1533 case "yadif + mcdeint (Slower)":
\r
1534 deinterlace = " --deinterlace=" + '"' + "2:-1:1" + '"';
\r
1536 case "yadif + mcdeint (Slowest)":
\r
1537 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1544 if (check_grayscale.Checked)
\r
1545 grayscale = " -g ";
\r
1547 if (CheckPixelRatio.Checked)
\r
1548 pixelRatio = " -p ";
\r
1550 if (Check_ChapterMarkers.Checked)
\r
1551 ChapterMarkers = " -m ";
\r
1553 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1554 // ----------------------------------------------------------------------
\r
1556 // Video Settings Tab
\r
1558 string videoBitrate = text_bitrate.Text;
\r
1559 string videoFilesize = text_filesize.Text;
\r
1560 double videoQuality = slider_videoQuality.Value;
\r
1561 string vidQSetting = "";
\r
1562 string twoPassEncoding = "";
\r
1563 string videoFramerate = drp_videoFramerate.Text;
\r
1564 string turboH264 = "";
\r
1565 string largeFile = "";
\r
1566 string deblock = "";
\r
1567 string detelecine = "";
\r
1568 string denoise = "";
\r
1569 string CRF = CheckCRF.CheckState.ToString();
\r
1572 if ((CRF == "Checked"))
\r
1577 if (videoBitrate != "")
\r
1578 videoBitrate = " -b "+ videoBitrate;
\r
1580 if (videoFilesize != "")
\r
1581 videoFilesize = " -S "+ videoFilesize;
\r
1583 // Video Quality Setting
\r
1585 if ((videoQuality == 0))
\r
1589 videoQuality = videoQuality / 100;
\r
1590 if (videoQuality == 1)
\r
1592 vidQSetting = "1.0";
\r
1595 vidQSetting = " -q " + videoQuality.ToString();
\r
1598 if (check_2PassEncode.Checked)
\r
1599 twoPassEncoding = " -2 ";
\r
1601 if (videoFramerate == "Automatic")
\r
1602 videoFramerate = "";
\r
1604 videoFramerate = " -r "+ videoFramerate;
\r
1606 if (check_turbo.Checked)
\r
1607 turboH264 = " -T ";
\r
1609 if (check_largeFile.Checked)
\r
1610 largeFile = " -4 ";
\r
1612 if (check_deblock.Checked)
\r
1613 deblock = " --deblock";
\r
1615 if (check_detelecine.Checked)
\r
1616 detelecine = " --detelecine";
\r
1618 switch (drp_deNoise.Text)
\r
1624 denoise = " --denoise=2:1:2:3";
\r
1627 denoise = " --denoise=3:2:2:3";
\r
1630 denoise = " --denoise=7:7:5:5";
\r
1637 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1638 // ----------------------------------------------------------------------
\r
1640 // Audio Settings Tab
\r
1642 string audioBitrate = drp_audioBitrate.Text;
\r
1643 string audioSampleRate = drp_audioSampleRate.Text;
\r
1644 string audioChannels = drp_audioChannels.Text;
\r
1645 string Mixdown = drp_audioMixDown.Text;
\r
1646 string SixChannelAudio = "";
\r
1648 if (audioBitrate != "")
\r
1649 audioBitrate = " -B "+ audioBitrate;
\r
1651 if (audioSampleRate != "")
\r
1652 audioSampleRate = " -R "+ audioSampleRate;
\r
1654 if (audioChannels == "Automatic")
\r
1655 audioChannels = "";
\r
1656 else if (audioChannels == "")
\r
1657 audioChannels = "";
\r
1661 tempSub = audioChannels.Split(' ');
\r
1662 audioChannels = " -a "+ tempSub[0];
\r
1674 Mixdown = "stereo";
\r
1676 case "Dolby Surround":
\r
1679 case "Dolby Pro Logic II":
\r
1682 case "6 Channel Discrete":
\r
1686 Mixdown = "stero";
\r
1690 if (Mixdown != "")
\r
1691 SixChannelAudio = " -6 "+ Mixdown;
\r
1693 SixChannelAudio = "";
\r
1695 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1696 // ----------------------------------------------------------------------
\r
1701 string h264Advanced = rtf_h264advanced.Text;
\r
1703 if ((h264Advanced == ""))
\r
1704 h264Advanced = "";
\r
1706 h264Advanced = " -x "+ h264Advanced;
\r
1709 string h264Settings = h264Advanced;
\r
1710 // ----------------------------------------------------------------------
\r
1712 // Processors (Program Settings)
\r
1714 string processors = Properties.Settings.Default.Processors;
\r
1715 // Number of Processors Handler
\r
1717 if (processors == "Automatic")
\r
1720 processors = " -C "+ processors+ " ";
\r
1723 string queryAdvancedSettings = processors;
\r
1724 // ----------------------------------------------------------------------
\r
1726 // Verbose option (Program Settings)
\r
1728 string verbose = "";
\r
1729 if (Properties.Settings.Default.verbose == "Checked")
\r
1732 // ----------------------------------------------------------------------
\r
1734 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1740 // This is the END of the road ------------------------------------------------------------------------------
\r