3 This file is part of the HandBrake source code.
\r
4 Homepage: <http://handbrake.fr>.
\r
5 It may be used under the terms of the GNU General Public License. */
\r
8 using System.Collections.Generic;
\r
10 using System.Windows.Forms;
\r
11 using System.Globalization;
\r
13 using System.Drawing;
\r
15 namespace Handbrake.Functions
\r
20 * Checks for updates and returns "true" boolean if one exists.
\r
22 public Boolean updateCheck(Boolean debug)
\r
26 Functions.RssReader rssRead = new Functions.RssReader();
\r
27 string build = rssRead.build();
\r
29 int latest = int.Parse(build);
\r
30 int current = Properties.Settings.Default.hb_build;
\r
31 int skip = Properties.Settings.Default.skipversion;
\r
39 Boolean update = (latest > current);
\r
43 catch (Exception exc)
\r
46 MessageBox.Show("Unable to check for updates, Please try again later. \n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
52 * Function which generates the filename and path automatically based on the Source Name, DVD title and DVD Chapters
\r
54 public void autoName(frmMain mainWindow)
\r
56 if (Properties.Settings.Default.autoNaming == "Checked")
\r
58 if (mainWindow.drp_dvdtitle.Text != "Automatic")
\r
60 string source = mainWindow.text_source.Text;
\r
61 string[] sourceName = source.Split('\\');
\r
62 source = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");
\r
64 string title = mainWindow.drp_dvdtitle.Text;
\r
65 string[] titlesplit = title.Split(' ');
\r
66 title = titlesplit[0];
\r
68 string cs = mainWindow.drop_chapterStart.Text;
\r
69 string cf = mainWindow.drop_chapterFinish.Text;
\r
71 if (title == "Automatic")
\r
82 if (!mainWindow.text_destination.Text.Contains("\\"))
\r
84 string filePath = "";
\r
85 if (Properties.Settings.Default.autoNamePath.Trim() != "")
\r
87 if (Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")
\r
88 filePath = Properties.Settings.Default.autoNamePath + "\\";
\r
90 mainWindow.text_destination.Text = filePath + source + "_T" + title + "_C" + cs + dash + cf + ".mp4";
\r
94 string dest = mainWindow.text_destination.Text;
\r
96 string[] destName = dest.Split('\\');
\r
99 string[] extension = dest.Split('.');
\r
100 string ext = extension[extension.Length - 1];
\r
102 destName[destName.Length - 1] = source + "_T" + title + "_C" + cs + dash + cf + "." + ext;
\r
104 string fullDest = "";
\r
105 foreach (string part in destName)
\r
107 if (fullDest != "")
\r
108 fullDest = fullDest + "\\" + part;
\r
110 fullDest = fullDest + part;
\r
113 mainWindow.text_destination.Text = fullDest;
\r
120 * This function takes in a Query which has been parsed by QueryParser and sets up the GUI.
\r
122 public void presetLoader(frmMain mainWindow, Functions.QueryParser presetQuery, string name)
\r
124 // ---------------------------
\r
126 // ---------------------------
\r
130 // Reset some vaules to stock first to prevent errors.
\r
131 mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
\r
133 // Now load all the new settings onto the main window
\r
134 if (presetQuery.Source != "")
\r
135 mainWindow.text_source.Text = presetQuery.Source;
\r
137 if (presetQuery.DVDTitle != 0)
\r
138 mainWindow.drp_dvdtitle.Text = presetQuery.DVDTitle.ToString();
\r
140 if (presetQuery.DVDChapterStart != 0)
\r
141 mainWindow.drop_chapterStart.Text = presetQuery.DVDChapterStart.ToString();
\r
143 if (presetQuery.DVDChapterFinish != 0)
\r
144 mainWindow.drop_chapterFinish.Text = presetQuery.DVDChapterFinish.ToString();
\r
146 if (presetQuery.Format != null)
\r
148 string destination = mainWindow.text_destination.Text;
\r
149 destination = destination.Replace(".mp4", "." + presetQuery.Format);
\r
150 destination = destination.Replace(".m4v", "." + presetQuery.Format);
\r
151 destination = destination.Replace(".avi", "." + presetQuery.Format);
\r
152 destination = destination.Replace(".mkv", "." + presetQuery.Format);
\r
153 destination = destination.Replace(".ogm", "." + presetQuery.Format);
\r
154 mainWindow.text_destination.Text = destination;
\r
160 #region destination
\r
162 if (presetQuery.Destination != "")
\r
163 mainWindow.text_destination.Text = presetQuery.Destination;
\r
165 mainWindow.drp_videoEncoder.Text = presetQuery.VideoEncoder;
\r
167 if (presetQuery.IpodAtom == true)
\r
168 mainWindow.check_iPodAtom.CheckState = CheckState.Checked;
\r
170 mainWindow.check_iPodAtom.CheckState = CheckState.Unchecked;
\r
172 if (presetQuery.OptimizeMP4 == true)
\r
173 mainWindow.check_optimiseMP4.CheckState = CheckState.Checked;
\r
175 mainWindow.check_optimiseMP4.CheckState = CheckState.Unchecked;
\r
179 // Picture Settings Tab
\r
181 mainWindow.drp_crop.SelectedIndex = 1;
\r
182 mainWindow.text_top.Text = presetQuery.CropTop;
\r
183 mainWindow.text_bottom.Text = presetQuery.CropBottom;
\r
184 mainWindow.text_left.Text = presetQuery.CropLeft;
\r
185 mainWindow.text_right.Text = presetQuery.CropRight;
\r
187 mainWindow.drp_deInterlace_option.Text = presetQuery.DeInterlace;
\r
188 mainWindow.drp_deNoise.Text = presetQuery.DeNoise;
\r
190 if (presetQuery.DeTelecine == true)
\r
191 mainWindow.check_detelecine.CheckState = CheckState.Checked;
\r
193 mainWindow.check_detelecine.CheckState = CheckState.Unchecked;
\r
196 if (presetQuery.DeBlock == true)
\r
197 mainWindow.check_deblock.CheckState = CheckState.Checked;
\r
199 mainWindow.check_deblock.CheckState = CheckState.Unchecked;
\r
202 if (presetQuery.Anamorphic == true)
\r
203 mainWindow.drp_anamorphic.SelectedIndex = 1;
\r
205 mainWindow.drp_anamorphic.SelectedIndex = 0;
\r
207 if (presetQuery.LooseAnamorphic == true)
\r
208 mainWindow.drp_anamorphic.SelectedIndex = 2;
\r
211 if (presetQuery.Anamorphic != true)
\r
212 mainWindow.drp_anamorphic.SelectedIndex = 0;
\r
216 if (presetQuery.Width != 0)
\r
217 mainWindow.text_width.Text = presetQuery.Width.ToString();
\r
220 mainWindow.text_width.Text = "";
\r
223 if (presetQuery.Height != 0)
\r
224 mainWindow.text_height.Text = presetQuery.Height.ToString();
\r
227 mainWindow.text_height.Text = "";
\r
230 if (presetQuery.VFR == true)
\r
231 mainWindow.check_vfr.CheckState = CheckState.Checked;
\r
233 mainWindow.check_vfr.CheckState = CheckState.Unchecked;
\r
236 // Video Settings Tab
\r
238 mainWindow.text_bitrate.Text = presetQuery.AverageVideoBitrate;
\r
239 mainWindow.text_filesize.Text = presetQuery.VideoTargetSize;
\r
240 mainWindow.slider_videoQuality.Value = presetQuery.VideoQuality;
\r
241 if (mainWindow.slider_videoQuality.Value != 0)
\r
243 int ql = presetQuery.VideoQuality;
\r
244 mainWindow.SliderValue.Text = ql.ToString() + "%";
\r
247 if (presetQuery.TwoPass == true)
\r
248 mainWindow.check_2PassEncode.CheckState = CheckState.Checked;
\r
250 mainWindow.check_2PassEncode.CheckState = CheckState.Unchecked;
\r
252 if (presetQuery.Grayscale == true)
\r
253 mainWindow.check_grayscale.CheckState = CheckState.Checked;
\r
255 mainWindow.check_grayscale.CheckState = CheckState.Unchecked;
\r
257 mainWindow.drp_videoFramerate.Text = presetQuery.VideoFramerate;
\r
259 if (presetQuery.TurboFirstPass == true)
\r
260 mainWindow.check_turbo.CheckState = CheckState.Checked;
\r
262 mainWindow.check_turbo.CheckState = CheckState.Unchecked;
\r
264 if (presetQuery.LargeMP4 == true)
\r
265 mainWindow.check_largeFile.CheckState = CheckState.Checked;
\r
268 mainWindow.check_largeFile.CheckState = CheckState.Unchecked;
\r
269 mainWindow.check_largeFile.BackColor = Color.Transparent;
\r
276 // Chapter Markers Tab
\r
277 #region Chapter Markers
\r
279 if (presetQuery.ChapterMarkers == true)
\r
281 mainWindow.Check_ChapterMarkers.CheckState = CheckState.Checked;
\r
282 mainWindow.text_destination.Text = mainWindow.text_destination.Text.Replace(".mp4", ".m4v");
\r
285 mainWindow.Check_ChapterMarkers.CheckState = CheckState.Unchecked;
\r
289 // Audio Settings Tab
\r
292 if (presetQuery.AudioTrack1 == "")
\r
293 mainWindow.drp_track1Audio.Text = "Automatic";
\r
295 mainWindow.drp_track1Audio.Text = presetQuery.AudioTrack1;
\r
297 if (presetQuery.AudioTrack2 == "None")
\r
299 mainWindow.drp_track2Audio.SelectedIndex = 0;
\r
300 mainWindow.drp_audsr_2.Enabled = false;
\r
301 mainWindow.drp_audmix_2.Enabled = false;
\r
302 mainWindow.drp_audenc_2.Enabled = false;
\r
303 mainWindow.drp_audbit_2.Enabled = false;
\r
307 mainWindow.drp_track2Audio.Text = presetQuery.AudioTrack2;
\r
308 mainWindow.drp_audsr_2.Enabled = true;
\r
309 mainWindow.drp_audmix_2.Enabled = true;
\r
310 mainWindow.drp_audenc_2.Enabled = true;
\r
311 mainWindow.drp_audbit_2.Enabled = true;
\r
314 if (presetQuery.AudioTrack3 == "None")
\r
316 mainWindow.drp_track3Audio.SelectedIndex = 0;
\r
317 mainWindow.drp_audsr_3.Enabled = false;
\r
318 mainWindow.drp_audmix_3.Enabled = false;
\r
319 mainWindow.drp_audenc_3.Enabled = false;
\r
320 mainWindow.drp_audbit_3.Enabled = false;
\r
325 mainWindow.drp_track3Audio.Text = presetQuery.AudioTrack3;
\r
326 mainWindow.drp_audsr_3.Enabled = true;
\r
327 mainWindow.drp_audmix_3.Enabled = true;
\r
328 mainWindow.drp_audenc_3.Enabled = true;
\r
329 mainWindow.drp_audbit_3.Enabled = true;
\r
332 if (presetQuery.AudioTrack4 == "None")
\r
334 mainWindow.drp_track4Audio.SelectedIndex = 0;
\r
335 mainWindow.drp_audsr_4.Enabled = false;
\r
336 mainWindow.drp_audmix_4.Enabled = false;
\r
337 mainWindow.drp_audenc_4.Enabled = false;
\r
338 mainWindow.drp_audbit_4.Enabled = false;
\r
342 mainWindow.drp_track4Audio.Text = presetQuery.AudioTrack4;
\r
343 mainWindow.drp_audsr_4.Enabled = true;
\r
344 mainWindow.drp_audmix_4.Enabled = true;
\r
345 mainWindow.drp_audenc_4.Enabled = true;
\r
346 mainWindow.drp_audbit_4.Enabled = true;
\r
349 if (presetQuery.AudioEncoder1 != null)
\r
350 mainWindow.drp_audenc_1.Text = presetQuery.AudioEncoder1;
\r
351 mainWindow.drp_audenc_2.Text = presetQuery.AudioEncoder2;
\r
352 mainWindow.drp_audenc_3.Text = presetQuery.AudioEncoder3;
\r
353 mainWindow.drp_audenc_4.Text = presetQuery.AudioEncoder4;
\r
355 if (presetQuery.AudioBitrate1 != null)
\r
356 mainWindow.drp_audbit_1.Text = presetQuery.AudioBitrate1;
\r
357 mainWindow.drp_audbit_2.Text = presetQuery.AudioBitrate2;
\r
358 mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
\r
359 mainWindow.drp_audbit_3.Text = presetQuery.AudioBitrate4;
\r
361 if (presetQuery.AudioSamplerate1 != null)
\r
362 mainWindow.drp_audsr_1.Text = presetQuery.AudioSamplerate1;
\r
363 mainWindow.drp_audsr_2.Text = presetQuery.AudioSamplerate2;
\r
364 mainWindow.drp_audsr_3.Text = presetQuery.AudioSamplerate3;
\r
365 mainWindow.drp_audsr_4.Text = presetQuery.AudioSamplerate4;
\r
367 mainWindow.drp_audmix_1.Text = presetQuery.AudioTrackMix1;
\r
368 mainWindow.drp_audmix_2.Text = presetQuery.AudioTrackMix2;
\r
369 mainWindow.drp_audmix_3.Text = presetQuery.AudioTrackMix3;
\r
370 mainWindow.drp_audmix_4.Text = presetQuery.AudioTrackMix4;
\r
373 // Dynamic Range Compression (Should be a float but we use double for ease)
\r
375 double actualValue = 0;
\r
377 value = presetQuery.DRC1;
\r
379 value = value - 10;
\r
380 mainWindow.trackBar1.Value = int.Parse(value.ToString());
\r
381 actualValue = presetQuery.DRC1 / 10;
\r
382 mainWindow.lbl_drc1.Text = actualValue.ToString();
\r
384 value = presetQuery.DRC2;
\r
386 value = value - 10;
\r
387 mainWindow.trackBar2.Value = int.Parse(value.ToString());
\r
388 actualValue = presetQuery.DRC2 / 10;
\r
389 mainWindow.lbl_drc2.Text = actualValue.ToString();
\r
391 value = presetQuery.DRC3;
\r
393 value = value - 10;
\r
394 mainWindow.trackBar3.Value = int.Parse(value.ToString());
\r
395 actualValue = presetQuery.DRC3 / 10;
\r
396 mainWindow.lbl_drc3.Text = actualValue.ToString();
\r
398 value = presetQuery.DRC4;
\r
400 value = value - 10;
\r
401 mainWindow.trackBar4.Value = int.Parse(value.ToString());
\r
402 actualValue = presetQuery.DRC4 / 10;
\r
403 mainWindow.lbl_drc4.Text = actualValue.ToString();
\r
407 mainWindow.drp_subtitle.Text = presetQuery.Subtitles;
\r
409 if (presetQuery.ForcedSubtitles == true)
\r
411 mainWindow.check_forced.CheckState = CheckState.Checked;
\r
412 mainWindow.check_forced.Enabled = true;
\r
415 mainWindow.check_forced.CheckState = CheckState.Unchecked;
\r
420 // H264 Tab & Preset Name
\r
422 mainWindow.rtf_x264Query.Text = presetQuery.H264Query;
\r
424 // Set the preset name
\r
425 mainWindow.groupBox_output.Text = "Output Settings (Preset: " + name + ")";
\r
430 * This takes all the widgets on frmMain
\r
432 public string GenerateTheQuery(frmMain mainWindow)
\r
437 string source = mainWindow.text_source.Text;
\r
438 string dvdTitle = mainWindow.drp_dvdtitle.Text;
\r
439 string chapterStart = mainWindow.drop_chapterStart.Text;
\r
440 string chapterFinish = mainWindow.drop_chapterFinish.Text;
\r
441 int totalChapters = mainWindow.drop_chapterFinish.Items.Count - 1;
\r
442 string dvdChapter = "";
\r
444 if ((source != "") && (source.Trim() != "Click 'Browse' to continue"))
\r
445 source = " -i " + '"' + source + '"';
\r
449 if (dvdTitle == "Automatic")
\r
453 string[] titleInfo = dvdTitle.Split(' ');
\r
454 dvdTitle = " -t " + titleInfo[0];
\r
457 if (chapterFinish.Equals("Auto") && chapterStart.Equals("Auto"))
\r
459 else if (chapterFinish == chapterStart)
\r
460 dvdChapter = " -c " + chapterStart;
\r
462 dvdChapter = " -c " + chapterStart + "-" + chapterFinish;
\r
464 string querySource = source + dvdTitle + dvdChapter;
\r
468 #region Destination
\r
470 string destination = mainWindow.text_destination.Text;
\r
471 string videoEncoder = mainWindow.drp_videoEncoder.Text;
\r
472 string width = mainWindow.text_width.Text;
\r
473 string height = mainWindow.text_height.Text;
\r
475 if (destination != "")
\r
476 destination = " -o " + '"' + destination + '"'; //'"'+
\r
479 switch (videoEncoder)
\r
482 videoEncoder = " -e ffmpeg";
\r
485 videoEncoder = " -e xvid";
\r
488 videoEncoder = " -e x264";
\r
490 case "H.264 (iPod)":
\r
491 videoEncoder = " -e x264b30";
\r
494 videoEncoder = " -e x264";
\r
499 width = " -w " + width;
\r
502 if (height == "Auto")
\r
506 else if (height != "")
\r
508 height = " -l " + height;
\r
512 string queryDestination = destination + videoEncoder + width + height;
\r
515 // Picture Settings Tab
\r
516 #region Picture Settings Tab
\r
518 string cropSetting = mainWindow.drp_crop.Text;
\r
519 string cropTop = mainWindow.text_top.Text;
\r
520 string cropBottom = mainWindow.text_bottom.Text;
\r
521 string cropLeft = mainWindow.text_left.Text;
\r
522 string cropRight = mainWindow.text_right.Text;
\r
523 string cropOut = "";
\r
524 string deInterlace_Option = mainWindow.drp_deInterlace_option.Text;
\r
525 string deinterlace = "";
\r
526 string grayscale = "";
\r
527 string pixelRatio = "";
\r
529 string deblock = "";
\r
530 string detelecine = "";
\r
531 string lanamorphic = "";
\r
535 if (cropSetting == "Automatic")
\r
537 else if (cropSetting == "No Crop")
\r
538 cropOut = " --crop 0:0:0:0 ";
\r
541 if ((mainWindow.text_top.Text == "") && (mainWindow.text_bottom.Text == "") && (mainWindow.text_left.Text == "") && (mainWindow.text_right.Text == ""))
\r
545 if (mainWindow.text_top.Text == "")
\r
547 if (mainWindow.text_bottom.Text == "")
\r
549 if (mainWindow.text_left.Text == "")
\r
551 if (mainWindow.text_right.Text == "")
\r
554 cropOut = " --crop " + cropTop + ":" + cropBottom + ":" + cropLeft + ":" + cropRight;
\r
558 switch (deInterlace_Option)
\r
564 deinterlace = " --deinterlace=\"fast\"";
\r
567 deinterlace = " --deinterlace=\"slow\"";
\r
570 deinterlace = " --deinterlace=\"slower\"";
\r
573 deinterlace = " --deinterlace=\"slowest\"";
\r
580 if (mainWindow.check_grayscale.Checked)
\r
581 grayscale = " -g ";
\r
583 if (mainWindow.drp_anamorphic.SelectedIndex == 1)
\r
584 pixelRatio = " -p ";
\r
585 else if (mainWindow.drp_anamorphic.SelectedIndex == 2)
\r
586 pixelRatio = " -P ";
\r
591 if (mainWindow.check_deblock.Checked)
\r
592 deblock = " --deblock";
\r
594 if (mainWindow.check_detelecine.Checked)
\r
595 detelecine = " --detelecine";
\r
597 if (mainWindow.check_vfr.Checked)
\r
602 string queryPictureSettings = cropOut + deinterlace + deblock + detelecine + vfr + grayscale + pixelRatio + lanamorphic;
\r
605 // Video Settings Tab
\r
606 #region Video Settings Tab
\r
608 string videoBitrate = mainWindow.text_bitrate.Text;
\r
609 string videoFilesize = mainWindow.text_filesize.Text;
\r
610 double videoQuality = mainWindow.slider_videoQuality.Value;
\r
611 string vidQSetting = "";
\r
612 string twoPassEncoding = "";
\r
613 string videoFramerate = mainWindow.drp_videoFramerate.Text;
\r
614 string vid_frame_rate = "";
\r
615 string turboH264 = "";
\r
616 string largeFile = "";
\r
617 string denoise = "";
\r
618 string ipodAtom = "";
\r
619 string optimizeMP4 = "";
\r
621 if (videoBitrate != "")
\r
622 videoBitrate = " -b " + videoBitrate;
\r
624 if (videoFilesize != "")
\r
625 videoFilesize = " -S " + videoFilesize;
\r
627 // Video Quality Setting
\r
629 if ((videoQuality == 0))
\r
633 videoQuality = videoQuality / 100;
\r
634 if (videoQuality == 1)
\r
636 vidQSetting = "1.0";
\r
638 vidQSetting = " -q " + videoQuality.ToString(new CultureInfo("en-US"));
\r
641 if (mainWindow.check_2PassEncode.Checked)
\r
642 twoPassEncoding = " -2 ";
\r
644 if (videoFramerate == "Same as source")
\r
645 vid_frame_rate = "";
\r
648 if (!mainWindow.check_vfr.Checked)
\r
649 vid_frame_rate = " -r " + videoFramerate;
\r
652 if (mainWindow.check_turbo.Checked)
\r
653 turboH264 = " -T ";
\r
655 if (mainWindow.check_largeFile.Checked)
\r
656 largeFile = " -4 ";
\r
659 switch (mainWindow.drp_deNoise.Text)
\r
665 denoise = " --denoise=\"weak\"";
\r
668 denoise = " --denoise=\"medium\"";
\r
671 denoise = " --denoise=\"strong\"";
\r
678 if (mainWindow.check_iPodAtom.Checked)
\r
681 if (mainWindow.check_optimiseMP4.Checked)
\r
682 optimizeMP4 = " -O ";
\r
685 string queryVideoSettings = videoBitrate + videoFilesize + vidQSetting + twoPassEncoding + vid_frame_rate + turboH264 + ipodAtom + optimizeMP4 + largeFile + denoise;
\r
688 // Audio Settings Tab
\r
689 #region Audio Settings Tab
\r
692 string tracks = "";
\r
693 string aencoder = "";
\r
694 string audioBitrate = "";
\r
695 string audioSampleRate = "";
\r
696 string Mixdown = "";
\r
698 string subScan = "";
\r
699 string forced = "";
\r
702 string track1 = mainWindow.drp_track1Audio.Text;
\r
703 string aencoder1 = mainWindow.drp_audenc_1.Text;
\r
704 string audioBitrate1 = mainWindow.drp_audbit_1.Text;
\r
705 string audioSampleRate1 = mainWindow.drp_audsr_1.Text;
\r
706 string Mixdown1 = mainWindow.drp_audmix_1.Text;
\r
707 string drc1 = mainWindow.trackBar1.Value.ToString();
\r
710 string track2 = mainWindow.drp_track2Audio.Text;
\r
711 string aencoder2 = mainWindow.drp_audenc_2.Text;
\r
712 string audioBitrate2 = mainWindow.drp_audbit_2.Text;
\r
713 string audioSampleRate2 = mainWindow.drp_audsr_2.Text;
\r
714 string Mixdown2 = mainWindow.drp_audmix_2.Text;
\r
715 string drc2 = mainWindow.trackBar2.Value.ToString();
\r
718 string track3 = mainWindow.drp_track3Audio.Text;
\r
719 string aencoder3 = mainWindow.drp_audenc_3.Text;
\r
720 string audioBitrate3 = mainWindow.drp_audbit_3.Text;
\r
721 string audioSampleRate3 = mainWindow.drp_audsr_3.Text;
\r
722 string Mixdown3 = mainWindow.drp_audmix_3.Text;
\r
723 string drc3 = mainWindow.trackBar3.Value.ToString();
\r
726 string track4 = mainWindow.drp_track4Audio.Text;
\r
727 string aencoder4 = mainWindow.drp_audenc_4.Text;
\r
728 string audioBitrate4 = mainWindow.drp_audbit_4.Text;
\r
729 string audioSampleRate4 = mainWindow.drp_audsr_4.Text;
\r
730 string Mixdown4 = mainWindow.drp_audmix_4.Text;
\r
731 string drc4 = mainWindow.trackBar4.Value.ToString();
\r
735 // Audio Track Selections
\r
737 if (track1 == "Automatic")
\r
738 tracks = " -a auto";
\r
739 else if (track1 == "")
\r
741 else if (track1 == "None")
\r
745 string[] tempSub = track1.Split(' ');
\r
746 tracks = " -a " + tempSub[0];
\r
749 if (track2 != "None")
\r
752 tempSub = track2.Split(' ');
\r
754 tracks = " -a none," + tempSub[0];
\r
756 tracks = tracks + "," + tempSub[0];
\r
759 if (track3 != "None")
\r
762 tempSub = track3.Split(' ');
\r
764 tracks = " -a none,none," + tempSub[0];
\r
766 tracks = tracks + "," + tempSub[0];
\r
769 if (track4 != "None")
\r
772 tempSub = track4.Split(' ');
\r
774 tracks = " -a none,none,none," + tempSub[0];
\r
776 tracks = tracks + "," + tempSub[0];
\r
782 if (aencoder1 != "")
\r
783 aencoder = " -E " + getAudioEncoder(aencoder1);
\r
785 if (aencoder2 != "")
\r
787 if (aencoder == "")
\r
788 aencoder = " -E faac," + getAudioEncoder(aencoder2);
\r
790 aencoder = aencoder + "," + getAudioEncoder(aencoder2);
\r
793 if (aencoder3 != "")
\r
795 if (aencoder == "")
\r
796 aencoder = " -E faac,faac," + getAudioEncoder(aencoder3);
\r
798 aencoder = aencoder + "," + getAudioEncoder(aencoder3);
\r
801 if (aencoder4 != "")
\r
803 if (aencoder == "")
\r
804 aencoder = " -E faac,faac,faac," + getAudioEncoder(aencoder4);
\r
806 aencoder = aencoder + "," + getAudioEncoder(aencoder4);
\r
810 // Audio Bitrate Selections
\r
812 if (audioBitrate1 != "")
\r
813 audioBitrate = " -B " + audioBitrate1;
\r
815 if (audioBitrate2 != "")
\r
817 if (audioBitrate == "")
\r
818 audioBitrate = " -B 160," + audioBitrate2;
\r
820 audioBitrate = audioBitrate + "," + audioBitrate2;
\r
823 if (audioBitrate3 != "")
\r
825 if (audioBitrate == "")
\r
826 audioBitrate = " -B 160,160," + audioBitrate3;
\r
828 audioBitrate = audioBitrate + "," + audioBitrate3;
\r
831 if (audioBitrate4 != "")
\r
833 if (audioBitrate == "")
\r
834 audioBitrate = " -B 160,160,160," + audioBitrate4;
\r
836 audioBitrate = audioBitrate + "," + audioBitrate4;
\r
839 //Audio Sample Rate - audioSampleRate
\r
841 if (audioSampleRate1 != "")
\r
842 audioSampleRate = " -R " + audioSampleRate1;
\r
844 if (audioSampleRate2 != "")
\r
846 if (audioSampleRate == "")
\r
847 audioSampleRate = " -R 48," + audioSampleRate2;
\r
849 audioSampleRate = audioSampleRate + "," + audioSampleRate2;
\r
852 if (audioSampleRate3 != "")
\r
854 if (audioSampleRate == "")
\r
855 audioSampleRate = " -R 48,48," + audioSampleRate3;
\r
857 audioSampleRate = audioSampleRate + "," + audioSampleRate3;
\r
860 if (audioSampleRate4 != "")
\r
862 if (audioSampleRate == "")
\r
863 audioSampleRate = " -R 48,48,48," + audioSampleRate4;
\r
865 audioSampleRate = audioSampleRate + "," + audioSampleRate4;
\r
869 // Audio Mixdown Selections
\r
872 if ((Mixdown1 != "") && (Mixdown1 != "Automatic"))
\r
873 Mixdown = " -6 " + getMixDown(Mixdown1);
\r
875 if ((Mixdown2 != "") && (Mixdown2 != "Automatic"))
\r
878 Mixdown = Mixdown + "," + getMixDown(Mixdown2);
\r
881 if ((Mixdown3 != "") && (Mixdown3 != "Automatic"))
\r
884 Mixdown = Mixdown + "," + getMixDown(Mixdown3);
\r
887 if ((Mixdown4 != "") && (Mixdown4 != "Automatic"))
\r
890 Mixdown = Mixdown + "," + getMixDown(Mixdown4);
\r
899 value = mainWindow.trackBar1.Value / 10.0;
\r
903 drc = " -D " + value;
\r
905 value = mainWindow.trackBar2.Value / 10.0;
\r
910 drc = " -D 1," + value;
\r
912 drc = drc + "," + value;
\r
915 value = mainWindow.trackBar3.Value / 10.0;
\r
920 drc = " -D 1,1," + value;
\r
922 drc = drc + "," + value;
\r
925 value = mainWindow.trackBar4.Value / 10.0;
\r
930 drc = " -D 1,1,1," + value;
\r
932 drc = drc + "," + value;
\r
937 string subtitles = mainWindow.drp_subtitle.Text;
\r
938 if (subtitles == "None")
\r
940 else if (subtitles == "")
\r
942 else if (subtitles == "Autoselect")
\r
950 tempSub = subtitles.Split(' ');
\r
951 subtitles = " -s " + tempSub[0];
\r
954 if (mainWindow.check_forced.Checked)
\r
958 string queryAudioSettings = tracks + aencoder + audioBitrate + audioSampleRate + Mixdown + drc + subScan + subtitles + forced;
\r
962 // Chapter Markers Tab
\r
963 #region Chapter Markers
\r
965 string ChapterMarkers = "";
\r
967 // Attach Source name and dvd title to the start of the chapters.csv filename.
\r
968 // This is for the queue. It allows different chapter name files for each title.
\r
969 string source_name = mainWindow.text_source.Text;
\r
970 string[] sourceName = source.Split('\\');
\r
971 source_name = sourceName[sourceName.Length - 1].Replace(".iso", "").Replace(".mpg", "").Replace(".ts", "").Replace(".ps", "");
\r
972 source_name = source_name.Replace("\"", "");
\r
974 string source_title = mainWindow.drp_dvdtitle.Text;
\r
975 string[] titlesplit = source_title.Split(' ');
\r
976 source_title = titlesplit[0];
\r
978 if (mainWindow.Check_ChapterMarkers.Checked)
\r
981 if ((source_name.Trim().Replace("-i ", "") != "Click 'Browse' to continue") && (source_name.Trim().Replace("-i ", "") != ""))
\r
983 if (source_title != "Automatic")
\r
985 string filename = source_name + "-" + source_title + "-chapters.csv";
\r
986 string path = Path.Combine(Path.GetTempPath(), filename);
\r
988 Boolean saveCSV = chapterCSVSave(mainWindow, path);
\r
989 if (saveCSV == false)
\r
990 ChapterMarkers = " -m ";
\r
993 ChapterMarkers = " --markers=" + "\"" + path + "\"";
\r
998 string filename = source_name + "-chapters.csv";
\r
999 string path = Path.Combine(Path.GetTempPath(), filename);
\r
1001 Boolean saveCSV = chapterCSVSave(mainWindow, path);
\r
1002 if (saveCSV == false)
\r
1003 ChapterMarkers = " -m ";
\r
1006 ChapterMarkers = " --markers=" + "\"" + path + "\"";
\r
1012 string path = Path.Combine(Path.GetTempPath(), "chapters.csv");
\r
1013 ChapterMarkers = " --markers=" + "\"" + path + "\"";
\r
1017 string chapter_markers = ChapterMarkers;
\r
1023 string h264Advanced = mainWindow.rtf_x264Query.Text;
\r
1025 if ((h264Advanced == ""))
\r
1026 h264Advanced = "";
\r
1028 h264Advanced = " -x " + h264Advanced;
\r
1031 string h264Settings = h264Advanced;
\r
1035 #region Processors / Other
\r
1037 string processors = Properties.Settings.Default.Processors;
\r
1038 // Number of Processors Handler
\r
1040 if (processors == "Automatic")
\r
1043 processors = " -C " + processors + " ";
\r
1046 string queryAdvancedSettings = processors;
\r
1048 string verbose = " -v ";
\r
1051 return querySource + queryDestination + queryPictureSettings + queryVideoSettings + h264Settings + queryAudioSettings + ChapterMarkers + queryAdvancedSettings + verbose;
\r
1055 * Set's up the DataGridView on the Chapters tab (frmMain)
\r
1057 public void chapterNaming(frmMain mainWindow)
\r
1061 mainWindow.data_chpt.Rows.Clear();
\r
1066 if (mainWindow.drop_chapterFinish.Text != "Auto")
\r
1067 finish = int.Parse(mainWindow.drop_chapterFinish.Text);
\r
1069 if (mainWindow.drop_chapterStart.Text != "Auto")
\r
1070 start = int.Parse(mainWindow.drop_chapterStart.Text);
\r
1072 rowCount = finish - (start - 1);
\r
1074 while (i < rowCount)
\r
1076 DataGridViewRow row = new DataGridViewRow();
\r
1078 mainWindow.data_chpt.Rows.Insert(i, row);
\r
1079 mainWindow.data_chpt.Rows[i].Cells[0].Value = (i + 1);
\r
1080 mainWindow.data_chpt.Rows[i].Cells[1].Value = "Chapter " + (i + 1);
\r
1084 catch (Exception exc)
\r
1086 MessageBox.Show("chapterNaming() Error has occured: \n" + exc.ToString());
\r
1091 * This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv in this applications
\r
1092 * running directory.
\r
1094 private Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)
\r
1098 StringBuilder csv = new StringBuilder();
\r
1100 foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)
\r
1102 csv.Append(row.Cells[0].Value.ToString());
\r
1104 csv.Append(row.Cells[1].Value.ToString());
\r
1105 csv.Append(Environment.NewLine);
\r
1107 StreamWriter file = new StreamWriter(file_path_name);
\r
1108 file.Write(csv.ToString());
\r
1114 catch (Exception exc)
\r
1116 MessageBox.Show("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode \n\n" + exc.ToString(), "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
\r
1122 private string getMixDown(string selectedAudio)
\r
1124 switch (selectedAudio)
\r
1132 case "Dolby Surround":
\r
1134 case "Dolby Pro Logic II":
\r
1136 case "6 Channel Discrete":
\r
1143 private string getAudioEncoder(string selectedEncoder)
\r
1145 switch (selectedEncoder)
\r
1161 // End of Functions
\r