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
12 namespace Handbrake.Functions
\r
14 internal class QueryParser
\r
16 private static readonly CultureInfo Culture = new CultureInfo("en-US", false);
\r
22 private int q_chaptersFinish;
\r
23 private int q_chaptersStart;
\r
24 private int q_dvdTitle;
\r
27 /// Returns an Integer
\r
28 /// DVD Title number.
\r
32 get { return q_dvdTitle; }
\r
37 /// DVD Chapter number or chapter range.
\r
39 public int DVDChapterStart
\r
41 get { return q_chaptersStart; }
\r
46 /// DVD Chapter number or chapter range.
\r
48 public int DVDChapterFinish
\r
50 get { return q_chaptersFinish; }
\r
57 private string q_format;
\r
58 private string q_videoEncoder;
\r
61 /// Returns a String
\r
62 /// Full path of the destination.
\r
64 public string Format
\r
66 get { return q_format; }
\r
70 /// Returns an String
\r
71 /// The Video Encoder used.
\r
73 public string VideoEncoder
\r
75 get { return q_videoEncoder; }
\r
80 #region Picture Settings
\r
82 private Boolean q_anamorphic;
\r
83 private Boolean q_chapterMarkers;
\r
84 private string q_cropbottom;
\r
85 private string q_cropLeft;
\r
86 private string q_cropRight;
\r
87 private string q_croptop;
\r
88 private string q_cropValues;
\r
89 private int q_deBlock;
\r
90 private string q_decomb;
\r
91 private string q_deinterlace;
\r
92 private string q_denoise;
\r
93 private string q_detelecine;
\r
94 private Boolean q_looseAnamorphic;
\r
95 private int q_maxHeight;
\r
96 private int q_maxWidth;
\r
97 private int q_videoHeight;
\r
98 private int q_videoWidth;
\r
102 /// The selected Width for the encoding.
\r
106 get { return q_videoWidth; }
\r
111 /// The selected Height for the encoding.
\r
115 get { return q_videoHeight; }
\r
120 /// The selected Width for the encoding.
\r
122 public int MaxWidth
\r
124 get { return q_maxWidth; }
\r
129 /// The selected Height for the encoding.
\r
131 public int MaxHeight
\r
133 get { return q_maxHeight; }
\r
137 /// Returns an String
\r
138 /// Cropping values.
\r
140 public string CropValues
\r
142 get { return q_cropValues; }
\r
146 /// Returns an String
\r
147 /// Cropping values.
\r
149 public string CropTop
\r
151 get { return q_croptop; }
\r
155 /// Returns an String
\r
156 /// Cropping values.
\r
158 public string CropBottom
\r
160 get { return q_cropbottom; }
\r
164 /// Returns an String
\r
165 /// Cropping values.
\r
167 public string CropLeft
\r
169 get { return q_cropLeft; }
\r
173 /// Returns an String
\r
174 /// Cropping values.
\r
176 public string CropRight
\r
178 get { return q_cropRight; }
\r
182 /// Returns a boolean to indicate wither DeTelecine is on or off
\r
184 public string DeTelecine
\r
186 get { return q_detelecine; }
\r
190 /// Returns a boolean to indicate wither DeBlock is on or off.
\r
194 get { return q_deBlock; }
\r
198 /// Returns a string with the De-Interlace option used.
\r
200 public string DeInterlace
\r
202 get { return q_deinterlace; }
\r
206 /// Returns a string with the DeNoise option used.
\r
208 public string DeNoise
\r
210 get { return q_denoise; }
\r
214 /// Returns a string with the DeNoise option used.
\r
216 public string Decomb
\r
218 get { return q_decomb; }
\r
222 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
224 public Boolean Anamorphic
\r
226 get { return q_anamorphic; }
\r
230 /// Returns a boolean to indicate wither Anamorphic is on or off.
\r
232 public Boolean LooseAnamorphic
\r
234 get { return q_looseAnamorphic; }
\r
238 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
240 public Boolean ChapterMarkers
\r
242 get { return q_chapterMarkers; }
\r
247 #region Video Settings
\r
249 private string q_avgBitrate;
\r
250 private Boolean q_grayscale;
\r
251 private Boolean q_ipodAtom;
\r
252 private Boolean q_largeMp4;
\r
253 private Boolean q_optimizeMp4;
\r
254 private Boolean q_turboFirst;
\r
256 private Boolean q_twoPass;
\r
257 private string q_videoFramerate;
\r
258 private float q_videoQuality;
\r
259 private string q_videoTargetSize;
\r
262 /// Returns a boolean to indicate wither Grayscale is on or off.
\r
264 public Boolean Grayscale
\r
266 get { return q_grayscale; }
\r
270 /// Returns a boolean to indicate wither Two Pass Encoding is on or off.
\r
272 public Boolean TwoPass
\r
274 get { return q_twoPass; }
\r
278 /// Returns a boolean to indicate wither Chapter Markers is on or off.
\r
280 public Boolean TurboFirstPass
\r
282 get { return q_turboFirst; }
\r
286 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
288 public Boolean LargeMP4
\r
290 get { return q_largeMp4; }
\r
294 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
296 public Boolean IpodAtom
\r
298 get { return q_ipodAtom; }
\r
302 /// Returns a boolean to indicate wither Larger MP4 files is on or off.
\r
304 public Boolean OptimizeMP4
\r
306 get { return q_optimizeMp4; }
\r
310 /// Returns a string with the video Framerate
\r
312 public string VideoFramerate
\r
314 get { return q_videoFramerate; }
\r
318 /// Returns a string with the average video bitrate
\r
320 public string AverageVideoBitrate
\r
322 get { return q_avgBitrate; }
\r
326 /// Returns a string with the video target size
\r
328 public string VideoTargetSize
\r
330 get { return q_videoTargetSize; }
\r
334 /// Returns a int with the video quality value
\r
336 public float VideoQuality
\r
338 get { return q_videoQuality; }
\r
343 #region Audio Settings
\r
345 private string q_audioBitrate1;
\r
346 private string q_audioBitrate2;
\r
347 private string q_audioBitrate3;
\r
348 private string q_audioBitrate4;
\r
349 private string q_audioEncoder1;
\r
350 private string q_audioEncoder2;
\r
351 private string q_audioEncoder3;
\r
352 private string q_audioEncoder4;
\r
353 private string q_audioSamplerate1;
\r
354 private string q_audioSamplerate2;
\r
355 private string q_audioSamplerate3;
\r
356 private string q_audioSamplerate4;
\r
357 private string q_audioTrack1;
\r
358 private string q_audioTrack2;
\r
359 private string q_audioTrack3;
\r
360 private string q_audioTrack4;
\r
361 private string q_audioTrackMix1;
\r
362 private string q_audioTrackMix2;
\r
363 private string q_audioTrackMix3;
\r
364 private string q_audioTrackMix4;
\r
365 private double q_drc1;
\r
366 private double q_drc2;
\r
367 private double q_drc3;
\r
368 private double q_drc4;
\r
369 private Boolean q_forcedSubs;
\r
370 private string q_subtitles;
\r
373 /// Returns a string with the selected Audio track
\r
375 public string AudioTrack1
\r
377 get { return q_audioTrack1; }
\r
381 /// Returns a string with the selected Audio track
\r
383 public string AudioTrack2
\r
385 get { return q_audioTrack2; }
\r
389 /// Returns a string with the selected Audio track
\r
391 public string AudioTrack3
\r
393 get { return q_audioTrack3; }
\r
397 /// Returns a string with the selected Audio track
\r
399 public string AudioTrack4
\r
401 get { return q_audioTrack4; }
\r
405 /// Returns a string with the First selected Audio track Mix
\r
407 public string AudioTrackMix1
\r
409 get { return q_audioTrackMix1; }
\r
413 /// Returns a string with the First selected Audio track Mix
\r
415 public string AudioTrackMix2
\r
417 get { return q_audioTrackMix2; }
\r
421 /// Returns a string with the First selected Audio track Mix
\r
423 public string AudioTrackMix3
\r
425 get { return q_audioTrackMix3; }
\r
429 /// Returns a string with the First selected Audio track Mix
\r
431 public string AudioTrackMix4
\r
433 get { return q_audioTrackMix4; }
\r
437 /// Returns an String
\r
438 /// The Audio Encoder used.
\r
440 public string AudioEncoder1
\r
442 get { return q_audioEncoder1; }
\r
446 /// Returns an String
\r
447 /// The Audio Encoder used.
\r
449 public string AudioEncoder2
\r
451 get { return q_audioEncoder2; }
\r
455 /// Returns an String
\r
456 /// The Audio Encoder used.
\r
458 public string AudioEncoder3
\r
460 get { return q_audioEncoder3; }
\r
464 /// Returns an String
\r
465 /// The Audio Encoder used.
\r
467 public string AudioEncoder4
\r
469 get { return q_audioEncoder4; }
\r
473 /// Returns a string with the audio bitrate
\r
475 public string AudioBitrate1
\r
477 get { return q_audioBitrate1; }
\r
481 /// Returns a string with the audio bitrate
\r
483 public string AudioBitrate2
\r
485 get { return q_audioBitrate2; }
\r
489 /// Returns a string with the audio bitrate
\r
491 public string AudioBitrate3
\r
493 get { return q_audioBitrate3; }
\r
497 /// Returns a string with the audio bitrate
\r
499 public string AudioBitrate4
\r
501 get { return q_audioBitrate4; }
\r
505 /// Returns a string with the audio sample rate
\r
507 public string AudioSamplerate1
\r
509 get { return q_audioSamplerate1; }
\r
513 /// Returns a string with the audio sample rate
\r
515 public string AudioSamplerate2
\r
517 get { return q_audioSamplerate2; }
\r
521 /// Returns a string with the audio sample rate
\r
523 public string AudioSamplerate3
\r
525 get { return q_audioSamplerate3; }
\r
529 /// Returns a string with the audio sample rate
\r
531 public string AudioSamplerate4
\r
533 get { return q_audioSamplerate4; }
\r
537 /// Returns a string with the selected subtitle track
\r
541 get { return q_drc1; }
\r
545 /// Returns a string with the selected subtitle track
\r
549 get { return q_drc2; }
\r
553 /// Returns a string with the selected subtitle track
\r
557 get { return q_drc3; }
\r
561 /// Returns a string with the selected subtitle track
\r
565 get { return q_drc4; }
\r
569 /// Returns a string with the selected subtitle track
\r
571 public string Subtitles
\r
573 get { return q_subtitles; }
\r
577 /// Returns a string with the selected subtitle track
\r
579 public Boolean ForcedSubtitles
\r
581 get { return q_forcedSubs; }
\r
588 private string q_h264;
\r
589 private Boolean q_verbose;
\r
592 /// Returns a string with the Advanced H264 query string
\r
594 public string H264Query
\r
596 get { return q_h264; }
\r
600 /// Returns a string with the Advanced H264 query string
\r
602 public Boolean Verbose
\r
604 get { return q_verbose; }
\r
611 // All the Main Window GUI options
\r
613 /// Takes in a query which can be in any order and parses it.
\r
614 /// All varibles are then set so they can be used elsewhere.
\r
616 /// <param name="input">A ClI Query</param>
\r
617 /// <returns>A Parsed Query</returns>
\r
618 public static QueryParser Parse(String input)
\r
620 var thisQuery = new QueryParser();
\r
622 #region Regular Expressions
\r
624 // Useful Destination Finder
\r
625 //Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9?';!^%&*()_\-:\\\s\.]+)(?:\"")");
\r
626 //Match source = r1.Match(input.Replace('"', '\"'));
\r
629 Match title = Regex.Match(input, @"-t ([0-9]*)");
\r
630 Match chapters = Regex.Match(input, @"-c ([0-9-]*)");
\r
633 Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");
\r
634 Match grayscale = Regex.Match(input, @" -g");
\r
635 Match largerMp4 = Regex.Match(input, @" -4");
\r
636 Match ipodAtom = Regex.Match(input, @" -I");
\r
638 //Picture Settings Tab
\r
639 Match width = Regex.Match(input, @"-w ([0-9]*)");
\r
640 Match height = Regex.Match(input, @"-l ([0-9]*)");
\r
641 Match maxWidth = Regex.Match(input, @"-X ([0-9]*)");
\r
642 Match maxHeight = Regex.Match(input, @"-Y ([0-9]*)");
\r
643 Match crop = Regex.Match(input, @"--crop ([0-9]*):([0-9]*):([0-9]*):([0-9]*)");
\r
644 Match lanamorphic = Regex.Match(input, @" -P");
\r
645 Match anamorphic = Regex.Match(input, @" -p ");
\r
647 // Picture Settings - Filters
\r
648 Match decomb = Regex.Match(input, @" --decomb");
\r
649 Match decombValue = Regex.Match(input, @" --decomb=\""([a-zA-Z0-9.:]*)\""");
\r
650 Match deinterlace = Regex.Match(input, @"--deinterlace=\""([a-zA-Z0-9.:]*)\""");
\r
651 Match denoise = Regex.Match(input, @"--denoise=\""([a-zA-Z0-9.:]*)\""");
\r
652 Match deblock = Regex.Match(input, @"--deblock=([0-9:]*)");
\r
653 Match detelecine = Regex.Match(input, @"--detelecine");
\r
654 Match detelecineValue = Regex.Match(input, @" --detelecine=\""([a-zA-Z0-9.:]*)\""");
\r
656 //Video Settings Tab
\r
657 Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");
\r
658 Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");
\r
659 Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");
\r
660 Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");
\r
661 Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");
\r
662 Match twoPass = Regex.Match(input, @" -2");
\r
663 Match turboFirstPass = Regex.Match(input, @" -T");
\r
664 Match optimizeMP4 = Regex.Match(input, @" -O");
\r
666 //Audio Settings Tab
\r
667 Match noAudio = Regex.Match(input, @"-a none");
\r
668 Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");
\r
669 Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");
\r
670 Match audioTrack3 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*)");
\r
671 Match audioTrack4 = Regex.Match(input, @"-a ([0-9]*),([0-9]*),([0-9]*),([0-9]*)");
\r
673 Match audioTrack1Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");
\r
674 Match audioTrack2Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
675 Match audioTrack3Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
676 Match audioTrack4Mix = Regex.Match(input, @"-6 ([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*),([0-9a-z0-9]*)");
\r
678 Match audioEncoder1 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*)");
\r
679 Match audioEncoder2 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
680 Match audioEncoder3 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
681 Match audioEncoder4 = Regex.Match(input, @"-E ([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*),([a-zA-Z0-9+]*)");
\r
683 Match audioBitrate1 = Regex.Match(input, @"-B ([0-9auto]*)");
\r
684 Match audioBitrate2 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*)");
\r
685 Match audioBitrate3 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
686 Match audioBitrate4 = Regex.Match(input, @"-B ([0-9auto]*),([0-9auto]*),([0-9auto]*),([0-9auto]*)");
\r
688 Match audioSampleRate1 = Regex.Match(input, @"-R ([0-9Auto.]*)");
\r
689 Match audioSampleRate2 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*)");
\r
690 Match audioSampleRate3 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
691 Match audioSampleRate4 = Regex.Match(input, @"-R ([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*),([0-9Auto.]*)");
\r
693 Match drc1 = Regex.Match(input, @"-D ([0-9.]*)");
\r
694 Match drc2 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*)");
\r
695 Match drc3 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*)");
\r
696 Match drc4 = Regex.Match(input, @"-D ([0-9.]*),([0-9.]*),([0-9.]*),([0-9.]*)");
\r
698 Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");
\r
699 Match subScan = Regex.Match(input, @" -U");
\r
700 Match forcedSubtitles = Regex.Match(input, @" -F");
\r
703 Match chapterMarkers = Regex.Match(input, @" -m");
\r
704 Match chapterMarkersFileMode = Regex.Match(input, @"--markers");
\r
707 Match x264 = Regex.Match(input, @"-x ([.,/a-zA-Z0-9=:-]*)");
\r
710 Match verbose = Regex.Match(input, @" -v");
\r
714 #region Set Varibles
\r
721 thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));
\r
723 if (chapters.Success)
\r
725 string[] actTitles = chapters.ToString().Replace("-c ", "").Split('-');
\r
726 thisQuery.q_chaptersStart = int.Parse(actTitles[0]);
\r
727 if (actTitles.Length > 1)
\r
729 thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);
\r
732 if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))
\r
733 thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;
\r
737 #region Output Settings
\r
739 if (format.Success)
\r
740 thisQuery.q_format = format.ToString().Replace("-f ", "");
\r
741 thisQuery.q_largeMp4 = largerMp4.Success;
\r
742 thisQuery.q_ipodAtom = ipodAtom.Success;
\r
743 thisQuery.q_optimizeMp4 = optimizeMP4.Success;
\r
747 #region Picture Tab
\r
750 thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));
\r
752 if (height.Success)
\r
753 thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));
\r
755 if (maxWidth.Success)
\r
756 thisQuery.q_maxWidth = int.Parse(maxWidth.ToString().Replace("-X ", ""));
\r
758 if (maxHeight.Success)
\r
759 thisQuery.q_maxHeight = int.Parse(maxHeight.ToString().Replace("-Y ", ""));
\r
763 thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");
\r
764 string[] actCropValues = thisQuery.q_cropValues.Split(':');
\r
765 thisQuery.q_croptop = actCropValues[0];
\r
766 thisQuery.q_cropbottom = actCropValues[1];
\r
767 thisQuery.q_cropLeft = actCropValues[2];
\r
768 thisQuery.q_cropRight = actCropValues[3];
\r
771 thisQuery.q_anamorphic = anamorphic.Success;
\r
772 thisQuery.q_looseAnamorphic = lanamorphic.Success;
\r
778 thisQuery.q_decomb = "Off";
\r
779 if (decomb.Success)
\r
781 thisQuery.q_decomb = "Default";
\r
782 if (decombValue.Success)
\r
783 thisQuery.q_decomb = decombValue.ToString().Replace("--decomb=", "").Replace("\"", "");
\r
786 thisQuery.q_deinterlace = "None";
\r
787 if (deinterlace.Success)
\r
789 thisQuery.q_deinterlace = deinterlace.ToString().Replace("--deinterlace=", "").Replace("\"", "");
\r
790 thisQuery.q_deinterlace = thisQuery.q_deinterlace.Replace("fast", "Fast").Replace("slow", "Slow").Replace("slower", "Slower");
\r
791 thisQuery.q_deinterlace = thisQuery.q_deinterlace.Replace("slowest", "Slowest");
\r
794 thisQuery.q_denoise = "None";
\r
795 if (denoise.Success)
\r
797 thisQuery.q_denoise = denoise.ToString().Replace("--denoise=", "").Replace("\"", "");
\r
798 thisQuery.q_denoise = thisQuery.q_denoise.Replace("weak", "Weak").Replace("medium", "Medium").Replace("strong", "Strong");
\r
801 string deblockValue = "";
\r
802 thisQuery.q_deBlock = 0;
\r
803 if (deblock.Success)
\r
804 deblockValue = deblock.ToString().Replace("--deblock=", "");
\r
805 if (deblockValue != "")
\r
806 int.TryParse(deblockValue, out thisQuery.q_deBlock);
\r
808 thisQuery.q_detelecine = "Off";
\r
809 if (detelecine.Success)
\r
811 thisQuery.q_detelecine = "Default";
\r
812 if (detelecineValue.Success)
\r
813 thisQuery.q_detelecine = detelecineValue.ToString().Replace("--detelecine=", "").Replace("\"", "");
\r
818 #region Video Settings Tab
\r
820 string videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");
\r
821 switch (videoEncoderConvertion)
\r
824 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
827 videoEncoderConvertion = "H.264 (x264)";
\r
830 videoEncoderConvertion = "VP3 (Theora)";
\r
833 videoEncoderConvertion = "MPEG-4 (FFmpeg)";
\r
836 thisQuery.q_videoEncoder = videoEncoderConvertion;
\r
837 thisQuery.q_videoFramerate = videoFramerate.Success ? videoFramerate.ToString().Replace("-r ", "") : "Same as source";
\r
838 thisQuery.q_grayscale = grayscale.Success;
\r
839 thisQuery.q_twoPass = twoPass.Success;
\r
840 thisQuery.q_turboFirst = turboFirstPass.Success;
\r
842 if (videoBitrate.Success)
\r
843 thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");
\r
844 if (videoFilesize.Success)
\r
845 thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");
\r
847 if (videoQuality.Success)
\r
849 float qConvert = float.Parse(videoQuality.ToString().Replace("-q ", ""), Culture);
\r
850 //qConvert = Math.Ceiling(qConvert);
\r
851 thisQuery.q_videoQuality = qConvert;
\r
858 if (noAudio.Success)
\r
859 thisQuery.q_audioTrack1 = "None";
\r
860 else if (audioTrack1.Success)
\r
861 thisQuery.q_audioTrack1 = "Automatic";
\r
863 if (audioTrack2.Success)
\r
865 string[] audioChan = audioTrack2.ToString().Split(',');
\r
866 thisQuery.q_audioTrack2 = audioChan[1];
\r
869 thisQuery.q_audioTrack2 = "None";
\r
871 if (audioTrack3.Success)
\r
873 string[] audioChan = audioTrack3.ToString().Split(',');
\r
874 thisQuery.q_audioTrack3 = audioChan[2];
\r
877 thisQuery.q_audioTrack3 = "None";
\r
879 if (audioTrack4.Success)
\r
881 string[] audioChan = audioTrack4.ToString().Split(',');
\r
882 thisQuery.q_audioTrack4 = audioChan[3];
\r
885 thisQuery.q_audioTrack4 = "None";
\r
889 thisQuery.q_audioTrackMix1 = "Automatic";
\r
890 if (audioTrack1Mix.Success)
\r
891 thisQuery.q_audioTrackMix1 =
\r
892 getMixDown(audioTrack1Mix.ToString().Replace("-6 ", "").Replace(" ", ""));
\r
894 thisQuery.q_audioTrackMix2 = "Automatic";
\r
895 if (audioTrack2Mix.Success)
\r
897 string[] audio2mix = audioTrack2Mix.ToString().Split(',');
\r
898 thisQuery.q_audioTrackMix2 = getMixDown(audio2mix[1].Trim());
\r
901 thisQuery.q_audioTrackMix3 = "Automatic";
\r
902 if (audioTrack3Mix.Success)
\r
904 string[] audio3mix = audioTrack3Mix.ToString().Split(',');
\r
905 thisQuery.q_audioTrackMix3 = getMixDown(audio3mix[2].Trim());
\r
908 thisQuery.q_audioTrackMix4 = "Automatic";
\r
909 if (audioTrack4Mix.Success)
\r
911 string[] audio4mix = audioTrack4Mix.ToString().Split(',');
\r
912 thisQuery.q_audioTrackMix4 = getMixDown(audio4mix[3].Trim());
\r
917 if (audioEncoder1.Success)
\r
918 thisQuery.q_audioEncoder1 = getAudioEncoder(audioEncoder1.ToString().Replace("-E ", ""));
\r
920 if (audioEncoder2.Success)
\r
922 string[] audio2enc = audioEncoder2.ToString().Split(',');
\r
923 thisQuery.q_audioEncoder2 = getAudioEncoder(audio2enc[1].Trim());
\r
926 if (audioEncoder3.Success)
\r
928 string[] audio3enc = audioEncoder3.ToString().Split(',');
\r
929 thisQuery.q_audioEncoder3 = getAudioEncoder(audio3enc[2].Trim());
\r
932 if (audioEncoder4.Success)
\r
934 string[] audio4enc = audioEncoder4.ToString().Split(',');
\r
935 thisQuery.q_audioEncoder4 = getAudioEncoder(audio4enc[3].Trim());
\r
940 thisQuery.q_audioBitrate1 = "";
\r
941 if (audioBitrate1.Success)
\r
943 thisQuery.q_audioBitrate1 = audioBitrate1.ToString().Replace("-B ", "").Trim();
\r
944 if (audioBitrate1.ToString().Replace("-B ", "").Trim() == "0") thisQuery.q_audioBitrate1 = "Auto";
\r
947 thisQuery.q_audioBitrate2 = "";
\r
948 if (audioBitrate2.Success && audioTrack2.Success)
\r
950 string[] audioBitrateSelect = audioBitrate2.ToString().Split(',');
\r
951 if (audioBitrateSelect[1].Trim() == "0") audioBitrateSelect[1] = "Auto";
\r
952 thisQuery.q_audioBitrate2 = audioBitrateSelect[1].Trim();
\r
955 thisQuery.q_audioBitrate3 = "";
\r
956 if (audioBitrate3.Success && audioTrack3.Success)
\r
958 string[] audioBitrateSelect = audioBitrate3.ToString().Split(',');
\r
959 if (audioBitrateSelect[2].Trim() == "0") audioBitrateSelect[2] = "Auto";
\r
960 thisQuery.q_audioBitrate3 = audioBitrateSelect[2].Trim();
\r
963 thisQuery.q_audioBitrate4 = "";
\r
964 if (audioBitrate4.Success)
\r
966 string[] audioBitrateSelect = audioBitrate4.ToString().Split(',');
\r
967 if (audioBitrateSelect[3].Trim() == "0") audioBitrateSelect[3] = "Auto";
\r
968 thisQuery.q_audioBitrate4 = audioBitrateSelect[3].Trim();
\r
972 // Audio Sample Rate
\r
973 // Make sure to change 0 to Auto
\r
974 thisQuery.q_audioSamplerate1 = "Auto";
\r
975 if (audioSampleRate1.Success)
\r
977 thisQuery.q_audioSamplerate1 = audioSampleRate1.ToString().Replace("-R ", "").Trim();
\r
978 if (thisQuery.q_audioSamplerate1 == "0") thisQuery.q_audioSamplerate1 = "Auto";
\r
982 if (audioSampleRate2.Success)
\r
984 string[] audioSRSelect = audioSampleRate2.ToString().Split(',');
\r
985 if (audioSRSelect[1] == "0") audioSRSelect[1] = "Auto";
\r
986 thisQuery.q_audioSamplerate2 = audioSRSelect[1].Trim();
\r
989 if (audioSampleRate3.Success)
\r
991 string[] audioSRSelect = audioSampleRate3.ToString().Split(',');
\r
992 if (audioSRSelect[2] == "0") audioSRSelect[2] = "Auto";
\r
993 thisQuery.q_audioSamplerate3 = audioSRSelect[2].Trim();
\r
996 if (audioSampleRate4.Success)
\r
998 string[] audioSRSelect = audioSampleRate4.ToString().Split(',');
\r
999 if (audioSRSelect[3] == "0") audioSRSelect[3] = "Auto";
\r
1000 thisQuery.q_audioSamplerate4 = audioSRSelect[3].Trim();
\r
1006 thisQuery.q_drc1 = 1;
\r
1009 string value = drc1.ToString().Replace("-D ", "");
\r
1010 float.TryParse(value, out drcValue);
\r
1011 thisQuery.q_drc1 = drcValue;
\r
1014 thisQuery.q_drc2 = 1;
\r
1017 string[] drcPoint = drc2.ToString().Split(',');
\r
1018 float.TryParse(drcPoint[1], out drcValue);
\r
1019 thisQuery.q_drc2 = drcValue;
\r
1022 thisQuery.q_drc3 = 1;
\r
1025 string[] drcPoint = drc3.ToString().Split(',');
\r
1026 float.TryParse(drcPoint[2], out drcValue);
\r
1027 thisQuery.q_drc3 = drcValue;
\r
1030 thisQuery.q_drc4 = 1;
\r
1033 string[] drcPoint = drc4.ToString().Split(',');
\r
1034 float.TryParse(drcPoint[3], out drcValue);
\r
1035 thisQuery.q_drc4 = drcValue;
\r
1039 if (subtitles.Success)
\r
1040 thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");
\r
1042 thisQuery.q_subtitles = subScan.Success ? "Autoselect" : "None";
\r
1044 thisQuery.q_forcedSubs = forcedSubtitles.Success;
\r
1048 #region Chapters Tab
\r
1049 if (chapterMarkersFileMode.Success || chapterMarkers.Success)
\r
1050 thisQuery.q_chapterMarkers = true;
\r
1053 #region H.264 and other
\r
1059 thisQuery.q_h264 = x264.ToString().Replace("-x ", "");
\r
1064 thisQuery.q_verbose = verbose.Success;
\r
1068 catch (Exception exc)
\r
1071 "An error has occured in the Query Parser. Please report this error on the forum in the 'Windows' support section. \n\n" +
\r
1072 exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
1080 private static string getMixDown(string mixdown)
\r
1089 return "Dolby Surround";
\r
1091 return "Dolby Pro Logic II";
\r
1093 return "6 Channel Discrete";
\r
1095 return "Automatic";
\r
1099 private static string getAudioEncoder(string audioEnc)
\r