OSDN Git Service

LinGui: fix start chapter range. allowed entry of chapter numbers beyond
[handbrake-jp/handbrake-jp-git.git] / scripts / manicure.rb
1 #! /usr/bin/ruby
2 # manincure.rb version 0.66
3
4 # This file is part of the HandBrake source code.
5 # Homepage: <http://handbrake.m0k.org/>.
6 # It may be used under the terms of the GNU General Public License.
7
8 # This script parses HandBrake's Mac presets into hashes, which can
9 # be displayed in various formats for use by the CLI and its wrappers.
10
11 # For handling command line arguments to the script
12 require 'optparse'
13 require 'ostruct'
14 require 'rubygems'
15 require 'plist'
16
17 # CLI options: (code based on http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html )
18 def readOptions
19   
20   # --[no-]cli-raw, -r gives raw CLI for wiki
21   # --cli-parse, -p gives CLI strings for wrappers
22   # --api, -a gives preset code for test.c
23   # --api-list, -A gives CLI strings for --preset-list display
24   # --[no-]header, -h turns off banner display
25   options = OpenStruct.new
26   options.cliraw = false
27   options.cliparse = false
28   options.api = false
29   options.apilist = false
30   options.header = false
31   
32   opts = OptionParser.new do |opts|
33     opts.banner = "Usage: manicure.rb [options]"
34     
35     opts.separator ""
36     opts.separator "Options:"
37     
38     opts.on("-r", "--cli-raw", "Gives example strings for the HB wiki") do |raw|
39       options.cliraw = raw
40       option_set = true
41     end
42     
43     opts.on("-p", "--cli-parse", "Gives presets as wrapper-parseable CLI", " option strings") do |par|
44       options.cliparse = par
45     end
46     
47     opts.on("-a", "--api", "Gives preset code for test.c") do |api|
48       options.api = api
49     end
50     
51     opts.on("-A", "--api-list", "Gives code for test.c's --preset-list", " options") do |alist|
52       options.apilist = alist
53     end
54     
55     opts.on("-H", "--Header", "Display a banner before each preset") do |head|
56       options.header = head
57     end
58     
59     opts.on_tail("-h", "--help", "Show this message") do
60         puts opts
61         exit
62     end
63   end.parse!
64   
65   return options
66   
67 end
68
69 # These arrays contain all the other presets and hashes that are going to be used.
70 # Yeah, they're global variables. In an object-oriented scripting language.
71 # Real smooth, huh?
72
73 # This class parses the user's presets .plist into an array of hashes
74 class Presets
75   
76   attr_reader :hashMasterList
77   
78   # Running initialization runs everything.
79   # Calling it will also call the parser
80   # and display output.
81   def initialize
82     
83    # Grab the user's home path
84    homeLocation = `echo $HOME`.chomp
85    
86    # Use that to build a path to the presets .plist
87    inputFile = homeLocation+'/Library/Application Support/HandBrake/UserPresets.plist'
88    
89     # Parse the presets into hashes
90     @hashMasterList = Plist::parse_xml( inputFile )
91     
92   end
93
94 end
95
96 # This class displays the presets to stdout in various formats.
97 class Display
98   
99   def initialize(hashMasterList, options)
100   
101     @hashMasterList = hashMasterList
102     @options = options
103
104     # A width of 40 gives nice, compact output.
105     @columnWidth=40
106     
107     # Print to screen.
108     displayCommandStrings
109     
110   end
111   
112   def displayCommandStrings # prints everything to screen
113     
114     # Iterate through the hashes.    
115     @hashMasterList.each do |hash|
116     
117       # Check to see whether we've got a preset or afolder
118       if !hash["Folder"]
119         # It's a top-level preset
120        displayIndividualPreset(hash, 0) 
121       else
122         # It's a folder, yay
123         displayFolder( hash, 0 )
124         hash["ChildrenArray"].each do |subhash|
125           # Drill down to see its contents
126           if !subhash["Folder"]
127             # It's a preset
128             displayIndividualPreset(subhash, 1)
129           else
130             # It's a folder
131             displayFolder( subhash, 1 )
132             subhash["ChildrenArray"].each do |subsubhash|
133               # At this point we're far enough down we won't try to drill further
134               if !subsubhash["Folder"]
135                 displayIndividualPreset(subsubhash, 2)
136               end
137             end
138             displayFolderCloser( 1 )
139           end
140         end
141         displayFolderCloser( 0 )
142       end
143     end
144   end
145   
146   def displayIndividualPreset(hash, depth)
147     if @options.header == true
148       # First throw up a header to make each preset distinct
149       displayHeader(hash)
150     end
151     
152     if @options.cliraw == true
153       # Show the preset's full CLI string equivalent
154       generateCLIString(hash, depth)
155     end
156     
157     if @options.cliparse == true
158       generateCLIParse(hash, depth)
159     end
160     
161     if @options.api == true
162       # Show the preset as code for test/test.c, HandBrakeCLI
163       generateAPIcalls(hash)
164     end
165     
166     if @options.apilist == true
167       # Show the preset as print statements, for CLI wrappers to parse.
168       generateAPIList(hash, depth) 
169     end
170   end
171   
172   def displayHeader(hash) # A distinct banner to separate each preset
173     
174     # Print a line of asterisks
175     puts "*" * @columnWidth
176     
177     # Print the name, centered
178     puts '* '+hash["PresetName"].to_s.center(@columnWidth-4)+' *'
179     
180     # Print a line of dashes
181     puts '~' * @columnWidth
182     
183     # Print the description, centered and word-wrapped
184     puts hash["PresetDescription"].to_s.center(@columnWidth).gsub(/\n/," ").scan(/\S.{0,#{@columnWidth-2}}\S(?=\s|$)|\S+/)
185     
186     # Print another line of dashes
187     puts '~' * @columnWidth
188     
189     # Print the formats the preset uses
190     puts "#{hash["FileCodecs"]}".center(@columnWidth)
191     
192     # Note if the preset isn't built-in
193     if hash["Type"] == 1
194       puts "Custom Preset".center(@columnWidth)
195     end
196
197     # Note if the preset is marked as default.
198     if hash["Default"] == 1
199       puts "This is your default preset.".center(@columnWidth)
200     end
201     
202     # End with a line of tildes.  
203     puts "~" * @columnWidth
204     
205   end
206   
207   def displayFolder( hash, depth )
208
209     if @options.cliraw == true
210       # Show the folder's full in a format that matches the CLI equivalents
211       generateCLIFolderString(hash, depth)
212     end
213     
214     if @options.cliparse == true
215       # Show the folder in a format that matches the CLI wrapper equivalents
216       generateCLIFolderParse(hash, depth)
217     end
218     
219     if @options.apilist == true
220       # Show the folder as print statements, for CLI wrappers to parse.
221       generateAPIFolderList(hash, depth) 
222     end
223     
224   end
225   
226   def displayFolderCloser( depth )
227     if @options.cliraw == true
228       # Show the folder's full in a format that matches the CLI equivalents
229       generateCLIFolderCloserString( depth )
230     end
231     
232     if @options.cliparse == true
233       # Show the folder in a format that matches the CLI wrapper equivalents
234       generateCLIFolderCloserParse( depth )
235     end
236     
237     if @options.apilist == true
238       # Show the folder as print statements, for CLI wrappers to parse.
239       generateAPIFolderCloserList( depth ) 
240     end
241   end
242   
243   def generateCLIFolderString( hash, depth ) # Shows the folder for the CLI equivalents
244     commandString = ""
245     depth.times do
246       commandString << "   "
247     end
248     (depth+1).times do
249       commandString << "<"
250     end
251     commandString << " " << hash["PresetName"] << "\n\n"
252     puts commandString
253   end
254   
255   def generateCLIFolderCloserString( depth )
256     commandString = ""
257     depth.times do
258       commandString << "   "
259     end
260     (depth+1).times do
261       commandString << ">"
262     end
263     commandString << "\n\n"
264     puts commandString
265   end
266   
267   def generateCLIString(hash, depth) # Makes a full CLI equivalent of a preset
268     commandString = ""
269     depth.times do
270       commandString << "   "
271     end
272     commandString << './HandBrakeCLI -i DVD -o ~/Movies/movie.'
273     
274     #Filename suffix
275     case hash["FileFormat"]
276     when /MP4/
277       commandString << "mp4 "
278     when /AVI/
279       commandString << "avi "
280     when /OGM/
281       commandString << "ogm "
282     when /MKV/
283       commandString << "mkv "
284     end
285     
286     #Video encoder
287     if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
288       commandString << " -e "
289       case hash["VideoEncoder"]
290       when /x264/
291         commandString << "x264"
292       when /XviD/
293         commandString << "xvid"
294       end
295     end
296
297     #VideoRateControl
298     case hash["VideoQualityType"]
299     when 0
300       commandString << " -S " << hash["VideoTargetSize"]
301     when 1
302       commandString << " -b " << hash["VideoAvgBitrate"]
303     when 2
304       commandString << " -q " << hash["VideoQualitySlider"].to_s
305     end
306
307     #FPS
308     if hash["VideoFramerate"] != "Same as source"
309       if hash["VideoFramerate"] == "23.976 (NTSC Film)"
310         commandString << " -r " << "23.976"
311       elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
312         commandString << " -r " << "29.97"
313       elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
314         commandString << " -r " << "25"
315       else
316         commandString << " -r " << hash["VideoFramerate"]
317       end
318     end
319     
320     #Audio tracks
321     commandString << " -a "
322     commandString << hash["Audio1Track"].to_s
323     if hash["Audio2Track"]
324       commandString << "," << hash["Audio2Track"].to_s
325     end
326     if hash["Audio3Track"]
327       commandString << "," << hash["Audio3Track"].to_s
328     end
329     if hash["Audio4Track"]
330       commandString << "," << hash["Audio4Track"].to_s
331     end
332     
333     #Audio encoders
334     commandString << " -E "
335     case hash["Audio1Encoder"]
336     when /AC3 /
337       commandString << "ac3"
338     when /AAC/
339       commandString << "faac"
340     when /Vorbis/
341       commandString << "vorbis"
342     when /MP3/
343       commandString << "lame"
344     end
345     case hash["Audio2Encoder"]
346     when /AC3 /
347       commandString << ",ac3"
348     when /AAC/
349       commandString << ",faac"
350     when /Vorbis/
351       commandString << ",vorbis"
352     when /MP3/
353       commandString << ",lame"
354     end
355     case hash["Audio3Encoder"]
356     when /AC3 /
357       commandString << ",ac3"
358     when /AAC/
359       commandString << ",faac"
360     when /Vorbis/
361       commandString << ",vorbis"
362     when /MP3/
363       commandString << ",lame"
364     end
365     case hash["Audio4Encoder"]
366     when /AC3 /
367       commandString << ",ac3"
368     when /AAC/
369       commandString << ",faac"
370     when /Vorbis/
371       commandString << ",vorbis"
372     when /MP3/
373       commandString << ",lame"
374     end
375     
376     #Audio bit rate
377     commandString << " -B "
378     commandString << hash["Audio1Bitrate"]
379     if hash["Audio2Bitrate"]
380       if hash["Audio2Encoder"] != "AC3 Passthru"
381         commandString << "," << hash["Audio2Bitrate"]
382       else
383         commandString << "," << "auto"
384       end
385     end
386     if hash["Audio3Bitrate"]
387       if hash["Audio3Encoder"] != "AC3 Passthru"
388         commandString << "," << hash["Audio3Bitrate"]
389       else
390         commandString << "," << "auto"
391       end
392     end
393     if hash["Audio4Bitrate"]
394       if hash["Audio4Encoder"] != "AC3 Passthru"
395         commandString << "," << hash["Audio4Bitrate"]
396       else
397         commandString << "," << "auto"
398       end
399     end
400
401     #Audio sample rate
402     commandString << " -R "
403     commandString << hash["Audio1Samplerate"]
404     if hash["Audio2Samplerate"]
405       commandString << "," << hash["Audio2Samplerate"]
406     end
407     if hash["Audio3Samplerate"]
408       commandString << "," << hash["Audio3Samplerate"]
409     end
410     if hash["Audio4Samplerate"]
411       commandString << "," << hash["Audio4Samplerate"]
412     end
413     
414     #Audio Mixdown
415     commandString << " -6 "
416     case hash["Audio1Mixdown"]
417     when /Mono/
418       commandString << "mono"
419     when /Stereo/
420       commandString << "stereo"
421     when /Dolby Surround/
422       commandString << "dpl1"
423     when /Dolby Pro Logic II/
424       commandString << "dpl2"
425     when /discrete/
426       commandString << "6ch"
427     when /Passthru/
428       commandString << "auto"
429     end
430     
431     if hash["Audio2Mixdown"]
432       case hash["Audio2Mixdown"]
433       when /Mono/
434         commandString << ",mono"
435       when /Stereo/
436         commandString << ",stereo"
437       when /Dolby Surround/
438         commandString << ",dpl1"
439       when /Dolby Pro Logic II/
440         commandString << ",dpl2"
441       when /discrete/
442         commandString << ",6ch"
443       when /Passthru/
444         commandString << ",auto"
445       end
446     end
447     
448     if hash["Audio3Mixdown"]
449       case hash["Audio3Mixdown"]
450       when /Mono/
451         commandString << ",mono"
452       when /Stereo/
453         commandString << ",stereo"
454       when /Dolby Surround/
455         commandString << ",dpl1"
456       when /Dolby Pro Logic II/
457         commandString << ",dpl2"
458       when /discrete/
459         commandString << ",6ch"
460       when /Passthru/
461         commandString << ",auto"
462       end
463     end
464     
465     if hash["Audio4Mixdown"]
466       case hash["Audio4Mixdown"]
467       when /Mono/
468         commandString << ",mono"
469       when /Stereo/
470         commandString << ",stereo"
471       when /Dolby Surround/
472         commandString << ",dpl1"
473       when /Dolby Pro Logic II/
474         commandString << ",dpl2"
475       when /discrete/
476         commandString << ",6ch"
477       when /Passthru/
478         commandString << ",auto"
479       end
480     end
481     
482     #Container
483     commandString << " -f "
484     case hash["FileFormat"]
485     when /MP4/
486       commandString << "mp4"
487     when /AVI/
488       commandString << "avi"
489     when /OGM/
490       commandString << "ogm"
491     when /MKV/
492       commandString << "mkv"
493     end
494     
495     #iPod MP4 atom
496     if hash["Mp4iPodCompatible"].to_i == 1
497       commandString << " -I"
498     end
499     
500     # 64-bit files
501     if hash["Mp4LargeFile"] == 1
502       commandString << " -4"
503     end
504     
505     #Cropping
506     if hash["PictureAutoCrop"] == 0
507       commandString << " --crop "
508       commandString << hash["PictureTopCrop"].to_s
509       commandString << ":"
510       commandString << hash["PictureBottomCrop"].to_s
511       commandString << ":"
512       commandString << hash["PictureLeftCrop"].to_s
513       commandString << ":"
514       commandString << hash["PictureRightCrop"].to_s
515     end
516     
517     #Dimensions
518     if hash["PictureWidth"] != 0
519       commandString << " -X "
520       commandString << hash["PictureWidth"].to_s
521     end
522     if hash["PictureHeight"] != 0
523       commandString << " -Y "
524       commandString << hash["PictureHeight"].to_s
525     end
526     
527     #Subtitles
528     if hash["Subtitles"] != "None"
529       if hash["Subtitles"] == "Autoselect"
530         commandString << " --subtitle-scan"
531       else
532         commandString << " -s "
533         commandString << hash["Subtitles"]
534       end
535     end
536
537     #Video Filters
538     if hash["UsesPictureFilters"] == 1
539       
540       case hash["PictureDeinterlace"]
541       when 1
542         commandString << " --deinterlace=\"fast\""
543       when 2
544         commandString << " --deinterlace=\slow\""
545       when 3
546         commandString << " --deinterlace=\"slower\""
547       when 4
548         commandString << " --deinterlace=\"slowest\""
549       end
550       
551       case hash["PictureDenoise"]
552       when 1
553         commandString << " --denoise=\"weak\""
554       when 2
555         commandString << " --denoise=\"medium\""
556       when 3
557         commandString << " --denoise=\"strong\""
558       end
559       
560       if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
561       if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
562       if hash["VFR"].to_i == 1 then commandString << " --vfr" end
563       if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
564       
565     end
566     
567     #Anamorphic
568     if hash["PicturePAR"] == 1
569       commandString << " -p"
570     elsif hash["PicturePAR"] == 2
571       commandString << " -P"
572     end
573
574     #Booleans
575     if hash["ChapterMarkers"] == 1 then commandString << " -m" end
576     if hash["VideoGrayScale"] == 1 then commandString << " -g" end
577     if hash["VideoTwoPass"] == 1 then commandString << " -2" end
578     if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
579
580     #x264 Options
581     if hash["x264Option"] != ""
582       commandString << " -x "
583       commandString << hash["x264Option"]
584     end
585     
586     # That's it, print to screen now
587     puts commandString
588     
589     #puts "*" * @columnWidth
590
591     puts  "\n"
592   end
593   
594   def generateCLIFolderParse( hash, depth ) # Shows the folder for wrappers to parse
595     commandString = ""
596     depth.times do
597       commandString << "   "
598     end
599     (depth+1).times do
600       commandString << "<"
601     end
602     commandString << " " << hash["PresetName"] << "\n\n"
603     puts commandString
604   end
605   
606   def generateCLIFolderCloserParse( depth )
607     commandString = ""
608     depth.times do
609       commandString << "   "
610     end
611     (depth+1).times do
612       commandString << ">"
613     end
614     commandString << "\n\n"
615     puts commandString
616   end
617   
618   def generateCLIParse(hash, depth) # Makes a CLI equivalent of all user presets, for wrappers to parse
619     commandString = ""
620     depth.times do
621       commandString << "   "
622     end
623     commandString << '+ ' << hash["PresetName"] << ":"
624         
625     #Video encoder
626     if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
627       commandString << " -e "
628       case hash["VideoEncoder"]
629       when /x264/
630         commandString << "x264"
631       when /XviD/
632         commandString << "xvid"
633       end
634     end
635
636     #VideoRateControl
637     case hash["VideoQualityType"]
638     when 0
639       commandString << " -S " << hash["VideoTargetSize"]
640     when 1
641       commandString << " -b " << hash["VideoAvgBitrate"]
642     when 2
643       commandString << " -q " << hash["VideoQualitySlider"].to_s
644     end
645
646     #FPS
647     if hash["VideoFramerate"] != "Same as source"
648       if hash["VideoFramerate"] == "23.976 (NTSC Film)"
649         commandString << " -r " << "23.976"
650       elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
651         commandString << " -r " << "29.97"
652       elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
653         commandString << " -r " << "25"
654       else
655         commandString << " -r " << hash["VideoFramerate"]
656       end
657     end
658     
659     #Audio tracks
660     commandString << " -a "
661     commandString << hash["Audio1Track"].to_s
662     if hash["Audio2Track"]
663       commandString << "," << hash["Audio2Track"].to_s
664     end
665     if hash["Audio3Track"]
666       commandString << "," << hash["Audio3Track"].to_s
667     end
668     if hash["Audio4Track"]
669       commandString << "," << hash["Audio4Track"].to_s
670     end
671     
672     #Audio encoders
673     commandString << " -E "
674     case hash["Audio1Encoder"]
675     when /AC3/
676       commandString << "ac3"
677     when /AAC/
678       commandString << "faac"
679     when /Vorbis/
680       commandString << "vorbis"
681     when /MP3/
682       commandString << "lame"
683     end
684     case hash["Audio2Encoder"]
685     when /AC3 /
686       commandString << ",ac3"
687     when /AAC/
688       commandString << ",faac"
689     when /Vorbis/
690       commandString << ",vorbis"
691     when /MP3/
692       commandString << ",lame"
693     end
694     case hash["Audio3Encoder"]
695     when /AC3 /
696       commandString << ",ac3"
697     when /AAC/
698       commandString << ",faac"
699     when /Vorbis/
700       commandString << ",vorbis"
701     when /MP3/
702       commandString << ",lame"
703     end
704     case hash["Audio4Encoder"]
705     when /AC3 /
706       commandString << ",ac3"
707     when /AAC/
708       commandString << ",faac"
709     when /Vorbis/
710       commandString << ",vorbis"
711     when /MP3/
712       commandString << ",lame"
713     end
714
715     #Audio bit rate
716     commandString << " -B "
717     commandString << hash["Audio1Bitrate"]
718     if hash["Audio2Bitrate"]
719       if hash["Audio2Encoder"] != "AC3 Passthru"
720         commandString << "," << hash["Audio2Bitrate"]
721       else
722         commandString << "," << "auto"
723       end
724     end
725     if hash["Audio3Bitrate"]
726       if hash["Audio3Encoder"] != "AC3 Passthru"
727         commandString << "," << hash["Audio3Bitrate"]
728       else
729         commandString << "," << "auto"
730       end
731     end
732     if hash["Audio4Bitrate"]
733       if hash["Audio4Encoder"] != "AC3 Passthru"
734         commandString << "," << hash["Audio4Bitrate"]
735       else
736         commandString << "," << "auto"
737       end
738     end
739
740     #Audio sample rate
741     commandString << " -R "
742     commandString << hash["Audio1Samplerate"]
743     if hash["Audio2Samplerate"]
744       commandString << "," << hash["Audio2Samplerate"]
745     end
746     if hash["Audio3Samplerate"]
747       commandString << "," << hash["Audio3Samplerate"]
748     end
749     if hash["Audio4Samplerate"]
750       commandString << "," << hash["Audio4Samplerate"]
751     end
752     
753     #Audio Mixdown
754     commandString << " -6 "
755     case hash["Audio1Mixdown"]
756     when /Mono/
757       commandString << "mono"
758     when /Stereo/
759       commandString << "stereo"
760     when /Dolby Surround/
761       commandString << "dpl1"
762     when /Dolby Pro Logic II/
763       commandString << "dpl2"
764     when /discrete/
765       commandString << "6ch"
766     when /Passthru/
767       commandString << "auto"
768     end
769     
770     if hash["Audio2Mixdown"]
771       case hash["Audio2Mixdown"]
772       when /Mono/
773         commandString << ",mono"
774       when /Stereo/
775         commandString << ",stereo"
776       when /Dolby Surround/
777         commandString << ",dpl1"
778       when /Dolby Pro Logic II/
779         commandString << ",dpl2"
780       when /discrete/
781         commandString << ",6ch"
782       when /Passthru/
783         commandString << ",auto"
784       end
785     end
786     
787     if hash["Audio3Mixdown"]
788       case hash["Audio3Mixdown"]
789       when /Mono/
790         commandString << ",mono"
791       when /Stereo/
792         commandString << ",stereo"
793       when /Dolby Surround/
794         commandString << ",dpl1"
795       when /Dolby Pro Logic II/
796         commandString << ",dpl2"
797       when /discrete/
798         commandString << ",6ch"
799       when /Passthru/
800         commandString << ",auto"
801       end
802     end
803     
804     if hash["Audio4Mixdown"]
805       case hash["Audio4Mixdown"]
806       when /Mono/
807         commandString << ",mono"
808       when /Stereo/
809         commandString << ",stereo"
810       when /Dolby Surround/
811         commandString << ",dpl1"
812       when /Dolby Pro Logic II/
813         commandString << ",dpl2"
814       when /discrete/
815         commandString << ",6ch"
816       when /Passthru/
817         commandString << ",auto"
818       end
819     end
820
821     
822     #Container
823     commandString << " -f "
824     case hash["FileFormat"]
825     when /MP4/
826       commandString << "mp4"
827     when /AVI/
828       commandString << "avi"
829     when /OGM/
830       commandString << "ogm"
831     when /MKV/
832       commandString << "mkv"
833     end
834     
835     #iPod MP4 atom
836     if hash["Mp4iPodCompatible"].to_i == 1
837       commandString << " -I"
838     end
839     
840     # 64-bit files
841     if hash["Mp4LargeFile"] == 1
842       commandString << " -4"
843     end
844     
845     #Cropping
846     if hash["PictureAutoCrop"] == 0
847       commandString << " --crop "
848       commandString << hash["PictureTopCrop"].to_s
849       commandString << ":"
850       commandString << hash["PictureBottomCrop"].to_s
851       commandString << ":"
852       commandString << hash["PictureLeftCrop"].to_s
853       commandString << ":"
854       commandString << hash["PictureRightCrop"].to_s
855     end
856     
857     #Dimensions
858     if hash["PictureWidth"] != 0
859       commandString << " -X "
860       commandString << hash["PictureWidth"].to_s
861     end
862     if hash["PictureHeight"] != 0
863       commandString << " -Y "
864       commandString << hash["PictureHeight"].to_s
865     end
866     
867     #Subtitles
868     if hash["Subtitles"] != "None"
869       if hash["Subtitles"] == "Autoselect"
870         commandString << " --subtitle-scan"
871       else
872         commandString << " -s "
873         commandString << hash["Subtitles"]
874       end
875     end
876     
877     #Video Filters
878     if hash["UsesPictureFilters"] == 1
879       
880       case hash["PictureDeinterlace"]
881       when 1
882         commandString << " --deinterlace=\"fast\""
883       when 2
884         commandString << " --deinterlace=\slow\""
885       when 3
886         commandString << " --deinterlace=\"slower\""
887       when 4
888         commandString << " --deinterlace=\"slowest\""
889       end
890       
891       case hash["PictureDenoise"]
892       when 1
893         commandString << " --denoise=\"weak\""
894       when 2
895         commandString << " --denoise=\"medium\""
896       when 3
897         commandString << " --denoise=\"strong\""
898       end
899       
900       if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
901       if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
902       if hash["VFR"].to_i == 1 then commandString << " --vfr" end
903       if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
904     end
905
906     #Anamorphic
907     if hash["PicturePAR"] == 1
908       commandString << " -p"
909     elsif hash["PicturePAR"] == 2
910       commandString << " -P"
911     end
912     
913     #Booleans
914     if hash["ChapterMarkers"] == 1 then commandString << " -m" end
915     if hash["VideoGrayScale"] == 1 then commandString << " -g" end
916     if hash["VideoTwoPass"] == 1 then commandString << " -2" end
917     if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
918
919     #x264 Options
920     if hash["x264Option"] != ""
921       commandString << " -x "
922       commandString << hash["x264Option"]
923     end
924     
925     # That's it, print to screen now
926     puts commandString
927     
928     #puts "*" * @columnWidth
929
930     puts  "\n"
931   end
932
933   def generateAPIcalls(hash) # Makes a C version of the preset ready for coding into the CLI
934     
935     commandString = "if (!strcmp(preset_name, \"" << hash["PresetName"] << "\"))\n{\n    "
936     
937     #Filename suffix
938     case hash["FileFormat"]
939     when /MP4/
940       commandString << "mux = " << "HB_MUX_MP4;\n    "
941     when /AVI/
942       commandString << "mux = " << "HB_MUX_AVI;\n    "
943     when /OGM/
944       commandString << "mux = " << "HB_MUX_OGM;\n    "
945     when /MKV/
946       commandString << "mux = " << "HB_MUX_MKV;\n    "
947     end
948     
949     #iPod MP4 atom
950     if hash["Mp4iPodCompatible"].to_i == 1
951       commandString << "job->ipod_atom = 1;\n   "
952     end
953     
954     # 64-bit files
955     if hash["Mp4LargeFile"] == 1
956       commandString << "job->largeFileSize = 1;\n    "
957     end
958     
959     #Video encoder
960     if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
961       commandString << "vcodec = "
962       case hash["VideoEncoder"]
963       when /x264/
964         commandString << "HB_VCODEC_X264;\n    "
965       when /XviD/
966         commandString << "HB_VCODEC_XVID;\n    "        
967       end
968     end
969
970     #VideoRateControl
971     case hash["VideoQualityType"]
972     when 0
973       commandString << "size = " << hash["VideoTargetSize"] << ";\n    "
974     when 1
975       commandString << "job->vbitrate = " << hash["VideoAvgBitrate"] << ";\n    "
976     when 2
977       commandString << "job->vquality = " << hash["VideoQualitySlider"].to_s << ";\n    "
978       commandString << "job->crf = 1;\n    "
979     end
980
981     #FPS
982     if hash["VideoFramerate"] != "Same as source"
983       if hash["VideoFramerate"] == "23.976 (NTSC Film)"
984         commandString << "job->vrate_base = " << "1126125;\n    "
985       elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
986         commandString << "job->vrate_base = " << "900900;\n    "
987       elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
988         commandString << "job->vrate_base = " << "1080000\n    "
989       # Gotta add the rest of the framerates for completion's sake.
990       end
991       commandString << "job->cfr = 1;\n    "
992     end
993     
994     #Audio tracks
995     commandString << "atracks = strdup(\""
996     commandString << hash["Audio1Track"].to_s
997     if hash["Audio2Track"]
998       commandString << "," << hash["Audio2Track"].to_s
999     end
1000     if hash["Audio3Track"]
1001       commandString << "," << hash["Audio3Track"].to_s
1002     end
1003     if hash["Audio4Track"]
1004       commandString << "," << hash["Audio4Track"].to_s
1005     end
1006     commandString << "\");\n    "
1007     
1008     # Audio bitrate
1009     commandString << "abitrates = strdup(\""
1010     if hash["Audio1Encoder"] != "AC3 Passthru"
1011       commandString << hash["Audio1Bitrate"]
1012     else
1013       commandString << "auto"
1014     end
1015     if hash["Audio2Bitrate"]
1016       if hash["Audio2Encoder"] != "AC3 Passthru"
1017         commandString << "," << hash["Audio2Bitrate"]
1018       else
1019         commandString << "," << "auto"
1020       end
1021     end
1022     if hash["Audio3Bitrate"]
1023       if hash["Audio3Encoder"] != "AC3 Passthru"
1024         commandString << "," << hash["Audio3Bitrate"]
1025       else
1026         commandString << "," << "auto"
1027       end
1028     end
1029     if hash["Audio4Bitrate"]
1030       if hash["Audio4Encoder"] != "AC3 Passthru"
1031         commandString << "," << hash["Audio4Bitrate"]
1032       else
1033         commandString << "," << "auto"
1034       end
1035     end
1036     commandString << "\");\n    "
1037         
1038     #Audio samplerate
1039     commandString << "arates = strdup(\""
1040     commandString << hash["Audio1Samplerate"]
1041     if hash["Audio2Samplerate"]
1042       commandString << "," << hash["Audio2Samplerate"]
1043     end
1044     if hash["Audio3Samplerate"]
1045       commandString << "," << hash["Audio3Samplerate"]
1046     end
1047     if hash["Audio4Samplerate"]
1048       commandString << "," << hash["Audio4Samplerate"]
1049     end
1050     commandString << "\");\n    "
1051       
1052     #Audio encoder
1053     commandString << "acodecs = strdup(\""
1054     case hash["Audio1Encoder"]
1055     when /AC3/
1056       commandString << "ac3"
1057     when /AAC/
1058       commandString << "faac"
1059     when /Vorbis/
1060       commandString << "vorbis"
1061     when /MP3/
1062       commandString << "lame"
1063     end
1064     case hash["Audio2Encoder"]
1065     when /AC3 /
1066       commandString << ",ac3"
1067     when /AAC/
1068       commandString << ",faac"
1069     when /Vorbis/
1070       commandString << ",vorbis"
1071     when /MP3/
1072       commandString << ",lame"
1073     end
1074     case hash["Audio3Encoder"]
1075     when /AC3 /
1076       commandString << ",ac3"
1077     when /AAC/
1078       commandString << ",faac"
1079     when /Vorbis/
1080       commandString << ",vorbis"
1081     when /MP3/
1082       commandString << ",lame"
1083     end
1084     case hash["Audio4Encoder"]
1085     when /AC3 /
1086       commandString << ",ac3"
1087     when /AAC/
1088       commandString << ",faac"
1089     when /Vorbis/
1090       commandString << ",vorbis"
1091     when /MP3/
1092       commandString << ",lame"
1093     end
1094     commandString << "\");\n    "
1095     
1096     #Audio mixdowns
1097     commandString << "mixdowns = strdup(\""
1098     case hash["Audio1Mixdown"]
1099     when /Mono/
1100       commandString << "mono"
1101     when /Stereo/
1102       commandString << "stereo"
1103     when /Dolby Surround/
1104       commandString << "dpl1"
1105     when /Dolby Pro Logic II/
1106       commandString << "dpl2"
1107     when /discrete/
1108       commandString << "6ch"
1109     when /Passthru/
1110       commandString << "auto"
1111     end
1112     if hash["Audio2Mixdown"]
1113       case hash["Audio2Mixdown"]
1114       when /Mono/
1115         commandString << ",mono"
1116       when /Stereo/
1117         commandString << ",stereo"
1118       when /Dolby Surround/
1119         commandString << ",dpl1"
1120       when /Dolby Pro Logic II/
1121         commandString << ",dpl2"
1122       when /discrete/
1123         commandString << ",6ch"
1124       when /Passthru/
1125         commandString << ",auto"
1126       end
1127     end
1128     if hash["Audio3Mixdown"]
1129       case hash["Audio3Mixdown"]
1130       when /Mono/
1131         commandString << ",mono"
1132       when /Stereo/
1133         commandString << ",stereo"
1134       when /Dolby Surround/
1135         commandString << ",dpl1"
1136       when /Dolby Pro Logic II/
1137         commandString << ",dpl2"
1138       when /discrete/
1139         commandString << ",6ch"
1140       when /Passthru/
1141         commandString << ",auto"
1142       end
1143     end
1144     if hash["Audio4Mixdown"]
1145       case hash["Audio4Mixdown"]
1146       when /Mono/
1147         commandString << ",mono"
1148       when /Stereo/
1149         commandString << ",stereo"
1150       when /Dolby Surround/
1151         commandString << ",dpl1"
1152       when /Dolby Pro Logic II/
1153         commandString << ",dpl2"
1154       when /discrete/
1155         commandString << ",6ch"
1156       when /Passthru/
1157         commandString << ",auto"
1158       end
1159     end
1160     commandString << "\");\n    "
1161     
1162     #Cropping
1163     if hash["PictureAutoCrop"] == 0
1164       commandString << "job->crop[0] = " << hash["PictureTopCrop"].to_s << ";\n    "
1165       commandString << "job->crop[1] = " << hash["PictureBottomCrop"].to_s << ";\n    "
1166       commandString << "job->crop[2] = " << hash["PictureLeftCrop"].to_s << ";\n    "
1167       commandString << "job->crop[4] - " << hash["PictureRightCrop"].to_s << ";\n    "
1168     end
1169     
1170     #Dimensions
1171     if hash["PictureWidth"] != 0
1172       commandString << "maxWidth = "
1173       commandString << hash["PictureWidth"].to_s << ";\n    "
1174     end
1175     if hash["PictureHeight"] != 0
1176       commandString << "maxHeight = "
1177       commandString << hash["PictureHeight"].to_s << ";\n    "
1178     end
1179     
1180     #Subtitles
1181     if hash["Subtitles"] != "None"
1182       if hash["Subtitles"] == "Autoselect"
1183         commandString << "subtitle_scan = 1;\n    "
1184       else
1185         commandString << "job->subtitle = "
1186         commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n    "
1187       end
1188     end
1189     
1190     #x264 Options
1191     if hash["x264Option"] != ""
1192       commandString << "x264opts = strdup(\""
1193       commandString << hash["x264Option"] << "\");\n    "
1194     end
1195     
1196     #Video Filters
1197     if hash["UsesPictureFilters"] == 1
1198       
1199       case hash["PictureDeinterlace"]
1200       when 1
1201         commandString << "deinterlace = 1;\n    "
1202         commandString << "deinterlace_opt = \"-1\";\n    "
1203       when 2
1204         commandString << "deinterlace = 1;\n    "
1205         commandString << "deinterlace_opt = \"2\";\n    "
1206       when 3
1207         commandString << "deinterlace = 1;\n    "
1208         commandString << "deinterlace_opt = \"0\";\n    "
1209       when 4
1210         commandString << "deinterlace = 1;\n    "
1211         commandString << "deinterlace_opt = \"1:-1:1\";\n    "
1212       end
1213       
1214       case hash["PictureDenoise"]
1215       when 1
1216         commandString << "denoise = 1;\n    "
1217         commandString << "denoise_opt = \"2:1:2:3\";\n    "
1218       when 2
1219         commandString << "denoise = 1;\n    "
1220         commandString << "denoise_opt = \"3:2:2:3\";\n    "
1221       when 3
1222         commandString << "denoise = 1;\n    "
1223         commandString << "denoise_opt = \"7:7:5:5\";\n    "
1224       end
1225       
1226       if hash["PictureDetelecine"] == 1 then commandString << "detelecine = 1;\n    " end
1227       if hash["PictureDeblock"] == 1 then commandString << "deblock = 1;\n    " end
1228       if hash["VFR"].to_i == 1 then commandString << "vfr = 1;\n    " end
1229       if hash["PictureDecomb"] == 1 then commandString << "decomb = 1;\n    " end
1230       
1231     end
1232     
1233     #Anamorphic
1234     if hash["PicturePAR"] == 1
1235       commandString << "pixelratio = 1;\n    "
1236     elsif hash["PicturePAR"] == 2
1237       commandString << "pixelratio = 2;\n    "
1238     end
1239     
1240     #Booleans
1241     if hash["ChapterMarkers"] == 1 then commandString << "job->chapter_markers = 1;\n    " end
1242     if hash["VideoGrayScale"] == 1 then commandString << "job->grayscale = 1;\n    " end
1243     if hash["VideoTwoPass"] == 1 then commandString << "twoPass = 1;\n    " end
1244     if hash["VideoTurboTwoPass"] == 1 then commandString << "turbo_opts_enabled = 1;\n" end
1245     
1246     commandString << "}"
1247     
1248     # That's it, print to screen now
1249     puts commandString
1250     #puts "*" * @columnWidth
1251     puts  "\n"
1252   end
1253   
1254   def generateAPIFolderList( hash, depth )
1255     commandString = ""
1256     
1257     commandString << "    printf(\"\\n"
1258     depth.times do
1259       commandString << "   "
1260     end
1261     (depth+1).times do
1262       commandString << "<"
1263     end
1264     commandString << " " << hash["PresetName"]
1265     commandString << "\\n\");\n\n"    
1266     puts commandString
1267   end
1268   
1269   def generateAPIFolderCloserList( depth )
1270     commandString = ""
1271     
1272     commandString << "    printf(\"\\n"
1273     depth.times do
1274       commandString << "   "
1275     end
1276     (depth+1).times do
1277       commandString << ">"
1278     end
1279     commandString << "\\n\");\n\n"    
1280     puts commandString
1281   end
1282   
1283   def generateAPIList(hash, depth) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse
1284     commandString = ""
1285     commandString << "    printf(\"\\n"
1286     depth.times do
1287       commandString << "   "
1288     end
1289            
1290     commandString << "+ " << hash["PresetName"] << ": "
1291         
1292     #Video encoder
1293     if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
1294       commandString << " -e "
1295       case hash["VideoEncoder"]
1296       when /x264/
1297         commandString << "x264 "
1298       when /XviD/
1299         commandString << "xvid "
1300       end
1301     end
1302
1303     #VideoRateControl
1304     case hash["VideoQualityType"]
1305     when 0
1306       commandString << " -S " << hash["VideoTargetSize"]
1307     when 1
1308       commandString << " -b " << hash["VideoAvgBitrate"]
1309     when 2
1310       commandString << " -q " << hash["VideoQualitySlider"].to_s
1311     end
1312
1313     #FPS
1314     if hash["VideoFramerate"] != "Same as source"
1315       if hash["VideoFramerate"] == "23.976 (NTSC Film)"
1316         commandString << " -r " << "23.976"
1317       elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
1318         commandString << " -r " << "29.97"
1319       elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
1320         commandString << " -r " << "25"
1321       else
1322         commandString << " -r " << hash["VideoFramerate"]
1323       end
1324     end
1325     
1326     #Audio tracks
1327     commandString << " -a "
1328     commandString << hash["Audio1Track"].to_s
1329     if hash["Audio2Track"]
1330       commandString << "," << hash["Audio2Track"].to_s
1331     end
1332     if hash["Audio3Track"]
1333       commandString << "," << hash["Audio3Track"].to_s
1334     end
1335     if hash["Audio4Track"]
1336       commandString << "," << hash["Audio4Track"].to_s
1337     end
1338     
1339     #Audio encoders
1340     commandString << " -E "
1341     case hash["Audio1Encoder"]
1342     when /AC3/
1343       commandString << "ac3"
1344     when /AAC/
1345       commandString << "faac"
1346     when /Vorbis/
1347       commandString << "vorbis"
1348     when /MP3/
1349       commandString << "lame"
1350     end
1351     case hash["Audio2Encoder"]
1352     when /AC3 /
1353       commandString << ",ac3"
1354     when /AAC/
1355       commandString << ",faac"
1356     when /Vorbis/
1357       commandString << ",vorbis"
1358     when /MP3/
1359       commandString << ",lame"
1360     end
1361     case hash["Audio3Encoder"]
1362     when /AC3 /
1363       commandString << ",ac3"
1364     when /AAC/
1365       commandString << ",faac"
1366     when /Vorbis/
1367       commandString << ",vorbis"
1368     when /MP3/
1369       commandString << ",lame"
1370     end
1371     case hash["Audio4Encoder"]
1372     when /AC3 /
1373       commandString << ",ac3"
1374     when /AAC/
1375       commandString << ",faac"
1376     when /Vorbis/
1377       commandString << ",vorbis"
1378     when /MP3/
1379       commandString << ",lame"
1380     end
1381
1382     #Audio bit rate
1383     commandString << " -B "
1384     commandString << hash["Audio1Bitrate"]
1385     if hash["Audio2Bitrate"]
1386       if hash["Audio2Encoder"] != "AC3 Passthru"
1387         commandString << "," << hash["Audio2Bitrate"]
1388       else
1389         commandString << "," << "auto"
1390       end
1391     end
1392     if hash["Audio3Bitrate"]
1393       if hash["Audio3Encoder"] != "AC3 Passthru"
1394         commandString << "," << hash["Audio3Bitrate"]
1395       else
1396         commandString << "," << "auto"
1397       end
1398     end
1399     if hash["Audio4Bitrate"]
1400       if hash["Audio4Encoder"] != "AC3 Passthru"
1401         commandString << "," << hash["Audio4Bitrate"]
1402       else
1403         commandString << "," << "auto"
1404       end
1405     end
1406
1407     #Audio sample rate
1408     commandString << " -R "
1409     commandString << hash["Audio1Samplerate"]
1410     if hash["Audio2Samplerate"]
1411       commandString << "," << hash["Audio2Samplerate"]
1412     end
1413     if hash["Audio3Samplerate"]
1414       commandString << "," << hash["Audio3Samplerate"]
1415     end
1416     if hash["Audio4Samplerate"]
1417       commandString << "," << hash["Audio4Samplerate"]
1418     end
1419     
1420     #Audio Mixdown
1421     commandString << " -6 "
1422     case hash["Audio1Mixdown"]
1423     when /Mono/
1424       commandString << "mono"
1425     when /Stereo/
1426       commandString << "stereo"
1427     when /Dolby Surround/
1428       commandString << "dpl1"
1429     when /Dolby Pro Logic II/
1430       commandString << "dpl2"
1431     when /discrete/
1432       commandString << "6ch"
1433     when /Passthru/
1434       commandString << "auto"
1435     end
1436     
1437     if hash["Audio2Mixdown"]
1438       case hash["Audio2Mixdown"]
1439       when /Mono/
1440         commandString << ",mono"
1441       when /Stereo/
1442         commandString << ",stereo"
1443       when /Dolby Surround/
1444         commandString << ",dpl1"
1445       when /Dolby Pro Logic II/
1446         commandString << ",dpl2"
1447       when /discrete/
1448         commandString << ",6ch"
1449       when /Passthru/
1450         commandString << ",auto"
1451       end
1452     end
1453     
1454     if hash["Audio3Mixdown"]
1455       case hash["Audio3Mixdown"]
1456       when /Mono/
1457         commandString << ",mono"
1458       when /Stereo/
1459         commandString << ",stereo"
1460       when /Dolby Surround/
1461         commandString << ",dpl1"
1462       when /Dolby Pro Logic II/
1463         commandString << ",dpl2"
1464       when /discrete/
1465         commandString << ",6ch"
1466       when /Passthru/
1467         commandString << ",auto"
1468       end
1469     end
1470     
1471     if hash["Audio4Mixdown"]
1472       case hash["Audio4Mixdown"]
1473       when /Mono/
1474         commandString << ",mono"
1475       when /Stereo/
1476         commandString << ",stereo"
1477       when /Dolby Surround/
1478         commandString << ",dpl1"
1479       when /Dolby Pro Logic II/
1480         commandString << ",dpl2"
1481       when /discrete/
1482         commandString << ",6ch"
1483       when /Passthru/
1484         commandString << ",auto"
1485       end
1486     end
1487     
1488     #Container
1489     commandString << " -f "
1490     case hash["FileFormat"]
1491     when /MP4/
1492       commandString << "mp4"
1493     when /AVI/
1494       commandString << "avi"
1495     when /OGM/
1496       commandString << "ogm"
1497     when /MKV/
1498       commandString << "mkv"
1499     end
1500     
1501     #iPod MP4 atom
1502     if hash["Mp4iPodCompatible"].to_i == 1
1503       commandString << " -I"
1504     end
1505     
1506     # 64-bit files
1507     if hash["Mp4LargeFile"] == 1
1508       commandString << " -4"
1509     end
1510     
1511     #Cropping
1512     if hash["PictureAutoCrop"] == 0
1513       commandString << " --crop "
1514       commandString << hash["PictureTopCrop"].to_s
1515       commandString << ":"
1516       commandString << hash["PictureBottomCrop"].to_s
1517       commandString << ":"
1518       commandString << hash["PictureLeftCrop"].to_s
1519       commandString << ":"
1520       commandString << hash["PictureRightCrop"].to_s
1521     end
1522     
1523     #Dimensions
1524     if hash["PictureWidth"] != 0
1525       commandString << " -X "
1526       commandString << hash["PictureWidth"].to_s
1527     end
1528     if hash["PictureHeight"] != 0
1529       commandString << " -Y "
1530       commandString << hash["PictureHeight"].to_s
1531     end
1532     
1533     #Subtitles
1534     if hash["Subtitles"] != "None"
1535       if hash["Subtitles"] == "Autoselect"
1536         commandString << " --subtitle-scan"
1537       else
1538         commandString << " -s "
1539         commandString << hash["Subtitles"]
1540       end
1541     end
1542     
1543     #Video Filters
1544     if hash["UsesPictureFilters"] == 1
1545       
1546       case hash["PictureDeinterlace"]
1547       when 1
1548         commandString << " --deinterlace=\\\"fast\\\""
1549       when 2
1550         commandString << " --deinterlace=\\\slow\\\""
1551       when 3
1552         commandString << " --deinterlace=\\\"slower\\\""
1553       when 4
1554         commandString << " --deinterlace=\\\"slowest\\\""
1555       end
1556       
1557       case hash["PictureDenoise"]
1558       when 1
1559         commandString << " --denoise=\\\"weak\\\""
1560       when 2
1561         commandString << " --denoise=\\\"medium\\\""
1562       when 3
1563         commandString << " --denoise=\\\"strong\\\""
1564       end
1565       
1566       if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
1567       if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
1568       if hash["VFR"].to_i == 1 then commandString << " --vfr" end
1569       if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
1570     end
1571     
1572     #Anamorphic
1573     if hash["PicturePAR"] == 1
1574       commandString << " -p"
1575     elsif hash["PicturePAR"] == 2
1576       commandString << " -P"
1577     end
1578     
1579     #Booleans
1580     if hash["ChapterMarkers"] == 1 then commandString << " -m" end
1581     if hash["VideoGrayScale"] == 1 then commandString << " -g" end
1582     if hash["VideoTwoPass"] == 1 then commandString << " -2" end
1583     if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
1584     
1585       #x264 Options
1586       if hash["x264Option"] != ""
1587         commandString << " -x "
1588         commandString << hash["x264Option"]
1589       end
1590     
1591     commandString << "\\n\");"
1592     
1593     # That's it, print to screen now
1594     puts commandString
1595     puts  "\n"
1596   end
1597   
1598 end
1599
1600 # First grab the specified CLI options
1601 options = readOptions
1602
1603 # Only run if one of the useful CLI flags have been passed
1604 if options.cliraw == true || options.cliparse == true || options.api == true || options.apilist == true
1605   # This line is the ignition -- generates hashes of
1606   # presets and then displays them to the screen
1607   # with the options the user selects on the CLI. 
1608   Display.new( Presets.new.hashMasterList, options )
1609 else
1610   # Direct the user to the help
1611   puts "\n\tUsage: manicure.rb [options]"
1612   puts "\tSee help with -h or --help"
1613 end