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