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
13 namespace Handbrake.Functions
\r
18 // All the Main Window GUI options
\r
22 private int q_dvdTitle;
\r
24 /// Returns an Integer
\r
25 /// DVD Title number.
\r
31 return this.q_dvdTitle;
\r
35 private int q_chaptersStart;
\r
38 /// DVD Chapter number or chapter range.
\r
40 public int DVDChapterStart
\r
44 return this.q_chaptersStart;
\r
48 private int q_chaptersFinish;
\r
51 /// DVD Chapter number or chapter range.
\r
53 public int DVDChapterFinish
\r
57 return this.q_chaptersFinish;
\r
63 private string q_format;
\r
65 /// Returns a String
\r
66 /// Full path of the destination.
\r
68 public string Format
\r
72 return this.q_format;
\r
76 private string q_videoEncoder;
\r
78 /// Returns an String
\r
79 /// The Video Encoder used.
\r
81 public string VideoEncoder
\r
85 return this.q_videoEncoder;
\r
90 #region Picture Settings
\r
91 private int q_videoWidth;
\r
94 /// The selected Width for the encoding.
\r
100 return this.q_videoWidth;
\r
104 private int q_videoHeight;
\r
107 /// The selected Height for the encoding.
\r
113 return this.q_videoHeight;
\r
117 private int q_maxWidth;
\r
120 /// The selected Width for the encoding.
\r
122 public int MaxWidth
\r
126 return this.q_maxWidth;
\r
130 private int q_maxHeight;
\r
133 /// The selected Height for the encoding.
\r
135 public int MaxHeight
\r
139 return this.q_maxHeight;
\r
143 private string q_cropValues;
\r
145 /// Returns an String
\r
146 /// Cropping values.
\r
148 public string CropValues
\r
152 return this.q_cropValues;
\r
156 private string q_croptop;
\r
158 /// Returns an String
\r
159 /// Cropping values.
\r
161 public string CropTop
\r
165 return this.q_croptop;
\r
169 private string q_cropbottom;
\r
171 /// Returns an String
\r
172 /// Cropping values.
\r
174 public string CropBottom
\r
178 return this.q_cropbottom;
\r
182 private string q_cropLeft;
\r
184 /// Returns an String
\r
185 /// Cropping values.
\r
187 public string CropLeft
\r
191 return this.q_cropLeft;
\r
195 private string q_cropRight;
\r
197 /// Returns an String
\r
198 /// Cropping values.
\r
200 public string CropRight
\r
204 return this.q_cropRight;
\r
208 private Boolean q_detelecine;
\r
210 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
212 public Boolean DeTelecine
\r
216 return this.q_detelecine;
\r
220 private int q_deBlock;
\r
222 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
228 return this.q_deBlock;
\r
232 private string q_deinterlace;
\r
234 /// Returns a string with the De-Interlace option used.
\r
236 public string DeInterlace
\r
240 return this.q_deinterlace;
\r
244 private string q_denoise;
\r
246 /// Returns a string with the DeNoise option used.
\r
248 public string DeNoise
\r
252 return this.q_denoise;
\r
256 private Boolean q_decomb;
\r
258 /// Returns a string with the DeNoise option used.
\r
260 public Boolean Decomb
\r
264 return this.q_decomb;
\r
268 private Boolean q_anamorphic;
\r
270 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
272 public Boolean Anamorphic
\r
276 return this.q_anamorphic;
\r
280 private Boolean q_looseAnamorphic;
\r
282 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
284 public Boolean LooseAnamorphic
\r
288 return this.q_looseAnamorphic;
\r
292 private Boolean q_chapterMarkers;
\r
294 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
296 public Boolean ChapterMarkers
\r
300 return this.q_chapterMarkers;
\r
305 #region Video Settings
\r
306 private Boolean q_grayscale;
\r
308 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
310 public Boolean Grayscale
\r
314 return this.q_grayscale;
\r
318 private Boolean q_twoPass;
\r
320 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
322 public Boolean TwoPass
\r
326 return this.q_twoPass;
\r
330 private Boolean q_turboFirst;
\r
332 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
334 public Boolean TurboFirstPass
\r
338 return this.q_turboFirst;
\r
342 private Boolean q_largeMp4;
\r
344 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
346 public Boolean LargeMP4
\r
350 return this.q_largeMp4;
\r
354 private Boolean q_ipodAtom;
\r
356 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
358 public Boolean IpodAtom
\r
362 return this.q_ipodAtom;
\r
366 private Boolean q_optimizeMp4;
\r
368 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
370 public Boolean OptimizeMP4
\r
374 return this.q_optimizeMp4;
\r
378 private string q_videoFramerate;
\r
380 /// Returns a string with the video Framerate
\r
382 public string VideoFramerate
\r
386 return this.q_videoFramerate;
\r
390 private string q_avgBitrate;
\r
392 /// Returns a string with the average video bitrate
\r
394 public string AverageVideoBitrate
\r
398 return this.q_avgBitrate;
\r
402 private string q_videoTargetSize;
\r
404 /// Returns a string with the video target size
\r
406 public string VideoTargetSize
\r
410 return this.q_videoTargetSize;
\r
414 private int q_videoQuality;
\r
416 /// Returns a int with the video quality value
\r
418 public int VideoQuality
\r
422 return this.q_videoQuality;
\r
428 #region Audio Settings
\r
429 private string q_audioTrack1;
\r
431 /// Returns a string with the selected Audio track
\r
433 public string AudioTrack1
\r
437 return this.q_audioTrack1;
\r
441 private string q_audioTrack2;
\r
443 /// Returns a string with the selected Audio track
\r
445 public string AudioTrack2
\r
449 return this.q_audioTrack2;
\r
453 private string q_audioTrack3;
\r
455 /// Returns a string with the selected Audio track
\r
457 public string AudioTrack3
\r
461 return this.q_audioTrack3;
\r
465 private string q_audioTrack4;
\r
467 /// Returns a string with the selected Audio track
\r
469 public string AudioTrack4
\r
473 return this.q_audioTrack4;
\r
477 private string q_audioTrackMix1;
\r
479 /// Returns a string with the First selected Audio track Mix
\r
481 public string AudioTrackMix1
\r
485 return this.q_audioTrackMix1;
\r
489 private string q_audioTrackMix2;
\r
491 /// Returns a string with the First selected Audio track Mix
\r
493 public string AudioTrackMix2
\r
497 return this.q_audioTrackMix2;
\r
501 private string q_audioTrackMix3;
\r
503 /// Returns a string with the First selected Audio track Mix
\r
505 public string AudioTrackMix3
\r
509 return this.q_audioTrackMix3;
\r
513 private string q_audioTrackMix4;
\r
515 /// Returns a string with the First selected Audio track Mix
\r
517 public string AudioTrackMix4
\r
521 return this.q_audioTrackMix4;
\r
525 private string q_audioEncoder1;
\r
527 /// Returns an String
\r
528 /// The Audio Encoder used.
\r
530 public string AudioEncoder1
\r
534 return this.q_audioEncoder1;
\r
538 private string q_audioEncoder2;
\r
540 /// Returns an String
\r
541 /// The Audio Encoder used.
\r
543 public string AudioEncoder2
\r
547 return this.q_audioEncoder2;
\r
551 private string q_audioEncoder3;
\r
553 /// Returns an String
\r
554 /// The Audio Encoder used.
\r
556 public string AudioEncoder3
\r
560 return this.q_audioEncoder3;
\r
564 private string q_audioEncoder4;
\r
566 /// Returns an String
\r
567 /// The Audio Encoder used.
\r
569 public string AudioEncoder4
\r
573 return this.q_audioEncoder4;
\r
577 private string q_audioBitrate1;
\r
579 /// Returns a string with the audio bitrate
\r
581 public string AudioBitrate1
\r
585 return this.q_audioBitrate1;
\r
589 private string q_audioBitrate2;
\r
591 /// Returns a string with the audio bitrate
\r
593 public string AudioBitrate2
\r
597 return this.q_audioBitrate2;
\r
601 private string q_audioBitrate3;
\r
603 /// Returns a string with the audio bitrate
\r
605 public string AudioBitrate3
\r
609 return this.q_audioBitrate3;
\r
613 private string q_audioBitrate4;
\r
615 /// Returns a string with the audio bitrate
\r
617 public string AudioBitrate4
\r
621 return this.q_audioBitrate4;
\r
625 private string q_audioSamplerate1;
\r
627 /// Returns a string with the audio sample rate
\r
629 public string AudioSamplerate1
\r
633 return this.q_audioSamplerate1;
\r
637 private string q_audioSamplerate2;
\r
639 /// Returns a string with the audio sample rate
\r
641 public string AudioSamplerate2
\r
645 return this.q_audioSamplerate2;
\r
649 private string q_audioSamplerate3;
\r
651 /// Returns a string with the audio sample rate
\r
653 public string AudioSamplerate3
\r
657 return this.q_audioSamplerate3;
\r
661 private string q_audioSamplerate4;
\r
663 /// Returns a string with the audio sample rate
\r
665 public string AudioSamplerate4
\r
669 return this.q_audioSamplerate4;
\r
673 private double q_drc1;
\r
675 /// Returns a string with the selected subtitle track
\r
681 return this.q_drc1;
\r
685 private double q_drc2;
\r
687 /// Returns a string with the selected subtitle track
\r
693 return this.q_drc2;
\r
697 private double q_drc3;
\r
699 /// Returns a string with the selected subtitle track
\r
705 return this.q_drc3;
\r
709 private double q_drc4;
\r
711 /// Returns a string with the selected subtitle track
\r
717 return this.q_drc4;
\r
721 private string q_subtitles;
\r
723 /// Returns a string with the selected subtitle track
\r
725 public string Subtitles
\r
729 return this.q_subtitles;
\r
733 private Boolean q_forcedSubs;
\r
735 /// Returns a string with the selected subtitle track
\r
737 public Boolean ForcedSubtitles
\r
741 return this.q_forcedSubs;
\r
748 private string q_h264;
\r
750 /// Returns a string with the Advanced H264 query string
\r
752 public string H264Query
\r
756 return this.q_h264;
\r
759 private Boolean q_verbose;
\r
761 /// Returns a string with the Advanced H264 query string
\r
763 public Boolean Verbose
\r
767 return this.q_verbose;
\r
775 /// Takes in a query which can be in any order and parses it.
\r
776 /// All varibles are then set so they can be used elsewhere.
\r
778 /// <param name="input">A ClI Query</param>
\r
779 /// <returns>A Parsed Query</returns>
\r
781 public static QueryParser Parse(String input)
\r
783 QueryParser thisQuery = new QueryParser();
\r
785 #region Regular Expressions
\r
786 // Useful Destination Finder
\r
787 //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");
\r
788 //Match source = r1.Match(input.Replace('"', '\"'));
\r
791 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
792 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
793 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
796 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
798 //Picture Settings Tab
\r
799 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
800 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
801 Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
\r
802 Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
\r
803 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z]*)\""");
\r
804 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z]*)\""");
\r
805 Match deblock = Regex.Match(input, @"--deblock=([0-9]*)");
\r
806 Match detelecine = Regex.Match(input, @"--detelecine");
\r
807 Match anamorphic = Regex.Match(input, @" -p ");
\r
808 Match chapterMarkers = Regex.Match(input, @" -m");
\r
809 Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
\r
810 Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
\r
811 Match lanamorphic = Regex.Match(input, @" -P");
\r
812 Match decomb = Regex.Match(input, @" --decomb");
\r
814 //Video Settings Tab
\r
815 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
816 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
817 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
818 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
819 Match twoPass = Regex.Match(input, @" -2");
\r
820 Match turboFirstPass = Regex.Match(input, @" -T");
\r
821 Match grayscale = Regex.Match(input, @" -g");
\r
822 Match largerMp4 = Regex.Match(input, @" -4");
\r
823 Match ipodAtom = Regex.Match(input, @" -I");
\r
824 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
826 //Audio Settings Tab
\r
827 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
828 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
829 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
830 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
832 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
833 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
834 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
835 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
837 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
838 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
839 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
840 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
842 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");
\r
843 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");
\r
844 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
845 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
847 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");
\r
848 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");
\r
849 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
850 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
852 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
853 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
854 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
855 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
857 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
858 Match subScan = Regex.Match(input, @" -U");
\r
859 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
862 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
865 Match verbose = Regex.Match(input, @" -v");
\r
868 #region Set Varibles
\r
872 if (title.Success != false)
\r
873 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
875 if (chapters.Success != false)
\r
877 string[] actTitles = new string[2];
\r
878 actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
879 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
880 if (actTitles.Length > 1)
\r
882 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
885 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
886 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
889 if (format.Success != false)
\r
890 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
894 #region Destination
\r
896 string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
897 switch (videoEncoderConvertion)
\r
900 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
903 videoEncoderConvertion = "MPEG-4 (XviD)";
\r
906 videoEncoderConvertion = "H.264 (x264)";
\r
909 videoEncoderConvertion = "VP3 (Theora)";
\r
912 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
915 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
919 #region Picture Tab
\r
921 if (width.Success != false)
\r
922 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
924 if (height.Success != false)
\r
925 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
927 if (maxWidth.Success != false)
\r
928 thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
\r
930 if (maxHeight.Success != false)
\r
931 thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
\r
933 if (crop.Success != false)
\r
935 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
936 string[] actCropValues = new string[3];
\r
937 actCropValues = thisQuery.q_cropValues.Split(':');
\r
938 thisQuery.q_croptop = actCropValues[0];
\r
939 thisQuery.q_cropbottom = actCropValues[1];
\r
940 thisQuery.q_cropLeft = actCropValues[2];
\r
941 thisQuery.q_cropRight = actCropValues[3];
\r
945 string deblockValue = "";
\r
946 thisQuery.q_deBlock = 0;
\r
947 if (deblock.Success != false)
\r
948 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
950 if (deblockValue != "")
\r
951 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
953 thisQuery.q_detelecine = detelecine.Success;
\r
954 thisQuery.q_decomb = decomb.Success;
\r
956 thisQuery.q_deinterlace = "None";
\r
957 if (deinterlace.Success != false)
\r
959 switch (deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"",""))
\r
962 thisQuery.q_deinterlace = "Fast";
\r
965 thisQuery.q_deinterlace = "Slow";
\r
968 thisQuery.q_deinterlace = "Slower";
\r
971 thisQuery.q_deinterlace = "Slowest";
\r
974 thisQuery.q_deinterlace = "None";
\r
979 thisQuery.q_denoise = "None";
\r
980 if (denoise.Success != false)
\r
982 switch (denoise.ToString().Replace("--denoise=", "").Replace("\"", ""))
\r
985 thisQuery.q_denoise = "Weak";
\r
988 thisQuery.q_denoise = "Medium";
\r
991 thisQuery.q_denoise = "Strong";
\r
994 thisQuery.q_denoise = "None";
\r
999 thisQuery.q_anamorphic = anamorphic.Success;
\r
1000 if (chapterMarkersFileMode.Success == true || chapterMarkers.Success == true)
\r
1001 thisQuery.q_chapterMarkers = true;
\r
1003 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
1007 #region Video Settings Tab
\r
1008 thisQuery.q_grayscale = grayscale.Success;
\r
1009 thisQuery.q_twoPass = twoPass.Success;
\r
1010 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
1011 thisQuery.q_largeMp4 = largerMp4.Success;
\r
1012 if (videoFramerate.Success != false)
\r
1013 thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
\r
1015 thisQuery.q_videoFramerate = "Same as source";
\r
1017 if (videoBitrate.Success != false)
\r
1018 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
1019 if (videoFilesize.Success != false)
\r
1020 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
1022 double qConvert = 0;
\r
1023 if (videoQuality.Success != false)
\r
1025 qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;
\r
1026 qConvert = System.Math.Ceiling(qConvert);
\r
1027 thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
\r
1029 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
1030 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
1037 thisQuery.q_audioTrack1 = "Automatic";
\r
1039 if (audioTrack2.Success != false)
\r
1041 string[] audioChan = audioTrack2.ToString().Split(',');
\r
1042 thisQuery.q_audioTrack2 = audioChan[1];
\r
1045 thisQuery.q_audioTrack2 = "None";
\r
1047 if (audioTrack3.Success != false)
\r
1049 string[] audioChan = audioTrack3.ToString().Split(',');
\r
1050 thisQuery.q_audioTrack3 = audioChan[2];
\r
1053 thisQuery.q_audioTrack3 = "None";
\r
1055 if (audioTrack4.Success != false)
\r
1057 string[] audioChan = audioTrack4.ToString().Split(',');
\r
1058 thisQuery.q_audioTrack4 = audioChan[3];
\r
1061 thisQuery.q_audioTrack4 = "None";
\r
1065 thisQuery.q_audioTrackMix1 = "Automatic";
\r
1066 if (audioTrack1Mix.Success != false)
\r
1067 thisQuery.q_audioTrackMix1 = getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
1069 thisQuery.q_audioTrackMix2 = "Automatic";
\r
1070 if (audioTrack2Mix.Success != false)
\r
1072 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
1073 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1].Trim());
\r
1076 thisQuery.q_audioTrackMix3 = "Automatic";
\r
1077 if (audioTrack3Mix.Success != false)
\r
1079 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
1080 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[2].Trim());
\r
1083 thisQuery.q_audioTrackMix4 = "Automatic";
\r
1084 if (audioTrack4Mix.Success != false)
\r
1086 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
1087 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[3].Trim());
\r
1092 if (audioEncoder1.Success != false)
\r
1093 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
1095 if (audioEncoder2.Success != false)
\r
1097 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
1098 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
1101 if (audioEncoder3.Success != false)
\r
1103 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
1104 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
1107 if (audioEncoder4.Success != false)
\r
1109 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
1110 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
1115 thisQuery.q_audioBitrate1 = "";
\r
1116 if (audioBitrate1.Success != false)
\r
1118 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
1119 if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.q_audioBitrate1 = "Auto";
\r
1122 thisQuery.q_audioBitrate2 = "";
\r
1123 if (audioBitrate2.Success != false && audioTrack2.Success == true)
\r
1125 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
1126 if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";
\r
1127 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
1130 thisQuery.q_audioBitrate3 = "";
\r
1131 if (audioBitrate3.Success != false && audioTrack3.Success == true)
\r
1133 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
1134 if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";
\r
1135 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
1138 thisQuery.q_audioBitrate4 = "";
\r
1139 if (audioBitrate4.Success != false)
\r
1141 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
1142 if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";
\r
1143 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
1147 // Audio Sample Rate
\r
1148 // Make sure to change 0 to Auto
\r
1149 thisQuery.q_audioSamplerate1 = "Auto";
\r
1150 if (audioSampleRate1.Success != false)
\r
1152 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
1153 if (thisQuery.q_audioSamplerate1 == "0") thisQuery.q_audioSamplerate1 = "Auto";
\r
1157 if (audioSampleRate2.Success != false)
\r
1159 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
1160 if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";
\r
1161 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
1164 if (audioSampleRate3.Success != false)
\r
1166 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
1167 if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";
\r
1168 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
1171 if (audioSampleRate4.Success != false)
\r
1173 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
1174 if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";
\r
1175 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1181 thisQuery.q_drc1 = 1;
\r
1182 if (drc1.Success != false)
\r
1184 string value = drc1.ToString().Replace("-D ", "");
\r
1185 float.TryParse(value, out drcValue);
\r
1186 thisQuery.q_drc1 = drcValue;
\r
1189 thisQuery.q_drc2 = 1;
\r
1190 if (drc2.Success != false)
\r
1192 string[] drcPoint = drc2.ToString().Split(',');
\r
1193 float.TryParse(drcPoint[1], out drcValue);
\r
1194 thisQuery.q_drc2 = drcValue;
\r
1197 thisQuery.q_drc3 = 1;
\r
1198 if (drc3.Success != false)
\r
1200 string[] drcPoint = drc3.ToString().Split(',');
\r
1201 float.TryParse(drcPoint[2], out drcValue);
\r
1202 thisQuery.q_drc3 = drcValue;
\r
1205 thisQuery.q_drc4 = 1;
\r
1206 if (drc4.Success != false)
\r
1208 string[] drcPoint = drc4.ToString().Split(',');
\r
1209 float.TryParse(drcPoint[3], out drcValue);
\r
1210 thisQuery.q_drc4 = drcValue;
\r
1214 if (subtitles.Success != false)
\r
1215 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1218 if (subScan.Success)
\r
1219 thisQuery.q_subtitles = "Autoselect";
\r
1221 thisQuery.q_subtitles = "None";
\r
1224 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1228 #region H.264 and other
\r
1232 if (x264.Success != false)
\r
1233 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1238 thisQuery.q_verbose = verbose.Success;
\r
1241 catch (Exception exc)
\r
1243 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
1250 private static string getMixDown(string mixdown)
\r
1259 return "Dolby Surround";
\r
1261 return "Dolby Pro Logic II";
\r
1263 return "6 Channel Discrete";
\r
1265 return "Automatic";
\r
1268 private static string getAudioEncoder(string audioEnc)
\r