2 using System.Collections.Generic;
\r
3 using System.ComponentModel;
\r
5 using System.Drawing;
\r
7 using System.Windows.Forms;
\r
13 public partial class frmMain : Form
\r
17 InitializeComponent();
\r
20 // --------------------------------------------------------------
\r
21 // onLoad - setup the program ready for use.
\r
22 // --------------------------------------------------------------
\r
23 private void frmMain_Load(object sender, EventArgs e)
\r
25 // Set the Version number lable to the corect version.
\r
26 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
28 // Run the update checker.
\r
31 // Now load the users default if required.
\r
36 public void loadUserDefaults()
\r
40 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
43 text_source.Text = Properties.Settings.Default.DVDSource;
\r
44 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
45 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
46 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
48 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
49 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
50 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
51 text_width.Text = Properties.Settings.Default.Width;
\r
52 text_height.Text = Properties.Settings.Default.Height;
\r
53 //Picture Settings Tab
\r
54 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
55 text_top.Text = Properties.Settings.Default.CropTop;
\r
56 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
57 text_left.Text = Properties.Settings.Default.CropLeft;
\r
58 text_right.Text = Properties.Settings.Default.CropRight;
\r
59 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
60 //Video Settings Tab
\r
61 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
62 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
63 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
64 if (Properties.Settings.Default.TwoPass == "Checked")
\r
66 check_2PassEncode.CheckState = CheckState.Checked;
\r
68 if (Properties.Settings.Default.DeInterlace == "Checked")
\r
70 check_DeInterlace.CheckState = CheckState.Checked;
\r
72 if (Properties.Settings.Default.Grayscale == "Checked")
\r
74 check_grayscale.CheckState = CheckState.Checked;
\r
77 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
79 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
81 CheckPixelRatio.CheckState = CheckState.Checked;
\r
83 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
85 check_turbo.CheckState = CheckState.Checked;
\r
87 if (Properties.Settings.Default.largeFile == "Checked")
\r
89 check_largeFile.CheckState = CheckState.Checked;
\r
91 //Audio Settings Tab
\r
92 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
93 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
94 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
96 if (Properties.Settings.Default.CRF == "Checked")
\r
98 CheckCRF.CheckState = CheckState.Checked;
\r
100 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
105 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
109 public void updateCheck()
\r
111 if (Properties.Settings.Default.updateStatus == "Checked")
\r
116 String updateFile = Properties.Settings.Default.updateFile;
\r
117 WebClient client = new WebClient();
\r
118 String data = client.DownloadString(updateFile);
\r
119 String[] versionData = data.Split('\n');
\r
121 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
123 lbl_update.Visible = true;
\r
126 //else fail displaying an error message.
\r
129 //Silently ignore the error
\r
136 // --------------------------------------------------------------
\r
138 // --------------------------------------------------------------
\r
140 // FILE MENU --------------------------------------------------------------
\r
141 private void mnu_open_Click(object sender, EventArgs e)
\r
144 File_Open.ShowDialog();
\r
145 filename = File_Open.FileName;
\r
146 if (filename != "")
\r
150 // Create StreamReader & open file
\r
151 StreamReader line = new StreamReader(filename);
\r
152 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
154 // Read in the data and set the correct GUI component with the setting.
\r
155 text_source.Text = line.ReadLine();
\r
156 drp_dvdtitle.Text = line.ReadLine();
\r
157 drop_chapterStart.Text = line.ReadLine();
\r
158 drop_chapterFinish.Text = line.ReadLine();
\r
159 text_destination.Text = line.ReadLine();
\r
160 drp_videoEncoder.Text = line.ReadLine();
\r
161 drp_audioCodec.Text = line.ReadLine();
\r
162 text_width.Text = line.ReadLine();
\r
163 text_height.Text = line.ReadLine();
\r
164 text_top.Text = line.ReadLine();
\r
165 text_bottom.Text = line.ReadLine();
\r
166 text_left.Text = line.ReadLine();
\r
167 text_right.Text = line.ReadLine();
\r
168 drp_subtitle.Text = line.ReadLine();
\r
169 text_bitrate.Text = line.ReadLine();
\r
170 text_filesize.Text = line.ReadLine();
\r
171 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
173 temporyLine = line.ReadLine();
\r
174 if (temporyLine == "Checked")
\r
176 check_2PassEncode.CheckState = CheckState.Checked;
\r
179 temporyLine = line.ReadLine();
\r
180 if (temporyLine == "Checked")
\r
182 check_DeInterlace.CheckState = CheckState.Checked;
\r
185 temporyLine = line.ReadLine();
\r
186 if (temporyLine == "Checked")
\r
188 check_grayscale.CheckState = CheckState.Checked;
\r
191 drp_videoFramerate.Text = line.ReadLine();
\r
193 temporyLine = line.ReadLine();
\r
194 if (temporyLine == "Checked")
\r
196 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
199 temporyLine = line.ReadLine();
\r
200 if (temporyLine == "Checked")
\r
202 CheckPixelRatio.CheckState = CheckState.Checked;
\r
205 temporyLine = line.ReadLine();
\r
206 if (temporyLine == "Checked")
\r
208 check_turbo.CheckState = CheckState.Checked;
\r
211 temporyLine = line.ReadLine();
\r
212 if (temporyLine == "Checked")
\r
214 check_largeFile.CheckState = CheckState.Checked;
\r
217 drp_audioBitrate.Text = line.ReadLine();
\r
218 drp_audioSampleRate.Text = line.ReadLine();
\r
219 drp_audioChannels.Text = line.ReadLine();
\r
220 drp_audioMixDown.Text = line.ReadLine();
\r
222 // Advanced H264 Options
\r
223 temporyLine = line.ReadLine();
\r
224 if (temporyLine == "Checked")
\r
226 CheckCRF.CheckState = CheckState.Checked;
\r
228 rtf_h264advanced.Text = line.ReadLine();
\r
230 // Close the stream
\r
234 // Fix for SliderValue not appearing when Opening saved file
\r
235 SliderValue.Text = slider_videoQuality.Value + "%";
\r
237 } catch (Exception){
\r
238 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
243 private void mnu_save_Click(object sender, EventArgs e)
\r
245 // Note : All these declarations are not really needed and should be removed at some point.
\r
246 // The values can simply be added directly to the WriteLine statments.
\r
249 string source = text_source.Text;
\r
250 string dvdTitle = drp_dvdtitle.Text;
\r
251 string ChapterStart = drop_chapterStart.Text;
\r
252 string ChapterFinish = drop_chapterFinish.Text;
\r
254 string destination = text_destination.Text;
\r
255 string videoEncoder = drp_videoEncoder.Text;
\r
256 string audioEncoder = drp_audioCodec.Text;
\r
257 string width = text_width.Text;
\r
258 string height = text_height.Text;
\r
259 //Picture Settings Tab
\r
260 string cropTop = text_top.Text;
\r
261 string cropBottom = text_bottom.Text;
\r
262 string cropLeft = text_left.Text;
\r
263 string cropRight = text_right.Text;
\r
264 string subtitles = drp_subtitle.Text;
\r
265 //Video Settings Tab
\r
266 string videoBitrate = text_bitrate.Text;
\r
267 string videoFilesize = text_filesize.Text;
\r
268 string videoQuality = slider_videoQuality.Value.ToString();
\r
269 string twoPassEncoding = check_2PassEncode.CheckState.ToString();
\r
270 string deinterlace = check_DeInterlace.CheckState.ToString();
\r
271 string grayscale = check_grayscale.CheckState.ToString();
\r
272 string videoFramerate = drp_videoFramerate.Text;
\r
273 string pixelRation = CheckPixelRatio.CheckState.ToString();
\r
274 string ChapterMarkers = Check_ChapterMarkers.CheckState.ToString();
\r
275 string turboH264 = check_turbo.CheckState.ToString();
\r
276 string largeFile = check_largeFile.CheckState.ToString();
\r
277 //Audio Settings Tab
\r
278 string audioBitrate = drp_audioBitrate.Text;
\r
279 string audioSampleRate = drp_audioSampleRate.Text;
\r
280 string audioChannels = drp_audioChannels.Text;
\r
281 string AudioMixDown = drp_audioMixDown.Text;
\r
283 string CRF = CheckCRF.CheckState.ToString();
\r
284 string advH264 = rtf_h264advanced.Text;
\r
287 File_Save.ShowDialog();
\r
288 filename = File_Save.FileName;
\r
289 if (filename != "")
\r
293 // Create a StreamWriter and open the file
\r
294 StreamWriter line = new StreamWriter(filename);
\r
296 line.WriteLine(source);
\r
297 line.WriteLine(dvdTitle);
\r
298 line.WriteLine(ChapterStart);
\r
299 line.WriteLine(ChapterFinish);
\r
300 line.WriteLine(destination);
\r
301 line.WriteLine(videoEncoder);
\r
302 line.WriteLine(audioEncoder);
\r
303 line.WriteLine(width);
\r
304 line.WriteLine(height);
\r
305 line.WriteLine(cropTop);
\r
306 line.WriteLine(cropBottom);
\r
307 line.WriteLine(cropLeft);
\r
308 line.WriteLine(cropRight);
\r
309 line.WriteLine(subtitles);
\r
310 line.WriteLine(videoBitrate);
\r
311 line.WriteLine(videoFilesize);
\r
312 line.WriteLine(videoQuality);
\r
313 line.WriteLine(twoPassEncoding);
\r
314 line.WriteLine(deinterlace);
\r
315 line.WriteLine(grayscale);
\r
316 line.WriteLine(videoFramerate);
\r
317 line.WriteLine(ChapterMarkers);
\r
318 line.WriteLine(pixelRation);
\r
319 line.WriteLine(turboH264);
\r
320 line.WriteLine(largeFile);
\r
321 line.WriteLine(audioBitrate);
\r
322 line.WriteLine(audioSampleRate);
\r
323 line.WriteLine(audioChannels);
\r
324 line.WriteLine(AudioMixDown);
\r
325 line.WriteLine(CRF);
\r
326 line.WriteLine(advH264);
\r
327 // close the stream
\r
329 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
333 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
339 private void mnu_update_Click(object sender, EventArgs e)
\r
341 Form Update = new frmUpdate();
\r
345 private void mnu_exit_Click(object sender, EventArgs e)
\r
350 // TOOLS MENU --------------------------------------------------------------
\r
351 private void mnu_encode_Click(object sender, EventArgs e)
\r
353 Form Queue = new frmQueue();
\r
357 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
359 Form DVDData = new frmDVDData();
\r
363 private void mnu_options_Click(object sender, EventArgs e)
\r
365 Form Options = new frmOptions();
\r
369 // PRESETS MENU --------------------------------------------------------------
\r
370 private void mnu_preset_ipod133_Click(object sender, EventArgs e)
\r
372 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
373 text_width.Text = "640";
\r
374 text_height.Text = "480";
\r
375 drp_videoEncoder.Text = "H.264 (iPod)";
\r
376 text_bitrate.Text = "1000";
\r
377 text_filesize.Text = "";
\r
378 slider_videoQuality.Value = 0;
\r
379 SliderValue.Text = "0%";
\r
380 drp_audioBitrate.Text = "160";
\r
381 rtf_h264advanced.Text = "";
\r
382 drp_crop.Text = "No Crop";
\r
385 private void mnu_preset_ipod178_Click(object sender, EventArgs e)
\r
387 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
388 text_width.Text = "640";
\r
389 text_height.Text = "352";
\r
390 drp_videoEncoder.Text = "H.264 (iPod)";
\r
391 text_bitrate.Text = "1000";
\r
392 text_filesize.Text = "";
\r
393 slider_videoQuality.Value = 0;
\r
394 SliderValue.Text = "0%";
\r
395 drp_audioBitrate.Text = "160";
\r
396 rtf_h264advanced.Text = "";
\r
397 drp_crop.Text = "No Crop";
\r
400 private void mnu_preset_ipod235_Click(object sender, EventArgs e)
\r
402 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
403 text_width.Text = "640";
\r
404 text_height.Text = "272";
\r
405 drp_videoEncoder.Text = "H.264 (iPod)";
\r
406 text_bitrate.Text = "1000";
\r
407 text_filesize.Text = "";
\r
408 slider_videoQuality.Value = 0;
\r
409 SliderValue.Text = "0%";
\r
410 drp_audioBitrate.Text = "160";
\r
411 rtf_h264advanced.Text = "";
\r
412 drp_crop.Text = "No Crop";
\r
415 private void mnu_appleTv_Click(object sender, EventArgs e)
\r
417 text_width.Text = "";
\r
418 text_height.Text = "";
\r
419 drp_videoEncoder.Text = "H.264";
\r
420 text_bitrate.Text = "3000";
\r
421 text_filesize.Text = "";
\r
422 slider_videoQuality.Value = 0;
\r
423 SliderValue.Text = "0%";
\r
424 drp_audioBitrate.Text = "160";
\r
425 CheckPixelRatio.CheckState = CheckState.Checked;
\r
426 drp_audioSampleRate.Text = "48";
\r
427 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:no-dct-decimate=1:trellis=2";
\r
428 drp_crop.Text = "No Crop";
\r
432 private void mnu_presetPS3_Click(object sender, EventArgs e)
\r
434 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
435 text_width.Text = "";
\r
436 text_height.Text = "";
\r
437 drp_videoEncoder.Text = "H.264";
\r
438 text_bitrate.Text = "3000";
\r
439 text_filesize.Text = "";
\r
440 slider_videoQuality.Value = 0;
\r
441 SliderValue.Text = "0%";
\r
442 drp_audioBitrate.Text = "160";
\r
443 CheckPixelRatio.CheckState = CheckState.Checked;
\r
444 drp_audioSampleRate.Text = "48";
\r
445 rtf_h264advanced.Text = "level=41";
\r
446 drp_crop.Text = "No Crop";
\r
449 private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)
\r
452 Properties.Settings.Default.DVDSource = text_source.Text;
\r
453 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
454 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
455 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
457 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
458 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
459 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
460 Properties.Settings.Default.Width = text_width.Text;
\r
461 Properties.Settings.Default.Height = text_height.Text;
\r
462 //Picture Settings Tab
\r
463 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
464 Properties.Settings.Default.CropTop = text_top.Text;
\r
465 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
466 Properties.Settings.Default.CropLeft = text_left.Text;
\r
467 Properties.Settings.Default.CropRight = text_right.Text;
\r
468 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
469 //Video Settings Tab
\r
470 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
471 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
472 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
473 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
474 Properties.Settings.Default.DeInterlace = check_DeInterlace.CheckState.ToString();
\r
475 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
476 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
477 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
478 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
479 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
480 //Audio Settings Tab
\r
481 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
482 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
483 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
485 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
486 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
487 Properties.Settings.Default.Save();
\r
490 // Help Menu --------------------------------------------------------------
\r
491 private void mnu_wiki_Click(object sender, EventArgs e)
\r
493 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac");
\r
496 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
498 System.Diagnostics.Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
501 private void mnu_faq_Click(object sender, EventArgs e)
\r
503 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
506 private void mnu_homepage_Click(object sender, EventArgs e)
\r
508 System.Diagnostics.Process.Start("http://handbrake.m0k.org");
\r
511 private void mnu_forum_Click(object sender, EventArgs e)
\r
513 System.Diagnostics.Process.Start("http://handbrake.m0k.org/forum");
\r
516 private void mnu_about_Click(object sender, EventArgs e)
\r
518 Form About = new frmAbout();
\r
524 // --------------------------------------------------------------
\r
525 // Buttons on the main Window
\r
526 // --------------------------------------------------------------
\r
527 private void btn_Browse_Click(object sender, EventArgs e)
\r
529 String filename ="";
\r
530 text_source.Text = "";
\r
532 if (RadioDVD.Checked)
\r
534 DVD_Open.ShowDialog();
\r
535 filename = DVD_Open.SelectedPath;
\r
536 if (filename != "")
\r
538 text_source.Text = filename;
\r
539 Form frmReadDVD = new frmReadDVD(filename);
\r
546 ISO_Open.ShowDialog();
\r
547 filename = ISO_Open.FileName;
\r
548 if (filename != "")
\r
550 text_source.Text = filename;
\r
551 Form frmReadDVD = new frmReadDVD(filename);
\r
560 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
562 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
564 DVD_Save.ShowDialog();
\r
565 text_destination.Text = DVD_Save.FileName;
\r
567 if (Check_ChapterMarkers.CheckState.ToString() == "Checked")
\r
569 string destination = text_destination.Text;
\r
570 destination = destination.Replace(".mp4", ".m4v");
\r
571 text_destination.Text = destination;
\r
575 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
577 rtf_h264advanced.Text = "";
\r
580 private void GenerateQuery_Click(object sender, EventArgs e)
\r
582 String query = GenerateTheQuery();
\r
583 QueryEditorText.Text = query;
\r
586 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
588 QueryEditorText.Text = "";
\r
591 private void btn_queue_Click(object sender, EventArgs e)
\r
593 Form Queue = new frmQueue();
\r
597 private void btn_encode_Click(object sender, EventArgs e)
\r
601 if (QueryEditorText.Text == "")
\r
603 query = GenerateTheQuery();
\r
604 MessageBox.Show(query);
\r
608 query = QueryEditorText.Text;
\r
611 System.Diagnostics.Process hbProc = new System.Diagnostics.Process();
\r
612 hbProc.StartInfo.FileName = "hbcli.exe";
\r
613 hbProc.StartInfo.Arguments = query;
\r
614 hbProc.StartInfo.UseShellExecute = false;
\r
618 MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
620 // TODO: Need to write a bit of code here to do process monitoring.
\r
621 // Note: hbProc.waitForExit will freeze the app, meaning one cannot add additional items to the queue during an encode.
\r
624 // --------------------------------------------------------------
\r
625 // Items that require actions on frmMain
\r
626 // --------------------------------------------------------------
\r
629 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
631 QueryEditorText.Text = "";
\r
632 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
634 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
635 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
639 if (chapterFinish < chapterStart)
\r
641 MessageBox.Show("Invalid Chapter Range! - Final chapter can not be smaller than the starting chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
646 MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
653 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
655 QueryEditorText.Text = "";
\r
656 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
658 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
659 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
663 if (chapterFinish > chapterStart)
\r
665 MessageBox.Show("Invalid Chapter Range! - Start chapter can not be larger than the Final chapter.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
670 MessageBox.Show("Invalid Character Entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
675 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
677 text_filesize.Text = "";
\r
678 slider_videoQuality.Value = 0;
\r
679 SliderValue.Text = "0%";
\r
680 CheckCRF.CheckState = CheckState.Unchecked;
\r
683 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
685 text_bitrate.Text = "";
\r
686 slider_videoQuality.Value = 0;
\r
687 SliderValue.Text = "0%";
\r
688 CheckCRF.CheckState = CheckState.Unchecked;
\r
691 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
693 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
694 text_bitrate.Text = "";
\r
695 text_filesize.Text = "";
\r
698 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
700 System.Diagnostics.Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
703 private void text_width_TextChanged(object sender, EventArgs e)
\r
707 if (CheckPixelRatio.CheckState.ToString() == "Checked") {
\r
708 text_width.Text = "";
\r
710 if ((int.Parse(text_width.Text) % 16) != 0){
\r
711 text_width.BackColor = Color.LightCoral;
\r
713 text_width.BackColor = Color.LightGreen;
\r
717 if (!lbl_Aspect.Text.Equals("Select a Title")){
\r
718 int height = int.Parse(text_width.Text) / int.Parse(lbl_Aspect.Text);
\r
719 int mod16 = height % 16;
\r
720 height = height - mod16;
\r
721 text_height.Text = height.ToString();
\r
724 } catch(Exception){
\r
728 private void text_height_TextChanged(object sender, EventArgs e)
\r
732 if (CheckPixelRatio.CheckState.ToString() == "Checked")
\r
734 text_height.Text = "";
\r
738 if ((int.Parse(text_height.Text) % 16) != 0)
\r
740 text_height.BackColor = Color.LightCoral;
\r
744 text_height.BackColor = Color.LightGreen;
\r
747 } catch(Exception){
\r
751 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
753 if ((string)drp_crop.SelectedItem == "Manual")
\r
755 text_left.Enabled = true;
\r
756 text_right.Enabled = true;
\r
757 text_top.Enabled = true;
\r
758 text_bottom.Enabled = true;
\r
761 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
763 text_left.Enabled = false;
\r
764 text_right.Enabled = false;
\r
765 text_top.Enabled = false;
\r
766 text_bottom.Enabled = false;
\r
767 text_left.Text = "";
\r
768 text_right.Text = "";
\r
769 text_top.Text = "";
\r
770 text_bottom.Text = "";
\r
772 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
774 string[] temp = new string[4];
\r
775 temp = lbl_RecomendedCrop.Text.Split('/');
\r
776 text_left.Text = temp[2];
\r
777 text_right.Text = temp[3];
\r
778 text_top.Text = temp[0];
\r
779 text_bottom.Text = temp[1];
\r
783 if ((string)drp_crop.SelectedItem == "No Crop")
\r
785 text_left.Enabled = false;
\r
786 text_right.Enabled = false;
\r
787 text_top.Enabled = false;
\r
788 text_bottom.Enabled = false;
\r
789 text_left.Text = "0";
\r
790 text_right.Text = "0";
\r
791 text_top.Text = "0";
\r
792 text_bottom.Text = "0";
\r
797 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
799 text_width.Text = "";
\r
800 text_height.Text = "";
\r
801 text_width.BackColor = Color.White;
\r
802 text_height.BackColor = Color.White;
\r
805 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
807 if (drp_dvdtitle.Items.Count == 1)
\r
809 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
813 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
816 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
818 drp_audioMixDown.Items.Clear();
\r
820 if (drp_audioCodec.Text == "AAC")
\r
822 drp_audioMixDown.Items.Add("Mono");
\r
823 drp_audioMixDown.Items.Add("Stereo");
\r
824 drp_audioMixDown.Items.Add("Dolby Surround");
\r
825 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
826 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
827 drp_audioBitrate.Items.Clear();
\r
828 drp_audioBitrate.Items.Add("32");
\r
829 drp_audioBitrate.Items.Add("40");
\r
830 drp_audioBitrate.Items.Add("48");
\r
831 drp_audioBitrate.Items.Add("56");
\r
832 drp_audioBitrate.Items.Add("64");
\r
833 drp_audioBitrate.Items.Add("80");
\r
834 drp_audioBitrate.Items.Add("86");
\r
835 drp_audioBitrate.Items.Add("112");
\r
836 drp_audioBitrate.Items.Add("128");
\r
837 drp_audioBitrate.Items.Add("160");
\r
842 drp_audioMixDown.Items.Add("Stereo");
\r
843 drp_audioMixDown.Items.Add("Dolby Surround");
\r
844 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
846 drp_audioBitrate.Items.Clear();
\r
847 drp_audioBitrate.Items.Add("32");
\r
848 drp_audioBitrate.Items.Add("40");
\r
849 drp_audioBitrate.Items.Add("48");
\r
850 drp_audioBitrate.Items.Add("56");
\r
851 drp_audioBitrate.Items.Add("64");
\r
852 drp_audioBitrate.Items.Add("80");
\r
853 drp_audioBitrate.Items.Add("86");
\r
854 drp_audioBitrate.Items.Add("112");
\r
855 drp_audioBitrate.Items.Add("128");
\r
856 drp_audioBitrate.Items.Add("160");
\r
857 drp_audioBitrate.Items.Add("192");
\r
858 drp_audioBitrate.Items.Add("224");
\r
859 drp_audioBitrate.Items.Add("256");
\r
860 drp_audioBitrate.Items.Add("320");
\r
861 drp_audioBitrate.Items.Add("384");
\r
865 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
867 if (drp_audioCodec.Text == "AAC")
\r
869 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
872 drp_audioBitrate.Items.Clear();
\r
873 drp_audioBitrate.Items.Add("32");
\r
874 drp_audioBitrate.Items.Add("40");
\r
875 drp_audioBitrate.Items.Add("48");
\r
876 drp_audioBitrate.Items.Add("56");
\r
877 drp_audioBitrate.Items.Add("64");
\r
878 drp_audioBitrate.Items.Add("80");
\r
879 drp_audioBitrate.Items.Add("86");
\r
880 drp_audioBitrate.Items.Add("112");
\r
881 drp_audioBitrate.Items.Add("128");
\r
882 drp_audioBitrate.Items.Add("160");
\r
883 drp_audioBitrate.Items.Add("192");
\r
884 drp_audioBitrate.Items.Add("224");
\r
885 drp_audioBitrate.Items.Add("256");
\r
886 drp_audioBitrate.Items.Add("320");
\r
887 drp_audioBitrate.Items.Add("384");
\r
892 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
894 if (Check_ChapterMarkers.CheckState.ToString() == "Checked")
\r
896 string destination = text_destination.Text;
\r
897 destination = destination.Replace(".mp4", ".m4v");
\r
898 text_destination.Text = destination;
\r
902 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
904 if (!text_destination.Text.Contains(".mp4"))
\r
906 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
907 check_largeFile.CheckState = CheckState.Unchecked;
\r
911 private void check_turbo_CheckedChanged(object sender, EventArgs e)
\r
913 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
915 MessageBox.Show("This option is only compatible with the H.264 encoder's", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
916 check_turbo.CheckState = CheckState.Unchecked;
\r
920 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
922 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
923 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
925 check_turbo.CheckState = CheckState.Unchecked;
\r
926 CheckCRF.CheckState = CheckState.Unchecked;
\r
930 private void CheckCRF_CheckedChanged(object sender, EventArgs e)
\r
932 if (slider_videoQuality.Value == 0)
\r
934 MessageBox.Show("This option is can only be used with the 'Video Quality' slider.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
935 CheckCRF.CheckState = CheckState.Unchecked;
\r
939 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
941 //TODO: Convert the Parsing Code.
\r
945 // The Query Generation Function
\r
949 // This function was imported from old vb.net version of this application.
\r
950 // It could probably do with being cleaned up a good deal at some point
\r
951 public string GenerateTheQuery()
\r
953 string source = text_source.Text;
\r
954 string dvdTitle = drp_dvdtitle.Text;
\r
955 string chapterStart = drop_chapterStart.Text;
\r
956 string chapterFinish = drop_chapterFinish.Text;
\r
957 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
958 string dvdChapter = "";
\r
962 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
964 source = " -i " + '"' + source+ '"'; //'"'+
\r
967 if (dvdTitle == "Automatic")
\r
971 string[] titleInfo = dvdTitle.Split(' ');
\r
972 dvdTitle = " -t "+ titleInfo[0];
\r
978 if ((chapterFinish.Equals("Auto") && chapterStart.Equals("Auto")))
\r
982 else if (chapterFinish == chapterStart)
\r
984 dvdChapter = " -c " + chapterStart;
\r
989 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
992 string querySource = source+ dvdTitle+ dvdChapter;
\r
993 // ----------------------------------------------------------------------
\r
997 string destination = text_destination.Text;
\r
998 string videoEncoder = drp_videoEncoder.Text;
\r
999 string audioEncoder = drp_audioCodec.Text;
\r
1000 string width = text_width.Text;
\r
1001 string height = text_height.Text;
\r
1002 if ((destination == ""))
\r
1004 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1009 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1012 if ((videoEncoder == "Mpeg 4"))
\r
1014 videoEncoder = " -e ffmpeg";
\r
1017 else if ((videoEncoder == "Xvid"))
\r
1019 videoEncoder = " -e xvid";
\r
1022 else if ((videoEncoder == "H.264"))
\r
1024 videoEncoder = " -e x264";
\r
1027 else if ((videoEncoder == "H.264 Baseline 1.3"))
\r
1029 videoEncoder = " -e x264b13";
\r
1032 else if ((videoEncoder == "H.264 (iPod)"))
\r
1034 videoEncoder = " -e x264b30";
\r
1037 if ((audioEncoder == "AAC"))
\r
1039 audioEncoder = " -E faac";
\r
1042 else if ((audioEncoder == "MP3"))
\r
1044 audioEncoder = " -E lame";
\r
1047 else if ((audioEncoder == "Vorbis"))
\r
1049 audioEncoder = " -E vorbis";
\r
1052 else if ((audioEncoder == "AC3"))
\r
1054 audioEncoder = " -E ac3";
\r
1057 if ((width != ""))
\r
1059 width = " -w "+ width;
\r
1062 if ((height != ""))
\r
1064 height = " -l "+ height;
\r
1067 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1068 // ----------------------------------------------------------------------
\r
1070 // Picture Settings Tab
\r
1072 string cropSetting = drp_crop.Text;
\r
1073 string cropTop = text_top.Text;
\r
1074 string cropBottom = text_bottom.Text;
\r
1075 string cropLeft = text_left.Text;
\r
1076 string cropRight = text_right.Text;
\r
1077 string subtitles = drp_subtitle.Text;
\r
1078 string cropOut = "";
\r
1079 // Returns Crop Query
\r
1081 if (cropSetting == "Auto Crop")
\r
1086 else if (cropSetting == "No Crop")
\r
1088 cropOut = " --crop 0:0:0:0 ";
\r
1093 cropOut = " --crop "+ cropTop+ ":"+ cropBottom+ ":"+ cropLeft+ ":"+ cropRight;
\r
1096 if ((subtitles == "None"))
\r
1101 else if ((subtitles == ""))
\r
1109 tempSub = subtitles.Split(' ');
\r
1110 subtitles = " -s "+ tempSub[0];
\r
1113 string queryPictureSettings = cropOut+ subtitles;
\r
1114 // ----------------------------------------------------------------------
\r
1116 // Video Settings Tab
\r
1118 string videoBitrate = text_bitrate.Text;
\r
1119 string videoFilesize = text_filesize.Text;
\r
1120 int videoQuality = slider_videoQuality.Value;
\r
1121 string vidQSetting;
\r
1122 string twoPassEncoding = check_2PassEncode.CheckState.ToString();
\r
1123 string deinterlace = check_DeInterlace.CheckState.ToString();
\r
1124 string grayscale = check_grayscale.CheckState.ToString();
\r
1125 string videoFramerate = drp_videoFramerate.Text;
\r
1126 string pixelRatio = CheckPixelRatio.CheckState.ToString();
\r
1127 string ChapterMarkers = Check_ChapterMarkers.CheckState.ToString();
\r
1128 string turboH264 = check_turbo.CheckState.ToString();
\r
1129 string largeFile = check_largeFile.CheckState.ToString();
\r
1131 if ((videoBitrate != ""))
\r
1133 videoBitrate = " -b "+ videoBitrate;
\r
1136 if ((videoFilesize != ""))
\r
1138 videoFilesize = " -S "+ videoFilesize;
\r
1141 // Video Quality Setting
\r
1143 if ((videoQuality == 0))
\r
1150 videoQuality = videoQuality/ 100;
\r
1151 if (videoQuality == 1)
\r
1153 vidQSetting = "1.0";
\r
1156 vidQSetting = " -q " + videoQuality.ToString();
\r
1159 if ((twoPassEncoding == "1"))
\r
1161 twoPassEncoding = " -2 ";
\r
1166 twoPassEncoding = "";
\r
1169 if ((deinterlace == "1"))
\r
1171 deinterlace = " -d ";
\r
1179 if ((grayscale == "1"))
\r
1181 grayscale = " -g ";
\r
1189 if ((videoFramerate == "Automatic"))
\r
1191 videoFramerate = "";
\r
1196 videoFramerate = " -r "+ videoFramerate;
\r
1199 if ((pixelRatio == "1"))
\r
1201 pixelRatio = " -p ";
\r
1209 if ((ChapterMarkers == "1"))
\r
1211 ChapterMarkers = " -m ";
\r
1216 ChapterMarkers = "";
\r
1219 if ((turboH264 == "1"))
\r
1221 turboH264 = " -T ";
\r
1229 if ((largeFile == "1"))
\r
1231 largeFile = " -4 ";
\r
1239 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + deinterlace + grayscale + videoFramerate + pixelRatio + ChapterMarkers + turboH264 + largeFile;
\r
1240 // ----------------------------------------------------------------------
\r
1242 // Audio Settings Tab
\r
1244 string audioBitrate = drp_audioBitrate.Text;
\r
1245 string audioSampleRate = drp_audioSampleRate.Text;
\r
1246 string audioChannels = drp_audioChannels.Text;
\r
1247 string Mixdown = drp_audioMixDown.Text;
\r
1248 string SixChannelAudio = "";
\r
1249 if ((audioBitrate != ""))
\r
1251 audioBitrate = " -B "+ audioBitrate;
\r
1254 if ((audioSampleRate != ""))
\r
1256 audioSampleRate = " -R "+ audioSampleRate;
\r
1259 if ((audioChannels == "Automatic"))
\r
1261 audioChannels = "";
\r
1264 else if ((audioChannels == ""))
\r
1266 audioChannels = "";
\r
1272 tempSub = audioChannels.Split(' ');
\r
1273 audioChannels = " -a "+ tempSub[0];
\r
1276 if ((Mixdown == "Automatic"))
\r
1281 else if (Mixdown == "Mono")
\r
1286 else if (Mixdown == "Stereo")
\r
1288 Mixdown = "stereo";
\r
1291 else if (Mixdown == "Dolby Surround")
\r
1296 else if (Mixdown == "Dolby Pro Logic II")
\r
1301 else if (Mixdown == "6 Channel Discrete")
\r
1308 Mixdown = "stero";
\r
1311 if ((Mixdown != ""))
\r
1313 SixChannelAudio = " -6 "+ Mixdown;
\r
1318 SixChannelAudio = "";
\r
1321 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1322 // ----------------------------------------------------------------------
\r
1326 string CRF = CheckCRF.CheckState.ToString();
\r
1327 string h264Advanced = rtf_h264advanced.Text;
\r
1338 if ((h264Advanced == ""))
\r
1340 h264Advanced = "";
\r
1345 h264Advanced = " -x "+ h264Advanced;
\r
1348 string h264Settings = CRF+ h264Advanced;
\r
1349 // ----------------------------------------------------------------------
\r
1351 // Processors (Program Settings)
\r
1353 string processors = Properties.Settings.Default.Processors;
\r
1354 // Number of Processors Handler
\r
1356 if ((processors == "Automatic"))
\r
1363 processors = " -C "+ processors+ " ";
\r
1366 string queryAdvancedSettings = processors;
\r
1367 // ----------------------------------------------------------------------
\r
1369 // Verbose option (Program Settings)
\r
1371 string verbose = "";
\r
1372 if ( Properties.Settings.Default.verbose == "1")
\r
1377 // ----------------------------------------------------------------------
\r
1379 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1382 // This is the END of the road ------------------------------------------------------------------------------
\r