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
16 public partial class frmMain : Form
\r
18 private Process hbProc;
\r
19 private Parsing.DVD thisDVD;
\r
21 // --------------------------------------------------------------
\r
22 // Some windows that require only 1 instance.
\r
23 // --------------------------------------------------------------
\r
24 private frmQueue queueWindow = new frmQueue();
\r
26 // --------------------------------------------------------------
\r
27 // Stuff that needs doing on startup.
\r
28 // - Load users default settings. (if required)
\r
29 // - Do an update check (if required)
\r
30 // --------------------------------------------------------------
\r
31 private frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
40 ThreadPool.QueueUserWorkItem(showSplash);
\r
43 InitializeComponent();
\r
45 // This is a quick Hack fix for the cross-thread problem with frmDvdIndo ************************
\r
46 dvdInfoWindow.Show();
\r
47 dvdInfoWindow.Hide();
\r
48 // **********************************************************************************************
\r
51 // Set the Version number lable to the corect version.
\r
52 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
54 // Run the update checker.
\r
57 // Now load the users default if required.
\r
60 // Display the quick start window if required.
\r
63 //MessageBox.Show(System.Environment.OSVersion.Version.ToString());
\r
67 public void showSplash(object sender)
\r
69 Form splash = new frmSplashScreen();
\r
75 public void loadUserDefaults()
\r
79 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
82 text_source.Text = Properties.Settings.Default.DVDSource;
\r
83 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
84 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
85 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
88 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
89 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
90 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
91 text_width.Text = Properties.Settings.Default.Width;
\r
92 text_height.Text = Properties.Settings.Default.Height;
\r
94 // Picture Settings Tab
\r
95 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
96 text_top.Text = Properties.Settings.Default.CropTop;
\r
97 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
98 text_left.Text = Properties.Settings.Default.CropLeft;
\r
99 text_right.Text = Properties.Settings.Default.CropRight;
\r
100 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
102 // Video Settings Tab
\r
103 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
104 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
105 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
107 if (Properties.Settings.Default.TwoPass == "Checked")
\r
109 check_2PassEncode.CheckState = CheckState.Checked;
\r
112 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
113 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
115 if (Properties.Settings.Default.detelecine == "Checked")
\r
117 check_detelecine.CheckState = CheckState.Checked;
\r
120 if (Properties.Settings.Default.detelecine == "Checked")
\r
122 check_deblock.CheckState = CheckState.Checked;
\r
126 if (Properties.Settings.Default.Grayscale == "Checked")
\r
128 check_grayscale.CheckState = CheckState.Checked;
\r
131 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
133 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
135 CheckPixelRatio.CheckState = CheckState.Checked;
\r
137 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
139 check_turbo.CheckState = CheckState.Checked;
\r
141 if (Properties.Settings.Default.largeFile == "Checked")
\r
143 check_largeFile.CheckState = CheckState.Checked;
\r
145 // Audio Settings Tab
\r
146 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
147 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
148 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
151 if (Properties.Settings.Default.CRF == "Checked")
\r
153 CheckCRF.CheckState = CheckState.Checked;
\r
155 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
160 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
164 public void updateCheck()
\r
166 if (Properties.Settings.Default.updateStatus == "Checked")
\r
170 String updateFile = Properties.Settings.Default.updateFile;
\r
171 WebClient client = new WebClient();
\r
172 String data = client.DownloadString(updateFile);
\r
173 String[] versionData = data.Split('\n');
\r
175 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
177 lbl_update.Visible = true;
\r
182 // Silently ignore the error
\r
187 public void quickStart()
\r
189 if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))
\r
191 frmQuickStart quickstart = new frmQuickStart();
\r
192 quickstart.ShowDialog();
\r
197 // --------------------------------------------------------------
\r
198 // The main Menu bar.
\r
199 // --------------------------------------------------------------
\r
203 private void mnu_open_Click(object sender, EventArgs e)
\r
206 File_Open.ShowDialog();
\r
207 filename = File_Open.FileName;
\r
208 if (filename != "")
\r
212 // Create StreamReader & open file
\r
213 StreamReader line = new StreamReader(filename);
\r
214 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
216 // Read in the data and set the correct GUI component with the setting.
\r
217 text_source.Text = line.ReadLine();
\r
218 drp_dvdtitle.Text = line.ReadLine();
\r
219 drop_chapterStart.Text = line.ReadLine();
\r
220 drop_chapterFinish.Text = line.ReadLine();
\r
221 text_destination.Text = line.ReadLine();
\r
222 drp_videoEncoder.Text = line.ReadLine();
\r
223 drp_audioCodec.Text = line.ReadLine();
\r
224 text_width.Text = line.ReadLine();
\r
225 text_height.Text = line.ReadLine();
\r
226 text_top.Text = line.ReadLine();
\r
227 text_bottom.Text = line.ReadLine();
\r
228 text_left.Text = line.ReadLine();
\r
229 text_right.Text = line.ReadLine();
\r
230 drp_subtitle.Text = line.ReadLine();
\r
231 text_bitrate.Text = line.ReadLine();
\r
232 text_filesize.Text = line.ReadLine();
\r
233 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
235 temporyLine = line.ReadLine();
\r
236 if (temporyLine == "Checked")
\r
238 check_2PassEncode.CheckState = CheckState.Checked;
\r
241 drp_deInterlace_option.Text = line.ReadLine();
\r
243 temporyLine = line.ReadLine();
\r
244 if (temporyLine == "Checked")
\r
246 check_grayscale.CheckState = CheckState.Checked;
\r
249 drp_videoFramerate.Text = line.ReadLine();
\r
251 temporyLine = line.ReadLine();
\r
252 if (temporyLine == "Checked")
\r
254 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
257 temporyLine = line.ReadLine();
\r
258 if (temporyLine == "Checked")
\r
260 CheckPixelRatio.CheckState = CheckState.Checked;
\r
263 temporyLine = line.ReadLine();
\r
264 if (temporyLine == "Checked")
\r
266 check_turbo.CheckState = CheckState.Checked;
\r
269 temporyLine = line.ReadLine();
\r
270 if (temporyLine == "Checked")
\r
272 check_largeFile.CheckState = CheckState.Checked;
\r
275 drp_audioBitrate.Text = line.ReadLine();
\r
276 drp_audioSampleRate.Text = line.ReadLine();
\r
277 drp_audioChannels.Text = line.ReadLine();
\r
278 drp_audioMixDown.Text = line.ReadLine();
\r
280 // Advanced H264 Options
\r
281 temporyLine = line.ReadLine();
\r
282 if (temporyLine == "Checked")
\r
284 CheckCRF.CheckState = CheckState.Checked;
\r
286 rtf_h264advanced.Text = line.ReadLine();
\r
288 // Close the stream
\r
292 // Fix for SliderValue not appearing when Opening saved file
\r
293 SliderValue.Text = slider_videoQuality.Value + "%";
\r
295 } catch (Exception){
\r
296 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
301 private void mnu_save_Click(object sender, EventArgs e)
\r
305 File_Save.ShowDialog();
\r
306 filename = File_Save.FileName;
\r
307 if (filename != "")
\r
311 // Create a StreamWriter and open the file
\r
312 StreamWriter line = new StreamWriter(filename);
\r
315 line.WriteLine(text_source.Text);
\r
316 line.WriteLine(drp_dvdtitle.Text);
\r
317 line.WriteLine(drop_chapterStart.Text);
\r
318 line.WriteLine(drop_chapterFinish.Text);
\r
320 line.WriteLine(text_destination.Text);
\r
321 line.WriteLine(drp_videoEncoder.Text);
\r
322 line.WriteLine(drp_audioCodec.Text);
\r
323 line.WriteLine(text_width.Text);
\r
324 line.WriteLine(text_height.Text);
\r
325 //Picture Settings Tab
\r
326 line.WriteLine(text_top.Text);
\r
327 line.WriteLine(text_bottom.Text);
\r
328 line.WriteLine(text_left.Text);
\r
329 line.WriteLine(text_right.Text);
\r
330 line.WriteLine(drp_subtitle.Text);
\r
331 //Video Settings Tab
\r
332 line.WriteLine(text_bitrate.Text);
\r
333 line.WriteLine(text_filesize.Text);
\r
334 line.WriteLine(slider_videoQuality.Value.ToString());
\r
335 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
336 line.WriteLine(drp_deInterlace_option.Text);
\r
337 line.WriteLine(check_grayscale.CheckState.ToString());
\r
338 line.WriteLine(drp_videoFramerate.Text);
\r
339 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
340 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
341 line.WriteLine(check_turbo.CheckState.ToString());
\r
342 line.WriteLine(check_largeFile.CheckState.ToString());
\r
343 //Audio Settings Tab
\r
344 line.WriteLine(drp_audioBitrate.Text);
\r
345 line.WriteLine(drp_audioSampleRate.Text);
\r
346 line.WriteLine(drp_audioChannels.Text);
\r
347 line.WriteLine(drp_audioMixDown.Text);
\r
349 line.WriteLine(CheckCRF.CheckState.ToString());
\r
350 line.WriteLine(rtf_h264advanced.Text);
\r
351 // close the stream
\r
353 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
357 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
363 private void mnu_update_Click(object sender, EventArgs e)
\r
365 Form Update = new frmUpdate();
\r
366 Update.ShowDialog();
\r
369 private void mnu_exit_Click(object sender, EventArgs e)
\r
378 private void mnu_encode_Click(object sender, EventArgs e)
\r
384 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
388 dvdInfoWindow.Show();
\r
393 // No action required
\r
396 // BUG *******************************************************
\r
397 // Cross-thread operation not valid: Control 'rtf_dvdInfo' accessed from a thread other than the thread it was created on.
\r
398 // This happens when the DVD is scanned and this item is then selected.
\r
399 // If this item is selected so a blank copy of the window appears, then a DVD is scanned, there is no cross-thread issue.
\r
400 // NOTE: Try/catch added to prevent final build crashing.
\r
401 // NOTE2: Included a quick fix in frmMain(). Simply show and hide the window when starting the app.
\r
402 // Note3: Suspect the problem lies with line 30.
\r
403 // ***********************************************************
\r
407 private void mnu_options_Click(object sender, EventArgs e)
\r
409 Form Options = new frmOptions();
\r
410 Options.ShowDialog();
\r
415 #region Presets Menu
\r
416 // Need to write a handler for file extension
\r
418 private void mnu_animation_Click(object sender, EventArgs e)
\r
420 CheckPixelRatio.CheckState = CheckState.Checked;
\r
421 text_width.Text = "";
\r
422 text_height.Text = "";
\r
423 drp_videoEncoder.Text = "H.264";
\r
424 text_bitrate.Text = "1000";
\r
425 text_filesize.Text = "";
\r
426 slider_videoQuality.Value = 0;
\r
427 SliderValue.Text = "0%";
\r
428 drp_audioBitrate.Text = "160";
\r
429 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
430 drp_audioSampleRate.Text = "48";
\r
431 rtf_h264advanced.Text = "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";
\r
432 drp_deInterlace_option.Text = "Origional (Fast)";
\r
433 check_2PassEncode.CheckState = CheckState.Checked;
\r
434 drp_crop.Text = "No Crop";
\r
435 check_turbo.CheckState = CheckState.Checked;
\r
436 drp_audioCodec.Text = "AAC";
\r
438 // Set file extension to MKV
\r
439 string destination = text_destination.Text;
\r
440 destination = destination.Replace(".mp4", ".mkv");
\r
441 destination = destination.Replace(".avi", ".mkv");
\r
442 destination = destination.Replace(".m4v", ".mkv");
\r
443 destination = destination.Replace(".ogm", ".mkv");
\r
444 text_destination.Text = destination;
\r
447 private void mnu_appleTv_Click(object sender, EventArgs e)
\r
449 CheckPixelRatio.CheckState = CheckState.Checked;
\r
450 text_width.Text = "";
\r
451 text_height.Text = "";
\r
452 drp_videoEncoder.Text = "H.264";
\r
453 text_bitrate.Text = "2500";
\r
454 text_filesize.Text = "";
\r
455 slider_videoQuality.Value = 0;
\r
456 SliderValue.Text = "0%";
\r
457 drp_audioBitrate.Text = "160";
\r
458 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
459 drp_audioSampleRate.Text = "48";
\r
460 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2";
\r
461 drp_deInterlace_option.Text = "None";
\r
462 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
463 drp_crop.Text = "No Crop";
\r
464 check_turbo.CheckState = CheckState.Unchecked;
\r
465 drp_audioCodec.Text = "AAC";
\r
468 private void mnu_bedlam_Click(object sender, EventArgs e)
\r
470 CheckPixelRatio.CheckState = CheckState.Checked;
\r
471 text_width.Text = "";
\r
472 text_height.Text = "";
\r
473 drp_videoEncoder.Text = "H.264";
\r
474 text_bitrate.Text = "1800";
\r
475 text_filesize.Text = "";
\r
476 slider_videoQuality.Value = 0;
\r
477 SliderValue.Text = "0%";
\r
478 drp_audioBitrate.Text = "160";
\r
479 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
480 drp_audioSampleRate.Text = "48";
\r
481 rtf_h264advanced.Text = "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";
\r
482 drp_deInterlace_option.Text = "None";
\r
483 check_2PassEncode.CheckState = CheckState.Checked;
\r
484 drp_crop.Text = "No Crop";
\r
485 check_turbo.CheckState = CheckState.Checked;
\r
486 drp_audioCodec.Text = "AC3";
\r
488 // Set file extension to MKV
\r
489 string destination = text_destination.Text;
\r
490 destination = destination.Replace(".mp4", ".mkv");
\r
491 destination = destination.Replace(".avi", ".mkv");
\r
492 destination = destination.Replace(".m4v", ".mkv");
\r
493 destination = destination.Replace(".ogm", ".mkv");
\r
494 text_destination.Text = destination;
\r
497 private void mnu_blind_Click(object sender, EventArgs e)
\r
499 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
500 text_width.Text = "512";
\r
501 text_height.Text = "";
\r
502 drp_videoEncoder.Text = "H.264";
\r
503 text_bitrate.Text = "512";
\r
504 text_filesize.Text = "";
\r
505 slider_videoQuality.Value = 0;
\r
506 SliderValue.Text = "0%";
\r
507 drp_audioBitrate.Text = "128";
\r
508 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
509 drp_audioSampleRate.Text = "48";
\r
510 rtf_h264advanced.Text = "";
\r
511 drp_deInterlace_option.Text = "None";
\r
512 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
513 drp_crop.Text = "No Crop";
\r
514 check_turbo.CheckState = CheckState.Unchecked;
\r
515 drp_audioCodec.Text = "AAC";
\r
518 private void mnu_broke_Click(object sender, EventArgs e)
\r
520 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
521 text_width.Text = "640";
\r
522 text_height.Text = "";
\r
523 drp_videoEncoder.Text = "H.264";
\r
524 text_bitrate.Text = "";
\r
525 text_filesize.Text = "695";
\r
526 slider_videoQuality.Value = 0;
\r
527 SliderValue.Text = "0%";
\r
528 drp_audioBitrate.Text = "128";
\r
529 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
530 drp_audioSampleRate.Text = "48";
\r
531 rtf_h264advanced.Text = "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";
\r
532 drp_deInterlace_option.Text = "None";
\r
533 check_2PassEncode.CheckState = CheckState.Checked;
\r
534 drp_crop.Text = "No Crop";
\r
535 check_turbo.CheckState = CheckState.Checked;
\r
536 drp_audioCodec.Text = "AAC";
\r
539 private void mnu_Classic_Click(object sender, EventArgs e)
\r
541 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
542 text_width.Text = "";
\r
543 text_height.Text = "";
\r
544 drp_videoEncoder.Text = "H.264";
\r
545 text_bitrate.Text = "1000";
\r
546 text_filesize.Text = "";
\r
547 slider_videoQuality.Value = 0;
\r
548 SliderValue.Text = "0%";
\r
549 drp_audioBitrate.Text = "160";
\r
550 Check_ChapterMarkers.CheckState = CheckState.Unchecked;
\r
551 drp_audioSampleRate.Text = "48";
\r
552 rtf_h264advanced.Text = "";
\r
553 drp_deInterlace_option.Text = "None";
\r
554 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
555 drp_crop.Text = "No Crop";
\r
556 check_turbo.CheckState = CheckState.Unchecked;
\r
557 drp_audioCodec.Text = "AAC";
\r
560 private void mnu_CQR_Click(object sender, EventArgs e)
\r
562 CheckPixelRatio.CheckState = CheckState.Checked;
\r
563 text_width.Text = "";
\r
564 text_height.Text = "";
\r
565 drp_videoEncoder.Text = "H.264";
\r
566 text_bitrate.Text = "";
\r
567 text_filesize.Text = "";
\r
568 slider_videoQuality.Value = 64;
\r
569 SliderValue.Text = "64%";
\r
570 drp_audioBitrate.Text = "160";
\r
571 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
572 drp_audioSampleRate.Text = "48";
\r
573 rtf_h264advanced.Text = "ref=3:mixed-refs:bframes=3:b-pyramid:b-rdo:bime:weightb:filter=-2,-1:subme=6:trellis=1:analyse=all:8x8dct:me=umh";
\r
574 drp_deInterlace_option.Text = "None";
\r
575 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
576 drp_crop.Text = "No Crop";
\r
577 check_turbo.CheckState = CheckState.Unchecked;
\r
578 drp_audioCodec.Text = "AC3";
\r
580 // Set file extension to MKV
\r
581 string destination = text_destination.Text;
\r
582 destination = destination.Replace(".mp4", ".mkv");
\r
583 destination = destination.Replace(".avi", ".mkv");
\r
584 destination = destination.Replace(".m4v", ".mkv");
\r
585 destination = destination.Replace(".ogm", ".mkv");
\r
586 text_destination.Text = destination;
\r
589 private void mnu_DSQ_Click(object sender, EventArgs e)
\r
591 CheckPixelRatio.CheckState = CheckState.Checked;
\r
592 text_width.Text = "";
\r
593 text_height.Text = "";
\r
594 drp_videoEncoder.Text = "H.264";
\r
595 text_bitrate.Text = "1600";
\r
596 text_filesize.Text = "";
\r
597 slider_videoQuality.Value = 0;
\r
598 SliderValue.Text = "0%";
\r
599 drp_audioBitrate.Text = "160";
\r
600 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
601 drp_audioSampleRate.Text = "48";
\r
602 rtf_h264advanced.Text = "ref=5:mixed-refs:bframes=3:bime:weightb:b-rdo:b-pyramid:me=umh:subme=7:trellis=1:analyse=all:8x8dct:no-fast-pskip";
\r
603 drp_deInterlace_option.Text = "None";
\r
604 check_2PassEncode.CheckState = CheckState.Checked;
\r
605 drp_crop.Text = "No Crop";
\r
606 check_turbo.CheckState = CheckState.Checked;
\r
607 drp_audioCodec.Text = "AC3";
\r
609 // Set file extension to MKV
\r
610 string destination = text_destination.Text;
\r
611 destination = destination.Replace(".mp4", ".mkv");
\r
612 destination = destination.Replace(".avi", ".mkv");
\r
613 destination = destination.Replace(".m4v", ".mkv");
\r
614 destination = destination.Replace(".ogm", ".mkv");
\r
615 text_destination.Text = destination;
\r
618 private void mnu_film_Click(object sender, EventArgs e)
\r
620 CheckPixelRatio.CheckState = CheckState.Checked;
\r
621 text_width.Text = "";
\r
622 text_height.Text = "";
\r
623 drp_videoEncoder.Text = "H.264";
\r
624 text_bitrate.Text = "2000";
\r
625 text_filesize.Text = "";
\r
626 slider_videoQuality.Value = 0;
\r
627 SliderValue.Text = "0%";
\r
628 drp_audioBitrate.Text = "160";
\r
629 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
630 drp_audioSampleRate.Text = "48";
\r
631 rtf_h264advanced.Text = "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";
\r
632 drp_deInterlace_option.Text = "None";
\r
633 check_2PassEncode.CheckState = CheckState.Checked;
\r
634 drp_crop.Text = "No Crop";
\r
635 check_turbo.CheckState = CheckState.Checked;
\r
636 drp_audioCodec.Text = "AC3";
\r
638 // Set file extension to MKV
\r
639 string destination = text_destination.Text;
\r
640 destination = destination.Replace(".mp4", ".mkv");
\r
641 destination = destination.Replace(".avi", ".mkv");
\r
642 destination = destination.Replace(".m4v", ".mkv");
\r
643 destination = destination.Replace(".ogm", ".mkv");
\r
644 text_destination.Text = destination;
\r
647 private void mnu_iphone_Click(object sender, EventArgs e)
\r
649 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
650 text_width.Text = "480";
\r
651 text_height.Text = "";
\r
652 drp_videoEncoder.Text = "H.264 (iPod)";
\r
653 text_bitrate.Text = "960";
\r
654 text_filesize.Text = "";
\r
655 slider_videoQuality.Value = 0;
\r
656 SliderValue.Text = "0%";
\r
657 drp_audioBitrate.Text = "128";
\r
658 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
659 drp_audioSampleRate.Text = "48";
\r
660 rtf_h264advanced.Text = "cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1";
\r
661 drp_deInterlace_option.Text = "None";
\r
662 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
663 drp_crop.Text = "No Crop";
\r
664 check_turbo.CheckState = CheckState.Unchecked;
\r
665 drp_audioCodec.Text = "AAC";
\r
668 private void mnu_ipod_Click(object sender, EventArgs e)
\r
670 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
671 text_width.Text = "640";
\r
672 text_height.Text = "";
\r
673 drp_videoEncoder.Text = "H.264 (iPod)";
\r
674 text_bitrate.Text = "1500";
\r
675 text_filesize.Text = "";
\r
676 slider_videoQuality.Value = 0;
\r
677 SliderValue.Text = "0%";
\r
678 drp_audioBitrate.Text = "160";
\r
679 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
680 drp_audioSampleRate.Text = "48";
\r
681 rtf_h264advanced.Text = "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";
\r
682 drp_deInterlace_option.Text = "None";
\r
683 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
684 drp_crop.Text = "No Crop";
\r
685 check_turbo.CheckState = CheckState.Unchecked;
\r
686 drp_audioCodec.Text = "AAC";
\r
689 private void mnu_ipodLow_Click(object sender, EventArgs e)
\r
691 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
692 text_width.Text = "320";
\r
693 text_height.Text = "";
\r
694 drp_videoEncoder.Text = "H.264 (iPod)";
\r
695 text_bitrate.Text = "700";
\r
696 text_filesize.Text = "";
\r
697 slider_videoQuality.Value = 0;
\r
698 SliderValue.Text = "0%";
\r
699 drp_audioBitrate.Text = "160";
\r
700 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
701 drp_audioSampleRate.Text = "48";
\r
702 rtf_h264advanced.Text = "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";
\r
703 drp_deInterlace_option.Text = "None";
\r
704 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
705 drp_crop.Text = "No Crop";
\r
706 check_turbo.CheckState = CheckState.Unchecked;
\r
707 drp_audioCodec.Text = "AAC";
\r
710 private void mnu_normal_Click(object sender, EventArgs e)
\r
712 CheckPixelRatio.CheckState = CheckState.Checked;
\r
713 text_width.Text = "";
\r
714 text_height.Text = "";
\r
715 drp_videoEncoder.Text = "H.264";
\r
716 text_bitrate.Text = "1500";
\r
717 text_filesize.Text = "";
\r
718 slider_videoQuality.Value = 0;
\r
719 SliderValue.Text = "0%";
\r
720 drp_audioBitrate.Text = "160";
\r
721 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
722 drp_audioSampleRate.Text = "48";
\r
723 rtf_h264advanced.Text = "ref=2:bframes=2:subme=5:me=umh";
\r
724 drp_deInterlace_option.Text = "None";
\r
725 check_2PassEncode.CheckState = CheckState.Checked;
\r
726 drp_crop.Text = "No Crop";
\r
727 check_turbo.CheckState = CheckState.Checked;
\r
728 drp_audioCodec.Text = "AAC";
\r
731 private void mnu_PS3_Click(object sender, EventArgs e)
\r
733 CheckPixelRatio.CheckState = CheckState.Checked;
\r
734 text_width.Text = "";
\r
735 text_height.Text = "";
\r
736 drp_videoEncoder.Text = "H.264";
\r
737 text_bitrate.Text = "2500";
\r
738 text_filesize.Text = "";
\r
739 slider_videoQuality.Value = 0;
\r
740 SliderValue.Text = "0%";
\r
741 drp_audioBitrate.Text = "160";
\r
742 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
743 drp_audioSampleRate.Text = "48";
\r
744 rtf_h264advanced.Text = "level=41:subme=5:me=umh";
\r
745 drp_deInterlace_option.Text = "None";
\r
746 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
747 drp_crop.Text = "No Crop";
\r
748 check_turbo.CheckState = CheckState.Unchecked;
\r
749 drp_audioCodec.Text = "AAC";
\r
752 private void mnu_psp_Click(object sender, EventArgs e)
\r
754 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
755 text_width.Text = "368";
\r
756 text_height.Text = "208";
\r
757 drp_videoEncoder.Text = "H.264";
\r
758 text_bitrate.Text = "1024";
\r
759 text_filesize.Text = "";
\r
760 slider_videoQuality.Value = 0;
\r
761 SliderValue.Text = "0%";
\r
762 drp_audioBitrate.Text = "160";
\r
763 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
764 drp_audioSampleRate.Text = "48";
\r
765 rtf_h264advanced.Text = "";
\r
766 drp_deInterlace_option.Text = "None";
\r
767 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
768 drp_crop.Text = "No Crop";
\r
769 check_turbo.CheckState = CheckState.Unchecked;
\r
770 drp_audioCodec.Text = "AAC";
\r
773 private void mnu_qt_Click(object sender, EventArgs e)
\r
775 CheckPixelRatio.CheckState = CheckState.Checked;
\r
776 text_width.Text = "";
\r
777 text_height.Text = "";
\r
778 drp_videoEncoder.Text = "H.264";
\r
779 text_bitrate.Text = "2000";
\r
780 text_filesize.Text = "";
\r
781 slider_videoQuality.Value = 0;
\r
782 SliderValue.Text = "0%";
\r
783 drp_audioBitrate.Text = "160";
\r
784 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
785 drp_audioSampleRate.Text = "48";
\r
786 rtf_h264advanced.Text = "ref=3:mixed-refs:bframes=3:bime:weightb:b-rdo:direct-auto:me=umh:subme=5:analyse=all:8x8dct:trellis=1:no-fast-pskip";
\r
787 drp_deInterlace_option.Text = "None";
\r
788 check_2PassEncode.CheckState = CheckState.Checked;
\r
789 drp_crop.Text = "No Crop";
\r
790 check_turbo.CheckState = CheckState.Checked;
\r
791 drp_audioCodec.Text = "AAC";
\r
794 private void mnu_television_Click(object sender, EventArgs e)
\r
796 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
797 text_width.Text = "";
\r
798 text_height.Text = "";
\r
799 drp_videoEncoder.Text = "H.264";
\r
800 text_bitrate.Text = "1300";
\r
801 text_filesize.Text = "";
\r
802 slider_videoQuality.Value = 0;
\r
803 SliderValue.Text = "0%";
\r
804 drp_audioBitrate.Text = "160";
\r
805 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
806 drp_audioSampleRate.Text = "48";
\r
807 rtf_h264advanced.Text = "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";
\r
808 drp_deInterlace_option.Text = "Origional (Fast)";
\r
809 check_2PassEncode.CheckState = CheckState.Checked;
\r
810 drp_crop.Text = "No Crop";
\r
811 check_turbo.CheckState = CheckState.Checked;
\r
812 drp_audioCodec.Text = "AAC";
\r
814 // Set file extension to MKV
\r
815 string destination = text_destination.Text;
\r
816 destination = destination.Replace(".mp4", ".mkv");
\r
817 destination = destination.Replace(".avi", ".mkv");
\r
818 destination = destination.Replace(".m4v", ".mkv");
\r
819 destination = destination.Replace(".ogm", ".mkv");
\r
820 text_destination.Text = destination;
\r
826 private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)
\r
829 Properties.Settings.Default.DVDSource = text_source.Text;
\r
830 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
831 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
832 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
834 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
835 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
836 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
837 Properties.Settings.Default.Width = text_width.Text;
\r
838 Properties.Settings.Default.Height = text_height.Text;
\r
839 //Picture Settings Tab
\r
840 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
841 Properties.Settings.Default.CropTop = text_top.Text;
\r
842 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
843 Properties.Settings.Default.CropLeft = text_left.Text;
\r
844 Properties.Settings.Default.CropRight = text_right.Text;
\r
845 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
846 //Video Settings Tab
\r
847 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
848 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
849 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
850 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
851 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
852 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
853 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
854 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
855 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
856 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
857 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
858 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
859 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
860 //Audio Settings Tab
\r
861 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
862 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
863 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
865 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
866 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
867 Properties.Settings.Default.Save();
\r
874 private void mnu_wiki_Click(object sender, EventArgs e)
\r
876 Process.Start("http://handbrake.m0k.org/trac");
\r
879 private void mnu_faq_Click(object sender, EventArgs e)
\r
881 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
884 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
886 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
889 private void mnu_homepage_Click(object sender, EventArgs e)
\r
891 Process.Start("http://handbrake.m0k.org");
\r
894 private void mnu_forum_Click(object sender, EventArgs e)
\r
896 Process.Start("http://handbrake.m0k.org/forum");
\r
899 private void mnu_about_Click(object sender, EventArgs e)
\r
901 Form About = new frmAbout();
\r
902 About.ShowDialog();
\r
907 // --------------------------------------------------------------
\r
908 // Buttons on the main Window
\r
909 // --------------------------------------------------------------
\r
912 private void btn_Browse_Click(object sender, EventArgs e)
\r
914 String filename ="";
\r
915 text_source.Text = "";
\r
917 if (RadioDVD.Checked)
\r
919 DVD_Open.ShowDialog();
\r
920 filename = DVD_Open.SelectedPath;
\r
921 if (filename != "")
\r
923 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
924 text_source.Text = filename;
\r
925 frmRD.ShowDialog();
\r
930 ISO_Open.ShowDialog();
\r
931 filename = ISO_Open.FileName;
\r
932 if (filename != "")
\r
934 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
935 text_source.Text = filename;
\r
936 frmRD.ShowDialog();
\r
940 // Check if there was titles in the dvd title dropdown
\r
941 if (filename == "")
\r
943 text_source.Text = "Click 'Browse' to continue";
\r
946 if (drp_dvdtitle.Items.Count == 0)
\r
948 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
952 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
954 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
956 DVD_Save.ShowDialog();
\r
957 text_destination.Text = DVD_Save.FileName;
\r
959 if (Check_ChapterMarkers.Checked)
\r
961 string destination = text_destination.Text;
\r
962 destination = destination.Replace(".mp4", ".m4v");
\r
963 text_destination.Text = destination;
\r
967 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
969 rtf_h264advanced.Text = "";
\r
972 private void GenerateQuery_Click(object sender, EventArgs e)
\r
974 String query = GenerateTheQuery();
\r
975 QueryEditorText.Text = query;
\r
978 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
980 QueryEditorText.Text = "";
\r
983 private void btn_queue_Click(object sender, EventArgs e)
\r
985 if (text_destination.Text != "" && text_source.Text != "")
\r
988 if (QueryEditorText.Text == "")
\r
990 query = GenerateTheQuery();
\r
994 query = QueryEditorText.Text;
\r
996 queueWindow.list_queue.Items.Add(query);
\r
997 queueWindow.Show();
\r
1001 MessageBox.Show("No Source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1005 private void showQueue()
\r
1007 queueWindow.Show();
\r
1012 //---------------------------------------------------
\r
1013 // Encode / Cancel Buttons
\r
1014 // Encode Progress Text Handler
\r
1015 //---------------------------------------------------
\r
1017 #region Encode/CLI
\r
1019 Functions.CLI process = new Functions.CLI();
\r
1021 private void btn_encode_Click(object sender, EventArgs e)
\r
1023 btn_eCancel.Enabled = true;
\r
1024 String query = "";
\r
1025 lbl_encode.Visible = false;
\r
1027 if (QueryEditorText.Text == "")
\r
1029 query = GenerateTheQuery();
\r
1033 query = QueryEditorText.Text;
\r
1036 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
1037 lbl_encode.Text = "Encoding Started";
\r
1040 private void btn_eCancel_Click(object sender, EventArgs e)
\r
1042 process.killCLI();
\r
1043 process.setNull();
\r
1044 lbl_encode.Text = "Encoding Canceled";
\r
1047 private void procMonitor(object state)
\r
1049 // Make sure we are not already encoding and if we are then display an error.
\r
1050 if (hbProc != null)
\r
1052 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1056 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
1057 MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
1058 hbProc.WaitForExit();
\r
1063 //*****************************************************************************************
\r
1065 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
1066 // video stream which has mild corruption issues every few seconds.
\r
1067 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
1068 //*****************************************************************************************
\r
1071 /*Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
\r
1072 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
1073 while (!encode.EndOfStream)
\r
1075 encode.ReadLine();
\r
1078 hbProc.WaitForExit();
\r
1079 process.closeCLI();
\r
1087 MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
1092 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
1094 if (this.InvokeRequired)
\r
1096 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
1097 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
1100 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
1105 //---------------------------------------------------
\r
1106 // Items that require actions on frmMain
\r
1107 //---------------------------------------------------
\r
1109 #region frmMain Actions
\r
1111 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
1113 lbl_chptWarn.Visible = false;
\r
1114 QueryEditorText.Text = "";
\r
1115 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1119 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1120 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1122 if (chapterFinish < chapterStart)
\r
1124 lbl_chptWarn.Visible = true;
\r
1125 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1130 lbl_chptWarn.Visible = true;
\r
1131 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1138 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1140 lbl_chptWarn.Visible = false;
\r
1141 QueryEditorText.Text = "";
\r
1142 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1146 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1147 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1149 if (chapterFinish < chapterStart)
\r
1151 lbl_chptWarn.Visible = true;
\r
1152 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1157 lbl_chptWarn.Visible = true;
\r
1158 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1163 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1165 text_filesize.Text = "";
\r
1166 slider_videoQuality.Value = 0;
\r
1167 SliderValue.Text = "0%";
\r
1168 CheckCRF.CheckState = CheckState.Unchecked;
\r
1169 CheckCRF.Enabled = false;
\r
1172 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1174 text_bitrate.Text = "";
\r
1175 slider_videoQuality.Value = 0;
\r
1176 SliderValue.Text = "0%";
\r
1177 CheckCRF.CheckState = CheckState.Unchecked;
\r
1178 CheckCRF.Enabled = false;
\r
1181 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1183 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1184 text_bitrate.Text = "";
\r
1185 text_filesize.Text = "";
\r
1186 CheckCRF.Enabled = true;
\r
1189 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1191 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1194 private void text_width_TextChanged(object sender, EventArgs e)
\r
1199 if (CheckPixelRatio.Checked)
\r
1201 text_width.Text = "";
\r
1202 text_width.BackColor = Color.White;
\r
1206 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1208 text_width.BackColor = Color.LightCoral;
\r
1212 text_width.BackColor = Color.LightGreen;
\r
1216 if (lbl_Aspect.Text != "Select a Title")
\r
1218 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1219 double mod16 = height % 16;
\r
1220 height = height - mod16;
\r
1222 if (text_width.Text == "")
\r
1224 text_height.Text = "";
\r
1225 text_width.BackColor = Color.White;
\r
1229 text_height.Text = height.ToString();
\r
1235 // No need to throw an error here.
\r
1241 private void text_height_TextChanged(object sender, EventArgs e)
\r
1245 if (text_height.Text != "Auto")
\r
1247 if (CheckPixelRatio.Checked)
\r
1249 text_height.Text = "";
\r
1250 text_width.BackColor = Color.White;
\r
1254 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1256 text_height.BackColor = Color.LightCoral;
\r
1260 text_height.BackColor = Color.LightGreen;
\r
1264 } catch(Exception){
\r
1265 // No need to alert the user.
\r
1269 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1271 if ((string)drp_crop.SelectedItem == "Manual")
\r
1273 text_left.Enabled = true;
\r
1274 text_right.Enabled = true;
\r
1275 text_top.Enabled = true;
\r
1276 text_bottom.Enabled = true;
\r
1279 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1281 text_left.Enabled = false;
\r
1282 text_right.Enabled = false;
\r
1283 text_top.Enabled = false;
\r
1284 text_bottom.Enabled = false;
\r
1285 text_left.Text = "";
\r
1286 text_right.Text = "";
\r
1287 text_top.Text = "";
\r
1288 text_bottom.Text = "";
\r
1290 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1292 string[] temp = new string[4];
\r
1293 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1294 text_left.Text = temp[2];
\r
1295 text_right.Text = temp[3];
\r
1296 text_top.Text = temp[0];
\r
1297 text_bottom.Text = temp[1];
\r
1301 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1303 text_left.Enabled = false;
\r
1304 text_right.Enabled = false;
\r
1305 text_top.Enabled = false;
\r
1306 text_bottom.Enabled = false;
\r
1307 text_left.Text = "0";
\r
1308 text_right.Text = "0";
\r
1309 text_top.Text = "0";
\r
1310 text_bottom.Text = "0";
\r
1315 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1317 text_width.Text = "";
\r
1318 text_height.Text = "";
\r
1319 text_width.BackColor = Color.White;
\r
1320 text_height.BackColor = Color.White;
\r
1323 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1325 if (drp_dvdtitle.Items.Count == 1)
\r
1327 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
1331 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1334 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1336 drp_audioMixDown.Items.Clear();
\r
1338 if (drp_audioCodec.Text == "AAC")
\r
1340 drp_audioMixDown.Items.Clear();
\r
1341 drp_audioMixDown.Items.Add("Mono");
\r
1342 drp_audioMixDown.Items.Add("Stereo");
\r
1343 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1344 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1345 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1347 drp_audioBitrate.Items.Clear();
\r
1348 drp_audioBitrate.Items.Add("32");
\r
1349 drp_audioBitrate.Items.Add("40");
\r
1350 drp_audioBitrate.Items.Add("48");
\r
1351 drp_audioBitrate.Items.Add("56");
\r
1352 drp_audioBitrate.Items.Add("64");
\r
1353 drp_audioBitrate.Items.Add("80");
\r
1354 drp_audioBitrate.Items.Add("86");
\r
1355 drp_audioBitrate.Items.Add("112");
\r
1356 drp_audioBitrate.Items.Add("128");
\r
1357 drp_audioBitrate.Items.Add("160");
\r
1362 drp_audioMixDown.Items.Clear();
\r
1363 drp_audioMixDown.Items.Add("Stereo");
\r
1364 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1365 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1367 drp_audioBitrate.Items.Clear();
\r
1368 drp_audioBitrate.Items.Add("32");
\r
1369 drp_audioBitrate.Items.Add("40");
\r
1370 drp_audioBitrate.Items.Add("48");
\r
1371 drp_audioBitrate.Items.Add("56");
\r
1372 drp_audioBitrate.Items.Add("64");
\r
1373 drp_audioBitrate.Items.Add("80");
\r
1374 drp_audioBitrate.Items.Add("86");
\r
1375 drp_audioBitrate.Items.Add("112");
\r
1376 drp_audioBitrate.Items.Add("128");
\r
1377 drp_audioBitrate.Items.Add("160");
\r
1378 drp_audioBitrate.Items.Add("192");
\r
1379 drp_audioBitrate.Items.Add("224");
\r
1380 drp_audioBitrate.Items.Add("256");
\r
1381 drp_audioBitrate.Items.Add("320");
\r
1382 drp_audioBitrate.Items.Add("384");
\r
1386 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1388 if (drp_audioCodec.Text == "AAC")
\r
1390 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1393 drp_audioBitrate.Items.Clear();
\r
1394 drp_audioBitrate.Items.Add("32");
\r
1395 drp_audioBitrate.Items.Add("40");
\r
1396 drp_audioBitrate.Items.Add("48");
\r
1397 drp_audioBitrate.Items.Add("56");
\r
1398 drp_audioBitrate.Items.Add("64");
\r
1399 drp_audioBitrate.Items.Add("80");
\r
1400 drp_audioBitrate.Items.Add("86");
\r
1401 drp_audioBitrate.Items.Add("112");
\r
1402 drp_audioBitrate.Items.Add("128");
\r
1403 drp_audioBitrate.Items.Add("160");
\r
1404 drp_audioBitrate.Items.Add("192");
\r
1405 drp_audioBitrate.Items.Add("224");
\r
1406 drp_audioBitrate.Items.Add("256");
\r
1407 drp_audioBitrate.Items.Add("320");
\r
1408 drp_audioBitrate.Items.Add("384");
\r
1413 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1415 if (Check_ChapterMarkers.Checked)
\r
1417 string destination = text_destination.Text;
\r
1418 destination = destination.Replace(".mp4", ".m4v");
\r
1419 text_destination.Text = destination;
\r
1423 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1425 if (!text_destination.Text.Contains(".mp4"))
\r
1427 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1428 check_largeFile.CheckState = CheckState.Unchecked;
\r
1432 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1434 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1435 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1437 check_turbo.CheckState = CheckState.Unchecked;
\r
1438 CheckCRF.CheckState = CheckState.Unchecked;
\r
1439 CheckCRF.Enabled = false;
\r
1440 check_turbo.Enabled = false;
\r
1441 h264Tab.Enabled = false;
\r
1445 CheckCRF.Enabled = true;
\r
1446 check_turbo.Enabled = true;
\r
1447 h264Tab.Enabled = true;
\r
1452 public void setStreamReader(Parsing.DVD dvd)
\r
1454 this.thisDVD = dvd;
\r
1457 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1459 // Reset some values on the form
\r
1460 lbl_Aspect.Text = "Select a Title";
\r
1461 lbl_RecomendedCrop.Text = "Select a Title";
\r
1462 drop_chapterStart.Items.Clear();
\r
1463 drop_chapterFinish.Items.Clear();
\r
1464 QueryEditorText.Text = "";
\r
1466 // If the dropdown is set to automatic nothing else needs to be done.
\r
1467 // Otheriwse if its not, title data has to be loased from parsing.
\r
1468 if (drp_dvdtitle.Text != "Automatic")
\r
1470 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1472 // Set the Aspect Ratio
\r
1473 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1475 // Set the Recommended Cropping values
\r
1476 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1478 // Populate the Start chapter Dropdown
\r
1479 drop_chapterStart.Items.Clear();
\r
1480 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1481 if (drop_chapterStart.Items.Count > 0)
\r
1483 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1486 // Populate the Final Chapter Dropdown
\r
1487 drop_chapterFinish.Items.Clear();
\r
1488 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1489 if (drop_chapterFinish.Items.Count > 0)
\r
1491 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1494 // Populate the Audio Channels Dropdown
\r
1495 drp_audioChannels.Items.Clear();
\r
1496 drp_audioChannels.Items.Add("Automatic");
\r
1497 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1498 if (drp_audioChannels.Items.Count > 0)
\r
1500 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1503 // Populate the Subtitles dropdown
\r
1504 drp_subtitle.Items.Clear();
\r
1505 drp_subtitle.Items.Add("None");
\r
1506 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1507 if (drp_subtitle.Items.Count > 0)
\r
1509 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1517 * ---------------------------------------------------
\r
1519 * The query Generation function.
\r
1521 * ---------------------------------------------------
\r
1524 #region Program Functions
\r
1526 public string GenerateTheQuery()
\r
1528 string source = text_source.Text;
\r
1529 string dvdTitle = drp_dvdtitle.Text;
\r
1530 string chapterStart = drop_chapterStart.Text;
\r
1531 string chapterFinish = drop_chapterFinish.Text;
\r
1532 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1533 string dvdChapter = "";
\r
1536 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1539 source = " -i " + '"' + source+ '"'; //'"'+
\r
1542 if (dvdTitle == "Automatic")
\r
1546 string[] titleInfo = dvdTitle.Split(' ');
\r
1547 dvdTitle = " -t "+ titleInfo[0];
\r
1550 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1552 else if (chapterFinish == chapterStart)
\r
1553 dvdChapter = " -c " + chapterStart;
\r
1555 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1557 string querySource = source+ dvdTitle+ dvdChapter;
\r
1558 // ----------------------------------------------------------------------
\r
1562 string destination = text_destination.Text;
\r
1563 string videoEncoder = drp_videoEncoder.Text;
\r
1564 string audioEncoder = drp_audioCodec.Text;
\r
1565 string width = text_width.Text;
\r
1566 string height = text_height.Text;
\r
1568 if (destination == "")
\r
1569 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1571 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1574 switch (videoEncoder)
\r
1577 videoEncoder = " -e ffmpeg";
\r
1580 videoEncoder = " -e xvid";
\r
1583 videoEncoder = " -e x264";
\r
1585 case "H.264 Baseline 1.3":
\r
1586 videoEncoder = " -e x264b13";
\r
1588 case "H.264 (iPod)":
\r
1589 videoEncoder = " -e x264b30";
\r
1592 videoEncoder = " -e x264";
\r
1596 switch (audioEncoder)
\r
1599 audioEncoder = " -E faac";
\r
1602 audioEncoder = " -E lame";
\r
1605 audioEncoder = " -E vorbis";
\r
1608 audioEncoder = " -E ac3";
\r
1611 audioEncoder = " -E faac";
\r
1616 width = " -w "+ width;
\r
1619 if (height == "Auto")
\r
1623 else if (height != "")
\r
1625 height = " -l " + height;
\r
1629 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1630 // ----------------------------------------------------------------------
\r
1632 // Picture Settings Tab
\r
1634 string cropSetting = drp_crop.Text;
\r
1635 string cropTop = text_top.Text;
\r
1636 string cropBottom = text_bottom.Text;
\r
1637 string cropLeft = text_left.Text;
\r
1638 string cropRight = text_right.Text;
\r
1639 string subtitles = drp_subtitle.Text;
\r
1640 string cropOut = "";
\r
1641 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1642 string deinterlace = "";
\r
1643 string grayscale = "";
\r
1644 string pixelRatio = "";
\r
1645 string ChapterMarkers = "";
\r
1646 // Returns Crop Query
\r
1648 if (cropSetting == "Auto Crop")
\r
1650 else if (cropSetting == "No Crop")
\r
1651 cropOut = " --crop 0:0:0:0 ";
\r
1653 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1655 if (subtitles == "None")
\r
1657 else if (subtitles == "")
\r
1662 tempSub = subtitles.Split(' ');
\r
1663 subtitles = " -s "+ tempSub[0];
\r
1666 switch (deInterlace_Option)
\r
1671 case "Origional (Fast)":
\r
1672 deinterlace = " --deinterlace";
\r
1674 case "yadif (Slow)":
\r
1675 deinterlace = " --deinterlace=" + '"' + "1" + '"';
\r
1677 case "yadif + mcdeint (Slower)":
\r
1678 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1680 case "yadif + mcdeint (Slowest)":
\r
1681 deinterlace = " --deinterlace=" + '"' + "3:-1:2" + '"';
\r
1684 deinterlace = " --deinterlace=";
\r
1688 if (check_grayscale.Checked)
\r
1689 grayscale = " -g ";
\r
1691 if (CheckPixelRatio.Checked)
\r
1692 pixelRatio = " -p ";
\r
1694 if (Check_ChapterMarkers.Checked)
\r
1695 ChapterMarkers = " -m ";
\r
1697 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1698 // ----------------------------------------------------------------------
\r
1700 // Video Settings Tab
\r
1702 string videoBitrate = text_bitrate.Text;
\r
1703 string videoFilesize = text_filesize.Text;
\r
1704 double videoQuality = slider_videoQuality.Value;
\r
1705 string vidQSetting = "";
\r
1706 string twoPassEncoding = "";
\r
1707 string videoFramerate = drp_videoFramerate.Text;
\r
1708 string turboH264 = "";
\r
1709 string largeFile = "";
\r
1710 string deblock = "";
\r
1711 string detelecine = "";
\r
1712 string denoise = "";
\r
1713 string CRF = CheckCRF.CheckState.ToString();
\r
1716 if ((CRF == "Checked"))
\r
1721 if (videoBitrate != "")
\r
1722 videoBitrate = " -b "+ videoBitrate;
\r
1724 if (videoFilesize != "")
\r
1725 videoFilesize = " -S "+ videoFilesize;
\r
1727 // Video Quality Setting
\r
1729 if ((videoQuality == 0))
\r
1733 videoQuality = videoQuality / 100;
\r
1734 if (videoQuality == 1)
\r
1736 vidQSetting = "1.0";
\r
1739 vidQSetting = " -q " + videoQuality.ToString();
\r
1742 if (check_2PassEncode.Checked)
\r
1743 twoPassEncoding = " -2 ";
\r
1745 if (videoFramerate == "Automatic")
\r
1746 videoFramerate = "";
\r
1748 videoFramerate = " -r "+ videoFramerate;
\r
1750 if (check_turbo.Checked)
\r
1751 turboH264 = " -T ";
\r
1753 if (check_largeFile.Checked)
\r
1754 largeFile = " -4 ";
\r
1756 if (check_deblock.Checked)
\r
1757 deblock = " --deblock";
\r
1759 if (check_detelecine.Checked)
\r
1760 detelecine = " --detelecine";
\r
1762 switch (drp_deNoise.Text)
\r
1768 denoise = " --denoise=3:2:3:3";
\r
1771 denoise = " --denoise=7:7:5:5";
\r
1778 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1779 // ----------------------------------------------------------------------
\r
1781 // Audio Settings Tab
\r
1783 string audioBitrate = drp_audioBitrate.Text;
\r
1784 string audioSampleRate = drp_audioSampleRate.Text;
\r
1785 string audioChannels = drp_audioChannels.Text;
\r
1786 string Mixdown = drp_audioMixDown.Text;
\r
1787 string SixChannelAudio = "";
\r
1789 if (audioBitrate != "")
\r
1790 audioBitrate = " -B "+ audioBitrate;
\r
1792 if (audioSampleRate != "")
\r
1793 audioSampleRate = " -R "+ audioSampleRate;
\r
1795 if (audioChannels == "Automatic")
\r
1796 audioChannels = "";
\r
1797 else if (audioChannels == "")
\r
1798 audioChannels = "";
\r
1802 tempSub = audioChannels.Split(' ');
\r
1803 audioChannels = " -a "+ tempSub[0];
\r
1815 Mixdown = "stereo";
\r
1817 case "Dolby Surround":
\r
1820 case "Dolby Pro Logic II":
\r
1823 case "6 Channel Discrete":
\r
1827 Mixdown = "stero";
\r
1831 if (Mixdown != "")
\r
1832 SixChannelAudio = " -6 "+ Mixdown;
\r
1834 SixChannelAudio = "";
\r
1836 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1837 // ----------------------------------------------------------------------
\r
1842 string h264Advanced = rtf_h264advanced.Text;
\r
1844 if ((h264Advanced == ""))
\r
1845 h264Advanced = "";
\r
1847 h264Advanced = " -x "+ h264Advanced;
\r
1850 string h264Settings = h264Advanced;
\r
1851 // ----------------------------------------------------------------------
\r
1853 // Processors (Program Settings)
\r
1855 string processors = Properties.Settings.Default.Processors;
\r
1856 // Number of Processors Handler
\r
1858 if (processors == "Automatic")
\r
1861 processors = " -C "+ processors+ " ";
\r
1864 string queryAdvancedSettings = processors;
\r
1865 // ----------------------------------------------------------------------
\r
1867 // Verbose option (Program Settings)
\r
1869 string verbose = "";
\r
1870 if (Properties.Settings.Default.verbose == "Checked")
\r
1873 // ----------------------------------------------------------------------
\r
1875 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1881 // This is the END of the road ------------------------------------------------------------------------------
\r