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 int q_maxWidth;
\r
148 /// The selected Width for the encoding.
\r
150 public int MaxWidth
\r
154 return this.q_maxWidth;
\r
158 private int q_maxHeight;
\r
161 /// The selected Height for the encoding.
\r
163 public int MaxHeight
\r
167 return this.q_maxHeight;
\r
171 private string q_cropValues;
\r
173 /// Returns an String
\r
174 /// Cropping values.
\r
176 public string CropValues
\r
180 return this.q_cropValues;
\r
184 private string q_croptop;
\r
186 /// Returns an String
\r
187 /// Cropping values.
\r
189 public string CropTop
\r
193 return this.q_croptop;
\r
197 private string q_cropbottom;
\r
199 /// Returns an String
\r
200 /// Cropping values.
\r
202 public string CropBottom
\r
206 return this.q_cropbottom;
\r
210 private string q_cropLeft;
\r
212 /// Returns an String
\r
213 /// Cropping values.
\r
215 public string CropLeft
\r
219 return this.q_cropLeft;
\r
223 private string q_cropRight;
\r
225 /// Returns an String
\r
226 /// Cropping values.
\r
228 public string CropRight
\r
232 return this.q_cropRight;
\r
236 private Boolean q_detelecine;
\r
238 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
240 public Boolean DeTelecine
\r
244 return this.q_detelecine;
\r
248 private int q_deBlock;
\r
250 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
256 return this.q_deBlock;
\r
260 private string q_deinterlace;
\r
262 /// Returns a string with the De-Interlace option used.
\r
264 public string DeInterlace
\r
268 return this.q_deinterlace;
\r
272 private string q_denoise;
\r
274 /// Returns a string with the DeNoise option used.
\r
276 public string DeNoise
\r
280 return this.q_denoise;
\r
284 private Boolean q_decomb;
\r
286 /// Returns a string with the DeNoise option used.
\r
288 public Boolean Decomb
\r
292 return this.q_decomb;
\r
296 private Boolean q_anamorphic;
\r
298 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
300 public Boolean Anamorphic
\r
304 return this.q_anamorphic;
\r
308 private Boolean q_looseAnamorphic;
\r
310 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
312 public Boolean LooseAnamorphic
\r
316 return this.q_looseAnamorphic;
\r
320 private Boolean q_chapterMarkers;
\r
322 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
324 public Boolean ChapterMarkers
\r
328 return this.q_chapterMarkers;
\r
333 #region Video Settings
\r
334 private Boolean q_grayscale;
\r
336 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
338 public Boolean Grayscale
\r
342 return this.q_grayscale;
\r
346 private Boolean q_twoPass;
\r
348 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
350 public Boolean TwoPass
\r
354 return this.q_twoPass;
\r
358 private Boolean q_turboFirst;
\r
360 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
362 public Boolean TurboFirstPass
\r
366 return this.q_turboFirst;
\r
370 private Boolean q_largeMp4;
\r
372 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
374 public Boolean LargeMP4
\r
378 return this.q_largeMp4;
\r
382 private Boolean q_ipodAtom;
\r
384 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
386 public Boolean IpodAtom
\r
390 return this.q_ipodAtom;
\r
394 private Boolean q_optimizeMp4;
\r
396 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
398 public Boolean OptimizeMP4
\r
402 return this.q_optimizeMp4;
\r
406 private string q_videoFramerate;
\r
408 /// Returns a string with the video Framerate
\r
410 public string VideoFramerate
\r
414 return this.q_videoFramerate;
\r
418 private string q_avgBitrate;
\r
420 /// Returns a string with the average video bitrate
\r
422 public string AverageVideoBitrate
\r
426 return this.q_avgBitrate;
\r
430 private string q_videoTargetSize;
\r
432 /// Returns a string with the video target size
\r
434 public string VideoTargetSize
\r
438 return this.q_videoTargetSize;
\r
442 private int q_videoQuality;
\r
444 /// Returns a int with the video quality value
\r
446 public int VideoQuality
\r
450 return this.q_videoQuality;
\r
456 #region Audio Settings
\r
457 private string q_audioTrack1;
\r
459 /// Returns a string with the selected Audio track
\r
461 public string AudioTrack1
\r
465 return this.q_audioTrack1;
\r
469 private string q_audioTrack2;
\r
471 /// Returns a string with the selected Audio track
\r
473 public string AudioTrack2
\r
477 return this.q_audioTrack2;
\r
481 private string q_audioTrack3;
\r
483 /// Returns a string with the selected Audio track
\r
485 public string AudioTrack3
\r
489 return this.q_audioTrack3;
\r
493 private string q_audioTrack4;
\r
495 /// Returns a string with the selected Audio track
\r
497 public string AudioTrack4
\r
501 return this.q_audioTrack4;
\r
505 private string q_audioTrackMix1;
\r
507 /// Returns a string with the First selected Audio track Mix
\r
509 public string AudioTrackMix1
\r
513 return this.q_audioTrackMix1;
\r
517 private string q_audioTrackMix2;
\r
519 /// Returns a string with the First selected Audio track Mix
\r
521 public string AudioTrackMix2
\r
525 return this.q_audioTrackMix2;
\r
529 private string q_audioTrackMix3;
\r
531 /// Returns a string with the First selected Audio track Mix
\r
533 public string AudioTrackMix3
\r
537 return this.q_audioTrackMix3;
\r
541 private string q_audioTrackMix4;
\r
543 /// Returns a string with the First selected Audio track Mix
\r
545 public string AudioTrackMix4
\r
549 return this.q_audioTrackMix4;
\r
553 private string q_audioEncoder1;
\r
555 /// Returns an String
\r
556 /// The Audio Encoder used.
\r
558 public string AudioEncoder1
\r
562 return this.q_audioEncoder1;
\r
566 private string q_audioEncoder2;
\r
568 /// Returns an String
\r
569 /// The Audio Encoder used.
\r
571 public string AudioEncoder2
\r
575 return this.q_audioEncoder2;
\r
579 private string q_audioEncoder3;
\r
581 /// Returns an String
\r
582 /// The Audio Encoder used.
\r
584 public string AudioEncoder3
\r
588 return this.q_audioEncoder3;
\r
592 private string q_audioEncoder4;
\r
594 /// Returns an String
\r
595 /// The Audio Encoder used.
\r
597 public string AudioEncoder4
\r
601 return this.q_audioEncoder4;
\r
605 private string q_audioBitrate1;
\r
607 /// Returns a string with the audio bitrate
\r
609 public string AudioBitrate1
\r
613 return this.q_audioBitrate1;
\r
617 private string q_audioBitrate2;
\r
619 /// Returns a string with the audio bitrate
\r
621 public string AudioBitrate2
\r
625 return this.q_audioBitrate2;
\r
629 private string q_audioBitrate3;
\r
631 /// Returns a string with the audio bitrate
\r
633 public string AudioBitrate3
\r
637 return this.q_audioBitrate3;
\r
641 private string q_audioBitrate4;
\r
643 /// Returns a string with the audio bitrate
\r
645 public string AudioBitrate4
\r
649 return this.q_audioBitrate4;
\r
653 private string q_audioSamplerate1;
\r
655 /// Returns a string with the audio sample rate
\r
657 public string AudioSamplerate1
\r
661 return this.q_audioSamplerate1;
\r
665 private string q_audioSamplerate2;
\r
667 /// Returns a string with the audio sample rate
\r
669 public string AudioSamplerate2
\r
673 return this.q_audioSamplerate2;
\r
677 private string q_audioSamplerate3;
\r
679 /// Returns a string with the audio sample rate
\r
681 public string AudioSamplerate3
\r
685 return this.q_audioSamplerate3;
\r
689 private string q_audioSamplerate4;
\r
691 /// Returns a string with the audio sample rate
\r
693 public string AudioSamplerate4
\r
697 return this.q_audioSamplerate4;
\r
701 private double q_drc1;
\r
703 /// Returns a string with the selected subtitle track
\r
709 return this.q_drc1;
\r
713 private double q_drc2;
\r
715 /// Returns a string with the selected subtitle track
\r
721 return this.q_drc2;
\r
725 private double q_drc3;
\r
727 /// Returns a string with the selected subtitle track
\r
733 return this.q_drc3;
\r
737 private double q_drc4;
\r
739 /// Returns a string with the selected subtitle track
\r
745 return this.q_drc4;
\r
749 private string q_subtitles;
\r
751 /// Returns a string with the selected subtitle track
\r
753 public string Subtitles
\r
757 return this.q_subtitles;
\r
761 private Boolean q_forcedSubs;
\r
763 /// Returns a string with the selected subtitle track
\r
765 public Boolean ForcedSubtitles
\r
769 return this.q_forcedSubs;
\r
776 private string q_h264;
\r
778 /// Returns a string with the Advanced H264 query string
\r
780 public string H264Query
\r
784 return this.q_h264;
\r
787 private Boolean q_verbose;
\r
789 /// Returns a string with the Advanced H264 query string
\r
791 public Boolean Verbose
\r
795 return this.q_verbose;
\r
803 /// Takes in a query which can be in any order and parses it.
\r
804 /// All varibles are then set so they can be used elsewhere.
\r
806 /// <param name="input">A ClI Query</param>
\r
807 /// <returns>A Parsed Query</returns>
\r
809 public static QueryParser Parse(String input)
\r
811 QueryParser thisQuery = new QueryParser();
\r
813 #region Regular Expressions
\r
815 Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");
\r
816 Match source = r1.Match(input.Replace('"', '\"'));
\r
817 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
818 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
819 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
822 Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9_\-:\\\s\.]+)(?:\"")");
\r
823 Match destination = r2.Match(input.Replace('"', '\"'));
\r
824 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
826 //Picture Settings Tab
\r
827 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
828 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
829 Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
\r
830 Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
\r
831 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z]*)\""");
\r
832 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z]*)\""");
\r
833 Match deblock = Regex.Match(input, @"--deblock=([0-9]*)");
\r
834 Match detelecine = Regex.Match(input, @"--detelecine");
\r
835 Match anamorphic = Regex.Match(input, @" -p ");
\r
836 Match chapterMarkers = Regex.Match(input, @" -m");
\r
837 Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
\r
838 Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
\r
839 Match lanamorphic = Regex.Match(input, @" -P");
\r
840 Match decomb = Regex.Match(input, @" --decomb");
\r
842 //Video Settings Tab
\r
843 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
844 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
845 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
846 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
847 Match twoPass = Regex.Match(input, @" -2");
\r
848 Match turboFirstPass = Regex.Match(input, @" -T");
\r
849 Match grayscale = Regex.Match(input, @" -g");
\r
850 Match largerMp4 = Regex.Match(input, @" -4");
\r
851 Match ipodAtom = Regex.Match(input, @" -I");
\r
852 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
854 //Audio Settings Tab
\r
855 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
856 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
857 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
858 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
860 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
861 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
862 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
863 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
865 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
866 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
867 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
868 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
870 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9]*)");
\r
871 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9]*),([0-9]*)");
\r
872 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*)");
\r
873 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
875 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9.]*)");
\r
876 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*)");
\r
877 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
878 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
880 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
881 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
882 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
883 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
885 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
886 Match subScan = Regex.Match(input, @" -U");
\r
887 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
890 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
893 Match verbose = Regex.Match(input, @" -v");
\r
896 #region Set Varibles
\r
902 thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");
\r
903 if (title.Success != false)
\r
904 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
906 if (chapters.Success != false)
\r
908 string[] actTitles = new string[2];
\r
909 actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
910 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
911 if (actTitles.Length > 1)
\r
913 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
916 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
917 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
920 if (format.Success != false)
\r
921 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
925 #region Destination
\r
926 thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");
\r
928 string videoEncoderConvertion;
\r
930 videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
931 switch (videoEncoderConvertion)
\r
934 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
937 videoEncoderConvertion = "MPEG-4 (XviD)";
\r
940 videoEncoderConvertion = "H.264 (x264)";
\r
943 videoEncoderConvertion = "VP3 (Theora)";
\r
946 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
949 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
953 #region Picture Tab
\r
955 if (width.Success != false)
\r
956 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
958 if (height.Success != false)
\r
959 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
961 if (maxWidth.Success != false)
\r
962 thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
\r
964 if (maxHeight.Success != false)
\r
965 thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
\r
967 if (crop.Success != false)
\r
969 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
970 string[] actCropValues = new string[3];
\r
971 actCropValues = thisQuery.q_cropValues.Split(':');
\r
972 thisQuery.q_croptop = actCropValues[0];
\r
973 thisQuery.q_cropbottom = actCropValues[1];
\r
974 thisQuery.q_cropLeft = actCropValues[2];
\r
975 thisQuery.q_cropRight = actCropValues[3];
\r
979 string deblockValue = "";
\r
980 thisQuery.q_deBlock = 0;
\r
981 if (deblock.Success != false)
\r
982 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
984 if (deblockValue != "")
\r
985 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
987 thisQuery.q_detelecine = detelecine.Success;
\r
988 thisQuery.q_decomb = decomb.Success;
\r
990 thisQuery.q_deinterlace = "None";
\r
991 if (deinterlace.Success != false)
\r
993 switch (deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"",""))
\r
996 thisQuery.q_deinterlace = "Fast";
\r
999 thisQuery.q_deinterlace = "Slow";
\r
1002 thisQuery.q_deinterlace = "Slower";
\r
1005 thisQuery.q_deinterlace = "Slowest";
\r
1008 thisQuery.q_deinterlace = "None";
\r
1013 thisQuery.q_denoise = "None";
\r
1014 if (denoise.Success != false)
\r
1016 switch (denoise.ToString().Replace("--denoise=", "").Replace("\"", ""))
\r
1019 thisQuery.q_denoise = "Weak";
\r
1022 thisQuery.q_denoise = "Medium";
\r
1025 thisQuery.q_denoise = "Strong";
\r
1028 thisQuery.q_denoise = "None";
\r
1033 thisQuery.q_anamorphic = anamorphic.Success;
\r
1034 if (chapterMarkersFileMode.Success == true || chapterMarkers.Success == true)
\r
1035 thisQuery.q_chapterMarkers = true;
\r
1037 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
1041 #region Video Settings Tab
\r
1042 thisQuery.q_grayscale = grayscale.Success;
\r
1043 thisQuery.q_twoPass = twoPass.Success;
\r
1044 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
1045 thisQuery.q_largeMp4 = largerMp4.Success;
\r
1046 if (videoFramerate.Success != false)
\r
1047 thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");
\r
1049 thisQuery.q_videoFramerate = "Same as source";
\r
1051 if (videoBitrate.Success != false)
\r
1052 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
1053 if (videoFilesize.Success != false)
\r
1054 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
1056 double qConvert = 0;
\r
1057 if (videoQuality.Success != false)
\r
1059 qConvert = double.Parse(videoQuality.ToString().Replace("-q ", ""), Functions.Encode.Culture) * 100;
\r
1060 qConvert = System.Math.Ceiling(qConvert);
\r
1061 thisQuery.q_videoQuality = int.Parse(qConvert.ToString());
\r
1063 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
1064 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
1071 if (audioTrack1.Success != false)
\r
1072 thisQuery.q_audioTrack1 = audioTrack1.ToString().Replace("-a ", "");
\r
1074 thisQuery.q_audioTrack1 = "Automatic";
\r
1076 if (audioTrack2.Success != false)
\r
1078 string[] audioChan = audioTrack2.ToString().Split(',');
\r
1079 thisQuery.q_audioTrack2 = audioChan[1];
\r
1082 thisQuery.q_audioTrack2 = "None";
\r
1084 if (audioTrack3.Success != false)
\r
1086 string[] audioChan = audioTrack3.ToString().Split(',');
\r
1087 thisQuery.q_audioTrack3 = audioChan[2];
\r
1090 thisQuery.q_audioTrack3 = "None";
\r
1092 if (audioTrack4.Success != false)
\r
1094 string[] audioChan = audioTrack4.ToString().Split(',');
\r
1095 thisQuery.q_audioTrack4 = audioChan[3];
\r
1098 thisQuery.q_audioTrack4 = "None";
\r
1102 thisQuery.q_audioTrackMix1 = "Automatic";
\r
1103 if (audioTrack1Mix.Success != false)
\r
1105 thisQuery.q_audioTrackMix1 = getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
1108 thisQuery.q_audioTrackMix2 = "Automatic";
\r
1109 if (audioTrack2Mix.Success != false)
\r
1111 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
1112 audio2mix[1] = audio2mix[1].Trim();
\r
1113 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1]);
\r
1116 thisQuery.q_audioTrackMix3 = "Automatic";
\r
1117 if (audioTrack3Mix.Success != false)
\r
1119 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
1120 audio3mix[1] = audio3mix[2].Trim();
\r
1121 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[1]);
\r
1124 thisQuery.q_audioTrackMix4 = "Automatic";
\r
1125 if (audioTrack4Mix.Success != false)
\r
1127 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
1128 audio4mix[1] = audio4mix[3].Trim();
\r
1129 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[1]);
\r
1134 if (audioEncoder1.Success != false)
\r
1135 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
1137 if (audioEncoder2.Success != false)
\r
1139 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
1140 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
1143 if (audioEncoder3.Success != false)
\r
1145 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
1146 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
1149 if (audioEncoder4.Success != false)
\r
1151 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
1152 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
1157 if (audioBitrate1.Success != false)
\r
1158 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
1160 thisQuery.q_audioBitrate1 = "";
\r
1162 if (audioBitrate2.Success != false)
\r
1164 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
1165 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
1168 thisQuery.q_audioBitrate2 = "";
\r
1170 if (audioBitrate3.Success != false)
\r
1172 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
1173 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
1176 thisQuery.q_audioBitrate3 = "";
\r
1178 if (audioBitrate4.Success != false)
\r
1180 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
1181 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
1184 thisQuery.q_audioBitrate4 = "";
\r
1187 // Audio Sample Rate
\r
1188 // Make sure to change 0 to Auto
\r
1189 if (audioSampleRate1.Success != false)
\r
1191 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
1192 if (thisQuery.q_audioSamplerate1 == "0")
\r
1193 thisQuery.q_audioSamplerate1 = "Auto";
\r
1196 thisQuery.q_audioSamplerate1 = "Auto";
\r
1198 if (audioSampleRate2.Success != false)
\r
1200 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
1201 if (audioSRSelect[1] == "0")
\r
1202 audioSRSelect[1] = "Auto";
\r
1203 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
1206 if (audioSampleRate3.Success != false)
\r
1208 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
1209 if (audioSRSelect[1] == "0")
\r
1210 audioSRSelect[1] = "Auto";
\r
1211 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
1214 if (audioSampleRate4.Success != false)
\r
1216 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
1217 if (audioSRSelect[1] == "0")
\r
1218 audioSRSelect[1] = "Auto";
\r
1219 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1223 if (drc1.Success != false)
\r
1225 string value = drc1.ToString().Replace("-D ", "");
\r
1226 float drcValue = float.Parse(value);
\r
1227 drcValue = drcValue * 10;
\r
1228 thisQuery.q_drc1 = drcValue;
\r
1231 thisQuery.q_drc1 = 10;
\r
1233 if (drc2.Success != false)
\r
1235 string[] drcPoint = drc2.ToString().Split(',');
\r
1236 string value = drcPoint[1];
\r
1237 float drcValue = float.Parse(value);
\r
1238 drcValue = drcValue * 10;
\r
1239 thisQuery.q_drc2 = drcValue;
\r
1242 thisQuery.q_drc2 = 10;
\r
1244 if (drc3.Success != false)
\r
1246 string[] drcPoint = drc3.ToString().Split(',');
\r
1247 string value = drcPoint[2];
\r
1248 float drcValue = float.Parse(value);
\r
1249 drcValue = drcValue * 10;
\r
1250 thisQuery.q_drc3 = drcValue;
\r
1253 thisQuery.q_drc3 = 10;
\r
1255 if (drc4.Success != false)
\r
1257 string[] drcPoint = drc4.ToString().Split(',');
\r
1258 string value = drcPoint[3];
\r
1259 float drcValue = float.Parse(value);
\r
1260 drcValue = drcValue * 10;
\r
1261 thisQuery.q_drc4 = drcValue;
\r
1264 thisQuery.q_drc4 = 10;
\r
1268 if (subtitles.Success != false)
\r
1269 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1272 if (subScan.Success)
\r
1273 thisQuery.q_subtitles = "Autoselect";
\r
1275 thisQuery.q_subtitles = "None";
\r
1278 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1282 #region H.264 and other
\r
1286 if (x264.Success != false)
\r
1287 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1292 thisQuery.q_verbose = verbose.Success;
\r
1295 catch (Exception exc)
\r
1297 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
1304 private static string getMixDown(string mixdown)
\r
1313 return "Dolby Surround";
\r
1315 return "Dolby Pro Logic II";
\r
1317 return "6 Channel Discrete";
\r
1319 return "Automatic";
\r
1322 private static string getAudioEncoder(string audioEnc)
\r