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.Globalization;
\r
9 using System.Text.RegularExpressions;
\r
10 using System.Windows.Forms;
\r
11 using System.Collections;
\r
13 namespace Handbrake.Functions
\r
15 internal class QueryParser
\r
17 private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
\r
23 private int q_chaptersFinish;
\r
24 private int q_chaptersStart;
\r
25 private int q_dvdTitle;
\r
28 /// Returns an Integer
\r
29 /// DVD Title number.
\r
33 get { return q_dvdTitle; }
\r
38 /// DVD Chapter number or chapter range.
\r
40 public int DVDChapterStart
\r
42 get { return q_chaptersStart; }
\r
47 /// DVD Chapter number or chapter range.
\r
49 public int DVDChapterFinish
\r
51 get { return q_chaptersFinish; }
\r
58 private string q_format;
\r
59 private string q_videoEncoder;
\r
62 /// Returns a String
\r
63 /// Full path of the destination.
\r
65 public string Format
\r
67 get { return q_format; }
\r
71 /// Returns an String
\r
72 /// The Video Encoder used.
\r
74 public string VideoEncoder
\r
76 get { return q_videoEncoder; }
\r
81 #region Picture Settings
\r
83 private Boolean q_anamorphic;
\r
84 private Boolean q_chapterMarkers;
\r
85 private string q_cropbottom;
\r
86 private string q_cropLeft;
\r
87 private string q_cropRight;
\r
88 private string q_croptop;
\r
89 private string q_cropValues;
\r
90 private int q_deBlock;
\r
91 private string q_decomb;
\r
92 private string q_deinterlace;
\r
93 private string q_denoise;
\r
94 private string q_detelecine;
\r
95 private Boolean q_looseAnamorphic;
\r
96 private int q_maxHeight;
\r
97 private int q_maxWidth;
\r
98 private int q_videoHeight;
\r
99 private int q_videoWidth;
\r
103 /// The selected Width for the encoding.
\r
107 get { return q_videoWidth; }
\r
112 /// The selected Height for the encoding.
\r
116 get { return q_videoHeight; }
\r
121 /// The selected Width for the encoding.
\r
123 public int MaxWidth
\r
125 get { return q_maxWidth; }
\r
130 /// The selected Height for the encoding.
\r
132 public int MaxHeight
\r
134 get { return q_maxHeight; }
\r
138 /// Returns an String
\r
139 /// Cropping values.
\r
141 public string CropValues
\r
143 get { return q_cropValues; }
\r
147 /// Returns an String
\r
148 /// Cropping values.
\r
150 public string CropTop
\r
152 get { return q_croptop; }
\r
156 /// Returns an String
\r
157 /// Cropping values.
\r
159 public string CropBottom
\r
161 get { return q_cropbottom; }
\r
165 /// Returns an String
\r
166 /// Cropping values.
\r
168 public string CropLeft
\r
170 get { return q_cropLeft; }
\r
174 /// Returns an String
\r
175 /// Cropping values.
\r
177 public string CropRight
\r
179 get { return q_cropRight; }
\r
183 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
185 public string DeTelecine
\r
187 get { return q_detelecine; }
\r
191 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
195 get { return q_deBlock; }
\r
199 /// Returns a string with the De-Interlace option used.
\r
201 public string DeInterlace
\r
203 get { return q_deinterlace; }
\r
207 /// Returns a string with the DeNoise option used.
\r
209 public string DeNoise
\r
211 get { return q_denoise; }
\r
215 /// Returns a string with the DeNoise option used.
\r
217 public string Decomb
\r
219 get { return q_decomb; }
\r
223 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
225 public Boolean Anamorphic
\r
227 get { return q_anamorphic; }
\r
231 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
233 public Boolean LooseAnamorphic
\r
235 get { return q_looseAnamorphic; }
\r
239 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
241 public Boolean ChapterMarkers
\r
243 get { return q_chapterMarkers; }
\r
248 #region Video Settings
\r
250 private string q_avgBitrate;
\r
251 private Boolean q_grayscale;
\r
252 private Boolean q_ipodAtom;
\r
253 private Boolean q_largeMp4;
\r
254 private Boolean q_optimizeMp4;
\r
255 private Boolean q_turboFirst;
\r
257 private Boolean q_twoPass;
\r
258 private string q_videoFramerate;
\r
259 private float q_videoQuality;
\r
260 private string q_videoTargetSize;
\r
263 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
265 public Boolean Grayscale
\r
267 get { return q_grayscale; }
\r
271 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
273 public Boolean TwoPass
\r
275 get { return q_twoPass; }
\r
279 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
281 public Boolean TurboFirstPass
\r
283 get { return q_turboFirst; }
\r
287 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
289 public Boolean LargeMP4
\r
291 get { return q_largeMp4; }
\r
295 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
297 public Boolean IpodAtom
\r
299 get { return q_ipodAtom; }
\r
303 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
305 public Boolean OptimizeMP4
\r
307 get { return q_optimizeMp4; }
\r
311 /// Returns a string with the video Framerate
\r
313 public string VideoFramerate
\r
315 get { return q_videoFramerate; }
\r
319 /// Returns a string with the average video bitrate
\r
321 public string AverageVideoBitrate
\r
323 get { return q_avgBitrate; }
\r
327 /// Returns a string with the video target size
\r
329 public string VideoTargetSize
\r
331 get { return q_videoTargetSize; }
\r
335 /// Returns a int with the video quality value
\r
337 public float VideoQuality
\r
339 get { return q_videoQuality; }
\r
344 #region Audio Settings
\r
346 private string q_audioBitrate1;
\r
347 private string q_audioBitrate2;
\r
348 private string q_audioBitrate3;
\r
349 private string q_audioBitrate4;
\r
350 private string q_audioEncoder1;
\r
351 private string q_audioEncoder2;
\r
352 private string q_audioEncoder3;
\r
353 private string q_audioEncoder4;
\r
354 private string q_audioSamplerate1;
\r
355 private string q_audioSamplerate2;
\r
356 private string q_audioSamplerate3;
\r
357 private string q_audioSamplerate4;
\r
358 private string q_audioTrack1;
\r
359 private string q_audioTrack2;
\r
360 private string q_audioTrack3;
\r
361 private string q_audioTrack4;
\r
362 private string q_audioTrackMix1;
\r
363 private string q_audioTrackMix2;
\r
364 private string q_audioTrackMix3;
\r
365 private string q_audioTrackMix4;
\r
366 private double q_drc1;
\r
367 private double q_drc2;
\r
368 private double q_drc3;
\r
369 private double q_drc4;
\r
370 private Boolean q_forcedSubs;
\r
371 private string q_subtitles;
\r
374 /// Returns a string with the selected Audio track
\r
376 public string AudioTrack1
\r
378 get { return q_audioTrack1; }
\r
382 /// Returns a string with the selected Audio track
\r
384 public string AudioTrack2
\r
386 get { return q_audioTrack2; }
\r
390 /// Returns a string with the selected Audio track
\r
392 public string AudioTrack3
\r
394 get { return q_audioTrack3; }
\r
398 /// Returns a string with the selected Audio track
\r
400 public string AudioTrack4
\r
402 get { return q_audioTrack4; }
\r
406 /// Returns a string with the First selected Audio track Mix
\r
408 public string AudioTrackMix1
\r
410 get { return q_audioTrackMix1; }
\r
414 /// Returns a string with the First selected Audio track Mix
\r
416 public string AudioTrackMix2
\r
418 get { return q_audioTrackMix2; }
\r
422 /// Returns a string with the First selected Audio track Mix
\r
424 public string AudioTrackMix3
\r
426 get { return q_audioTrackMix3; }
\r
430 /// Returns a string with the First selected Audio track Mix
\r
432 public string AudioTrackMix4
\r
434 get { return q_audioTrackMix4; }
\r
438 /// Returns an String
\r
439 /// The Audio Encoder used.
\r
441 public string AudioEncoder1
\r
443 get { return q_audioEncoder1; }
\r
447 /// Returns an String
\r
448 /// The Audio Encoder used.
\r
450 public string AudioEncoder2
\r
452 get { return q_audioEncoder2; }
\r
456 /// Returns an String
\r
457 /// The Audio Encoder used.
\r
459 public string AudioEncoder3
\r
461 get { return q_audioEncoder3; }
\r
465 /// Returns an String
\r
466 /// The Audio Encoder used.
\r
468 public string AudioEncoder4
\r
470 get { return q_audioEncoder4; }
\r
474 /// Returns a string with the audio bitrate
\r
476 public string AudioBitrate1
\r
478 get { return q_audioBitrate1; }
\r
482 /// Returns a string with the audio bitrate
\r
484 public string AudioBitrate2
\r
486 get { return q_audioBitrate2; }
\r
490 /// Returns a string with the audio bitrate
\r
492 public string AudioBitrate3
\r
494 get { return q_audioBitrate3; }
\r
498 /// Returns a string with the audio bitrate
\r
500 public string AudioBitrate4
\r
502 get { return q_audioBitrate4; }
\r
506 /// Returns a string with the audio sample rate
\r
508 public string AudioSamplerate1
\r
510 get { return q_audioSamplerate1; }
\r
514 /// Returns a string with the audio sample rate
\r
516 public string AudioSamplerate2
\r
518 get { return q_audioSamplerate2; }
\r
522 /// Returns a string with the audio sample rate
\r
524 public string AudioSamplerate3
\r
526 get { return q_audioSamplerate3; }
\r
530 /// Returns a string with the audio sample rate
\r
532 public string AudioSamplerate4
\r
534 get { return q_audioSamplerate4; }
\r
538 /// Returns a string with the selected subtitle track
\r
542 get { return q_drc1; }
\r
546 /// Returns a string with the selected subtitle track
\r
550 get { return q_drc2; }
\r
554 /// Returns a string with the selected subtitle track
\r
558 get { return q_drc3; }
\r
562 /// Returns a string with the selected subtitle track
\r
566 get { return q_drc4; }
\r
570 /// Returns a string with the selected subtitle track
\r
572 public string Subtitles
\r
574 get { return q_subtitles; }
\r
578 /// Returns a string with the selected subtitle track
\r
580 public Boolean ForcedSubtitles
\r
582 get { return q_forcedSubs; }
\r
589 private string q_h264;
\r
590 private Boolean q_verbose;
\r
593 /// Returns a string with the Advanced H264 query string
\r
595 public string H264Query
\r
597 get { return q_h264; }
\r
601 /// Returns a string with the Advanced H264 query string
\r
603 public Boolean Verbose
\r
605 get { return q_verbose; }
\r
612 // All the Main Window GUI options
\r
614 /// Takes in a query which can be in any order and parses it.
\r
615 /// All varibles are then set so they can be used elsewhere.
\r
617 /// <param name="input">A ClI Query</param>
\r
618 /// <returns>A Parsed Query</returns>
\r
619 public static QueryParser Parse(String input)
\r
621 var thisQuery = new QueryParser();
\r
623 #region Regular Expressions
\r
625 // Useful Destination Finder
\r
626 //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");
\r
627 //Match source = r1.Match(input.Replace('"', '\"'));
\r
630 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
631 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
634 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
635 Match grayscale = Regex.Match(input, @" -g");
\r
636 Match largerMp4 = Regex.Match(input, @" -4");
\r
637 Match ipodAtom = Regex.Match(input, @" -I");
\r
639 //Picture Settings Tab
\r
640 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
641 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
642 Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
\r
643 Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
\r
644 Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
\r
645 Match lanamorphic = Regex.Match(input, @" -P");
\r
646 Match anamorphic = Regex.Match(input, @" -p ");
\r
648 // Picture Settings - Filters
\r
649 Match decomb = Regex.Match(input, @" --decomb");
\r
650 Match decombValue = Regex.Match(input, @" --decomb=\""([a-zA-Z0-9.:]*)\""");
\r
651 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\""");
\r
652 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\""");
\r
653 Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)");
\r
654 Match detelecine = Regex.Match(input, @"--detelecine");
\r
655 Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");
\r
657 //Video Settings Tab
\r
658 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
659 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
660 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
661 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
662 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
663 Match twoPass = Regex.Match(input, @" -2");
\r
664 Match turboFirstPass = Regex.Match(input, @" -T");
\r
665 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
667 //Audio Settings Tab
\r
668 Match noAudio = Regex.Match(input, @"-a none");
\r
669 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
670 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
671 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
672 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
674 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
675 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
676 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
677 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
679 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
680 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
681 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
682 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
684 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");
\r
685 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");
\r
686 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
687 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
689 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");
\r
690 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");
\r
691 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
692 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
694 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
695 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
696 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
697 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
699 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
700 Match subScan = Regex.Match(input, @" -U");
\r
701 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
704 Match chapterMarkers = Regex.Match(input, @" -m");
\r
705 Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
\r
708 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
711 Match verbose = Regex.Match(input, @" -v");
\r
715 #region Set Varibles
\r
722 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
724 if (chapters.Success)
\r
726 string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
727 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
728 if (actTitles.Length > 1)
\r
730 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
733 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
734 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
738 #region Output Settings
\r
740 if (format.Success)
\r
741 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
742 thisQuery.q_largeMp4 = largerMp4.Success;
\r
743 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
744 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
748 #region Picture Tab
\r
751 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
753 if (height.Success)
\r
754 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
756 if (maxWidth.Success)
\r
757 thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
\r
759 if (maxHeight.Success)
\r
760 thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
\r
764 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
765 string[] actCropValues = thisQuery.q_cropValues.Split(':');
\r
766 thisQuery.q_croptop = actCropValues[0];
\r
767 thisQuery.q_cropbottom = actCropValues[1];
\r
768 thisQuery.q_cropLeft = actCropValues[2];
\r
769 thisQuery.q_cropRight = actCropValues[3];
\r
772 thisQuery.q_anamorphic = anamorphic.Success;
\r
773 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
779 thisQuery.q_decomb = "Off";
\r
780 if (decomb.Success)
\r
782 thisQuery.q_decomb = "Default";
\r
783 if (decombValue.Success)
\r
784 thisQuery.q_decomb = decombValue.ToString().Replace("--decomb=", "").Replace("\"", "");
\r
787 thisQuery.q_deinterlace = "None";
\r
788 if (deinterlace.Success)
\r
790 thisQuery.q_deinterlace = deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"", "");
\r
791 thisQuery.q_deinterlace = thisQuery.q_deinterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");
\r
792 thisQuery.q_deinterlace = thisQuery.q_deinterlace.Replace("slowest", "Slowest");
\r
795 thisQuery.q_denoise = "None";
\r
796 if (denoise.Success)
\r
798 thisQuery.q_denoise = denoise.ToString().Replace("--denoise=", "").Replace("\"", "");
\r
799 thisQuery.q_denoise = thisQuery.q_denoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");
\r
802 string deblockValue = "";
\r
803 thisQuery.q_deBlock = 0;
\r
804 if (deblock.Success)
\r
805 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
806 if (deblockValue != "")
\r
807 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
809 thisQuery.q_detelecine = "Off";
\r
810 if (detelecine.Success)
\r
812 thisQuery.q_detelecine = "Default";
\r
813 if (detelecineValue.Success)
\r
814 thisQuery.q_detelecine = detelecineValue.ToString().Replace("--detelecine=", "").Replace("\"", "");
\r
819 #region Video Settings Tab
\r
821 string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
822 switch (videoEncoderConvertion)
\r
825 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
828 videoEncoderConvertion = "MPEG-4 (XviD)";
\r
831 videoEncoderConvertion = "H.264 (x264)";
\r
834 videoEncoderConvertion = "VP3 (Theora)";
\r
837 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
840 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
841 thisQuery.q_videoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";
\r
842 thisQuery.q_grayscale = grayscale.Success;
\r
843 thisQuery.q_twoPass = twoPass.Success;
\r
844 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
846 if (videoBitrate.Success)
\r
847 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
848 if (videoFilesize.Success)
\r
849 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
851 if (videoQuality.Success)
\r
853 float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);
\r
854 //qConvert = Math.Ceiling(qConvert);
\r
855 thisQuery.q_videoQuality = qConvert;
\r
862 if (noAudio.Success)
\r
863 thisQuery.q_audioTrack1 = "None";
\r
864 else if (audioTrack1.Success)
\r
865 thisQuery.q_audioTrack1 = "Automatic";
\r
867 if (audioTrack2.Success)
\r
869 string[] audioChan = audioTrack2.ToString().Split(',');
\r
870 thisQuery.q_audioTrack2 = audioChan[1];
\r
873 thisQuery.q_audioTrack2 = "None";
\r
875 if (audioTrack3.Success)
\r
877 string[] audioChan = audioTrack3.ToString().Split(',');
\r
878 thisQuery.q_audioTrack3 = audioChan[2];
\r
881 thisQuery.q_audioTrack3 = "None";
\r
883 if (audioTrack4.Success)
\r
885 string[] audioChan = audioTrack4.ToString().Split(',');
\r
886 thisQuery.q_audioTrack4 = audioChan[3];
\r
889 thisQuery.q_audioTrack4 = "None";
\r
893 thisQuery.q_audioTrackMix1 = "Automatic";
\r
894 if (audioTrack1Mix.Success)
\r
895 thisQuery.q_audioTrackMix1 =
\r
896 getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
898 thisQuery.q_audioTrackMix2 = "Automatic";
\r
899 if (audioTrack2Mix.Success)
\r
901 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
902 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1].Trim());
\r
905 thisQuery.q_audioTrackMix3 = "Automatic";
\r
906 if (audioTrack3Mix.Success)
\r
908 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
909 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[2].Trim());
\r
912 thisQuery.q_audioTrackMix4 = "Automatic";
\r
913 if (audioTrack4Mix.Success)
\r
915 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
916 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[3].Trim());
\r
921 if (audioEncoder1.Success)
\r
922 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
924 if (audioEncoder2.Success)
\r
926 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
927 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
930 if (audioEncoder3.Success)
\r
932 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
933 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
936 if (audioEncoder4.Success)
\r
938 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
939 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
944 thisQuery.q_audioBitrate1 = "";
\r
945 if (audioBitrate1.Success)
\r
947 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
948 if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.q_audioBitrate1 = "Auto";
\r
951 thisQuery.q_audioBitrate2 = "";
\r
952 if (audioBitrate2.Success && audioTrack2.Success)
\r
954 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
955 if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";
\r
956 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
959 thisQuery.q_audioBitrate3 = "";
\r
960 if (audioBitrate3.Success && audioTrack3.Success)
\r
962 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
963 if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";
\r
964 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
967 thisQuery.q_audioBitrate4 = "";
\r
968 if (audioBitrate4.Success)
\r
970 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
971 if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";
\r
972 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
976 // Audio Sample Rate
\r
977 // Make sure to change 0 to Auto
\r
978 thisQuery.q_audioSamplerate1 = "Auto";
\r
979 if (audioSampleRate1.Success)
\r
981 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
982 if (thisQuery.q_audioSamplerate1 == "0") thisQuery.q_audioSamplerate1 = "Auto";
\r
986 if (audioSampleRate2.Success)
\r
988 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
989 if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";
\r
990 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
993 if (audioSampleRate3.Success)
\r
995 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
996 if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";
\r
997 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
1000 if (audioSampleRate4.Success)
\r
1002 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
1003 if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";
\r
1004 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1010 thisQuery.q_drc1 = 1;
\r
1013 string value = drc1.ToString().Replace("-D ", "");
\r
1014 float.TryParse(value, out drcValue);
\r
1015 thisQuery.q_drc1 = drcValue;
\r
1018 thisQuery.q_drc2 = 1;
\r
1021 string[] drcPoint = drc2.ToString().Split(',');
\r
1022 float.TryParse(drcPoint[1], out drcValue);
\r
1023 thisQuery.q_drc2 = drcValue;
\r
1026 thisQuery.q_drc3 = 1;
\r
1029 string[] drcPoint = drc3.ToString().Split(',');
\r
1030 float.TryParse(drcPoint[2], out drcValue);
\r
1031 thisQuery.q_drc3 = drcValue;
\r
1034 thisQuery.q_drc4 = 1;
\r
1037 string[] drcPoint = drc4.ToString().Split(',');
\r
1038 float.TryParse(drcPoint[3], out drcValue);
\r
1039 thisQuery.q_drc4 = drcValue;
\r
1043 if (subtitles.Success)
\r
1044 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1047 if (subScan.Success)
\r
1048 thisQuery.q_subtitles = "Autoselect";
\r
1050 thisQuery.q_subtitles = "None";
\r
1053 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1057 #region Chapters Tab
\r
1058 if (chapterMarkersFileMode.Success || chapterMarkers.Success)
\r
1059 thisQuery.q_chapterMarkers = true;
\r
1062 #region H.264 and other
\r
1068 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1073 thisQuery.q_verbose = verbose.Success;
\r
1077 catch (Exception exc)
\r
1080 "An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" +
\r
1081 exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
1089 private static string getMixDown(string mixdown)
\r
1098 return "Dolby Surround";
\r
1100 return "Dolby Pro Logic II";
\r
1102 return "6 Channel Discrete";
\r
1104 return "Automatic";
\r
1108 private static string getAudioEncoder(string audioEnc)
\r