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
23 private string q_source;
\r
25 /// Returns a String
\r
26 /// Full path of the source.
\r
28 public string Source
\r
32 return this.q_source;
\r
36 private int q_dvdTitle;
\r
38 /// Returns an Integer
\r
39 /// DVD Title number.
\r
45 return this.q_dvdTitle;
\r
49 private int q_chaptersStart;
\r
52 /// DVD Chapter number or chapter range.
\r
54 public int DVDChapterStart
\r
58 return this.q_chaptersStart;
\r
62 private int q_chaptersFinish;
\r
65 /// DVD Chapter number or chapter range.
\r
67 public int DVDChapterFinish
\r
71 return this.q_chaptersFinish;
\r
78 private string q_destination;
\r
80 /// Returns a String
\r
81 /// Full path of the destination.
\r
83 public string Destination
\r
87 return this.q_destination;
\r
91 private string q_format;
\r
93 /// Returns a String
\r
94 /// Full path of the destination.
\r
96 public string Format
\r
100 return this.q_format;
\r
104 private string q_videoEncoder;
\r
106 /// Returns an String
\r
107 /// The Video Encoder used.
\r
109 public string VideoEncoder
\r
113 return this.q_videoEncoder;
\r
118 #region Picture Settings
\r
119 private int q_videoWidth;
\r
122 /// The selected Width for the encoding.
\r
128 return this.q_videoWidth;
\r
132 private int q_videoHeight;
\r
135 /// The selected Height for the encoding.
\r
141 return this.q_videoHeight;
\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 Boolean q_vfr;
\r
224 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
234 private int q_deBlock;
\r
236 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
242 return this.q_deBlock;
\r
246 private string q_deinterlace;
\r
248 /// Returns a string with the De-Interlace option used.
\r
250 public string DeInterlace
\r
254 return this.q_deinterlace;
\r
258 private string q_denoise;
\r
260 /// Returns a string with the DeNoise option used.
\r
262 public string DeNoise
\r
266 return this.q_denoise;
\r
270 private Boolean q_decomb;
\r
272 /// Returns a string with the DeNoise option used.
\r
274 public Boolean Decomb
\r
278 return this.q_decomb;
\r
282 private Boolean q_anamorphic;
\r
284 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
286 public Boolean Anamorphic
\r
290 return this.q_anamorphic;
\r
294 private Boolean q_looseAnamorphic;
\r
296 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
298 public Boolean LooseAnamorphic
\r
302 return this.q_looseAnamorphic;
\r
306 private Boolean q_chapterMarkers;
\r
308 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
310 public Boolean ChapterMarkers
\r
314 return this.q_chapterMarkers;
\r
319 #region Video Settings
\r
320 private Boolean q_grayscale;
\r
322 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
324 public Boolean Grayscale
\r
328 return this.q_grayscale;
\r
332 private Boolean q_twoPass;
\r
334 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
336 public Boolean TwoPass
\r
340 return this.q_twoPass;
\r
344 private Boolean q_turboFirst;
\r
346 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
348 public Boolean TurboFirstPass
\r
352 return this.q_turboFirst;
\r
356 private Boolean q_largeMp4;
\r
358 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
360 public Boolean LargeMP4
\r
364 return this.q_largeMp4;
\r
368 private Boolean q_ipodAtom;
\r
370 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
372 public Boolean IpodAtom
\r
376 return this.q_ipodAtom;
\r
380 private Boolean q_optimizeMp4;
\r
382 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
384 public Boolean OptimizeMP4
\r
388 return this.q_optimizeMp4;
\r
392 private string q_videoFramerate;
\r
394 /// Returns a string with the video Framerate
\r
396 public string VideoFramerate
\r
400 return this.q_videoFramerate;
\r
404 private string q_avgBitrate;
\r
406 /// Returns a string with the average video bitrate
\r
408 public string AverageVideoBitrate
\r
412 return this.q_avgBitrate;
\r
416 private string q_videoTargetSize;
\r
418 /// Returns a string with the video target size
\r
420 public string VideoTargetSize
\r
424 return this.q_videoTargetSize;
\r
428 private int q_videoQuality;
\r
430 /// Returns a int with the video quality value
\r
432 public int VideoQuality
\r
436 return this.q_videoQuality;
\r
442 #region Audio Settings
\r
443 private string q_audioTrack1;
\r
445 /// Returns a string with the selected Audio track
\r
447 public string AudioTrack1
\r
451 return this.q_audioTrack1;
\r
455 private string q_audioTrack2;
\r
457 /// Returns a string with the selected Audio track
\r
459 public string AudioTrack2
\r
463 return this.q_audioTrack2;
\r
467 private string q_audioTrack3;
\r
469 /// Returns a string with the selected Audio track
\r
471 public string AudioTrack3
\r
475 return this.q_audioTrack3;
\r
479 private string q_audioTrack4;
\r
481 /// Returns a string with the selected Audio track
\r
483 public string AudioTrack4
\r
487 return this.q_audioTrack4;
\r
491 private string q_audioTrackMix1;
\r
493 /// Returns a string with the First selected Audio track Mix
\r
495 public string AudioTrackMix1
\r
499 return this.q_audioTrackMix1;
\r
503 private string q_audioTrackMix2;
\r
505 /// Returns a string with the First selected Audio track Mix
\r
507 public string AudioTrackMix2
\r
511 return this.q_audioTrackMix2;
\r
515 private string q_audioTrackMix3;
\r
517 /// Returns a string with the First selected Audio track Mix
\r
519 public string AudioTrackMix3
\r
523 return this.q_audioTrackMix3;
\r
527 private string q_audioTrackMix4;
\r
529 /// Returns a string with the First selected Audio track Mix
\r
531 public string AudioTrackMix4
\r
535 return this.q_audioTrackMix4;
\r
539 private string q_audioEncoder1;
\r
541 /// Returns an String
\r
542 /// The Audio Encoder used.
\r
544 public string AudioEncoder1
\r
548 return this.q_audioEncoder1;
\r
552 private string q_audioEncoder2;
\r
554 /// Returns an String
\r
555 /// The Audio Encoder used.
\r
557 public string AudioEncoder2
\r
561 return this.q_audioEncoder2;
\r
565 private string q_audioEncoder3;
\r
567 /// Returns an String
\r
568 /// The Audio Encoder used.
\r
570 public string AudioEncoder3
\r
574 return this.q_audioEncoder3;
\r
578 private string q_audioEncoder4;
\r
580 /// Returns an String
\r
581 /// The Audio Encoder used.
\r
583 public string AudioEncoder4
\r
587 return this.q_audioEncoder4;
\r
591 private string q_audioBitrate1;
\r
593 /// Returns a string with the audio bitrate
\r
595 public string AudioBitrate1
\r
599 return this.q_audioBitrate1;
\r
603 private string q_audioBitrate2;
\r
605 /// Returns a string with the audio bitrate
\r
607 public string AudioBitrate2
\r
611 return this.q_audioBitrate2;
\r
615 private string q_audioBitrate3;
\r
617 /// Returns a string with the audio bitrate
\r
619 public string AudioBitrate3
\r
623 return this.q_audioBitrate3;
\r
627 private string q_audioBitrate4;
\r
629 /// Returns a string with the audio bitrate
\r
631 public string AudioBitrate4
\r
635 return this.q_audioBitrate4;
\r
639 private string q_audioSamplerate1;
\r
641 /// Returns a string with the audio sample rate
\r
643 public string AudioSamplerate1
\r
647 return this.q_audioSamplerate1;
\r
651 private string q_audioSamplerate2;
\r
653 /// Returns a string with the audio sample rate
\r
655 public string AudioSamplerate2
\r
659 return this.q_audioSamplerate2;
\r
663 private string q_audioSamplerate3;
\r
665 /// Returns a string with the audio sample rate
\r
667 public string AudioSamplerate3
\r
671 return this.q_audioSamplerate3;
\r
675 private string q_audioSamplerate4;
\r
677 /// Returns a string with the audio sample rate
\r
679 public string AudioSamplerate4
\r
683 return this.q_audioSamplerate4;
\r
687 private double q_drc1;
\r
689 /// Returns a string with the selected subtitle track
\r
695 return this.q_drc1;
\r
699 private double q_drc2;
\r
701 /// Returns a string with the selected subtitle track
\r
707 return this.q_drc2;
\r
711 private double q_drc3;
\r
713 /// Returns a string with the selected subtitle track
\r
719 return this.q_drc3;
\r
723 private double q_drc4;
\r
725 /// Returns a string with the selected subtitle track
\r
731 return this.q_drc4;
\r
735 private string q_subtitles;
\r
737 /// Returns a string with the selected subtitle track
\r
739 public string Subtitles
\r
743 return this.q_subtitles;
\r
747 private Boolean q_forcedSubs;
\r
749 /// Returns a string with the selected subtitle track
\r
751 public Boolean ForcedSubtitles
\r
755 return this.q_forcedSubs;
\r
762 private string q_h264;
\r
764 /// Returns a string with the Advanced H264 query string
\r
766 public string H264Query
\r
770 return this.q_h264;
\r
773 private Boolean q_verbose;
\r
775 /// Returns a string with the Advanced H264 query string
\r
777 public Boolean Verbose
\r
781 return this.q_verbose;
\r
789 /// Takes in a query which can be in any order and parses it.
\r
790 /// All varibles are then set so they can be used elsewhere.
\r
792 /// <param name="input">A ClI Query</param>
\r
793 /// <returns>A Parsed Query</returns>
\r
795 public static QueryParser Parse(String input)
\r
797 QueryParser thisQuery = new QueryParser();
\r
799 #region Regular Expressions
\r
801 Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");
\r
802 Match source = r1.Match(input.Replace('"', '\"'));
\r
803 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
804 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
805 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
808 Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");
\r
809 Match destination = r2.Match(input.Replace('"', '\"'));
\r
810 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
812 //Picture Settings Tab
\r
813 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
814 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
815 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z]*)\""");
\r
816 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z]*)\""");
\r
817 Match deblock = Regex.Match(input, @"--deblock=([0-9]*)");
\r
818 Match detelecine = Regex.Match(input, @"--detelecine");
\r
819 Match anamorphic = Regex.Match(input, @" -p ");
\r
820 Match chapterMarkers = Regex.Match(input, @" -m");
\r
821 Match crop = Regex.Match(input, @"--crop ([0-9]):([0-9]):([0-9]):([0-9])");
\r
822 Match vfr = Regex.Match(input, @" -V");
\r
823 Match lanamorphic = Regex.Match(input, @" -P");
\r
824 Match decomb = Regex.Match(input, @" --decomb");
\r
826 //Video Settings Tab
\r
827 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
828 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
829 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
830 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
831 Match twoPass = Regex.Match(input, @" -2");
\r
832 Match turboFirstPass = Regex.Match(input, @" -T");
\r
833 Match grayscale = Regex.Match(input, @" -g");
\r
834 Match largerMp4 = Regex.Match(input, @" -4");
\r
835 Match ipodAtom = Regex.Match(input, @" -I");
\r
836 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
838 //Audio Settings Tab
\r
839 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
840 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
841 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
842 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
844 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
845 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
846 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
847 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
849 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
850 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
851 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
852 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
854 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9]*)");
\r
855 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9]*),([0-9]*)");
\r
856 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*)");
\r
857 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
859 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9.]*)");
\r
860 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*)");
\r
861 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
862 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
864 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
865 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
866 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
867 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
869 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
870 Match subScan = Regex.Match(input, @" -U");
\r
871 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
874 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
877 Match verbose = Regex.Match(input, @" -v");
\r
880 #region Set Varibles
\r
886 thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");
\r
887 if (title.Success != false)
\r
888 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
890 if (chapters.Success != false)
\r
892 string[] actTitles = new string[2];
\r
893 actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
894 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
895 if (actTitles.Length > 1)
\r
897 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
900 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
901 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
904 if (format.Success != false)
\r
905 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
909 #region Destination
\r
910 thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");
\r
912 string videoEncoderConvertion;
\r
914 videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
915 switch (videoEncoderConvertion)
\r
918 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
921 videoEncoderConvertion = "MPEG-4 (XviD)";
\r
924 videoEncoderConvertion = "H.264 (x264)";
\r
927 videoEncoderConvertion = "VP3 (Theora)";
\r
930 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
933 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
937 #region Picture Tab
\r
939 if (width.Success != false)
\r
940 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
942 if (height.Success != false)
\r
943 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
945 if (crop.Success != false)
\r
947 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
948 string[] actCropValues = new string[3];
\r
949 actCropValues = thisQuery.q_cropValues.Split(':');
\r
950 thisQuery.q_croptop = actCropValues[0];
\r
951 thisQuery.q_cropbottom = actCropValues[1];
\r
952 thisQuery.q_cropLeft = actCropValues[2];
\r
953 thisQuery.q_cropRight = actCropValues[3];
\r
957 string deblockValue = "";
\r
958 thisQuery.q_deBlock = 0;
\r
959 if (deblock.Success != false)
\r
960 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
962 if (deblockValue != "")
\r
963 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
965 thisQuery.q_detelecine = detelecine.Success;
\r
966 thisQuery.q_decomb = decomb.Success;
\r
968 thisQuery.q_deinterlace = "None";
\r
969 if (deinterlace.Success != false)
\r
971 switch (deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"",""))
\r
974 thisQuery.q_deinterlace = "Fast";
\r
977 thisQuery.q_deinterlace = "Slow";
\r
980 thisQuery.q_deinterlace = "Slower";
\r
983 thisQuery.q_deinterlace = "Slowest";
\r
986 thisQuery.q_deinterlace = "None";
\r
991 thisQuery.q_denoise = "None";
\r
992 if (denoise.Success != false)
\r
994 switch (denoise.ToString().Replace("--denoise=", "").Replace("\"", ""))
\r
997 thisQuery.q_denoise = "Weak";
\r
1000 thisQuery.q_denoise = "Medium";
\r
1003 thisQuery.q_denoise = "Strong";
\r
1006 thisQuery.q_denoise = "None";
\r
1011 thisQuery.q_anamorphic = anamorphic.Success;
\r
1012 thisQuery.q_chapterMarkers = chapterMarkers.Success;
\r
1013 thisQuery.q_vfr = vfr.Success;
\r
1014 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
1018 #region Video Settings Tab
\r
1019 thisQuery.q_grayscale = grayscale.Success;
\r
1020 thisQuery.q_twoPass = twoPass.Success;
\r
1021 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
1022 thisQuery.q_largeMp4 = largerMp4.Success;
\r
1023 if (videoFramerate.Success != false)
\r
1024 thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
\r
1026 thisQuery.q_videoFramerate = "Same as source";
\r
1028 if (videoBitrate.Success != false)
\r
1029 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
1030 if (videoFilesize.Success != false)
\r
1031 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
1033 double qConvert = 0;
\r
1034 if (videoQuality.Success != false)
\r
1036 qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;
\r
1037 qConvert = System.Math.Ceiling(qConvert);
\r
1038 thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
\r
1040 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
1041 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
1048 if (audioTrack1.Success != false)
\r
1049 thisQuery.q_audioTrack1 = audioTrack1.ToString().Replace("-a ", "");
\r
1051 thisQuery.q_audioTrack1 = "Automatic";
\r
1053 if (audioTrack2.Success != false)
\r
1055 string[] audioChan = audioTrack2.ToString().Split(',');
\r
1056 thisQuery.q_audioTrack2 = audioChan[1];
\r
1059 thisQuery.q_audioTrack2 = "None";
\r
1061 if (audioTrack3.Success != false)
\r
1063 string[] audioChan = audioTrack3.ToString().Split(',');
\r
1064 thisQuery.q_audioTrack3 = audioChan[2];
\r
1067 thisQuery.q_audioTrack3 = "None";
\r
1069 if (audioTrack4.Success != false)
\r
1071 string[] audioChan = audioTrack4.ToString().Split(',');
\r
1072 thisQuery.q_audioTrack4 = audioChan[3];
\r
1075 thisQuery.q_audioTrack4 = "None";
\r
1079 thisQuery.q_audioTrackMix1 = "Automatic";
\r
1080 if (audioTrack1Mix.Success != false)
\r
1082 thisQuery.q_audioTrackMix1 = getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
1085 thisQuery.q_audioTrackMix2 = "Automatic";
\r
1086 if (audioTrack2Mix.Success != false)
\r
1088 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
1089 audio2mix[1] = audio2mix[1].Trim();
\r
1090 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1]);
\r
1093 thisQuery.q_audioTrackMix3 = "Automatic";
\r
1094 if (audioTrack3Mix.Success != false)
\r
1096 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
1097 audio3mix[1] = audio3mix[2].Trim();
\r
1098 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[1]);
\r
1101 thisQuery.q_audioTrackMix4 = "Automatic";
\r
1102 if (audioTrack4Mix.Success != false)
\r
1104 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
1105 audio4mix[1] = audio4mix[3].Trim();
\r
1106 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[1]);
\r
1111 if (audioEncoder1.Success != false)
\r
1112 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
1114 if (audioEncoder2.Success != false)
\r
1116 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
1117 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
1120 if (audioEncoder3.Success != false)
\r
1122 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
1123 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
1126 if (audioEncoder4.Success != false)
\r
1128 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
1129 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
1134 if (audioBitrate1.Success != false)
\r
1135 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
1137 thisQuery.q_audioBitrate1 = "";
\r
1139 if (audioBitrate2.Success != false)
\r
1141 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
1142 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
1145 thisQuery.q_audioBitrate2 = "";
\r
1147 if (audioBitrate3.Success != false)
\r
1149 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
1150 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
1153 thisQuery.q_audioBitrate3 = "";
\r
1155 if (audioBitrate4.Success != false)
\r
1157 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
1158 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
1161 thisQuery.q_audioBitrate4 = "";
\r
1164 // Audio Sample Rate
\r
1165 // Make sure to change 0 to Auto
\r
1166 if (audioSampleRate1.Success != false)
\r
1168 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
1169 if (thisQuery.q_audioSamplerate1 == "0")
\r
1170 thisQuery.q_audioSamplerate1 = "Auto";
\r
1173 thisQuery.q_audioSamplerate1 = "Auto";
\r
1175 if (audioSampleRate2.Success != false)
\r
1177 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
1178 if (audioSRSelect[1] == "0")
\r
1179 audioSRSelect[1] = "Auto";
\r
1180 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
1183 if (audioSampleRate3.Success != false)
\r
1185 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
1186 if (audioSRSelect[1] == "0")
\r
1187 audioSRSelect[1] = "Auto";
\r
1188 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
1191 if (audioSampleRate4.Success != false)
\r
1193 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
1194 if (audioSRSelect[1] == "0")
\r
1195 audioSRSelect[1] = "Auto";
\r
1196 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1200 if (drc1.Success != false)
\r
1202 string value = drc1.ToString().Replace("-D ", "");
\r
1203 float drcValue = float.Parse(value);
\r
1204 drcValue = drcValue * 10;
\r
1205 thisQuery.q_drc1 = drcValue;
\r
1208 thisQuery.q_drc1 = 0;
\r
1210 if (drc2.Success != false)
\r
1212 string[] drcPoint = drc2.ToString().Split(',');
\r
1213 string value = drcPoint[1];
\r
1214 float drcValue = float.Parse(value);
\r
1215 drcValue = drcValue * 10;
\r
1216 thisQuery.q_drc2 = drcValue;
\r
1219 thisQuery.q_drc2 = 0;
\r
1221 if (drc3.Success != false)
\r
1223 string[] drcPoint = drc3.ToString().Split(',');
\r
1224 string value = drcPoint[2];
\r
1225 float drcValue = float.Parse(value);
\r
1226 drcValue = drcValue * 10;
\r
1227 thisQuery.q_drc3 = drcValue;
\r
1230 thisQuery.q_drc3 = 0;
\r
1232 if (drc4.Success != false)
\r
1234 string[] drcPoint = drc4.ToString().Split(',');
\r
1235 string value = drcPoint[3];
\r
1236 float drcValue = float.Parse(value);
\r
1237 drcValue = drcValue * 10;
\r
1238 thisQuery.q_drc4 = drcValue;
\r
1241 thisQuery.q_drc4 = 0;
\r
1245 if (subtitles.Success != false)
\r
1246 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1249 if (subScan.Success)
\r
1250 thisQuery.q_subtitles = "Autoselect";
\r
1252 thisQuery.q_subtitles = "None";
\r
1255 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1259 #region H.264 and other
\r
1263 if (x264.Success != false)
\r
1264 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1269 thisQuery.q_verbose = verbose.Success;
\r
1272 catch (Exception exc)
\r
1274 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
1281 private static string getMixDown(string mixdown)
\r
1290 return "Dolby Surround";
\r
1292 return "Dolby Pro Logic II";
\r
1294 return "6 Channel Discrete";
\r
1296 return "Automatic";
\r
1299 private static string getAudioEncoder(string audioEnc)
\r