2 using System.Collections.Generic;
\r
3 using System.ComponentModel;
\r
5 using System.Drawing;
\r
7 using System.Windows.Forms;
\r
10 using System.Diagnostics;
\r
11 using System.Threading;
\r
15 public partial class frmMain : Form
\r
17 private System.Diagnostics.Process hbProc;
\r
18 private Parsing.DVD thisDVD;
\r
20 // --------------------------------------------------------------
\r
21 // Some windows that require only 1 instance.
\r
22 // --------------------------------------------------------------
\r
23 private frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
24 private frmQueue queueWindow = new frmQueue();
\r
28 InitializeComponent();
\r
30 // Set the Version number lable to the corect version.
\r
31 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
33 // Run the update checker.
\r
36 // Now load the users default if required.
\r
40 public void loadUserDefaults()
\r
44 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
47 text_source.Text = Properties.Settings.Default.DVDSource;
\r
48 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
49 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
50 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
53 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
54 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
55 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
56 text_width.Text = Properties.Settings.Default.Width;
\r
57 text_height.Text = Properties.Settings.Default.Height;
\r
59 // Picture Settings Tab
\r
60 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
61 text_top.Text = Properties.Settings.Default.CropTop;
\r
62 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
63 text_left.Text = Properties.Settings.Default.CropLeft;
\r
64 text_right.Text = Properties.Settings.Default.CropRight;
\r
65 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
67 // Video Settings Tab
\r
68 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
69 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
70 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
72 if (Properties.Settings.Default.TwoPass == "Checked")
\r
74 check_2PassEncode.CheckState = CheckState.Checked;
\r
76 if (Properties.Settings.Default.DeInterlace == "Checked")
\r
78 check_DeInterlace.CheckState = CheckState.Checked;
\r
80 if (Properties.Settings.Default.Grayscale == "Checked")
\r
82 check_grayscale.CheckState = CheckState.Checked;
\r
85 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
87 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
89 CheckPixelRatio.CheckState = CheckState.Checked;
\r
91 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
93 check_turbo.CheckState = CheckState.Checked;
\r
95 if (Properties.Settings.Default.largeFile == "Checked")
\r
97 check_largeFile.CheckState = CheckState.Checked;
\r
99 // Audio Settings Tab
\r
100 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
101 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
102 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
105 if (Properties.Settings.Default.CRF == "Checked")
\r
107 CheckCRF.CheckState = CheckState.Checked;
\r
109 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
114 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
118 public void updateCheck()
\r
120 if (Properties.Settings.Default.updateStatus == "Checked")
\r
125 String updateFile = Properties.Settings.Default.updateFile;
\r
126 WebClient client = new WebClient();
\r
127 String data = client.DownloadString(updateFile);
\r
128 String[] versionData = data.Split('\n');
\r
130 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
132 lbl_update.Visible = true;
\r
135 // else fail displaying an error message.
\r
138 // Silently ignore the error
\r
143 #region The Menu Bar
\r
146 private void mnu_open_Click(object sender, EventArgs e)
\r
149 File_Open.ShowDialog();
\r
150 filename = File_Open.FileName;
\r
151 if (filename != "")
\r
155 // Create StreamReader & open file
\r
156 StreamReader line = new StreamReader(filename);
\r
157 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
159 // Read in the data and set the correct GUI component with the setting.
\r
160 text_source.Text = line.ReadLine();
\r
161 drp_dvdtitle.Text = line.ReadLine();
\r
162 drop_chapterStart.Text = line.ReadLine();
\r
163 drop_chapterFinish.Text = line.ReadLine();
\r
164 text_destination.Text = line.ReadLine();
\r
165 drp_videoEncoder.Text = line.ReadLine();
\r
166 drp_audioCodec.Text = line.ReadLine();
\r
167 text_width.Text = line.ReadLine();
\r
168 text_height.Text = line.ReadLine();
\r
169 text_top.Text = line.ReadLine();
\r
170 text_bottom.Text = line.ReadLine();
\r
171 text_left.Text = line.ReadLine();
\r
172 text_right.Text = line.ReadLine();
\r
173 drp_subtitle.Text = line.ReadLine();
\r
174 text_bitrate.Text = line.ReadLine();
\r
175 text_filesize.Text = line.ReadLine();
\r
176 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
178 temporyLine = line.ReadLine();
\r
179 if (temporyLine == "Checked")
\r
181 check_2PassEncode.CheckState = CheckState.Checked;
\r
184 temporyLine = line.ReadLine();
\r
185 if (temporyLine == "Checked")
\r
187 check_DeInterlace.CheckState = CheckState.Checked;
\r
190 temporyLine = line.ReadLine();
\r
191 if (temporyLine == "Checked")
\r
193 check_grayscale.CheckState = CheckState.Checked;
\r
196 drp_videoFramerate.Text = line.ReadLine();
\r
198 temporyLine = line.ReadLine();
\r
199 if (temporyLine == "Checked")
\r
201 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
204 temporyLine = line.ReadLine();
\r
205 if (temporyLine == "Checked")
\r
207 CheckPixelRatio.CheckState = CheckState.Checked;
\r
210 temporyLine = line.ReadLine();
\r
211 if (temporyLine == "Checked")
\r
213 check_turbo.CheckState = CheckState.Checked;
\r
216 temporyLine = line.ReadLine();
\r
217 if (temporyLine == "Checked")
\r
219 check_largeFile.CheckState = CheckState.Checked;
\r
222 drp_audioBitrate.Text = line.ReadLine();
\r
223 drp_audioSampleRate.Text = line.ReadLine();
\r
224 drp_audioChannels.Text = line.ReadLine();
\r
225 drp_audioMixDown.Text = line.ReadLine();
\r
227 // Advanced H264 Options
\r
228 temporyLine = line.ReadLine();
\r
229 if (temporyLine == "Checked")
\r
231 CheckCRF.CheckState = CheckState.Checked;
\r
233 rtf_h264advanced.Text = line.ReadLine();
\r
235 // Close the stream
\r
239 // Fix for SliderValue not appearing when Opening saved file
\r
240 SliderValue.Text = slider_videoQuality.Value + "%";
\r
242 } catch (Exception){
\r
243 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
248 private void mnu_save_Click(object sender, EventArgs e)
\r
252 File_Save.ShowDialog();
\r
253 filename = File_Save.FileName;
\r
254 if (filename != "")
\r
258 // Create a StreamWriter and open the file
\r
259 StreamWriter line = new StreamWriter(filename);
\r
262 line.WriteLine(text_source.Text);
\r
263 line.WriteLine(drp_dvdtitle.Text);
\r
264 line.WriteLine(drop_chapterStart.Text);
\r
265 line.WriteLine(drop_chapterFinish.Text);
\r
267 line.WriteLine(text_destination.Text);
\r
268 line.WriteLine(drp_videoEncoder.Text);
\r
269 line.WriteLine(drp_audioCodec.Text);
\r
270 line.WriteLine(text_width.Text);
\r
271 line.WriteLine(text_height.Text);
\r
272 //Picture Settings Tab
\r
273 line.WriteLine(text_top.Text);
\r
274 line.WriteLine(text_bottom.Text);
\r
275 line.WriteLine(text_left.Text);
\r
276 line.WriteLine(text_right.Text);
\r
277 line.WriteLine(drp_subtitle.Text);
\r
278 //Video Settings Tab
\r
279 line.WriteLine(text_bitrate.Text);
\r
280 line.WriteLine(text_filesize.Text);
\r
281 line.WriteLine(slider_videoQuality.Value.ToString());
\r
282 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
283 line.WriteLine(check_DeInterlace.CheckState.ToString());
\r
284 line.WriteLine(check_grayscale.CheckState.ToString());
\r
285 line.WriteLine(drp_videoFramerate.Text);
\r
286 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
287 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
288 line.WriteLine(check_turbo.CheckState.ToString());
\r
289 line.WriteLine(check_largeFile.CheckState.ToString());
\r
290 //Audio Settings Tab
\r
291 line.WriteLine(drp_audioBitrate.Text);
\r
292 line.WriteLine(drp_audioSampleRate.Text);
\r
293 line.WriteLine(drp_audioChannels.Text);
\r
294 line.WriteLine(drp_audioMixDown.Text);
\r
296 line.WriteLine(CheckCRF.CheckState.ToString());
\r
297 line.WriteLine(rtf_h264advanced.Text);
\r
298 // close the stream
\r
300 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
304 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
310 private void mnu_update_Click(object sender, EventArgs e)
\r
312 Form Update = new frmUpdate();
\r
313 Update.ShowDialog();
\r
316 private void mnu_exit_Click(object sender, EventArgs e)
\r
325 private void mnu_encode_Click(object sender, EventArgs e)
\r
330 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
332 dvdInfoWindow.Show();
\r
335 private void mnu_options_Click(object sender, EventArgs e)
\r
337 Form Options = new frmOptions();
\r
338 Options.ShowDialog();
\r
343 #region Presets Menu
\r
345 private void mnu_preset_ipod133_Click(object sender, EventArgs e)
\r
347 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
348 text_width.Text = "640";
\r
349 text_height.Text = "480";
\r
350 drp_videoEncoder.Text = "H.264 (iPod)";
\r
351 text_bitrate.Text = "1000";
\r
352 text_filesize.Text = "";
\r
353 slider_videoQuality.Value = 0;
\r
354 SliderValue.Text = "0%";
\r
355 drp_audioBitrate.Text = "160";
\r
356 rtf_h264advanced.Text = "";
\r
357 drp_crop.Text = "No Crop";
\r
360 private void mnu_preset_ipod178_Click(object sender, EventArgs e)
\r
362 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
363 text_width.Text = "640";
\r
364 text_height.Text = "352";
\r
365 drp_videoEncoder.Text = "H.264 (iPod)";
\r
366 text_bitrate.Text = "1000";
\r
367 text_filesize.Text = "";
\r
368 slider_videoQuality.Value = 0;
\r
369 SliderValue.Text = "0%";
\r
370 drp_audioBitrate.Text = "160";
\r
371 rtf_h264advanced.Text = "";
\r
372 drp_crop.Text = "No Crop";
\r
375 private void mnu_preset_ipod235_Click(object sender, EventArgs e)
\r
377 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
378 text_width.Text = "640";
\r
379 text_height.Text = "272";
\r
380 drp_videoEncoder.Text = "H.264 (iPod)";
\r
381 text_bitrate.Text = "1000";
\r
382 text_filesize.Text = "";
\r
383 slider_videoQuality.Value = 0;
\r
384 SliderValue.Text = "0%";
\r
385 drp_audioBitrate.Text = "160";
\r
386 rtf_h264advanced.Text = "";
\r
387 drp_crop.Text = "No Crop";
\r
390 private void mnu_appleTv_Click(object sender, EventArgs e)
\r
392 text_width.Text = "";
\r
393 text_height.Text = "";
\r
394 drp_videoEncoder.Text = "H.264";
\r
395 text_bitrate.Text = "3000";
\r
396 text_filesize.Text = "";
\r
397 slider_videoQuality.Value = 0;
\r
398 SliderValue.Text = "0%";
\r
399 drp_audioBitrate.Text = "160";
\r
400 CheckPixelRatio.CheckState = CheckState.Checked;
\r
401 drp_audioSampleRate.Text = "48";
\r
402 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
\r
403 drp_crop.Text = "No Crop";
\r
407 private void mnu_presetPS3_Click(object sender, EventArgs e)
\r
409 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
410 text_width.Text = "";
\r
411 text_height.Text = "";
\r
412 drp_videoEncoder.Text = "H.264";
\r
413 text_bitrate.Text = "3000";
\r
414 text_filesize.Text = "";
\r
415 slider_videoQuality.Value = 0;
\r
416 SliderValue.Text = "0%";
\r
417 drp_audioBitrate.Text = "160";
\r
418 CheckPixelRatio.CheckState = CheckState.Checked;
\r
419 drp_audioSampleRate.Text = "48";
\r
420 rtf_h264advanced.Text = "level=41";
\r
421 drp_crop.Text = "No Crop";
\r
424 private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)
\r
427 Properties.Settings.Default.DVDSource = text_source.Text;
\r
428 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
429 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
430 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
432 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
433 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
434 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
435 Properties.Settings.Default.Width = text_width.Text;
\r
436 Properties.Settings.Default.Height = text_height.Text;
\r
437 //Picture Settings Tab
\r
438 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
439 Properties.Settings.Default.CropTop = text_top.Text;
\r
440 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
441 Properties.Settings.Default.CropLeft = text_left.Text;
\r
442 Properties.Settings.Default.CropRight = text_right.Text;
\r
443 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
444 //Video Settings Tab
\r
445 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
446 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
447 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
448 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
449 Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();
\r
450 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
451 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
452 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
453 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
454 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
455 //Audio Settings Tab
\r
456 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
457 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
458 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
460 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
461 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
462 Properties.Settings.Default.Save();
\r
469 private void mnu_wiki_Click(object sender, EventArgs e)
\r
471 Process.Start("http://handbrake.m0k.org/trac");
\r
474 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
476 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
479 private void mnu_faq_Click(object sender, EventArgs e)
\r
481 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
484 private void mnu_homepage_Click(object sender, EventArgs e)
\r
486 Process.Start("http://handbrake.m0k.org");
\r
489 private void mnu_forum_Click(object sender, EventArgs e)
\r
491 Process.Start("http://handbrake.m0k.org/forum");
\r
494 private void mnu_about_Click(object sender, EventArgs e)
\r
496 Form About = new frmAbout();
\r
497 About.ShowDialog();
\r
503 // --------------------------------------------------------------
\r
504 // Buttons on the main Window
\r
505 // --------------------------------------------------------------
\r
506 private void btn_Browse_Click(object sender, EventArgs e)
\r
509 String filename ="";
\r
510 text_source.Text = "";
\r
512 if (RadioDVD.Checked)
\r
514 DVD_Open.ShowDialog();
\r
515 filename = DVD_Open.SelectedPath;
\r
516 if (filename != "")
\r
518 text_source.Text = filename;
\r
519 Form frmReadDVD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
520 frmReadDVD.ShowDialog();
\r
525 ISO_Open.ShowDialog();
\r
526 filename = ISO_Open.FileName;
\r
527 if (filename != "")
\r
529 text_source.Text = filename;
\r
530 Form frmReadDVD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
531 frmReadDVD.ShowDialog();
\r
535 // Quick check to make sure some titles were found.
\r
536 if (filename != "")
\r
538 if (drp_dvdtitle.Items.Count == 0)
\r
540 MessageBox.Show("No Title(s) found. Please make sure you have selected a valid, non-copy protected source.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
545 text_source.Text = "Click 'Browse' to continue";
\r
550 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
552 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
554 DVD_Save.ShowDialog();
\r
555 text_destination.Text = DVD_Save.FileName;
\r
557 if (Check_ChapterMarkers.Checked)
\r
559 string destination = text_destination.Text;
\r
560 destination = destination.Replace(".mp4", ".m4v");
\r
561 text_destination.Text = destination;
\r
565 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
567 rtf_h264advanced.Text = "";
\r
570 private void GenerateQuery_Click(object sender, EventArgs e)
\r
572 String query = GenerateTheQuery();
\r
573 QueryEditorText.Text = query;
\r
576 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
578 QueryEditorText.Text = "";
\r
581 private void btn_queue_Click(object sender, EventArgs e)
\r
583 String query = GenerateTheQuery();
\r
584 queueWindow.list_queue.Items.Add(query);
\r
585 queueWindow.Show();
\r
588 private void showQueue()
\r
590 queueWindow.Show();
\r
593 private void btn_encode_Click(object sender, EventArgs e)
\r
597 if (QueryEditorText.Text == "")
\r
599 query = GenerateTheQuery();
\r
603 query = QueryEditorText.Text;
\r
606 hbProc = new System.Diagnostics.Process();
\r
607 hbProc.StartInfo.FileName = "hbcli.exe";
\r
608 hbProc.StartInfo.Arguments = query;
\r
609 hbProc.StartInfo.UseShellExecute = false;
\r
612 // Set the process Priority
\r
613 string priority = Properties.Settings.Default.processPriority;
\r
617 hbProc.PriorityClass = ProcessPriorityClass.RealTime;
\r
620 hbProc.PriorityClass = ProcessPriorityClass.High;
\r
622 case "Above Normal":
\r
623 hbProc.PriorityClass = ProcessPriorityClass.AboveNormal;
\r
626 hbProc.PriorityClass = ProcessPriorityClass.Normal;
\r
629 hbProc.PriorityClass = ProcessPriorityClass.Idle;
\r
632 hbProc.PriorityClass = ProcessPriorityClass.BelowNormal;
\r
636 ThreadPool.QueueUserWorkItem(procMonitor);
\r
637 // TODO: Need to write a bit of code here to do process monitoring.
\r
640 private void procMonitor(object state)
\r
642 MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
643 hbProc.WaitForExit();
\r
646 MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
650 //---------------------------------------------------
\r
651 // Items that require actions on frmMain
\r
652 //---------------------------------------------------
\r
654 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
656 lbl_chptWarn.Visible = false;
\r
657 QueryEditorText.Text = "";
\r
658 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
662 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
663 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
665 if (chapterFinish < chapterStart)
\r
667 lbl_chptWarn.Visible = true;
\r
668 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
673 lbl_chptWarn.Visible = true;
\r
674 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
681 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
683 lbl_chptWarn.Visible = false;
\r
684 QueryEditorText.Text = "";
\r
685 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
689 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
690 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
692 if (chapterFinish < chapterStart)
\r
694 lbl_chptWarn.Visible = true;
\r
695 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
700 lbl_chptWarn.Visible = true;
\r
701 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
706 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
708 text_filesize.Text = "";
\r
709 slider_videoQuality.Value = 0;
\r
710 SliderValue.Text = "0%";
\r
711 CheckCRF.CheckState = CheckState.Unchecked;
\r
714 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
716 text_bitrate.Text = "";
\r
717 slider_videoQuality.Value = 0;
\r
718 SliderValue.Text = "0%";
\r
719 CheckCRF.CheckState = CheckState.Unchecked;
\r
722 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
724 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
725 text_bitrate.Text = "";
\r
726 text_filesize.Text = "";
\r
729 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
731 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
734 private void text_width_TextChanged(object sender, EventArgs e)
\r
738 if (CheckPixelRatio.Checked) {
\r
739 text_width.Text = "";
\r
741 if ((int.Parse(text_width.Text) % 16) != 0){
\r
742 text_width.BackColor = Color.LightCoral;
\r
744 text_width.BackColor = Color.LightGreen;
\r
748 // There is a bug here *******************************************************************
\r
749 if (!lbl_Aspect.Text.Equals("Select a Title")){
\r
750 int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);
\r
751 MessageBox.Show("test");
\r
752 int mod16 = height % 16;
\r
753 height = height - mod16;
\r
754 text_height.Text = height.ToString();
\r
757 } catch(Exception){
\r
758 // No need to alert the user if there is a problem here.
\r
762 private void text_height_TextChanged(object sender, EventArgs e)
\r
766 if (CheckPixelRatio.Checked)
\r
768 text_height.Text = "";
\r
772 if ((int.Parse(text_height.Text) % 16) != 0)
\r
774 text_height.BackColor = Color.LightCoral;
\r
778 text_height.BackColor = Color.LightGreen;
\r
781 } catch(Exception){
\r
782 // No need to alert the user.
\r
786 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
788 if ((string)drp_crop.SelectedItem == "Manual")
\r
790 text_left.Enabled = true;
\r
791 text_right.Enabled = true;
\r
792 text_top.Enabled = true;
\r
793 text_bottom.Enabled = true;
\r
796 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
798 text_left.Enabled = false;
\r
799 text_right.Enabled = false;
\r
800 text_top.Enabled = false;
\r
801 text_bottom.Enabled = false;
\r
802 text_left.Text = "";
\r
803 text_right.Text = "";
\r
804 text_top.Text = "";
\r
805 text_bottom.Text = "";
\r
807 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
809 string[] temp = new string[4];
\r
810 temp = lbl_RecomendedCrop.Text.Split('/');
\r
811 text_left.Text = temp[2];
\r
812 text_right.Text = temp[3];
\r
813 text_top.Text = temp[0];
\r
814 text_bottom.Text = temp[1];
\r
818 if ((string)drp_crop.SelectedItem == "No Crop")
\r
820 text_left.Enabled = false;
\r
821 text_right.Enabled = false;
\r
822 text_top.Enabled = false;
\r
823 text_bottom.Enabled = false;
\r
824 text_left.Text = "0";
\r
825 text_right.Text = "0";
\r
826 text_top.Text = "0";
\r
827 text_bottom.Text = "0";
\r
832 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
834 text_width.Text = "";
\r
835 text_height.Text = "";
\r
836 text_width.BackColor = Color.White;
\r
837 text_height.BackColor = Color.White;
\r
840 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
842 if (drp_dvdtitle.Items.Count == 1)
\r
844 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
848 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
851 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
853 drp_audioMixDown.Items.Clear();
\r
855 if (drp_audioCodec.Text == "AAC")
\r
857 drp_audioMixDown.Items.Clear();
\r
858 drp_audioMixDown.Items.Add("Mono");
\r
859 drp_audioMixDown.Items.Add("Stereo");
\r
860 drp_audioMixDown.Items.Add("Dolby Surround");
\r
861 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
862 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
864 drp_audioBitrate.Items.Clear();
\r
865 drp_audioBitrate.Items.Add("32");
\r
866 drp_audioBitrate.Items.Add("40");
\r
867 drp_audioBitrate.Items.Add("48");
\r
868 drp_audioBitrate.Items.Add("56");
\r
869 drp_audioBitrate.Items.Add("64");
\r
870 drp_audioBitrate.Items.Add("80");
\r
871 drp_audioBitrate.Items.Add("86");
\r
872 drp_audioBitrate.Items.Add("112");
\r
873 drp_audioBitrate.Items.Add("128");
\r
874 drp_audioBitrate.Items.Add("160");
\r
879 drp_audioMixDown.Items.Clear();
\r
880 drp_audioMixDown.Items.Add("Stereo");
\r
881 drp_audioMixDown.Items.Add("Dolby Surround");
\r
882 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
884 drp_audioBitrate.Items.Clear();
\r
885 drp_audioBitrate.Items.Add("32");
\r
886 drp_audioBitrate.Items.Add("40");
\r
887 drp_audioBitrate.Items.Add("48");
\r
888 drp_audioBitrate.Items.Add("56");
\r
889 drp_audioBitrate.Items.Add("64");
\r
890 drp_audioBitrate.Items.Add("80");
\r
891 drp_audioBitrate.Items.Add("86");
\r
892 drp_audioBitrate.Items.Add("112");
\r
893 drp_audioBitrate.Items.Add("128");
\r
894 drp_audioBitrate.Items.Add("160");
\r
895 drp_audioBitrate.Items.Add("192");
\r
896 drp_audioBitrate.Items.Add("224");
\r
897 drp_audioBitrate.Items.Add("256");
\r
898 drp_audioBitrate.Items.Add("320");
\r
899 drp_audioBitrate.Items.Add("384");
\r
903 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
905 if (drp_audioCodec.Text == "AAC")
\r
907 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
910 drp_audioBitrate.Items.Clear();
\r
911 drp_audioBitrate.Items.Add("32");
\r
912 drp_audioBitrate.Items.Add("40");
\r
913 drp_audioBitrate.Items.Add("48");
\r
914 drp_audioBitrate.Items.Add("56");
\r
915 drp_audioBitrate.Items.Add("64");
\r
916 drp_audioBitrate.Items.Add("80");
\r
917 drp_audioBitrate.Items.Add("86");
\r
918 drp_audioBitrate.Items.Add("112");
\r
919 drp_audioBitrate.Items.Add("128");
\r
920 drp_audioBitrate.Items.Add("160");
\r
921 drp_audioBitrate.Items.Add("192");
\r
922 drp_audioBitrate.Items.Add("224");
\r
923 drp_audioBitrate.Items.Add("256");
\r
924 drp_audioBitrate.Items.Add("320");
\r
925 drp_audioBitrate.Items.Add("384");
\r
930 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
932 if (Check_ChapterMarkers.Checked)
\r
934 string destination = text_destination.Text;
\r
935 destination = destination.Replace(".mp4", ".m4v");
\r
936 text_destination.Text = destination;
\r
940 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
942 if (!text_destination.Text.Contains(".mp4"))
\r
944 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
945 check_largeFile.CheckState = CheckState.Unchecked;
\r
949 private void check_turbo_CheckedChanged(object sender, EventArgs e)
\r
951 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
953 MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
954 check_turbo.CheckState = CheckState.Unchecked;
\r
958 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
960 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
961 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
963 check_turbo.CheckState = CheckState.Unchecked;
\r
964 CheckCRF.CheckState = CheckState.Unchecked;
\r
968 private void CheckCRF_CheckedChanged(object sender, EventArgs e)
\r
970 if (slider_videoQuality.Value == 0)
\r
972 MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
973 CheckCRF.CheckState = CheckState.Unchecked;
\r
977 public void setStreamReader(Parsing.DVD dvd)
\r
979 this.thisDVD = dvd;
\r
982 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
984 // Reset some values on the form
\r
985 lbl_Aspect.Text = "Select a Title";
\r
986 lbl_RecomendedCrop.Text = "Select a Title";
\r
987 drop_chapterStart.Items.Clear();
\r
988 drop_chapterFinish.Items.Clear();
\r
989 QueryEditorText.Text = "";
\r
991 // If the dropdown is set to automatic nothing else needs to be done.
\r
992 // Otheriwse if its not, title data has to be loased from parsing.
\r
993 if (drp_dvdtitle.Text != "Automatic")
\r
995 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
996 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
997 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
999 drop_chapterStart.Items.Clear();
\r
1000 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1001 if (drop_chapterStart.Items.Count > 0)
\r
1003 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1006 drop_chapterFinish.Items.Clear();
\r
1007 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1008 if (drop_chapterFinish.Items.Count > 0)
\r
1010 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1013 drp_audioChannels.Items.Clear();
\r
1014 drp_subtitle.Items.Add("Automatic");
\r
1015 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1016 if (drp_audioChannels.Items.Count > 0)
\r
1018 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1021 drp_subtitle.Items.Clear();
\r
1022 drp_subtitle.Items.Add("None");
\r
1023 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1024 if (drp_subtitle.Items.Count > 0)
\r
1026 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1031 // The Query Generation Function
\r
1032 // This function was imported from old vb.net version of this application.
\r
1033 // It could probably do with being cleaned up a good deal at some point
\r
1035 public string GenerateTheQuery()
\r
1037 string source = text_source.Text;
\r
1038 string dvdTitle = drp_dvdtitle.Text;
\r
1039 string chapterStart = drop_chapterStart.Text;
\r
1040 string chapterFinish = drop_chapterFinish.Text;
\r
1041 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1042 string dvdChapter = "";
\r
1045 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1048 source = " -i " + '"' + source+ '"'; //'"'+
\r
1051 if (dvdTitle == "Automatic")
\r
1055 string[] titleInfo = dvdTitle.Split(' ');
\r
1056 dvdTitle = " -t "+ titleInfo[0];
\r
1059 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1061 else if (chapterFinish == chapterStart)
\r
1062 dvdChapter = " -c " + chapterStart;
\r
1064 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1066 string querySource = source+ dvdTitle+ dvdChapter;
\r
1067 // ----------------------------------------------------------------------
\r
1071 string destination = text_destination.Text;
\r
1072 string videoEncoder = drp_videoEncoder.Text;
\r
1073 string audioEncoder = drp_audioCodec.Text;
\r
1074 string width = text_width.Text;
\r
1075 string height = text_height.Text;
\r
1077 if (destination == "")
\r
1078 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1080 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1083 switch (videoEncoder)
\r
1086 videoEncoder = " -e ffmpeg";
\r
1089 videoEncoder = " -e xvid";
\r
1092 videoEncoder = " -e x264";
\r
1094 case "H.264 Baseline 1.3":
\r
1095 videoEncoder = " -e x264b13";
\r
1097 case "H.264 (iPod)":
\r
1098 videoEncoder = " -e x264b30";
\r
1101 videoEncoder = " -e x264";
\r
1105 switch (audioEncoder)
\r
1108 audioEncoder = " -E faac";
\r
1111 audioEncoder = " -E lame";
\r
1114 audioEncoder = " -E vorbis";
\r
1117 audioEncoder = " -E ac3";
\r
1120 audioEncoder = " -E faac";
\r
1125 width = " -w "+ width;
\r
1129 height = " -l "+ height;
\r
1132 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1133 // ----------------------------------------------------------------------
\r
1135 // Picture Settings Tab
\r
1137 string cropSetting = drp_crop.Text;
\r
1138 string cropTop = text_top.Text;
\r
1139 string cropBottom = text_bottom.Text;
\r
1140 string cropLeft = text_left.Text;
\r
1141 string cropRight = text_right.Text;
\r
1142 string subtitles = drp_subtitle.Text;
\r
1143 string cropOut = "";
\r
1144 // Returns Crop Query
\r
1146 if (cropSetting == "Auto Crop")
\r
1148 else if (cropSetting == "No Crop")
\r
1149 cropOut = " --crop 0:0:0:0 ";
\r
1151 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1153 if (subtitles == "None")
\r
1155 else if (subtitles == "")
\r
1160 tempSub = subtitles.Split(' ');
\r
1161 subtitles = " -s "+ tempSub[0];
\r
1164 string queryPictureSettings = cropOut+ subtitles;
\r
1165 // ----------------------------------------------------------------------
\r
1167 // Video Settings Tab
\r
1169 string videoBitrate = text_bitrate.Text;
\r
1170 string videoFilesize = text_filesize.Text;
\r
1171 int videoQuality = slider_videoQuality.Value;
\r
1172 string vidQSetting = "";
\r
1173 string twoPassEncoding = "";
\r
1174 string deinterlace = "";
\r
1175 string grayscale = "";
\r
1176 string videoFramerate = drp_videoFramerate.Text;
\r
1177 string pixelRatio = "";
\r
1178 string ChapterMarkers = "";
\r
1179 string turboH264 = "";
\r
1180 string largeFile = "";
\r
1182 if (videoBitrate != "")
\r
1183 videoBitrate = " -b "+ videoBitrate;
\r
1185 if (videoFilesize != "")
\r
1186 videoFilesize = " -S "+ videoFilesize;
\r
1188 // Video Quality Setting
\r
1190 if ((videoQuality == 0))
\r
1194 videoQuality = videoQuality/ 100;
\r
1195 if (videoQuality == 1)
\r
1197 vidQSetting = "1.0";
\r
1200 vidQSetting = " -q " + videoQuality.ToString();
\r
1203 if (check_2PassEncode.Checked)
\r
1204 twoPassEncoding = " -2 ";
\r
1206 if (check_DeInterlace.Checked)
\r
1207 deinterlace = " -d ";
\r
1209 if (check_grayscale.Checked)
\r
1210 grayscale = " -g ";
\r
1212 if (videoFramerate == "Automatic")
\r
1213 videoFramerate = "";
\r
1215 videoFramerate = " -r "+ videoFramerate;
\r
1217 if (CheckPixelRatio.Checked)
\r
1218 pixelRatio = " -p ";
\r
1220 if (Check_ChapterMarkers.Checked)
\r
1221 ChapterMarkers = " -m ";
\r
1223 if (check_turbo.Checked)
\r
1224 turboH264 = " -T ";
\r
1226 if (check_largeFile.Checked)
\r
1227 largeFile = " -4 ";
\r
1229 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;
\r
1230 // ----------------------------------------------------------------------
\r
1232 // Audio Settings Tab
\r
1234 string audioBitrate = drp_audioBitrate.Text;
\r
1235 string audioSampleRate = drp_audioSampleRate.Text;
\r
1236 string audioChannels = drp_audioChannels.Text;
\r
1237 string Mixdown = drp_audioMixDown.Text;
\r
1238 string SixChannelAudio = "";
\r
1240 if (audioBitrate != "")
\r
1241 audioBitrate = " -B "+ audioBitrate;
\r
1243 if (audioSampleRate != "")
\r
1244 audioSampleRate = " -R "+ audioSampleRate;
\r
1246 if (audioChannels == "Automatic")
\r
1247 audioChannels = "";
\r
1248 else if (audioChannels == "")
\r
1249 audioChannels = "";
\r
1253 tempSub = audioChannels.Split(' ');
\r
1254 audioChannels = " -a "+ tempSub[0];
\r
1266 Mixdown = "stereo";
\r
1268 case "Dolby Surround":
\r
1271 case "Dolby Pro Logic II":
\r
1274 case "6 Channel Discrete":
\r
1278 Mixdown = "stero";
\r
1282 if (Mixdown != "")
\r
1283 SixChannelAudio = " -6 "+ Mixdown;
\r
1285 SixChannelAudio = "";
\r
1287 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1288 // ----------------------------------------------------------------------
\r
1292 string CRF = CheckCRF.CheckState.ToString();
\r
1293 string h264Advanced = rtf_h264advanced.Text;
\r
1299 if ((h264Advanced == ""))
\r
1300 h264Advanced = "";
\r
1302 h264Advanced = " -x "+ h264Advanced;
\r
1305 string h264Settings = CRF+ h264Advanced;
\r
1306 // ----------------------------------------------------------------------
\r
1308 // Processors (Program Settings)
\r
1310 string processors = Properties.Settings.Default.Processors;
\r
1311 // Number of Processors Handler
\r
1313 if (processors == "Automatic")
\r
1316 processors = " -C "+ processors+ " ";
\r
1319 string queryAdvancedSettings = processors;
\r
1320 // ----------------------------------------------------------------------
\r
1322 // Verbose option (Program Settings)
\r
1324 string verbose = "";
\r
1325 if (Properties.Settings.Default.verbose == "Checked")
\r
1328 // ----------------------------------------------------------------------
\r
1330 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1335 // This is the END of the road ------------------------------------------------------------------------------
\r