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.Text.RegularExpressions;
\r
11 using System.Windows.Forms;
\r
12 using System.Globalization;
\r
14 namespace Handbrake.Functions
\r
18 static readonly private CultureInfo Culture = new CultureInfo("en-US", false);
\r
20 // All the Main Window GUI options
\r
24 private int q_dvdTitle;
\r
26 /// Returns an Integer
\r
27 /// DVD Title number.
\r
33 return this.q_dvdTitle;
\r
37 private int q_chaptersStart;
\r
40 /// DVD Chapter number or chapter range.
\r
42 public int DVDChapterStart
\r
46 return this.q_chaptersStart;
\r
50 private int q_chaptersFinish;
\r
53 /// DVD Chapter number or chapter range.
\r
55 public int DVDChapterFinish
\r
59 return this.q_chaptersFinish;
\r
65 private string q_format;
\r
67 /// Returns a String
\r
68 /// Full path of the destination.
\r
70 public string Format
\r
74 return this.q_format;
\r
78 private string q_videoEncoder;
\r
80 /// Returns an String
\r
81 /// The Video Encoder used.
\r
83 public string VideoEncoder
\r
87 return this.q_videoEncoder;
\r
92 #region Picture Settings
\r
93 private int q_videoWidth;
\r
96 /// The selected Width for the encoding.
\r
102 return this.q_videoWidth;
\r
106 private int q_videoHeight;
\r
109 /// The selected Height for the encoding.
\r
115 return this.q_videoHeight;
\r
119 private int q_maxWidth;
\r
122 /// The selected Width for the encoding.
\r
124 public int MaxWidth
\r
128 return this.q_maxWidth;
\r
132 private int q_maxHeight;
\r
135 /// The selected Height for the encoding.
\r
137 public int MaxHeight
\r
141 return this.q_maxHeight;
\r
145 private string q_cropValues;
\r
147 /// Returns an String
\r
148 /// Cropping values.
\r
150 public string CropValues
\r
154 return this.q_cropValues;
\r
158 private string q_croptop;
\r
160 /// Returns an String
\r
161 /// Cropping values.
\r
163 public string CropTop
\r
167 return this.q_croptop;
\r
171 private string q_cropbottom;
\r
173 /// Returns an String
\r
174 /// Cropping values.
\r
176 public string CropBottom
\r
180 return this.q_cropbottom;
\r
184 private string q_cropLeft;
\r
186 /// Returns an String
\r
187 /// Cropping values.
\r
189 public string CropLeft
\r
193 return this.q_cropLeft;
\r
197 private string q_cropRight;
\r
199 /// Returns an String
\r
200 /// Cropping values.
\r
202 public string CropRight
\r
206 return this.q_cropRight;
\r
210 private Boolean q_detelecine;
\r
212 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
214 public Boolean DeTelecine
\r
218 return this.q_detelecine;
\r
222 private int q_deBlock;
\r
224 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
230 return this.q_deBlock;
\r
234 private string q_deinterlace;
\r
236 /// Returns a string with the De-Interlace option used.
\r
238 public string DeInterlace
\r
242 return this.q_deinterlace;
\r
246 private string q_denoise;
\r
248 /// Returns a string with the DeNoise option used.
\r
250 public string DeNoise
\r
254 return this.q_denoise;
\r
258 private Boolean q_decomb;
\r
260 /// Returns a string with the DeNoise option used.
\r
262 public Boolean Decomb
\r
266 return this.q_decomb;
\r
270 private Boolean q_anamorphic;
\r
272 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
274 public Boolean Anamorphic
\r
278 return this.q_anamorphic;
\r
282 private Boolean q_looseAnamorphic;
\r
284 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
286 public Boolean LooseAnamorphic
\r
290 return this.q_looseAnamorphic;
\r
294 private Boolean q_chapterMarkers;
\r
296 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
298 public Boolean ChapterMarkers
\r
302 return this.q_chapterMarkers;
\r
307 #region Video Settings
\r
308 private Boolean q_grayscale;
\r
310 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
312 public Boolean Grayscale
\r
316 return this.q_grayscale;
\r
320 private Boolean q_twoPass;
\r
322 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
324 public Boolean TwoPass
\r
328 return this.q_twoPass;
\r
332 private Boolean q_turboFirst;
\r
334 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
336 public Boolean TurboFirstPass
\r
340 return this.q_turboFirst;
\r
344 private Boolean q_largeMp4;
\r
346 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
348 public Boolean LargeMP4
\r
352 return this.q_largeMp4;
\r
356 private Boolean q_ipodAtom;
\r
358 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
360 public Boolean IpodAtom
\r
364 return this.q_ipodAtom;
\r
368 private Boolean q_optimizeMp4;
\r
370 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
372 public Boolean OptimizeMP4
\r
376 return this.q_optimizeMp4;
\r
380 private string q_videoFramerate;
\r
382 /// Returns a string with the video Framerate
\r
384 public string VideoFramerate
\r
388 return this.q_videoFramerate;
\r
392 private string q_avgBitrate;
\r
394 /// Returns a string with the average video bitrate
\r
396 public string AverageVideoBitrate
\r
400 return this.q_avgBitrate;
\r
404 private string q_videoTargetSize;
\r
406 /// Returns a string with the video target size
\r
408 public string VideoTargetSize
\r
412 return this.q_videoTargetSize;
\r
416 private int q_videoQuality;
\r
418 /// Returns a int with the video quality value
\r
420 public int VideoQuality
\r
424 return this.q_videoQuality;
\r
430 #region Audio Settings
\r
431 private string q_audioTrack1;
\r
433 /// Returns a string with the selected Audio track
\r
435 public string AudioTrack1
\r
439 return this.q_audioTrack1;
\r
443 private string q_audioTrack2;
\r
445 /// Returns a string with the selected Audio track
\r
447 public string AudioTrack2
\r
451 return this.q_audioTrack2;
\r
455 private string q_audioTrack3;
\r
457 /// Returns a string with the selected Audio track
\r
459 public string AudioTrack3
\r
463 return this.q_audioTrack3;
\r
467 private string q_audioTrack4;
\r
469 /// Returns a string with the selected Audio track
\r
471 public string AudioTrack4
\r
475 return this.q_audioTrack4;
\r
479 private string q_audioTrackMix1;
\r
481 /// Returns a string with the First selected Audio track Mix
\r
483 public string AudioTrackMix1
\r
487 return this.q_audioTrackMix1;
\r
491 private string q_audioTrackMix2;
\r
493 /// Returns a string with the First selected Audio track Mix
\r
495 public string AudioTrackMix2
\r
499 return this.q_audioTrackMix2;
\r
503 private string q_audioTrackMix3;
\r
505 /// Returns a string with the First selected Audio track Mix
\r
507 public string AudioTrackMix3
\r
511 return this.q_audioTrackMix3;
\r
515 private string q_audioTrackMix4;
\r
517 /// Returns a string with the First selected Audio track Mix
\r
519 public string AudioTrackMix4
\r
523 return this.q_audioTrackMix4;
\r
527 private string q_audioEncoder1;
\r
529 /// Returns an String
\r
530 /// The Audio Encoder used.
\r
532 public string AudioEncoder1
\r
536 return this.q_audioEncoder1;
\r
540 private string q_audioEncoder2;
\r
542 /// Returns an String
\r
543 /// The Audio Encoder used.
\r
545 public string AudioEncoder2
\r
549 return this.q_audioEncoder2;
\r
553 private string q_audioEncoder3;
\r
555 /// Returns an String
\r
556 /// The Audio Encoder used.
\r
558 public string AudioEncoder3
\r
562 return this.q_audioEncoder3;
\r
566 private string q_audioEncoder4;
\r
568 /// Returns an String
\r
569 /// The Audio Encoder used.
\r
571 public string AudioEncoder4
\r
575 return this.q_audioEncoder4;
\r
579 private string q_audioBitrate1;
\r
581 /// Returns a string with the audio bitrate
\r
583 public string AudioBitrate1
\r
587 return this.q_audioBitrate1;
\r
591 private string q_audioBitrate2;
\r
593 /// Returns a string with the audio bitrate
\r
595 public string AudioBitrate2
\r
599 return this.q_audioBitrate2;
\r
603 private string q_audioBitrate3;
\r
605 /// Returns a string with the audio bitrate
\r
607 public string AudioBitrate3
\r
611 return this.q_audioBitrate3;
\r
615 private string q_audioBitrate4;
\r
617 /// Returns a string with the audio bitrate
\r
619 public string AudioBitrate4
\r
623 return this.q_audioBitrate4;
\r
627 private string q_audioSamplerate1;
\r
629 /// Returns a string with the audio sample rate
\r
631 public string AudioSamplerate1
\r
635 return this.q_audioSamplerate1;
\r
639 private string q_audioSamplerate2;
\r
641 /// Returns a string with the audio sample rate
\r
643 public string AudioSamplerate2
\r
647 return this.q_audioSamplerate2;
\r
651 private string q_audioSamplerate3;
\r
653 /// Returns a string with the audio sample rate
\r
655 public string AudioSamplerate3
\r
659 return this.q_audioSamplerate3;
\r
663 private string q_audioSamplerate4;
\r
665 /// Returns a string with the audio sample rate
\r
667 public string AudioSamplerate4
\r
671 return this.q_audioSamplerate4;
\r
675 private double q_drc1;
\r
677 /// Returns a string with the selected subtitle track
\r
683 return this.q_drc1;
\r
687 private double q_drc2;
\r
689 /// Returns a string with the selected subtitle track
\r
695 return this.q_drc2;
\r
699 private double q_drc3;
\r
701 /// Returns a string with the selected subtitle track
\r
707 return this.q_drc3;
\r
711 private double q_drc4;
\r
713 /// Returns a string with the selected subtitle track
\r
719 return this.q_drc4;
\r
723 private string q_subtitles;
\r
725 /// Returns a string with the selected subtitle track
\r
727 public string Subtitles
\r
731 return this.q_subtitles;
\r
735 private Boolean q_forcedSubs;
\r
737 /// Returns a string with the selected subtitle track
\r
739 public Boolean ForcedSubtitles
\r
743 return this.q_forcedSubs;
\r
750 private string q_h264;
\r
752 /// Returns a string with the Advanced H264 query string
\r
754 public string H264Query
\r
758 return this.q_h264;
\r
761 private Boolean q_verbose;
\r
763 /// Returns a string with the Advanced H264 query string
\r
765 public Boolean Verbose
\r
769 return this.q_verbose;
\r
777 /// Takes in a query which can be in any order and parses it.
\r
778 /// All varibles are then set so they can be used elsewhere.
\r
780 /// <param name="input">A ClI Query</param>
\r
781 /// <returns>A Parsed Query</returns>
\r
783 public static QueryParser Parse(String input)
\r
785 QueryParser thisQuery = new QueryParser();
\r
787 #region Regular Expressions
\r
788 // Useful Destination Finder
\r
789 //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");
\r
790 //Match source = r1.Match(input.Replace('"', '\"'));
\r
793 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
794 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
795 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
798 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
800 //Picture Settings Tab
\r
801 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
802 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
803 Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
\r
804 Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
\r
805 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z]*)\""");
\r
806 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z]*)\""");
\r
807 Match deblock = Regex.Match(input, @"--deblock=([0-9]*)");
\r
808 Match detelecine = Regex.Match(input, @"--detelecine");
\r
809 Match anamorphic = Regex.Match(input, @" -p ");
\r
810 Match chapterMarkers = Regex.Match(input, @" -m");
\r
811 Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
\r
812 Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
\r
813 Match lanamorphic = Regex.Match(input, @" -P");
\r
814 Match decomb = Regex.Match(input, @" --decomb");
\r
816 //Video Settings Tab
\r
817 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
818 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
819 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
820 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
821 Match twoPass = Regex.Match(input, @" -2");
\r
822 Match turboFirstPass = Regex.Match(input, @" -T");
\r
823 Match grayscale = Regex.Match(input, @" -g");
\r
824 Match largerMp4 = Regex.Match(input, @" -4");
\r
825 Match ipodAtom = Regex.Match(input, @" -I");
\r
826 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
828 //Audio Settings Tab
\r
829 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
830 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
831 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
832 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
834 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
835 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
836 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
837 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
839 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
840 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
841 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
842 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
844 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");
\r
845 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");
\r
846 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
847 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
849 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");
\r
850 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");
\r
851 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
852 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
854 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
855 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
856 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
857 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
859 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
860 Match subScan = Regex.Match(input, @" -U");
\r
861 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
864 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
867 Match verbose = Regex.Match(input, @" -v");
\r
870 #region Set Varibles
\r
874 if (title.Success != false)
\r
875 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
877 if (chapters.Success != false)
\r
879 string[] actTitles = new string[2];
\r
880 actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
881 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
882 if (actTitles.Length > 1)
\r
884 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
887 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
888 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
891 if (format.Success != false)
\r
892 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
896 #region Destination
\r
898 string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
899 switch (videoEncoderConvertion)
\r
902 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
905 videoEncoderConvertion = "MPEG-4 (XviD)";
\r
908 videoEncoderConvertion = "H.264 (x264)";
\r
911 videoEncoderConvertion = "VP3 (Theora)";
\r
914 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
917 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
921 #region Picture Tab
\r
923 if (width.Success != false)
\r
924 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
926 if (height.Success != false)
\r
927 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
929 if (maxWidth.Success != false)
\r
930 thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
\r
932 if (maxHeight.Success != false)
\r
933 thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
\r
935 if (crop.Success != false)
\r
937 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
938 string[] actCropValues = new string[3];
\r
939 actCropValues = thisQuery.q_cropValues.Split(':');
\r
940 thisQuery.q_croptop = actCropValues[0];
\r
941 thisQuery.q_cropbottom = actCropValues[1];
\r
942 thisQuery.q_cropLeft = actCropValues[2];
\r
943 thisQuery.q_cropRight = actCropValues[3];
\r
947 string deblockValue = "";
\r
948 thisQuery.q_deBlock = 0;
\r
949 if (deblock.Success != false)
\r
950 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
952 if (deblockValue != "")
\r
953 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
955 thisQuery.q_detelecine = detelecine.Success;
\r
956 thisQuery.q_decomb = decomb.Success;
\r
958 thisQuery.q_deinterlace = "None";
\r
959 if (deinterlace.Success != false)
\r
961 switch (deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"",""))
\r
964 thisQuery.q_deinterlace = "Fast";
\r
967 thisQuery.q_deinterlace = "Slow";
\r
970 thisQuery.q_deinterlace = "Slower";
\r
973 thisQuery.q_deinterlace = "Slowest";
\r
976 thisQuery.q_deinterlace = "None";
\r
981 thisQuery.q_denoise = "None";
\r
982 if (denoise.Success != false)
\r
984 switch (denoise.ToString().Replace("--denoise=", "").Replace("\"", ""))
\r
987 thisQuery.q_denoise = "Weak";
\r
990 thisQuery.q_denoise = "Medium";
\r
993 thisQuery.q_denoise = "Strong";
\r
996 thisQuery.q_denoise = "None";
\r
1001 thisQuery.q_anamorphic = anamorphic.Success;
\r
1002 if (chapterMarkersFileMode.Success == true || chapterMarkers.Success == true)
\r
1003 thisQuery.q_chapterMarkers = true;
\r
1005 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
1009 #region Video Settings Tab
\r
1010 thisQuery.q_grayscale = grayscale.Success;
\r
1011 thisQuery.q_twoPass = twoPass.Success;
\r
1012 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
1013 thisQuery.q_largeMp4 = largerMp4.Success;
\r
1014 if (videoFramerate.Success != false)
\r
1015 thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
\r
1017 thisQuery.q_videoFramerate = "Same as source";
\r
1019 if (videoBitrate.Success != false)
\r
1020 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
1021 if (videoFilesize.Success != false)
\r
1022 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
1024 double qConvert = 0;
\r
1025 if (videoQuality.Success != false)
\r
1027 qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Culture) * 100;
\r
1028 qConvert = System.Math.Ceiling(qConvert);
\r
1029 thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
\r
1031 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
1032 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
1039 thisQuery.q_audioTrack1 = "Automatic";
\r
1041 if (audioTrack2.Success != false)
\r
1043 string[] audioChan = audioTrack2.ToString().Split(',');
\r
1044 thisQuery.q_audioTrack2 = audioChan[1];
\r
1047 thisQuery.q_audioTrack2 = "None";
\r
1049 if (audioTrack3.Success != false)
\r
1051 string[] audioChan = audioTrack3.ToString().Split(',');
\r
1052 thisQuery.q_audioTrack3 = audioChan[2];
\r
1055 thisQuery.q_audioTrack3 = "None";
\r
1057 if (audioTrack4.Success != false)
\r
1059 string[] audioChan = audioTrack4.ToString().Split(',');
\r
1060 thisQuery.q_audioTrack4 = audioChan[3];
\r
1063 thisQuery.q_audioTrack4 = "None";
\r
1067 thisQuery.q_audioTrackMix1 = "Automatic";
\r
1068 if (audioTrack1Mix.Success != false)
\r
1069 thisQuery.q_audioTrackMix1 = getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
1071 thisQuery.q_audioTrackMix2 = "Automatic";
\r
1072 if (audioTrack2Mix.Success != false)
\r
1074 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
1075 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1].Trim());
\r
1078 thisQuery.q_audioTrackMix3 = "Automatic";
\r
1079 if (audioTrack3Mix.Success != false)
\r
1081 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
1082 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[2].Trim());
\r
1085 thisQuery.q_audioTrackMix4 = "Automatic";
\r
1086 if (audioTrack4Mix.Success != false)
\r
1088 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
1089 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[3].Trim());
\r
1094 if (audioEncoder1.Success != false)
\r
1095 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
1097 if (audioEncoder2.Success != false)
\r
1099 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
1100 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
1103 if (audioEncoder3.Success != false)
\r
1105 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
1106 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
1109 if (audioEncoder4.Success != false)
\r
1111 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
1112 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
1117 thisQuery.q_audioBitrate1 = "";
\r
1118 if (audioBitrate1.Success != false)
\r
1120 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
1121 if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.q_audioBitrate1 = "Auto";
\r
1124 thisQuery.q_audioBitrate2 = "";
\r
1125 if (audioBitrate2.Success != false && audioTrack2.Success == true)
\r
1127 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
1128 if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";
\r
1129 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
1132 thisQuery.q_audioBitrate3 = "";
\r
1133 if (audioBitrate3.Success != false && audioTrack3.Success == true)
\r
1135 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
1136 if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";
\r
1137 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
1140 thisQuery.q_audioBitrate4 = "";
\r
1141 if (audioBitrate4.Success != false)
\r
1143 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
1144 if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";
\r
1145 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
1149 // Audio Sample Rate
\r
1150 // Make sure to change 0 to Auto
\r
1151 thisQuery.q_audioSamplerate1 = "Auto";
\r
1152 if (audioSampleRate1.Success != false)
\r
1154 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
1155 if (thisQuery.q_audioSamplerate1 == "0") thisQuery.q_audioSamplerate1 = "Auto";
\r
1159 if (audioSampleRate2.Success != false)
\r
1161 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
1162 if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";
\r
1163 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
1166 if (audioSampleRate3.Success != false)
\r
1168 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
1169 if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";
\r
1170 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
1173 if (audioSampleRate4.Success != false)
\r
1175 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
1176 if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";
\r
1177 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1183 thisQuery.q_drc1 = 1;
\r
1184 if (drc1.Success != false)
\r
1186 string value = drc1.ToString().Replace("-D ", "");
\r
1187 float.TryParse(value, out drcValue);
\r
1188 thisQuery.q_drc1 = drcValue;
\r
1191 thisQuery.q_drc2 = 1;
\r
1192 if (drc2.Success != false)
\r
1194 string[] drcPoint = drc2.ToString().Split(',');
\r
1195 float.TryParse(drcPoint[1], out drcValue);
\r
1196 thisQuery.q_drc2 = drcValue;
\r
1199 thisQuery.q_drc3 = 1;
\r
1200 if (drc3.Success != false)
\r
1202 string[] drcPoint = drc3.ToString().Split(',');
\r
1203 float.TryParse(drcPoint[2], out drcValue);
\r
1204 thisQuery.q_drc3 = drcValue;
\r
1207 thisQuery.q_drc4 = 1;
\r
1208 if (drc4.Success != false)
\r
1210 string[] drcPoint = drc4.ToString().Split(',');
\r
1211 float.TryParse(drcPoint[3], out drcValue);
\r
1212 thisQuery.q_drc4 = drcValue;
\r
1216 if (subtitles.Success != false)
\r
1217 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1220 if (subScan.Success)
\r
1221 thisQuery.q_subtitles = "Autoselect";
\r
1223 thisQuery.q_subtitles = "None";
\r
1226 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1230 #region H.264 and other
\r
1234 if (x264.Success != false)
\r
1235 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1240 thisQuery.q_verbose = verbose.Success;
\r
1243 catch (Exception exc)
\r
1245 MessageBox.Show("An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" + exc.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
1252 private static string getMixDown(string mixdown)
\r
1261 return "Dolby Surround";
\r
1263 return "Dolby Pro Logic II";
\r
1265 return "6 Channel Discrete";
\r
1267 return "Automatic";
\r
1270 private static string getAudioEncoder(string audioEnc)
\r