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
12 using System.Runtime.InteropServices;
\r
17 public partial class frmMain : Form
\r
20 private Process hbProc;
\r
21 private Parsing.DVD thisDVD;
\r
23 // --------------------------------------------------------------
\r
24 // Some windows that require only 1 instance.
\r
25 // --------------------------------------------------------------
\r
26 private frmQueue queueWindow = new frmQueue();
\r
28 // --------------------------------------------------------------
\r
29 // Stuff that needs doing on startup.
\r
30 // - Load users default settings. (if required)
\r
31 // - Do an update check (if required)
\r
32 // --------------------------------------------------------------
\r
33 private frmDvdInfo dvdInfoWindow = new frmDvdInfo();
\r
38 ThreadPool.QueueUserWorkItem(showSplash);
\r
41 InitializeComponent();
\r
43 // This is a quick Hack fix for the cross-thread problem with frmDvdIndo ************************
\r
44 dvdInfoWindow.Show();
\r
45 dvdInfoWindow.Hide();
\r
46 // **********************************************************************************************
\r
49 // Set the Version number lable to the corect version.
\r
50 Version.Text = "Version " + Properties.Settings.Default.GuiVersion;
\r
52 // Run the update checker.
\r
55 // Now load the users default if required.
\r
58 // Display the quick start window if required.
\r
61 //MessageBox.Show(System.Environment.OSVersion.Version.ToString());
\r
65 public void showSplash(object sender)
\r
67 Form splash = new frmSplashScreen();
\r
73 public void loadUserDefaults()
\r
77 if (Properties.Settings.Default.defaultSettings == "Checked")
\r
80 text_source.Text = Properties.Settings.Default.DVDSource;
\r
81 drp_dvdtitle.Text = Properties.Settings.Default.DVDTitle;
\r
82 drop_chapterStart.Text = Properties.Settings.Default.ChapterStart;
\r
83 drop_chapterFinish.Text = Properties.Settings.Default.ChapterFinish;
\r
86 text_destination.Text = Properties.Settings.Default.VideoDest;
\r
87 drp_videoEncoder.Text = Properties.Settings.Default.VideoEncoder;
\r
88 drp_audioCodec.Text = Properties.Settings.Default.AudioEncoder;
\r
89 text_width.Text = Properties.Settings.Default.Width;
\r
90 text_height.Text = Properties.Settings.Default.Height;
\r
92 // Picture Settings Tab
\r
93 drp_crop.Text = Properties.Settings.Default.CroppingOption;
\r
94 text_top.Text = Properties.Settings.Default.CropTop;
\r
95 text_bottom.Text = Properties.Settings.Default.CropBottom;
\r
96 text_left.Text = Properties.Settings.Default.CropLeft;
\r
97 text_right.Text = Properties.Settings.Default.CropRight;
\r
98 drp_subtitle.Text = Properties.Settings.Default.Subtitles;
\r
100 // Video Settings Tab
\r
101 text_bitrate.Text = Properties.Settings.Default.VideoBitrate;
\r
102 text_filesize.Text = Properties.Settings.Default.VideoFilesize;
\r
103 slider_videoQuality.Value = Properties.Settings.Default.VideoQuality;
\r
105 if (Properties.Settings.Default.TwoPass == "Checked")
\r
107 check_2PassEncode.CheckState = CheckState.Checked;
\r
110 drp_deInterlace_option.Text = Properties.Settings.Default.DeInterlace;
\r
111 drp_deNoise.Text = Properties.Settings.Default.denoise;
\r
113 if (Properties.Settings.Default.detelecine == "Checked")
\r
115 check_detelecine.CheckState = CheckState.Checked;
\r
118 if (Properties.Settings.Default.detelecine == "Checked")
\r
120 check_deblock.CheckState = CheckState.Checked;
\r
124 if (Properties.Settings.Default.Grayscale == "Checked")
\r
126 check_grayscale.CheckState = CheckState.Checked;
\r
129 drp_videoFramerate.Text = Properties.Settings.Default.Framerate;
\r
131 if (Properties.Settings.Default.PixelRatio == "Checked")
\r
133 CheckPixelRatio.CheckState = CheckState.Checked;
\r
135 if (Properties.Settings.Default.turboFirstPass == "Checked")
\r
137 check_turbo.CheckState = CheckState.Checked;
\r
139 if (Properties.Settings.Default.largeFile == "Checked")
\r
141 check_largeFile.CheckState = CheckState.Checked;
\r
143 // Audio Settings Tab
\r
144 drp_audioBitrate.Text = Properties.Settings.Default.AudioBitrate;
\r
145 drp_audioSampleRate.Text = Properties.Settings.Default.AudioSampleRate;
\r
146 drp_audioChannels.Text = Properties.Settings.Default.AudioChannels;
\r
149 if (Properties.Settings.Default.CRF == "Checked")
\r
151 CheckCRF.CheckState = CheckState.Checked;
\r
153 rtf_h264advanced.Text = Properties.Settings.Default.H264;
\r
158 // No real need to alert the user. Try/Catch only in just incase there is a problem reading the settings xml file.
\r
162 public void updateCheck()
\r
164 if (Properties.Settings.Default.updateStatus == "Checked")
\r
168 String updateFile = Properties.Settings.Default.updateFile;
\r
169 WebClient client = new WebClient();
\r
170 String data = client.DownloadString(updateFile);
\r
171 String[] versionData = data.Split('\n');
\r
173 if ((versionData[0] != Properties.Settings.Default.GuiVersion) || (versionData[1] != Properties.Settings.Default.CliVersion))
\r
175 lbl_update.Visible = true;
\r
180 // Silently ignore the error
\r
185 public void quickStart()
\r
187 if ((Properties.Settings.Default.QuickStartWindow == "Checked") || (Properties.Settings.Default.QuickStartWindow == ""))
\r
189 frmQuickStart quickstart = new frmQuickStart();
\r
190 quickstart.ShowDialog();
\r
195 // --------------------------------------------------------------
\r
196 // The main Menu bar.
\r
197 // --------------------------------------------------------------
\r
201 private void mnu_open_Click(object sender, EventArgs e)
\r
204 File_Open.ShowDialog();
\r
205 filename = File_Open.FileName;
\r
206 if (filename != "")
\r
210 // Create StreamReader & open file
\r
211 StreamReader line = new StreamReader(filename);
\r
212 string temporyLine; // Used for reading the line into a varible before processing on the checkState items below.
\r
214 // Read in the data and set the correct GUI component with the setting.
\r
215 text_source.Text = line.ReadLine();
\r
216 drp_dvdtitle.Text = line.ReadLine();
\r
217 drop_chapterStart.Text = line.ReadLine();
\r
218 drop_chapterFinish.Text = line.ReadLine();
\r
219 text_destination.Text = line.ReadLine();
\r
220 drp_videoEncoder.Text = line.ReadLine();
\r
221 drp_audioCodec.Text = line.ReadLine();
\r
222 text_width.Text = line.ReadLine();
\r
223 text_height.Text = line.ReadLine();
\r
224 text_top.Text = line.ReadLine();
\r
225 text_bottom.Text = line.ReadLine();
\r
226 text_left.Text = line.ReadLine();
\r
227 text_right.Text = line.ReadLine();
\r
228 drp_subtitle.Text = line.ReadLine();
\r
229 text_bitrate.Text = line.ReadLine();
\r
230 text_filesize.Text = line.ReadLine();
\r
231 slider_videoQuality.Value = int.Parse(line.ReadLine());
\r
233 temporyLine = line.ReadLine();
\r
234 if (temporyLine == "Checked")
\r
236 check_2PassEncode.CheckState = CheckState.Checked;
\r
239 drp_deInterlace_option.Text = line.ReadLine();
\r
241 temporyLine = line.ReadLine();
\r
242 if (temporyLine == "Checked")
\r
244 check_grayscale.CheckState = CheckState.Checked;
\r
247 drp_videoFramerate.Text = line.ReadLine();
\r
249 temporyLine = line.ReadLine();
\r
250 if (temporyLine == "Checked")
\r
252 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
255 temporyLine = line.ReadLine();
\r
256 if (temporyLine == "Checked")
\r
258 CheckPixelRatio.CheckState = CheckState.Checked;
\r
261 temporyLine = line.ReadLine();
\r
262 if (temporyLine == "Checked")
\r
264 check_turbo.CheckState = CheckState.Checked;
\r
267 temporyLine = line.ReadLine();
\r
268 if (temporyLine == "Checked")
\r
270 check_largeFile.CheckState = CheckState.Checked;
\r
273 drp_audioBitrate.Text = line.ReadLine();
\r
274 drp_audioSampleRate.Text = line.ReadLine();
\r
275 drp_audioChannels.Text = line.ReadLine();
\r
276 drp_audioMixDown.Text = line.ReadLine();
\r
278 // Advanced H264 Options
\r
279 temporyLine = line.ReadLine();
\r
280 if (temporyLine == "Checked")
\r
282 CheckCRF.CheckState = CheckState.Checked;
\r
284 rtf_h264advanced.Text = line.ReadLine();
\r
286 // Close the stream
\r
290 // Fix for SliderValue not appearing when Opening saved file
\r
291 SliderValue.Text = slider_videoQuality.Value + "%";
\r
293 } catch (Exception){
\r
294 MessageBox.Show("Unable to load profile.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
\r
299 private void mnu_save_Click(object sender, EventArgs e)
\r
303 File_Save.ShowDialog();
\r
304 filename = File_Save.FileName;
\r
305 if (filename != "")
\r
309 // Create a StreamWriter and open the file
\r
310 StreamWriter line = new StreamWriter(filename);
\r
313 line.WriteLine(text_source.Text);
\r
314 line.WriteLine(drp_dvdtitle.Text);
\r
315 line.WriteLine(drop_chapterStart.Text);
\r
316 line.WriteLine(drop_chapterFinish.Text);
\r
318 line.WriteLine(text_destination.Text);
\r
319 line.WriteLine(drp_videoEncoder.Text);
\r
320 line.WriteLine(drp_audioCodec.Text);
\r
321 line.WriteLine(text_width.Text);
\r
322 line.WriteLine(text_height.Text);
\r
323 //Picture Settings Tab
\r
324 line.WriteLine(text_top.Text);
\r
325 line.WriteLine(text_bottom.Text);
\r
326 line.WriteLine(text_left.Text);
\r
327 line.WriteLine(text_right.Text);
\r
328 line.WriteLine(drp_subtitle.Text);
\r
329 //Video Settings Tab
\r
330 line.WriteLine(text_bitrate.Text);
\r
331 line.WriteLine(text_filesize.Text);
\r
332 line.WriteLine(slider_videoQuality.Value.ToString());
\r
333 line.WriteLine(check_2PassEncode.CheckState.ToString());
\r
334 line.WriteLine(drp_deInterlace_option.Text);
\r
335 line.WriteLine(check_grayscale.CheckState.ToString());
\r
336 line.WriteLine(drp_videoFramerate.Text);
\r
337 line.WriteLine(Check_ChapterMarkers.CheckState.ToString());
\r
338 line.WriteLine(CheckPixelRatio.CheckState.ToString());
\r
339 line.WriteLine(check_turbo.CheckState.ToString());
\r
340 line.WriteLine(check_largeFile.CheckState.ToString());
\r
341 //Audio Settings Tab
\r
342 line.WriteLine(drp_audioBitrate.Text);
\r
343 line.WriteLine(drp_audioSampleRate.Text);
\r
344 line.WriteLine(drp_audioChannels.Text);
\r
345 line.WriteLine(drp_audioMixDown.Text);
\r
347 line.WriteLine(CheckCRF.CheckState.ToString());
\r
348 line.WriteLine(rtf_h264advanced.Text);
\r
349 // close the stream
\r
351 MessageBox.Show("Your profile has been sucessfully saved.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
355 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
361 private void mnu_update_Click(object sender, EventArgs e)
\r
363 Form Update = new frmUpdate();
\r
364 Update.ShowDialog();
\r
367 private void mnu_exit_Click(object sender, EventArgs e)
\r
376 private void mnu_encode_Click(object sender, EventArgs e)
\r
382 private void mnu_viewDVDdata_Click(object sender, EventArgs e)
\r
386 dvdInfoWindow.Show();
\r
391 // No action required
\r
394 // BUG *******************************************************
\r
395 // Cross-thread operation not valid: Control 'rtf_dvdInfo' accessed from a thread other than the thread it was created on.
\r
396 // This happens when the DVD is scanned and this item is then selected.
\r
397 // 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
398 // NOTE: Try/catch added to prevent final build crashing.
\r
399 // NOTE2: Included a quick fix in frmMain(). Simply show and hide the window when starting the app.
\r
400 // Note3: Suspect the problem lies with line 30.
\r
401 // ***********************************************************
\r
405 private void mnu_options_Click(object sender, EventArgs e)
\r
407 Form Options = new frmOptions();
\r
408 Options.ShowDialog();
\r
413 #region Presets Menu
\r
414 // Need to write a handler for file extension
\r
416 private void mnu_animation_Click(object sender, EventArgs e)
\r
418 CheckPixelRatio.CheckState = CheckState.Checked;
\r
419 text_width.Text = "";
\r
420 text_height.Text = "";
\r
421 drp_videoEncoder.Text = "H.264";
\r
422 text_bitrate.Text = "1000";
\r
423 text_filesize.Text = "";
\r
424 slider_videoQuality.Value = 0;
\r
425 SliderValue.Text = "0%";
\r
426 drp_audioBitrate.Text = "160";
\r
427 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
428 drp_audioSampleRate.Text = "48";
\r
429 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
430 drp_deInterlace_option.Text = "Origional (Fast)";
\r
431 check_2PassEncode.CheckState = CheckState.Checked;
\r
432 drp_crop.Text = "No Crop";
\r
433 check_turbo.CheckState = CheckState.Checked;
\r
434 drp_audioCodec.Text = "AAC";
\r
436 // Set file extension to MKV
\r
437 string destination = text_destination.Text;
\r
438 destination = destination.Replace(".mp4", ".mkv");
\r
439 destination = destination.Replace(".avi", ".mkv");
\r
440 destination = destination.Replace(".m4v", ".mkv");
\r
441 destination = destination.Replace(".ogm", ".mkv");
\r
442 text_destination.Text = destination;
\r
445 private void mnu_appleTv_Click(object sender, EventArgs e)
\r
447 CheckPixelRatio.CheckState = CheckState.Checked;
\r
448 text_width.Text = "";
\r
449 text_height.Text = "";
\r
450 drp_videoEncoder.Text = "H.264";
\r
451 text_bitrate.Text = "2500";
\r
452 text_filesize.Text = "";
\r
453 slider_videoQuality.Value = 0;
\r
454 SliderValue.Text = "0%";
\r
455 drp_audioBitrate.Text = "160";
\r
456 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
457 drp_audioSampleRate.Text = "48";
\r
458 rtf_h264advanced.Text = "bframes=3:ref=1:subme=5:me=umh:no-fast-pskip=1:trellis=2";
\r
459 drp_deInterlace_option.Text = "None";
\r
460 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
461 drp_crop.Text = "No Crop";
\r
462 check_turbo.CheckState = CheckState.Unchecked;
\r
463 drp_audioCodec.Text = "AAC";
\r
466 private void mnu_bedlam_Click(object sender, EventArgs e)
\r
468 CheckPixelRatio.CheckState = CheckState.Checked;
\r
469 text_width.Text = "";
\r
470 text_height.Text = "";
\r
471 drp_videoEncoder.Text = "H.264";
\r
472 text_bitrate.Text = "1800";
\r
473 text_filesize.Text = "";
\r
474 slider_videoQuality.Value = 0;
\r
475 SliderValue.Text = "0%";
\r
476 drp_audioBitrate.Text = "160";
\r
477 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
478 drp_audioSampleRate.Text = "48";
\r
479 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
480 drp_deInterlace_option.Text = "None";
\r
481 check_2PassEncode.CheckState = CheckState.Checked;
\r
482 drp_crop.Text = "No Crop";
\r
483 check_turbo.CheckState = CheckState.Checked;
\r
484 drp_audioCodec.Text = "AC3";
\r
486 // Set file extension to MKV
\r
487 string destination = text_destination.Text;
\r
488 destination = destination.Replace(".mp4", ".mkv");
\r
489 destination = destination.Replace(".avi", ".mkv");
\r
490 destination = destination.Replace(".m4v", ".mkv");
\r
491 destination = destination.Replace(".ogm", ".mkv");
\r
492 text_destination.Text = destination;
\r
495 private void mnu_blind_Click(object sender, EventArgs e)
\r
497 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
498 text_width.Text = "512";
\r
499 text_height.Text = "";
\r
500 drp_videoEncoder.Text = "H.264";
\r
501 text_bitrate.Text = "512";
\r
502 text_filesize.Text = "";
\r
503 slider_videoQuality.Value = 0;
\r
504 SliderValue.Text = "0%";
\r
505 drp_audioBitrate.Text = "128";
\r
506 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
507 drp_audioSampleRate.Text = "48";
\r
508 rtf_h264advanced.Text = "";
\r
509 drp_deInterlace_option.Text = "None";
\r
510 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
511 drp_crop.Text = "No Crop";
\r
512 check_turbo.CheckState = CheckState.Unchecked;
\r
513 drp_audioCodec.Text = "AAC";
\r
516 private void mnu_broke_Click(object sender, EventArgs e)
\r
518 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
519 text_width.Text = "640";
\r
520 text_height.Text = "";
\r
521 drp_videoEncoder.Text = "H.264";
\r
522 text_bitrate.Text = "";
\r
523 text_filesize.Text = "695";
\r
524 slider_videoQuality.Value = 0;
\r
525 SliderValue.Text = "0%";
\r
526 drp_audioBitrate.Text = "128";
\r
527 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
528 drp_audioSampleRate.Text = "48";
\r
529 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
530 drp_deInterlace_option.Text = "None";
\r
531 check_2PassEncode.CheckState = CheckState.Checked;
\r
532 drp_crop.Text = "No Crop";
\r
533 check_turbo.CheckState = CheckState.Checked;
\r
534 drp_audioCodec.Text = "AAC";
\r
537 private void mnu_Classic_Click(object sender, EventArgs e)
\r
539 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
540 text_width.Text = "";
\r
541 text_height.Text = "";
\r
542 drp_videoEncoder.Text = "H.264";
\r
543 text_bitrate.Text = "1000";
\r
544 text_filesize.Text = "";
\r
545 slider_videoQuality.Value = 0;
\r
546 SliderValue.Text = "0%";
\r
547 drp_audioBitrate.Text = "160";
\r
548 Check_ChapterMarkers.CheckState = CheckState.Unchecked;
\r
549 drp_audioSampleRate.Text = "48";
\r
550 rtf_h264advanced.Text = "";
\r
551 drp_deInterlace_option.Text = "None";
\r
552 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
553 drp_crop.Text = "No Crop";
\r
554 check_turbo.CheckState = CheckState.Unchecked;
\r
555 drp_audioCodec.Text = "AAC";
\r
558 private void mnu_CQR_Click(object sender, EventArgs e)
\r
560 CheckPixelRatio.CheckState = CheckState.Checked;
\r
561 text_width.Text = "";
\r
562 text_height.Text = "";
\r
563 drp_videoEncoder.Text = "H.264";
\r
564 text_bitrate.Text = "";
\r
565 text_filesize.Text = "";
\r
566 slider_videoQuality.Value = 64;
\r
567 SliderValue.Text = "64%";
\r
568 drp_audioBitrate.Text = "160";
\r
569 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
570 drp_audioSampleRate.Text = "48";
\r
571 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
572 drp_deInterlace_option.Text = "None";
\r
573 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
574 drp_crop.Text = "No Crop";
\r
575 check_turbo.CheckState = CheckState.Unchecked;
\r
576 drp_audioCodec.Text = "AC3";
\r
578 // Set file extension to MKV
\r
579 string destination = text_destination.Text;
\r
580 destination = destination.Replace(".mp4", ".mkv");
\r
581 destination = destination.Replace(".avi", ".mkv");
\r
582 destination = destination.Replace(".m4v", ".mkv");
\r
583 destination = destination.Replace(".ogm", ".mkv");
\r
584 text_destination.Text = destination;
\r
587 private void mnu_DSQ_Click(object sender, EventArgs e)
\r
589 CheckPixelRatio.CheckState = CheckState.Checked;
\r
590 text_width.Text = "";
\r
591 text_height.Text = "";
\r
592 drp_videoEncoder.Text = "H.264";
\r
593 text_bitrate.Text = "1600";
\r
594 text_filesize.Text = "";
\r
595 slider_videoQuality.Value = 0;
\r
596 SliderValue.Text = "0%";
\r
597 drp_audioBitrate.Text = "160";
\r
598 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
599 drp_audioSampleRate.Text = "48";
\r
600 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
601 drp_deInterlace_option.Text = "None";
\r
602 check_2PassEncode.CheckState = CheckState.Checked;
\r
603 drp_crop.Text = "No Crop";
\r
604 check_turbo.CheckState = CheckState.Checked;
\r
605 drp_audioCodec.Text = "AC3";
\r
607 // Set file extension to MKV
\r
608 string destination = text_destination.Text;
\r
609 destination = destination.Replace(".mp4", ".mkv");
\r
610 destination = destination.Replace(".avi", ".mkv");
\r
611 destination = destination.Replace(".m4v", ".mkv");
\r
612 destination = destination.Replace(".ogm", ".mkv");
\r
613 text_destination.Text = destination;
\r
616 private void mnu_film_Click(object sender, EventArgs e)
\r
618 CheckPixelRatio.CheckState = CheckState.Checked;
\r
619 text_width.Text = "";
\r
620 text_height.Text = "";
\r
621 drp_videoEncoder.Text = "H.264";
\r
622 text_bitrate.Text = "2000";
\r
623 text_filesize.Text = "";
\r
624 slider_videoQuality.Value = 0;
\r
625 SliderValue.Text = "0%";
\r
626 drp_audioBitrate.Text = "160";
\r
627 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
628 drp_audioSampleRate.Text = "48";
\r
629 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
630 drp_deInterlace_option.Text = "None";
\r
631 check_2PassEncode.CheckState = CheckState.Checked;
\r
632 drp_crop.Text = "No Crop";
\r
633 check_turbo.CheckState = CheckState.Checked;
\r
634 drp_audioCodec.Text = "AC3";
\r
636 // Set file extension to MKV
\r
637 string destination = text_destination.Text;
\r
638 destination = destination.Replace(".mp4", ".mkv");
\r
639 destination = destination.Replace(".avi", ".mkv");
\r
640 destination = destination.Replace(".m4v", ".mkv");
\r
641 destination = destination.Replace(".ogm", ".mkv");
\r
642 text_destination.Text = destination;
\r
645 private void mnu_iphone_Click(object sender, EventArgs e)
\r
647 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
648 text_width.Text = "480";
\r
649 text_height.Text = "";
\r
650 drp_videoEncoder.Text = "H.264 (iPod)";
\r
651 text_bitrate.Text = "960";
\r
652 text_filesize.Text = "";
\r
653 slider_videoQuality.Value = 0;
\r
654 SliderValue.Text = "0%";
\r
655 drp_audioBitrate.Text = "128";
\r
656 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
657 drp_audioSampleRate.Text = "48";
\r
658 rtf_h264advanced.Text = "cabac=0:ref=1:analyse=all:me=umh:subme=6:no-fast-pskip=1:trellis=1";
\r
659 drp_deInterlace_option.Text = "None";
\r
660 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
661 drp_crop.Text = "No Crop";
\r
662 check_turbo.CheckState = CheckState.Unchecked;
\r
663 drp_audioCodec.Text = "AAC";
\r
666 private void mnu_ipod_Click(object sender, EventArgs e)
\r
668 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
669 text_width.Text = "640";
\r
670 text_height.Text = "";
\r
671 drp_videoEncoder.Text = "H.264 (iPod)";
\r
672 text_bitrate.Text = "1500";
\r
673 text_filesize.Text = "";
\r
674 slider_videoQuality.Value = 0;
\r
675 SliderValue.Text = "0%";
\r
676 drp_audioBitrate.Text = "160";
\r
677 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
678 drp_audioSampleRate.Text = "48";
\r
679 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
680 drp_deInterlace_option.Text = "None";
\r
681 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
682 drp_crop.Text = "No Crop";
\r
683 check_turbo.CheckState = CheckState.Unchecked;
\r
684 drp_audioCodec.Text = "AAC";
\r
687 private void mnu_ipodLow_Click(object sender, EventArgs e)
\r
689 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
690 text_width.Text = "320";
\r
691 text_height.Text = "";
\r
692 drp_videoEncoder.Text = "H.264 (iPod)";
\r
693 text_bitrate.Text = "700";
\r
694 text_filesize.Text = "";
\r
695 slider_videoQuality.Value = 0;
\r
696 SliderValue.Text = "0%";
\r
697 drp_audioBitrate.Text = "160";
\r
698 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
699 drp_audioSampleRate.Text = "48";
\r
700 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
701 drp_deInterlace_option.Text = "None";
\r
702 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
703 drp_crop.Text = "No Crop";
\r
704 check_turbo.CheckState = CheckState.Unchecked;
\r
705 drp_audioCodec.Text = "AAC";
\r
708 private void mnu_normal_Click(object sender, EventArgs e)
\r
710 CheckPixelRatio.CheckState = CheckState.Checked;
\r
711 text_width.Text = "";
\r
712 text_height.Text = "";
\r
713 drp_videoEncoder.Text = "H.264";
\r
714 text_bitrate.Text = "1500";
\r
715 text_filesize.Text = "";
\r
716 slider_videoQuality.Value = 0;
\r
717 SliderValue.Text = "0%";
\r
718 drp_audioBitrate.Text = "160";
\r
719 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
720 drp_audioSampleRate.Text = "48";
\r
721 rtf_h264advanced.Text = "ref=2:bframes=2:subme=5:me=umh";
\r
722 drp_deInterlace_option.Text = "None";
\r
723 check_2PassEncode.CheckState = CheckState.Checked;
\r
724 drp_crop.Text = "No Crop";
\r
725 check_turbo.CheckState = CheckState.Checked;
\r
726 drp_audioCodec.Text = "AAC";
\r
729 private void mnu_PS3_Click(object sender, EventArgs e)
\r
731 CheckPixelRatio.CheckState = CheckState.Checked;
\r
732 text_width.Text = "";
\r
733 text_height.Text = "";
\r
734 drp_videoEncoder.Text = "H.264";
\r
735 text_bitrate.Text = "2500";
\r
736 text_filesize.Text = "";
\r
737 slider_videoQuality.Value = 0;
\r
738 SliderValue.Text = "0%";
\r
739 drp_audioBitrate.Text = "160";
\r
740 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
741 drp_audioSampleRate.Text = "48";
\r
742 rtf_h264advanced.Text = "level=41:subme=5:me=umh";
\r
743 drp_deInterlace_option.Text = "None";
\r
744 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
745 drp_crop.Text = "No Crop";
\r
746 check_turbo.CheckState = CheckState.Unchecked;
\r
747 drp_audioCodec.Text = "AAC";
\r
750 private void mnu_psp_Click(object sender, EventArgs e)
\r
752 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
753 text_width.Text = "368";
\r
754 text_height.Text = "208";
\r
755 drp_videoEncoder.Text = "H.264";
\r
756 text_bitrate.Text = "1024";
\r
757 text_filesize.Text = "";
\r
758 slider_videoQuality.Value = 0;
\r
759 SliderValue.Text = "0%";
\r
760 drp_audioBitrate.Text = "160";
\r
761 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
762 drp_audioSampleRate.Text = "48";
\r
763 rtf_h264advanced.Text = "";
\r
764 drp_deInterlace_option.Text = "None";
\r
765 check_2PassEncode.CheckState = CheckState.Unchecked;
\r
766 drp_crop.Text = "No Crop";
\r
767 check_turbo.CheckState = CheckState.Unchecked;
\r
768 drp_audioCodec.Text = "AAC";
\r
771 private void mnu_qt_Click(object sender, EventArgs e)
\r
773 CheckPixelRatio.CheckState = CheckState.Checked;
\r
774 text_width.Text = "";
\r
775 text_height.Text = "";
\r
776 drp_videoEncoder.Text = "H.264";
\r
777 text_bitrate.Text = "2000";
\r
778 text_filesize.Text = "";
\r
779 slider_videoQuality.Value = 0;
\r
780 SliderValue.Text = "0%";
\r
781 drp_audioBitrate.Text = "160";
\r
782 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
783 drp_audioSampleRate.Text = "48";
\r
784 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
785 drp_deInterlace_option.Text = "None";
\r
786 check_2PassEncode.CheckState = CheckState.Checked;
\r
787 drp_crop.Text = "No Crop";
\r
788 check_turbo.CheckState = CheckState.Checked;
\r
789 drp_audioCodec.Text = "AAC";
\r
792 private void mnu_television_Click(object sender, EventArgs e)
\r
794 CheckPixelRatio.CheckState = CheckState.Unchecked;
\r
795 text_width.Text = "";
\r
796 text_height.Text = "";
\r
797 drp_videoEncoder.Text = "H.264";
\r
798 text_bitrate.Text = "1300";
\r
799 text_filesize.Text = "";
\r
800 slider_videoQuality.Value = 0;
\r
801 SliderValue.Text = "0%";
\r
802 drp_audioBitrate.Text = "160";
\r
803 Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
804 drp_audioSampleRate.Text = "48";
\r
805 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
806 drp_deInterlace_option.Text = "Origional (Fast)";
\r
807 check_2PassEncode.CheckState = CheckState.Checked;
\r
808 drp_crop.Text = "No Crop";
\r
809 check_turbo.CheckState = CheckState.Checked;
\r
810 drp_audioCodec.Text = "AAC";
\r
812 // Set file extension to MKV
\r
813 string destination = text_destination.Text;
\r
814 destination = destination.Replace(".mp4", ".mkv");
\r
815 destination = destination.Replace(".avi", ".mkv");
\r
816 destination = destination.Replace(".m4v", ".mkv");
\r
817 destination = destination.Replace(".ogm", ".mkv");
\r
818 text_destination.Text = destination;
\r
824 private void mnu_ProgramDefaultOptions_Click(object sender, EventArgs e)
\r
827 Properties.Settings.Default.DVDSource = text_source.Text;
\r
828 Properties.Settings.Default.DVDTitle = drp_dvdtitle.Text;
\r
829 Properties.Settings.Default.ChapterStart = drop_chapterStart.Text;
\r
830 Properties.Settings.Default.ChapterFinish = drop_chapterFinish.Text;
\r
832 Properties.Settings.Default.VideoDest = text_destination.Text;
\r
833 Properties.Settings.Default.VideoEncoder = drp_videoEncoder.Text;
\r
834 Properties.Settings.Default.AudioEncoder = drp_audioCodec.Text;
\r
835 Properties.Settings.Default.Width = text_width.Text;
\r
836 Properties.Settings.Default.Height = text_height.Text;
\r
837 //Picture Settings Tab
\r
838 Properties.Settings.Default.CroppingOption = drp_crop.Text;
\r
839 Properties.Settings.Default.CropTop = text_top.Text;
\r
840 Properties.Settings.Default.CropBottom = text_bottom.Text;
\r
841 Properties.Settings.Default.CropLeft = text_left.Text;
\r
842 Properties.Settings.Default.CropRight = text_right.Text;
\r
843 Properties.Settings.Default.Subtitles = drp_subtitle.Text;
\r
844 //Video Settings Tab
\r
845 Properties.Settings.Default.VideoBitrate = text_bitrate.Text;
\r
846 Properties.Settings.Default.VideoFilesize = text_filesize.Text;
\r
847 Properties.Settings.Default.VideoQuality = slider_videoQuality.Value;
\r
848 Properties.Settings.Default.TwoPass = check_2PassEncode.CheckState.ToString();
\r
849 Properties.Settings.Default.DeInterlace = drp_deInterlace_option.Text;
\r
850 Properties.Settings.Default.Grayscale = check_grayscale.CheckState.ToString();
\r
851 Properties.Settings.Default.Framerate = drp_videoFramerate.Text;
\r
852 Properties.Settings.Default.PixelRatio = CheckPixelRatio.CheckState.ToString();
\r
853 Properties.Settings.Default.turboFirstPass = check_turbo.CheckState.ToString();
\r
854 Properties.Settings.Default.largeFile = check_largeFile.CheckState.ToString();
\r
855 Properties.Settings.Default.detelecine = check_detelecine.CheckState.ToString();
\r
856 Properties.Settings.Default.denoise = drp_deNoise.Text;
\r
857 Properties.Settings.Default.deblock = check_deblock.CheckState.ToString();
\r
858 //Audio Settings Tab
\r
859 Properties.Settings.Default.AudioBitrate = drp_audioBitrate.Text;
\r
860 Properties.Settings.Default.AudioSampleRate = drp_audioSampleRate.Text;
\r
861 Properties.Settings.Default.AudioChannels = drp_audioChannels.Text;
\r
863 Properties.Settings.Default.CRF = CheckCRF.CheckState.ToString();
\r
864 Properties.Settings.Default.H264 = rtf_h264advanced.Text;
\r
865 Properties.Settings.Default.Save();
\r
872 private void mnu_wiki_Click(object sender, EventArgs e)
\r
874 Process.Start("http://handbrake.m0k.org/trac");
\r
877 private void mnu_faq_Click(object sender, EventArgs e)
\r
879 Process.Start("http://handbrake.m0k.org/trac/wiki/WindowsGuiFaq");
\r
882 private void mnu_onlineDocs_Click(object sender, EventArgs e)
\r
884 Process.Start("http://handbrake.m0k.org/?page_id=11");
\r
887 private void mnu_homepage_Click(object sender, EventArgs e)
\r
889 Process.Start("http://handbrake.m0k.org");
\r
892 private void mnu_forum_Click(object sender, EventArgs e)
\r
894 Process.Start("http://handbrake.m0k.org/forum");
\r
897 private void mnu_about_Click(object sender, EventArgs e)
\r
899 Form About = new frmAbout();
\r
900 About.ShowDialog();
\r
905 // --------------------------------------------------------------
\r
906 // Buttons on the main Window
\r
907 // --------------------------------------------------------------
\r
910 private void btn_Browse_Click(object sender, EventArgs e)
\r
912 String filename ="";
\r
913 text_source.Text = "";
\r
915 if (RadioDVD.Checked)
\r
917 DVD_Open.ShowDialog();
\r
918 filename = DVD_Open.SelectedPath;
\r
919 if (filename != "")
\r
921 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
922 text_source.Text = filename;
\r
923 frmRD.ShowDialog();
\r
928 ISO_Open.ShowDialog();
\r
929 filename = ISO_Open.FileName;
\r
930 if (filename != "")
\r
932 Form frmRD = new frmReadDVD(filename, this, dvdInfoWindow);
\r
933 text_source.Text = filename;
\r
934 frmRD.ShowDialog();
\r
938 // Check if there was titles in the dvd title dropdown
\r
939 if (filename == "")
\r
941 text_source.Text = "Click 'Browse' to continue";
\r
944 if (drp_dvdtitle.Items.Count == 0)
\r
946 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
950 private void btn_destBrowse_Click(object sender, EventArgs e)
\r
952 // TODO: Need to write some code to check if there is a reasonable amount of disk space left.
\r
954 DVD_Save.ShowDialog();
\r
955 text_destination.Text = DVD_Save.FileName;
\r
957 if (Check_ChapterMarkers.Checked)
\r
959 string destination = text_destination.Text;
\r
960 destination = destination.Replace(".mp4", ".m4v");
\r
961 text_destination.Text = destination;
\r
965 private void btn_h264Clear_Click(object sender, EventArgs e)
\r
967 rtf_h264advanced.Text = "";
\r
970 private void GenerateQuery_Click(object sender, EventArgs e)
\r
972 String query = GenerateTheQuery();
\r
973 QueryEditorText.Text = query;
\r
976 private void btn_ClearQuery_Click(object sender, EventArgs e)
\r
978 QueryEditorText.Text = "";
\r
981 private void btn_queue_Click(object sender, EventArgs e)
\r
983 if (text_destination.Text != "" && text_source.Text != "")
\r
986 if (QueryEditorText.Text == "")
\r
988 query = GenerateTheQuery();
\r
992 query = QueryEditorText.Text;
\r
994 queueWindow.list_queue.Items.Add(query);
\r
995 queueWindow.Show();
\r
999 MessageBox.Show("No Source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1003 private void showQueue()
\r
1005 queueWindow.Show();
\r
1010 //---------------------------------------------------
\r
1011 // Encode / Cancel Buttons
\r
1012 // Encode Progress Text Handler
\r
1013 //---------------------------------------------------
\r
1015 #region Encode/CLI
\r
1017 Functions.CLI process = new Functions.CLI();
\r
1019 private void btn_encode_Click(object sender, EventArgs e)
\r
1021 btn_eCancel.Enabled = true;
\r
1022 String query = "";
\r
1023 lbl_encode.Visible = false;
\r
1025 if (QueryEditorText.Text == "")
\r
1027 query = GenerateTheQuery();
\r
1031 query = QueryEditorText.Text;
\r
1034 ThreadPool.QueueUserWorkItem(procMonitor, query);
\r
1035 lbl_encode.Text = "Encoding Started";
\r
1038 private void btn_eCancel_Click(object sender, EventArgs e)
\r
1040 process.killCLI();
\r
1041 process.setNull();
\r
1042 lbl_encode.Text = "Encoding Canceled";
\r
1045 private void procMonitor(object state)
\r
1047 // Make sure we are not already encoding and if we are then display an error.
\r
1048 if (hbProc != null)
\r
1050 MessageBox.Show("Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1054 hbProc = process.runCli(this, (string)state, false, false, false, false);
\r
1055 MessageBox.Show("The encode process has now started.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
1056 hbProc.WaitForExit();
\r
1061 //*****************************************************************************************
\r
1063 // When the below code is used and standard error is set to true, hbcli is outputing a
\r
1064 // video stream which has mild corruption issues every few seconds.
\r
1065 // Maybe an issue with the Parser cauing the CLI to hickup/pause?
\r
1066 //*****************************************************************************************
\r
1069 /*Parsing.Parser encode = new Parsing.Parser(hbProc.StandardError.BaseStream);
\r
1070 encode.OnEncodeProgress += encode_OnEncodeProgress;
\r
1071 while (!encode.EndOfStream)
\r
1073 encode.ReadLine();
\r
1076 hbProc.WaitForExit();
\r
1077 process.closeCLI();
\r
1085 MessageBox.Show("The encode process has now ended.", "Status", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
\r
1090 private void encode_OnEncodeProgress(object Sender, int CurrentTask, int TaskCount, float PercentComplete, float CurrentFps, float AverageFps, TimeSpan TimeRemaining)
\r
1092 if (this.InvokeRequired)
\r
1094 this.BeginInvoke(new Parsing.EncodeProgressEventHandler(encode_OnEncodeProgress),
\r
1095 new object[] { Sender, CurrentTask, TaskCount, PercentComplete, CurrentFps, AverageFps, TimeRemaining });
\r
1098 lbl_encode.Text = string.Format("Encode Progress: {0}%, FPS: {1}, Avg FPS: {2}, Time Remaining: {3} ", PercentComplete, CurrentFps, AverageFps, TimeRemaining);
\r
1103 //---------------------------------------------------
\r
1104 // Items that require actions on frmMain
\r
1105 //---------------------------------------------------
\r
1107 #region frmMain Actions
\r
1109 private void drop_chapterStart_SelectedIndexChanged(object sender, EventArgs e)
\r
1111 lbl_chptWarn.Visible = false;
\r
1112 QueryEditorText.Text = "";
\r
1113 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1117 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1118 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1120 if (chapterFinish < chapterStart)
\r
1122 lbl_chptWarn.Visible = true;
\r
1123 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1128 lbl_chptWarn.Visible = true;
\r
1129 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1136 private void drop_chapterFinish_SelectedIndexChanged(object sender, EventArgs e)
\r
1138 lbl_chptWarn.Visible = false;
\r
1139 QueryEditorText.Text = "";
\r
1140 if ((drop_chapterFinish.Text != "Auto") && (drop_chapterStart.Text != "Auto"))
\r
1144 int chapterFinish = int.Parse(drop_chapterFinish.Text);
\r
1145 int chapterStart = int.Parse(drop_chapterStart.Text);
\r
1147 if (chapterFinish < chapterStart)
\r
1149 lbl_chptWarn.Visible = true;
\r
1150 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1155 lbl_chptWarn.Visible = true;
\r
1156 lbl_chptWarn.Text = "Invalid Chapter Range!";
\r
1161 private void text_bitrate_TextChanged(object sender, EventArgs e)
\r
1163 text_filesize.Text = "";
\r
1164 slider_videoQuality.Value = 0;
\r
1165 SliderValue.Text = "0%";
\r
1166 CheckCRF.CheckState = CheckState.Unchecked;
\r
1167 CheckCRF.Enabled = false;
\r
1170 private void text_filesize_TextChanged(object sender, EventArgs e)
\r
1172 text_bitrate.Text = "";
\r
1173 slider_videoQuality.Value = 0;
\r
1174 SliderValue.Text = "0%";
\r
1175 CheckCRF.CheckState = CheckState.Unchecked;
\r
1176 CheckCRF.Enabled = false;
\r
1179 private void slider_videoQuality_Scroll(object sender, EventArgs e)
\r
1181 SliderValue.Text = slider_videoQuality.Value.ToString() + "%";
\r
1182 text_bitrate.Text = "";
\r
1183 text_filesize.Text = "";
\r
1184 CheckCRF.Enabled = true;
\r
1187 private void label_h264_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
\r
1189 Process.Start("http://handbrake.m0k.org/trac/wiki/x264Options");
\r
1192 private void text_width_TextChanged(object sender, EventArgs e)
\r
1197 if (CheckPixelRatio.Checked)
\r
1199 text_width.Text = "";
\r
1200 text_width.BackColor = Color.White;
\r
1204 if ((int.Parse(text_width.Text) % 16) != 0)
\r
1206 text_width.BackColor = Color.LightCoral;
\r
1210 text_width.BackColor = Color.LightGreen;
\r
1214 if (lbl_Aspect.Text != "Select a Title")
\r
1216 double height = int.Parse(text_width.Text) / double.Parse(lbl_Aspect.Text);
\r
1217 double mod16 = height % 16;
\r
1218 height = height - mod16;
\r
1220 if (text_width.Text == "")
\r
1222 text_height.Text = "";
\r
1223 text_width.BackColor = Color.White;
\r
1227 text_height.Text = height.ToString();
\r
1233 // No need to throw an error here.
\r
1239 private void text_height_TextChanged(object sender, EventArgs e)
\r
1243 if (text_height.Text != "Auto")
\r
1245 if (CheckPixelRatio.Checked)
\r
1247 text_height.Text = "";
\r
1248 text_width.BackColor = Color.White;
\r
1252 if ((int.Parse(text_height.Text) % 16) != 0)
\r
1254 text_height.BackColor = Color.LightCoral;
\r
1258 text_height.BackColor = Color.LightGreen;
\r
1262 } catch(Exception){
\r
1263 // No need to alert the user.
\r
1267 private void drp_crop_SelectedIndexChanged(object sender, EventArgs e)
\r
1269 if ((string)drp_crop.SelectedItem == "Manual")
\r
1271 text_left.Enabled = true;
\r
1272 text_right.Enabled = true;
\r
1273 text_top.Enabled = true;
\r
1274 text_bottom.Enabled = true;
\r
1277 if ((string)drp_crop.SelectedItem == "Auto Crop")
\r
1279 text_left.Enabled = false;
\r
1280 text_right.Enabled = false;
\r
1281 text_top.Enabled = false;
\r
1282 text_bottom.Enabled = false;
\r
1283 text_left.Text = "";
\r
1284 text_right.Text = "";
\r
1285 text_top.Text = "";
\r
1286 text_bottom.Text = "";
\r
1288 if (lbl_RecomendedCrop.Text != "Select a Title")
\r
1290 string[] temp = new string[4];
\r
1291 temp = lbl_RecomendedCrop.Text.Split('/');
\r
1292 text_left.Text = temp[2];
\r
1293 text_right.Text = temp[3];
\r
1294 text_top.Text = temp[0];
\r
1295 text_bottom.Text = temp[1];
\r
1299 if ((string)drp_crop.SelectedItem == "No Crop")
\r
1301 text_left.Enabled = false;
\r
1302 text_right.Enabled = false;
\r
1303 text_top.Enabled = false;
\r
1304 text_bottom.Enabled = false;
\r
1305 text_left.Text = "0";
\r
1306 text_right.Text = "0";
\r
1307 text_top.Text = "0";
\r
1308 text_bottom.Text = "0";
\r
1313 private void CheckPixelRatio_CheckedChanged(object sender, EventArgs e)
\r
1315 text_width.Text = "";
\r
1316 text_height.Text = "";
\r
1317 text_width.BackColor = Color.White;
\r
1318 text_height.BackColor = Color.White;
\r
1321 private void drp_dvdtitle_Click(object sender, EventArgs e)
\r
1323 if (drp_dvdtitle.Items.Count == 0)
\r
1325 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
1329 private void drp_audioCodec_SelectedIndexChanged(object sender, EventArgs e)
\r
1332 //CLI Audio mixdown Names: mono stereo dpl1 dpl2 6ch
\r
1334 drp_audioMixDown.Items.Clear();
\r
1336 if (drp_audioCodec.Text == "AAC")
\r
1338 drp_audioMixDown.Items.Clear();
\r
1339 drp_audioMixDown.Items.Add("Mono");
\r
1340 drp_audioMixDown.Items.Add("Stereo");
\r
1341 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1342 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1343 drp_audioMixDown.Items.Add("6 Channel Discrete");
\r
1345 drp_audioBitrate.Items.Clear();
\r
1346 drp_audioBitrate.Items.Add("32");
\r
1347 drp_audioBitrate.Items.Add("40");
\r
1348 drp_audioBitrate.Items.Add("48");
\r
1349 drp_audioBitrate.Items.Add("56");
\r
1350 drp_audioBitrate.Items.Add("64");
\r
1351 drp_audioBitrate.Items.Add("80");
\r
1352 drp_audioBitrate.Items.Add("86");
\r
1353 drp_audioBitrate.Items.Add("112");
\r
1354 drp_audioBitrate.Items.Add("128");
\r
1355 drp_audioBitrate.Items.Add("160");
\r
1360 drp_audioMixDown.Items.Clear();
\r
1361 drp_audioMixDown.Items.Add("Stereo");
\r
1362 drp_audioMixDown.Items.Add("Dolby Surround");
\r
1363 drp_audioMixDown.Items.Add("Dolby Pro Logic II");
\r
1365 drp_audioBitrate.Items.Clear();
\r
1366 drp_audioBitrate.Items.Add("32");
\r
1367 drp_audioBitrate.Items.Add("40");
\r
1368 drp_audioBitrate.Items.Add("48");
\r
1369 drp_audioBitrate.Items.Add("56");
\r
1370 drp_audioBitrate.Items.Add("64");
\r
1371 drp_audioBitrate.Items.Add("80");
\r
1372 drp_audioBitrate.Items.Add("86");
\r
1373 drp_audioBitrate.Items.Add("112");
\r
1374 drp_audioBitrate.Items.Add("128");
\r
1375 drp_audioBitrate.Items.Add("160");
\r
1376 drp_audioBitrate.Items.Add("192");
\r
1377 drp_audioBitrate.Items.Add("224");
\r
1378 drp_audioBitrate.Items.Add("256");
\r
1379 drp_audioBitrate.Items.Add("320");
\r
1380 drp_audioBitrate.Items.Add("384");
\r
1384 private void drp_audioMixDown_SelectedIndexChanged(object sender, EventArgs e)
\r
1386 if (drp_audioCodec.Text == "AAC")
\r
1388 if (drp_audioMixDown.Text == "6 Channel Discrete")
\r
1391 drp_audioBitrate.Items.Clear();
\r
1392 drp_audioBitrate.Items.Add("32");
\r
1393 drp_audioBitrate.Items.Add("40");
\r
1394 drp_audioBitrate.Items.Add("48");
\r
1395 drp_audioBitrate.Items.Add("56");
\r
1396 drp_audioBitrate.Items.Add("64");
\r
1397 drp_audioBitrate.Items.Add("80");
\r
1398 drp_audioBitrate.Items.Add("86");
\r
1399 drp_audioBitrate.Items.Add("112");
\r
1400 drp_audioBitrate.Items.Add("128");
\r
1401 drp_audioBitrate.Items.Add("160");
\r
1402 drp_audioBitrate.Items.Add("192");
\r
1403 drp_audioBitrate.Items.Add("224");
\r
1404 drp_audioBitrate.Items.Add("256");
\r
1405 drp_audioBitrate.Items.Add("320");
\r
1406 drp_audioBitrate.Items.Add("384");
\r
1411 private void Check_ChapterMarkers_CheckedChanged(object sender, EventArgs e)
\r
1413 if (Check_ChapterMarkers.Checked)
\r
1415 string destination = text_destination.Text;
\r
1416 destination = destination.Replace(".mp4", ".m4v");
\r
1417 text_destination.Text = destination;
\r
1421 private void check_largeFile_CheckedChanged(object sender, EventArgs e)
\r
1423 if (!text_destination.Text.Contains(".mp4"))
\r
1425 MessageBox.Show("This option is only compatible with the mp4 file container.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1426 check_largeFile.CheckState = CheckState.Unchecked;
\r
1430 private void drp_videoEncoder_SelectedIndexChanged(object sender, EventArgs e)
\r
1432 //Turn off some options which are H.264 only when the user selects a non h.264 encoder
\r
1433 if (!drp_videoEncoder.Text.Contains("H.264"))
\r
1435 check_turbo.CheckState = CheckState.Unchecked;
\r
1436 CheckCRF.CheckState = CheckState.Unchecked;
\r
1437 CheckCRF.Enabled = false;
\r
1438 check_turbo.Enabled = false;
\r
1439 h264Tab.Enabled = false;
\r
1443 CheckCRF.Enabled = true;
\r
1444 check_turbo.Enabled = true;
\r
1445 h264Tab.Enabled = true;
\r
1450 public void setStreamReader(Parsing.DVD dvd)
\r
1452 this.thisDVD = dvd;
\r
1455 private void drp_dvdtitle_SelectedIndexChanged(object sender, EventArgs e)
\r
1457 // Reset some values on the form
\r
1458 lbl_Aspect.Text = "Select a Title";
\r
1459 lbl_RecomendedCrop.Text = "Select a Title";
\r
1460 drop_chapterStart.Items.Clear();
\r
1461 drop_chapterFinish.Items.Clear();
\r
1462 QueryEditorText.Text = "";
\r
1464 // If the dropdown is set to automatic nothing else needs to be done.
\r
1465 // Otheriwse if its not, title data has to be loased from parsing.
\r
1466 if (drp_dvdtitle.Text != "Automatic")
\r
1468 Parsing.Title selectedTitle = drp_dvdtitle.SelectedItem as Parsing.Title;
\r
1470 // Set the Aspect Ratio
\r
1471 lbl_Aspect.Text = selectedTitle.AspectRatio.ToString();
\r
1473 // Set the Recommended Cropping values
\r
1474 lbl_RecomendedCrop.Text = string.Format("{0}/{1}/{2}/{3}", selectedTitle.AutoCropDimensions[0], selectedTitle.AutoCropDimensions[1], selectedTitle.AutoCropDimensions[2], selectedTitle.AutoCropDimensions[3]);
\r
1476 // Populate the Start chapter Dropdown
\r
1477 drop_chapterStart.Items.Clear();
\r
1478 drop_chapterStart.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1479 if (drop_chapterStart.Items.Count > 0)
\r
1481 drop_chapterStart.Text = drop_chapterStart.Items[0].ToString();
\r
1484 // Populate the Final Chapter Dropdown
\r
1485 drop_chapterFinish.Items.Clear();
\r
1486 drop_chapterFinish.Items.AddRange(selectedTitle.Chapters.ToArray());
\r
1487 if (drop_chapterFinish.Items.Count > 0)
\r
1489 drop_chapterFinish.Text = drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString();
\r
1492 // Populate the Audio Channels Dropdown
\r
1493 drp_audioChannels.Items.Clear();
\r
1494 drp_audioChannels.Items.Add("Automatic");
\r
1495 drp_audioChannels.Items.AddRange(selectedTitle.AudioTracks.ToArray());
\r
1496 if (drp_audioChannels.Items.Count > 0)
\r
1498 drp_audioChannels.Text = drp_audioChannels.Items[0].ToString();
\r
1501 // Populate the Subtitles dropdown
\r
1502 drp_subtitle.Items.Clear();
\r
1503 drp_subtitle.Items.Add("None");
\r
1504 drp_subtitle.Items.AddRange(selectedTitle.Subtitles.ToArray());
\r
1505 if (drp_subtitle.Items.Count > 0)
\r
1507 drp_subtitle.Text = drp_subtitle.Items[0].ToString();
\r
1515 * ---------------------------------------------------
\r
1517 * The query Generation function.
\r
1519 * ---------------------------------------------------
\r
1522 #region Program Functions
\r
1524 public string GenerateTheQuery()
\r
1526 string source = text_source.Text;
\r
1527 string dvdTitle = drp_dvdtitle.Text;
\r
1528 string chapterStart = drop_chapterStart.Text;
\r
1529 string chapterFinish = drop_chapterFinish.Text;
\r
1530 int totalChapters = drop_chapterFinish.Items.Count - 1;
\r
1531 string dvdChapter = "";
\r
1534 MessageBox.Show("No Source has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1537 source = " -i " + '"' + source+ '"'; //'"'+
\r
1540 if (dvdTitle == "Automatic")
\r
1544 string[] titleInfo = dvdTitle.Split(' ');
\r
1545 dvdTitle = " -t "+ titleInfo[0];
\r
1548 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
1550 else if (chapterFinish == chapterStart)
\r
1551 dvdChapter = " -c " + chapterStart;
\r
1553 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
1555 string querySource = source+ dvdTitle+ dvdChapter;
\r
1556 // ----------------------------------------------------------------------
\r
1560 string destination = text_destination.Text;
\r
1561 string videoEncoder = drp_videoEncoder.Text;
\r
1562 string audioEncoder = drp_audioCodec.Text;
\r
1563 string width = text_width.Text;
\r
1564 string height = text_height.Text;
\r
1566 if (destination == "")
\r
1567 MessageBox.Show("No destination has been selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1569 destination = " -o " + '"' + destination + '"'; //'"'+
\r
1572 switch (videoEncoder)
\r
1575 videoEncoder = " -e ffmpeg";
\r
1578 videoEncoder = " -e xvid";
\r
1581 videoEncoder = " -e x264";
\r
1583 case "H.264 Baseline 1.3":
\r
1584 videoEncoder = " -e x264b13";
\r
1586 case "H.264 (iPod)":
\r
1587 videoEncoder = " -e x264b30";
\r
1590 videoEncoder = " -e x264";
\r
1594 switch (audioEncoder)
\r
1597 audioEncoder = " -E faac";
\r
1600 audioEncoder = " -E lame";
\r
1603 audioEncoder = " -E vorbis";
\r
1606 audioEncoder = " -E ac3";
\r
1609 audioEncoder = " -E faac";
\r
1614 width = " -w "+ width;
\r
1617 if (height == "Auto")
\r
1621 else if (height != "")
\r
1623 height = " -l " + height;
\r
1627 string queryDestination = destination+ videoEncoder+ audioEncoder+ width+ height;
\r
1628 // ----------------------------------------------------------------------
\r
1630 // Picture Settings Tab
\r
1632 string cropSetting = drp_crop.Text;
\r
1633 string cropTop = text_top.Text;
\r
1634 string cropBottom = text_bottom.Text;
\r
1635 string cropLeft = text_left.Text;
\r
1636 string cropRight = text_right.Text;
\r
1637 string subtitles = drp_subtitle.Text;
\r
1638 string cropOut = "";
\r
1639 string deInterlace_Option = drp_deInterlace_option.Text;
\r
1640 string deinterlace = "";
\r
1641 string grayscale = "";
\r
1642 string pixelRatio = "";
\r
1643 string ChapterMarkers = "";
\r
1644 // Returns Crop Query
\r
1646 if (cropSetting == "Auto Crop")
\r
1648 else if (cropSetting == "No Crop")
\r
1649 cropOut = " --crop 0:0:0:0 ";
\r
1652 if (text_top.Text == "")
\r
1654 if (text_bottom.Text == "")
\r
1656 if (text_left.Text == "")
\r
1658 if (text_right.Text == "")
\r
1661 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
1664 if (subtitles == "None")
\r
1666 else if (subtitles == "")
\r
1671 tempSub = subtitles.Split(' ');
\r
1672 subtitles = " -s "+ tempSub[0];
\r
1675 switch (deInterlace_Option)
\r
1680 case "Origional (Fast)":
\r
1681 deinterlace = " --deinterlace";
\r
1683 case "yadif (Slow)":
\r
1684 deinterlace = " --deinterlace=" + '"' + "1" + '"';
\r
1686 case "yadif + mcdeint (Slower)":
\r
1687 deinterlace = " --deinterlace=" + '"' + "1:-1:1" + '"';
\r
1689 case "yadif + mcdeint (Slowest)":
\r
1690 deinterlace = " --deinterlace=" + '"' + "3:-1:2" + '"';
\r
1693 deinterlace = " --deinterlace=";
\r
1697 if (check_grayscale.Checked)
\r
1698 grayscale = " -g ";
\r
1700 if (CheckPixelRatio.Checked)
\r
1701 pixelRatio = " -p ";
\r
1703 if (Check_ChapterMarkers.Checked)
\r
1704 ChapterMarkers = " -m ";
\r
1706 string queryPictureSettings = cropOut + subtitles + deinterlace + grayscale + pixelRatio + ChapterMarkers;
\r
1707 // ----------------------------------------------------------------------
\r
1709 // Video Settings Tab
\r
1711 string videoBitrate = text_bitrate.Text;
\r
1712 string videoFilesize = text_filesize.Text;
\r
1713 double videoQuality = slider_videoQuality.Value;
\r
1714 string vidQSetting = "";
\r
1715 string twoPassEncoding = "";
\r
1716 string videoFramerate = drp_videoFramerate.Text;
\r
1717 string turboH264 = "";
\r
1718 string largeFile = "";
\r
1719 string deblock = "";
\r
1720 string detelecine = "";
\r
1721 string denoise = "";
\r
1722 string CRF = CheckCRF.CheckState.ToString();
\r
1725 if ((CRF == "Checked"))
\r
1730 if (videoBitrate != "")
\r
1731 videoBitrate = " -b "+ videoBitrate;
\r
1733 if (videoFilesize != "")
\r
1734 videoFilesize = " -S "+ videoFilesize;
\r
1736 // Video Quality Setting
\r
1738 if ((videoQuality == 0))
\r
1742 videoQuality = videoQuality / 100;
\r
1743 if (videoQuality == 1)
\r
1745 vidQSetting = "1.0";
\r
1748 vidQSetting = " -q " + videoQuality.ToString();
\r
1751 if (check_2PassEncode.Checked)
\r
1752 twoPassEncoding = " -2 ";
\r
1754 if (videoFramerate == "Automatic")
\r
1755 videoFramerate = "";
\r
1757 videoFramerate = " -r "+ videoFramerate;
\r
1759 if (check_turbo.Checked)
\r
1760 turboH264 = " -T ";
\r
1762 if (check_largeFile.Checked)
\r
1763 largeFile = " -4 ";
\r
1765 if (check_deblock.Checked)
\r
1766 deblock = " --deblock";
\r
1768 if (check_detelecine.Checked)
\r
1769 detelecine = " --detelecine";
\r
1771 switch (drp_deNoise.Text)
\r
1777 denoise = " --denoise=3:2:3:3";
\r
1780 denoise = " --denoise=7:7:5:5";
\r
1787 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + videoFramerate + turboH264 + largeFile + deblock + detelecine + denoise;
\r
1788 // ----------------------------------------------------------------------
\r
1790 // Audio Settings Tab
\r
1792 string audioBitrate = drp_audioBitrate.Text;
\r
1793 string audioSampleRate = drp_audioSampleRate.Text;
\r
1794 string audioChannels = drp_audioChannels.Text;
\r
1795 string Mixdown = drp_audioMixDown.Text;
\r
1796 string SixChannelAudio = "";
\r
1798 if (audioBitrate != "")
\r
1799 audioBitrate = " -B "+ audioBitrate;
\r
1801 if (audioSampleRate != "")
\r
1802 audioSampleRate = " -R "+ audioSampleRate;
\r
1804 if (audioChannels == "Automatic")
\r
1805 audioChannels = "";
\r
1806 else if (audioChannels == "")
\r
1807 audioChannels = "";
\r
1811 tempSub = audioChannels.Split(' ');
\r
1812 audioChannels = " -a "+ tempSub[0];
\r
1824 Mixdown = "stereo";
\r
1826 case "Dolby Surround":
\r
1829 case "Dolby Pro Logic II":
\r
1832 case "6 Channel Discrete":
\r
1836 Mixdown = "stero";
\r
1840 if (Mixdown != "")
\r
1841 SixChannelAudio = " -6 "+ Mixdown;
\r
1843 SixChannelAudio = "";
\r
1845 string queryAudioSettings = audioBitrate+ audioSampleRate+ audioChannels+ SixChannelAudio;
\r
1846 // ----------------------------------------------------------------------
\r
1851 string h264Advanced = rtf_h264advanced.Text;
\r
1853 if ((h264Advanced == ""))
\r
1854 h264Advanced = "";
\r
1856 h264Advanced = " -x "+ h264Advanced;
\r
1859 string h264Settings = h264Advanced;
\r
1860 // ----------------------------------------------------------------------
\r
1862 // Processors (Program Settings)
\r
1864 string processors = Properties.Settings.Default.Processors;
\r
1865 // Number of Processors Handler
\r
1867 if (processors == "Automatic")
\r
1870 processors = " -C "+ processors+ " ";
\r
1873 string queryAdvancedSettings = processors;
\r
1874 // ----------------------------------------------------------------------
\r
1876 // Verbose option (Program Settings)
\r
1878 string verbose = "";
\r
1879 if (Properties.Settings.Default.verbose == "Checked")
\r
1882 // ----------------------------------------------------------------------
\r
1884 return querySource+ queryDestination+ queryPictureSettings+ queryVideoSettings+ h264Settings+ queryAudioSettings+ queryAdvancedSettings+ verbose;
\r
1890 // This is the END of the road ------------------------------------------------------------------------------
\r