OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / QueryParser.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Text;\r
4 using System.Text.RegularExpressions;\r
5 using System.Windows.Forms;\r
6 \r
7 namespace Handbrake.Functions\r
8 {\r
9     class QueryParser\r
10     {\r
11 \r
12         // All the Main Window GUI options\r
13         #region Varibles\r
14 \r
15         private string q_source;\r
16         /// <summary>\r
17         /// Returns a String \r
18         /// Full path of the source.\r
19         /// </summary>\r
20         public string Source\r
21         {\r
22             get\r
23             {\r
24                 return this.q_source;\r
25             }\r
26         }\r
27 \r
28         private string q_destination;\r
29         /// <summary>\r
30         /// Returns a String \r
31         /// Full path of the destination.\r
32         /// </summary>\r
33         public string Destination\r
34         {\r
35             get\r
36             {\r
37                 return this.q_destination;\r
38             }\r
39         }\r
40 \r
41         private string q_format;\r
42         /// <summary>\r
43         /// Returns a String \r
44         /// Full path of the destination.\r
45         /// </summary>\r
46         public string Format\r
47         {\r
48             get\r
49             {\r
50                 return this.q_format;\r
51             }\r
52         }\r
53 \r
54         private int q_dvdTitle;\r
55         /// <summary>\r
56         /// Returns an Integer\r
57         /// DVD Title number.\r
58         /// </summary>\r
59         public int DVDTitle\r
60         {\r
61             get\r
62             {\r
63                 return this.q_dvdTitle;\r
64             }\r
65         }\r
66 \r
67         private int q_chaptersStart;\r
68         /// <summary>\r
69         /// Returns an Int\r
70         /// DVD Chapter number or chapter range.\r
71         /// </summary>\r
72         public int DVDChapterStart\r
73         {\r
74             get\r
75             {\r
76                 return this.q_chaptersStart;\r
77             }\r
78         }\r
79 \r
80         private int q_chaptersFinish;\r
81         /// <summary>\r
82         /// Returns an Int\r
83         /// DVD Chapter number or chapter range.\r
84         /// </summary>\r
85         public int DVDChapterFinish\r
86         {\r
87             get\r
88             {\r
89                 return this.q_chaptersFinish;\r
90             }\r
91         }\r
92 \r
93         private string q_videoEncoder;\r
94         /// <summary>\r
95         /// Returns an String\r
96         /// The Video Encoder used.\r
97         /// </summary>\r
98         public string VideoEncoder\r
99         {\r
100             get\r
101             {\r
102                 return this.q_videoEncoder;\r
103             }\r
104         }\r
105 \r
106         private string q_audioEncoder;\r
107         /// <summary>\r
108         /// Returns an String\r
109         /// The Audio Encoder used.\r
110         /// </summary>\r
111         public string AudioEncoder\r
112         {\r
113             get\r
114             {\r
115                 return this.q_audioEncoder;\r
116             }\r
117         }\r
118 \r
119         private int q_videoWidth;\r
120         /// <summary>\r
121         /// Returns an Int\r
122         /// The selected Width for the encoding.\r
123         /// </summary>\r
124         public int Width\r
125         {\r
126             get\r
127             {\r
128                 return this.q_videoWidth;\r
129             }\r
130         }\r
131 \r
132         private int q_videoHeight;\r
133         /// <summary>\r
134         /// Returns an Int\r
135         /// The selected Height for the encoding.\r
136         /// </summary>\r
137         public int Height\r
138         {\r
139             get\r
140             {\r
141                 return this.q_videoHeight;\r
142             }\r
143         }\r
144 \r
145         private string q_cropValues;\r
146         /// <summary>\r
147         /// Returns an String\r
148         /// Cropping values.\r
149         /// </summary>\r
150         public string CropValues\r
151         {\r
152             get\r
153             {\r
154                 return this.q_cropValues;\r
155             }\r
156         }\r
157 \r
158         private string q_croptop;\r
159         /// <summary>\r
160         /// Returns an String\r
161         /// Cropping values.\r
162         /// </summary>\r
163         public string CropTop\r
164         {\r
165             get\r
166             {\r
167                 return this.q_croptop;\r
168             }\r
169         }\r
170 \r
171         private string q_cropbottom;\r
172         /// <summary>\r
173         /// Returns an String\r
174         /// Cropping values.\r
175         /// </summary>\r
176         public string CropBottom\r
177         {\r
178             get\r
179             {\r
180                 return this.q_cropbottom;\r
181             }\r
182         }\r
183 \r
184         private string q_cropLeft;\r
185         /// <summary>\r
186         /// Returns an String\r
187         /// Cropping values.\r
188         /// </summary>\r
189         public string CropLeft\r
190         {\r
191             get\r
192             {\r
193                 return this.q_cropLeft;\r
194             }\r
195         }\r
196 \r
197         private string q_cropRight;\r
198         /// <summary>\r
199         /// Returns an String\r
200         /// Cropping values.\r
201         /// </summary>\r
202         public string CropRight\r
203         {\r
204             get\r
205             {\r
206                 return this.q_cropRight;\r
207             }\r
208         }\r
209 \r
210         private Boolean q_detelecine;\r
211         /// <summary>\r
212         /// Returns a boolean to indicate wither DeTelecine is on or off\r
213         /// </summary>\r
214         public Boolean DeTelecine\r
215         {\r
216             get\r
217             {\r
218                 return this.q_detelecine;\r
219             }\r
220         }\r
221 \r
222         private Boolean q_vfr;\r
223         /// <summary>\r
224         /// Returns a boolean to indicate wither DeTelecine is on or off\r
225         /// </summary>\r
226         public Boolean VFR\r
227         {\r
228             get\r
229             {\r
230                 return this.q_vfr;\r
231             }\r
232         }\r
233 \r
234         private Boolean q_deBlock;\r
235         /// <summary>\r
236         /// Returns a boolean to indicate wither DeBlock is on or off.\r
237         /// </summary>\r
238         public Boolean DeBlock\r
239         {\r
240             get\r
241             {\r
242                 return this.q_deBlock;\r
243             }\r
244         }\r
245 \r
246         private string q_deinterlace;\r
247         /// <summary>\r
248         /// Returns a string with the De-Interlace option used.\r
249         /// </summary>\r
250         public string DeInterlace\r
251         {\r
252             get\r
253             {\r
254                 return this.q_deinterlace;\r
255             }\r
256         }\r
257 \r
258         private string q_denoise;\r
259         /// <summary>\r
260         /// Returns a string with the DeNoise option used.\r
261         /// </summary>\r
262         public string DeNoise\r
263         {\r
264             get\r
265             {\r
266                 return this.q_denoise;\r
267             }\r
268         }\r
269 \r
270         private Boolean q_anamorphic;\r
271         /// <summary>\r
272         /// Returns a boolean to indicate wither Anamorphic is on or off.\r
273         /// </summary>\r
274         public Boolean Anamorphic\r
275         {\r
276             get\r
277             {\r
278                 return this.q_anamorphic;\r
279             }\r
280         }\r
281 \r
282         private Boolean q_looseAnamorphic;\r
283         /// <summary>\r
284         /// Returns a boolean to indicate wither Anamorphic is on or off.\r
285         /// </summary>\r
286         public Boolean LooseAnamorphic\r
287         {\r
288             get\r
289             {\r
290                 return this.q_looseAnamorphic;\r
291             }\r
292         }\r
293 \r
294         private Boolean q_chapterMarkers;\r
295         /// <summary>\r
296         /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
297         /// </summary>\r
298         public Boolean ChapterMarkers\r
299         {\r
300             get\r
301             {\r
302                 return this.q_chapterMarkers;\r
303             }\r
304         }\r
305 \r
306         private Boolean q_grayscale;\r
307         /// <summary>\r
308         /// Returns a boolean to indicate wither Grayscale is on or off.\r
309         /// </summary>\r
310         public Boolean Grayscale\r
311         {\r
312             get\r
313             {\r
314                 return this.q_grayscale;\r
315             }\r
316         }\r
317 \r
318         private Boolean q_twoPass;\r
319         /// <summary>\r
320         /// Returns a boolean to indicate wither Two Pass Encoding is on or off.\r
321         /// </summary>\r
322         public Boolean TwoPass\r
323         {\r
324             get\r
325             {\r
326                 return this.q_twoPass;\r
327             }\r
328         }\r
329 \r
330         private Boolean q_turboFirst;\r
331         /// <summary>\r
332         /// Returns a boolean to indicate wither Chapter Markers is on or off.\r
333         /// </summary>\r
334         public Boolean TurboFirstPass\r
335         {\r
336             get\r
337             {\r
338                 return this.q_turboFirst;\r
339             }\r
340         }\r
341 \r
342         private Boolean q_largeMp4;\r
343         /// <summary>\r
344         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
345         /// </summary>\r
346         public Boolean LargeMP4\r
347         {\r
348             get\r
349             {\r
350                 return this.q_largeMp4;\r
351             }\r
352         }\r
353 \r
354         private Boolean q_ipodAtom;\r
355         /// <summary>\r
356         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
357         /// </summary>\r
358         public Boolean IpodAtom\r
359         {\r
360             get\r
361             {\r
362                 return this.q_ipodAtom;\r
363             }\r
364         }\r
365 \r
366         private Boolean q_optimizeMp4;\r
367         /// <summary>\r
368         /// Returns a boolean to indicate wither Larger MP4 files is on or off.\r
369         /// </summary>\r
370         public Boolean OptimizeMP4\r
371         {\r
372             get\r
373             {\r
374                 return this.q_optimizeMp4;\r
375             }\r
376         }\r
377 \r
378         private string q_videoFramerate;\r
379         /// <summary>\r
380         /// Returns a string with the video Framerate\r
381         /// </summary>\r
382         public string VideoFramerate\r
383         {\r
384             get\r
385             {\r
386                 return this.q_videoFramerate;\r
387             }\r
388         }\r
389 \r
390         private string q_avgBitrate;\r
391         /// <summary>\r
392         /// Returns a string with the average video bitrate\r
393         /// </summary>\r
394         public string AverageVideoBitrate\r
395         {\r
396             get\r
397             {\r
398                 return this.q_avgBitrate;\r
399             }\r
400         }\r
401 \r
402         private string q_videoTargetSize;\r
403         /// <summary>\r
404         /// Returns a string with the video target size\r
405         /// </summary>\r
406         public string VideoTargetSize\r
407         {\r
408             get\r
409             {\r
410                 return this.q_videoTargetSize;\r
411             }\r
412         }\r
413 \r
414         private int q_videoQuality;\r
415         /// <summary>\r
416         /// Returns a int with the video quality value\r
417         /// </summary>\r
418         public int VideoQuality\r
419         {\r
420             get\r
421             {\r
422                 return this.q_videoQuality;\r
423             }\r
424         }\r
425 \r
426         private Boolean q_crf;\r
427         /// <summary>\r
428         /// Returns a boolean to indicate if CRF is on or off.\r
429         /// </summary>\r
430         public Boolean CRF\r
431         {\r
432             get\r
433             {\r
434                 return this.q_crf;\r
435             }\r
436         }\r
437 \r
438         private string q_audioBitrate;\r
439         /// <summary>\r
440         /// Returns a string with the audio bitrate\r
441         /// </summary>\r
442         public string AudioBitrate\r
443         {\r
444             get\r
445             {\r
446                 return this.q_audioBitrate;\r
447             }\r
448         }\r
449 \r
450         private string q_audioSamplerate;\r
451         /// <summary>\r
452         /// Returns a string with the audio sample rate\r
453         /// </summary>\r
454         public string AudioSampleBitrate\r
455         {\r
456             get\r
457             {\r
458                 return this.q_audioSamplerate;\r
459             }\r
460         }\r
461 \r
462         private string q_audioTrack1;\r
463         /// <summary>\r
464         /// Returns a string with the First selected Audio track\r
465         /// </summary>\r
466         public string AudioTrack1\r
467         {\r
468             get\r
469             {\r
470                 return this.q_audioTrack1;\r
471             }\r
472         }\r
473 \r
474         private string q_audioTrack2;\r
475         /// <summary>\r
476         /// Returns a string with the First selected Audio track\r
477         /// </summary>\r
478         public string AudioTrack2\r
479         {\r
480             get\r
481             {\r
482                 return this.q_audioTrack2;\r
483             }\r
484         }\r
485 \r
486         private string q_audioTrackMix;\r
487         /// <summary>\r
488         /// Returns a string with the First selected Audio track Mix\r
489         /// </summary>\r
490         public string AudioTrackMix\r
491         {\r
492             get\r
493             {\r
494                 return this.q_audioTrackMix;\r
495             }\r
496         }\r
497 \r
498         private string q_subtitles;\r
499         /// <summary>\r
500         /// Returns a string with the selected subtitle track\r
501         /// </summary>\r
502         public string Subtitles\r
503         {\r
504             get\r
505             {\r
506                 return this.q_subtitles;\r
507             }\r
508         }\r
509 \r
510         private Boolean q_forcedSubs;\r
511         /// <summary>\r
512         /// Returns a string with the selected subtitle track\r
513         /// </summary>\r
514         public Boolean ForcedSubtitles\r
515         {\r
516             get\r
517             {\r
518                 return this.q_forcedSubs;\r
519             }\r
520         }\r
521 \r
522         private string q_h264;\r
523         /// <summary>\r
524         /// Returns a string with the Advanced H264 query string\r
525         /// </summary>\r
526         public string H264Query\r
527         {\r
528             get\r
529             {\r
530                 return this.q_h264;\r
531             }\r
532         }\r
533         private Boolean q_verbose;\r
534         /// <summary>\r
535         /// Returns a string with the Advanced H264 query string\r
536         /// </summary>\r
537         public Boolean Verbose\r
538         {\r
539             get\r
540             {\r
541                 return this.q_verbose;\r
542             }\r
543         }\r
544         #endregion\r
545 \r
546         // Takes in a query which can be in any order and parses it. All varibles are then set so they can be used elsewhere.\r
547         public static QueryParser Parse(String input)\r
548         {\r
549             QueryParser thisQuery = new QueryParser();\r
550 \r
551             #region reg exp\r
552             //Source\r
553             Regex r1 = new Regex(@"(-i)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");\r
554             Match source = r1.Match(input.Replace('"', '\"'));\r
555             Match title = Regex.Match(input, @"-t ([0-9]*)");\r
556             Match chapters = Regex.Match(input, @"-c ([0-9-]*)");\r
557             Match format = Regex.Match(input, @"-f ([a-z0-9a-z0-9a-z0-9]*)");\r
558 \r
559             //Destination\r
560             Regex r2 = new Regex(@"(-o)(?:\s\"")([a-zA-Z0-9:\\\s\.]+)(?:\"")");\r
561             Match destination = r2.Match(input.Replace('"', '\"'));\r
562             Match width = Regex.Match(input, @"-w ([0-9]*)");\r
563             Match height = Regex.Match(input, @"-l ([0-9]*)");\r
564             Match videoEncoder = Regex.Match(input, @"-e ([a-zA-Z0-9]*)");\r
565             Match audioEncoder = Regex.Match(input, @"-E ([a-zA-Z0-9]*)");\r
566 \r
567             //Picture Settings Tab\r
568             Match deinterlace = Regex.Match(input, @"--deinterlace=([a-z]*)");\r
569             Match denoise = Regex.Match(input, @"--denoise=([a-z]*)");\r
570             Match deblock = Regex.Match(input, @"--deblock");\r
571             Match detelecine = Regex.Match(input, @"--detelecine");\r
572             Match anamorphic = Regex.Match(input, @"-p ");\r
573             Match chapterMarkers = Regex.Match(input, @"-m");\r
574             Match crop = Regex.Match(input, @"--crop ([0-9]):([0-9]):([0-9]):([0-9])");\r
575             Match vfr = Regex.Match(input, @"-V");\r
576             Match lanamorphic = Regex.Match(input, @"-P");\r
577 \r
578             //Video Settings Tab\r
579             Match videoFramerate = Regex.Match(input, @"-r ([0-9]*)");\r
580             Match videoBitrate = Regex.Match(input, @"-b ([0-9]*)");\r
581             Match videoQuality = Regex.Match(input, @"-q ([0-9.]*)");\r
582             Match videoFilesize = Regex.Match(input, @"-S ([0-9.]*)");\r
583             Match CRF = Regex.Match(input, @"-Q");\r
584             Match twoPass = Regex.Match(input, @"-2");\r
585             Match turboFirstPass = Regex.Match(input, @"-T");\r
586             Match grayscale = Regex.Match(input, @"-g");\r
587             Match largerMp4 = Regex.Match(input, @"-4");\r
588             Match ipodAtom = Regex.Match(input, @"-I");\r
589             Match optimizeMP4 = Regex.Match(input, @"-O");\r
590 \r
591             //Audio Settings Tab\r
592             Match subtitles = Regex.Match(input, @"-s ([0-9a-zA-Z]*)");\r
593             Match subScan = Regex.Match(input, @"-U");\r
594             Match audioBitrate = Regex.Match(input, @"-B ([0-9]*)");\r
595             Match audioSampleRate = Regex.Match(input, @"-R ([0-9.]*)");\r
596             Match audioChannelsMix = Regex.Match(input, @"-6 ([0-9a-z0-9]*)");  // 1 -6 dpl2 // Broken\r
597             Match audioTrack1 = Regex.Match(input, @"-a ([0-9]*)");\r
598             Match audioTrack2 = Regex.Match(input, @"-a ([0-9]*),([0-9]*)");\r
599             Match forcedSubtitles = Regex.Match(input, @"-F");\r
600 \r
601             //H264 Tab\r
602             Match x264 = Regex.Match(input, @"-x ([,a-zA-Z0-9=:-]*)");\r
603 \r
604             //Program Options\r
605             Match verbose = Regex.Match(input, @"-v");\r
606             #endregion\r
607 \r
608             try\r
609             {\r
610                 //\r
611                 // Source\r
612                 //\r
613                 #region Source Tab\r
614 \r
615                 thisQuery.q_source = source.ToString().Replace("-i ", "").Replace("\"", "");\r
616                 if (title.Success != false)\r
617                     thisQuery.q_dvdTitle = int.Parse(title.ToString().Replace("-t ", ""));\r
618 \r
619                 if (chapters.Success != false)\r
620                 {\r
621                     string[] actTitles = new string[2];\r
622                     actTitles = chapters.ToString().Replace("-c ", "").Split('-');\r
623                     thisQuery.q_chaptersStart = int.Parse(actTitles[0]);\r
624                     if (actTitles.Length > 1)\r
625                     {\r
626                         MessageBox.Show(actTitles[1]);\r
627                         thisQuery.q_chaptersFinish = int.Parse(actTitles[1]);\r
628                     }\r
629 \r
630                     if ((thisQuery.q_chaptersStart == 1) && (thisQuery.q_chaptersFinish == 0))\r
631                         thisQuery.q_chaptersFinish = thisQuery.q_chaptersStart;\r
632                 }\r
633 \r
634                 if (format.Success != false)\r
635                     thisQuery.q_format = format.ToString().Replace("-f ", "");\r
636 \r
637                 #endregion\r
638 \r
639                 //\r
640                 // Destination\r
641                 //\r
642                 #region Destination\r
643                 thisQuery.q_destination = destination.ToString().Replace("-o ", "").Replace("\"", "");\r
644 \r
645                 string videoEncoderConvertion;\r
646                 string audioEncoderConvertion;\r
647 \r
648                 videoEncoderConvertion = videoEncoder.ToString().Replace("-e ", "");\r
649                 switch (videoEncoderConvertion)\r
650                 {\r
651                     case "ffmpeg":\r
652                         videoEncoderConvertion = "Mpeg 4";\r
653                         break;\r
654                     case "xvid":\r
655                         videoEncoderConvertion = "Xvid";\r
656                         break;\r
657                     case "x264":\r
658                         videoEncoderConvertion = "H.264";\r
659                         break;\r
660                     case "x264b13":\r
661                         videoEncoderConvertion = "H.264 Baseline 1.3";\r
662                         break;\r
663                     case "x264b30":\r
664                         videoEncoderConvertion = "H.264 (iPod)";\r
665                         break;\r
666                     default:\r
667                         videoEncoderConvertion = "Mpeg 4";\r
668                         break;\r
669                 }\r
670                 thisQuery.q_videoEncoder = videoEncoderConvertion;\r
671 \r
672                 audioEncoderConvertion = audioEncoder.ToString().Replace("-E ", "");\r
673                 switch (audioEncoderConvertion)\r
674                 {\r
675                     case "faac":\r
676                         audioEncoderConvertion = "AAC";\r
677                         break;\r
678                     case "lame":\r
679                         audioEncoderConvertion = "MP3";\r
680                         break;\r
681                     case "vorbis":\r
682                         audioEncoderConvertion = "Vorbis";\r
683                         break;\r
684                     case "ac3":\r
685                         audioEncoderConvertion = "AC3";\r
686                         break;\r
687                     default:\r
688                         audioEncoderConvertion = "AAC";\r
689                         break;\r
690                 }\r
691                 thisQuery.q_audioEncoder = audioEncoderConvertion;\r
692 \r
693 \r
694                 if (width.Success != false)\r
695                     thisQuery.q_videoWidth = int.Parse(width.ToString().Replace("-w ", ""));\r
696 \r
697                 if (height.Success != false)\r
698                     thisQuery.q_videoHeight = int.Parse(height.ToString().Replace("-l ", ""));\r
699 \r
700                 #endregion\r
701 \r
702                 //\r
703                 //Picture Settings Tab\r
704                 //\r
705                 #region Picture Tab\r
706                 if (crop.Success != false)\r
707                 {\r
708                     thisQuery.q_cropValues = crop.ToString().Replace("--crop ", "");\r
709                     string[] actCropValues = new string[3];\r
710                     actCropValues = thisQuery.q_cropValues.Split(':');\r
711                     thisQuery.q_croptop = actCropValues[0];\r
712                     thisQuery.q_cropbottom = actCropValues[1];\r
713                     thisQuery.q_cropLeft = actCropValues[2];\r
714                     thisQuery.q_cropRight = actCropValues[3];\r
715                 }\r
716 \r
717                 thisQuery.q_detelecine = detelecine.Success;\r
718                 thisQuery.q_deBlock = deblock.Success;\r
719 \r
720                 thisQuery.q_deinterlace = "None";\r
721                 if (deinterlace.Success != false)\r
722                 {\r
723                     switch (deinterlace.ToString().Replace("--deinterlace=", ""))\r
724                     {\r
725                         case "fast":\r
726                             thisQuery.q_deinterlace = "Original (Fast)";\r
727                             break;\r
728                         case "slow":\r
729                             thisQuery.q_deinterlace = "yadif (Slow)";\r
730                             break;\r
731                         case "slower":\r
732                             thisQuery.q_deinterlace = "yadif + mcdeint (Slower)";\r
733                             break;\r
734                         case "slowest":\r
735                             thisQuery.q_deinterlace = "yadif + mcdeint (Slowest)";\r
736                             break;\r
737                         default:\r
738                             thisQuery.q_deinterlace = "None";\r
739                             break;\r
740                     }\r
741                 }\r
742 \r
743                 thisQuery.q_denoise = "None";\r
744                 if (denoise.Success != false)\r
745                 {\r
746                     switch (denoise.ToString().Replace("--denoise=", ""))\r
747                     {\r
748                         case "weak":\r
749                             thisQuery.q_denoise = "Weak";\r
750                             break;\r
751                         case "medium":\r
752                             thisQuery.q_denoise = "Medium";\r
753                             break;\r
754                         case "strong":\r
755                             thisQuery.q_denoise = "Strong";\r
756                             break;\r
757                         default:\r
758                             thisQuery.q_denoise = "None";\r
759                             break;\r
760                     }\r
761 \r
762                 }\r
763                 thisQuery.q_anamorphic = anamorphic.Success;\r
764                 thisQuery.q_chapterMarkers = chapterMarkers.Success;\r
765                 thisQuery.q_vfr = vfr.Success;\r
766                 thisQuery.q_looseAnamorphic = lanamorphic.Success;\r
767 \r
768                 #endregion\r
769 \r
770                 //\r
771                 //Video Settings Tab\r
772                 //\r
773                 #region Video\r
774                 thisQuery.q_grayscale = grayscale.Success;\r
775                 thisQuery.q_twoPass = twoPass.Success;\r
776                 thisQuery.q_turboFirst = turboFirstPass.Success;\r
777                 thisQuery.q_largeMp4 = largerMp4.Success;\r
778                 if (videoFramerate.Success != false)\r
779                     thisQuery.q_videoFramerate = videoFramerate.ToString().Replace("-r ", "");\r
780                 else\r
781                     thisQuery.q_videoFramerate = "Automatic";\r
782 \r
783                 if (videoBitrate.Success != false)\r
784                     thisQuery.q_avgBitrate = videoBitrate.ToString().Replace("-b ", "");\r
785                 if (videoFilesize.Success != false)\r
786                     thisQuery.q_videoTargetSize = videoFilesize.ToString().Replace("-S ", "");\r
787 \r
788                 double qConvert = 0;\r
789                 if (videoQuality.Success != false)\r
790                 {\r
791                     qConvert = double.Parse(videoQuality.ToString().Replace("-q ", "")) * 100;\r
792                     qConvert = System.Math.Ceiling(qConvert);\r
793                     thisQuery.q_videoQuality = int.Parse(qConvert.ToString());\r
794                 }\r
795                 thisQuery.q_crf = CRF.Success;\r
796                 thisQuery.q_ipodAtom = ipodAtom.Success;\r
797                 thisQuery.q_optimizeMp4 = optimizeMP4.Success;\r
798 \r
799                 #endregion\r
800 \r
801                 //\r
802                 //Audio Settings Tab\r
803                 //\r
804                 #region Audio\r
805                 if (audioBitrate.Success != false)\r
806                     thisQuery.q_audioBitrate = audioBitrate.ToString().Replace("-B ", "");\r
807 \r
808                 if (audioSampleRate.Success != false)\r
809                     thisQuery.q_audioSamplerate = audioSampleRate.ToString().Replace("-R ", "");\r
810 \r
811                 if (audioTrack1.Success != false)\r
812                     thisQuery.q_audioTrack1 = audioTrack1.ToString().Replace("-a ", "");\r
813                 else\r
814                     thisQuery.q_audioTrack1 = "Automatic";\r
815 \r
816                 if (audioTrack2.Success != false)\r
817                 {\r
818                     string[] audioChan = audioTrack2.ToString().Split(',');\r
819                     thisQuery.q_audioTrack2 = audioChan[1];\r
820                 }\r
821                 else\r
822                     thisQuery.q_audioTrack2 = "None";\r
823 \r
824                 thisQuery.q_audioTrackMix = "Automatic";\r
825                 if (audioChannelsMix.Success != false)\r
826                 {\r
827                     switch (audioChannelsMix.ToString().Replace("-6 ", "").Replace(" ", ""))\r
828                     {\r
829                         case "mono":\r
830                             thisQuery.q_audioTrackMix = "Mono";\r
831                             break;\r
832                         case "stereo":\r
833                             thisQuery.q_audioTrackMix = "Stereo";\r
834                             break;\r
835                         case "dpl1":\r
836                             thisQuery.q_audioTrackMix = "Dolby Surround";\r
837                             break;\r
838                         case "dpl2":\r
839                             thisQuery.q_audioTrackMix = "Dolby Pro Logic II";\r
840                             break;\r
841                         case "6ch":\r
842                             thisQuery.q_audioTrackMix = "6 Channel Discrete";\r
843                             break;\r
844                         default:\r
845                             thisQuery.q_audioTrackMix = "Automatic";\r
846                             break;\r
847                     }\r
848 \r
849                 }\r
850                 if (subtitles.Success != false)\r
851                     thisQuery.q_subtitles = subtitles.ToString().Replace("-s ", "");\r
852                 else\r
853                 {\r
854                     if (subScan.Success)\r
855                         thisQuery.q_subtitles = "Autoselect";\r
856                     else\r
857                         thisQuery.q_subtitles = "None";\r
858                 }\r
859 \r
860                 thisQuery.q_forcedSubs = forcedSubtitles.Success;\r
861 \r
862                 #endregion\r
863 \r
864                 //\r
865                 //H264 tab and other \r
866                 //\r
867                 #region h264 and other\r
868                 //\r
869                 //H264 Tab\r
870                 //\r
871                 if (x264.Success != false)\r
872                 {\r
873                     thisQuery.q_h264 = x264.ToString().Replace("-x ", "");\r
874                 }\r
875 \r
876                 //\r
877                 //Progam Options\r
878                 //\r
879                 thisQuery.q_verbose = verbose.Success;\r
880                 #endregion\r
881             }\r
882             catch (Exception exc)\r
883             {\r
884                 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
885             }\r
886 \r
887             return thisQuery;\r
888         }\r
889     }\r
890 }