OSDN Git Service

ffmpeg release 0.5 (http://www.ffmpeg.org/changelog.html)
[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 << "if( !atracks )\n    "
996     commandString << "{\n    "
997     commandString << "    atracks = strdup(\""
998     commandString << hash["Audio1Track"].to_s
999     if hash["Audio2Track"]
1000       commandString << "," << hash["Audio2Track"].to_s
1001     end
1002     if hash["Audio3Track"]
1003       commandString << "," << hash["Audio3Track"].to_s
1004     end
1005     if hash["Audio4Track"]
1006       commandString << "," << hash["Audio4Track"].to_s
1007     end
1008     commandString << "\");\n    "
1009     commandString << "}\n    "
1010     
1011     # Audio bitrate
1012     commandString << "if( !abitrates )\n    "
1013     commandString << "{\n    "
1014     commandString << "    abitrates = strdup(\""
1015     if hash["Audio1Encoder"] != "AC3 Passthru"
1016       commandString << hash["Audio1Bitrate"]
1017     else
1018       commandString << "auto"
1019     end
1020     if hash["Audio2Bitrate"]
1021       if hash["Audio2Encoder"] != "AC3 Passthru"
1022         commandString << "," << hash["Audio2Bitrate"]
1023       else
1024         commandString << "," << "auto"
1025       end
1026     end
1027     if hash["Audio3Bitrate"]
1028       if hash["Audio3Encoder"] != "AC3 Passthru"
1029         commandString << "," << hash["Audio3Bitrate"]
1030       else
1031         commandString << "," << "auto"
1032       end
1033     end
1034     if hash["Audio4Bitrate"]
1035       if hash["Audio4Encoder"] != "AC3 Passthru"
1036         commandString << "," << hash["Audio4Bitrate"]
1037       else
1038         commandString << "," << "auto"
1039       end
1040     end
1041     commandString << "\");\n    "
1042     commandString << "}\n    "
1043         
1044     #Audio samplerate
1045     commandString << "if( !arates )\n    "
1046     commandString << "{\n    "
1047     commandString << "    arates = strdup(\""
1048     commandString << hash["Audio1Samplerate"]
1049     if hash["Audio2Samplerate"]
1050       commandString << "," << hash["Audio2Samplerate"]
1051     end
1052     if hash["Audio3Samplerate"]
1053       commandString << "," << hash["Audio3Samplerate"]
1054     end
1055     if hash["Audio4Samplerate"]
1056       commandString << "," << hash["Audio4Samplerate"]
1057     end
1058     commandString << "\");\n    "
1059     commandString << "}\n    "
1060       
1061     #Audio encoder
1062     commandString << "if( !acodecs )\n    "
1063     commandString << "{\n    "
1064     commandString << "    acodecs = strdup(\""
1065     case hash["Audio1Encoder"]
1066     when /AC3/
1067       commandString << "ac3"
1068     when /AAC/
1069       commandString << "faac"
1070     when /Vorbis/
1071       commandString << "vorbis"
1072     when /MP3/
1073       commandString << "lame"
1074     end
1075     case hash["Audio2Encoder"]
1076     when /AC3 /
1077       commandString << ",ac3"
1078     when /AAC/
1079       commandString << ",faac"
1080     when /Vorbis/
1081       commandString << ",vorbis"
1082     when /MP3/
1083       commandString << ",lame"
1084     end
1085     case hash["Audio3Encoder"]
1086     when /AC3 /
1087       commandString << ",ac3"
1088     when /AAC/
1089       commandString << ",faac"
1090     when /Vorbis/
1091       commandString << ",vorbis"
1092     when /MP3/
1093       commandString << ",lame"
1094     end
1095     case hash["Audio4Encoder"]
1096     when /AC3 /
1097       commandString << ",ac3"
1098     when /AAC/
1099       commandString << ",faac"
1100     when /Vorbis/
1101       commandString << ",vorbis"
1102     when /MP3/
1103       commandString << ",lame"
1104     end
1105     commandString << "\");\n    "
1106     commandString << "}\n    "
1107     
1108     #Audio mixdowns
1109     commandString << "if( !mixdowns )\n    "
1110     commandString << "{\n    "
1111     commandString << "    mixdowns = strdup(\""
1112     case hash["Audio1Mixdown"]
1113     when /Mono/
1114       commandString << "mono"
1115     when /Stereo/
1116       commandString << "stereo"
1117     when /Dolby Surround/
1118       commandString << "dpl1"
1119     when /Dolby Pro Logic II/
1120       commandString << "dpl2"
1121     when /discrete/
1122       commandString << "6ch"
1123     when /Passthru/
1124       commandString << "auto"
1125     end
1126     if hash["Audio2Mixdown"]
1127       case hash["Audio2Mixdown"]
1128       when /Mono/
1129         commandString << ",mono"
1130       when /Stereo/
1131         commandString << ",stereo"
1132       when /Dolby Surround/
1133         commandString << ",dpl1"
1134       when /Dolby Pro Logic II/
1135         commandString << ",dpl2"
1136       when /discrete/
1137         commandString << ",6ch"
1138       when /Passthru/
1139         commandString << ",auto"
1140       end
1141     end
1142     if hash["Audio3Mixdown"]
1143       case hash["Audio3Mixdown"]
1144       when /Mono/
1145         commandString << ",mono"
1146       when /Stereo/
1147         commandString << ",stereo"
1148       when /Dolby Surround/
1149         commandString << ",dpl1"
1150       when /Dolby Pro Logic II/
1151         commandString << ",dpl2"
1152       when /discrete/
1153         commandString << ",6ch"
1154       when /Passthru/
1155         commandString << ",auto"
1156       end
1157     end
1158     if hash["Audio4Mixdown"]
1159       case hash["Audio4Mixdown"]
1160       when /Mono/
1161         commandString << ",mono"
1162       when /Stereo/
1163         commandString << ",stereo"
1164       when /Dolby Surround/
1165         commandString << ",dpl1"
1166       when /Dolby Pro Logic II/
1167         commandString << ",dpl2"
1168       when /discrete/
1169         commandString << ",6ch"
1170       when /Passthru/
1171         commandString << ",auto"
1172       end
1173     end
1174     commandString << "\");\n    "
1175     commandString << "}\n    "
1176     
1177     #Cropping
1178     if hash["PictureAutoCrop"] == 0
1179       commandString << "job->crop[0] = " << hash["PictureTopCrop"].to_s << ";\n    "
1180       commandString << "job->crop[1] = " << hash["PictureBottomCrop"].to_s << ";\n    "
1181       commandString << "job->crop[2] = " << hash["PictureLeftCrop"].to_s << ";\n    "
1182       commandString << "job->crop[4] - " << hash["PictureRightCrop"].to_s << ";\n    "
1183     end
1184     
1185     #Dimensions
1186     if hash["PictureWidth"] != 0
1187       commandString << "maxWidth = "
1188       commandString << hash["PictureWidth"].to_s << ";\n    "
1189     end
1190     if hash["PictureHeight"] != 0
1191       commandString << "maxHeight = "
1192       commandString << hash["PictureHeight"].to_s << ";\n    "
1193     end
1194     
1195     #Subtitles
1196     if hash["Subtitles"] != "None"
1197       if hash["Subtitles"] == "Autoselect"
1198         commandString << "subtitle_scan = 1;\n    "
1199       else
1200         commandString << "job->subtitle = "
1201         commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n    "
1202       end
1203     end
1204     
1205     #x264 Options
1206     if hash["x264Option"] != ""
1207       commandString << "if( !x264opts )\n    "
1208       commandString << "{\n    "
1209       commandString << "    x264opts = strdup(\""
1210       commandString << hash["x264Option"] << "\");\n    "
1211       commandString << "}\n    "
1212     end
1213     
1214     #Video Filters
1215     if hash["UsesPictureFilters"] == 1
1216       
1217       case hash["PictureDeinterlace"]
1218       when 1
1219         commandString << "deinterlace = 1;\n    "
1220         commandString << "deinterlace_opt = \"-1\";\n    "
1221       when 2
1222         commandString << "deinterlace = 1;\n    "
1223         commandString << "deinterlace_opt = \"2\";\n    "
1224       when 3
1225         commandString << "deinterlace = 1;\n    "
1226         commandString << "deinterlace_opt = \"0\";\n    "
1227       when 4
1228         commandString << "deinterlace = 1;\n    "
1229         commandString << "deinterlace_opt = \"1:-1:1\";\n    "
1230       end
1231       
1232       case hash["PictureDenoise"]
1233       when 1
1234         commandString << "denoise = 1;\n    "
1235         commandString << "denoise_opt = \"2:1:2:3\";\n    "
1236       when 2
1237         commandString << "denoise = 1;\n    "
1238         commandString << "denoise_opt = \"3:2:2:3\";\n    "
1239       when 3
1240         commandString << "denoise = 1;\n    "
1241         commandString << "denoise_opt = \"7:7:5:5\";\n    "
1242       end
1243       
1244       if hash["PictureDetelecine"] == 1 then commandString << "detelecine = 1;\n    " end
1245       if hash["PictureDeblock"] == 1 then commandString << "deblock = 1;\n    " end
1246       if hash["VFR"].to_i == 1 then commandString << "vfr = 1;\n    " end
1247       if hash["PictureDecomb"] == 1 then commandString << "decomb = 1;\n    " end
1248       
1249     end
1250     
1251     #Anamorphic
1252     if hash["PicturePAR"] == 1
1253       commandString << "pixelratio = 1;\n    "
1254     elsif hash["PicturePAR"] == 2
1255       commandString << "pixelratio = 2;\n    "
1256     end
1257     
1258     #Booleans
1259     if hash["ChapterMarkers"] == 1 then commandString << "job->chapter_markers = 1;\n    " end
1260     if hash["VideoGrayScale"] == 1 then commandString << "job->grayscale = 1;\n    " end
1261     if hash["VideoTwoPass"] == 1 then commandString << "twoPass = 1;\n    " end
1262     if hash["VideoTurboTwoPass"] == 1 then commandString << "turbo_opts_enabled = 1;\n" end
1263     
1264     commandString << "}"
1265     
1266     # That's it, print to screen now
1267     puts commandString
1268     #puts "*" * @columnWidth
1269     puts  "\n"
1270   end
1271   
1272   def generateAPIFolderList( hash, depth )
1273     commandString = ""
1274     
1275     commandString << "    printf(\"\\n"
1276     depth.times do
1277       commandString << "   "
1278     end
1279     (depth+1).times do
1280       commandString << "<"
1281     end
1282     commandString << " " << hash["PresetName"]
1283     commandString << "\\n\");\n\n"    
1284     puts commandString
1285   end
1286   
1287   def generateAPIFolderCloserList( depth )
1288     commandString = ""
1289     
1290     commandString << "    printf(\"\\n"
1291     depth.times do
1292       commandString << "   "
1293     end
1294     (depth+1).times do
1295       commandString << ">"
1296     end
1297     commandString << "\\n\");\n\n"    
1298     puts commandString
1299   end
1300   
1301   def generateAPIList(hash, depth) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse
1302     commandString = ""
1303     commandString << "    printf(\"\\n"
1304     depth.times do
1305       commandString << "   "
1306     end
1307            
1308     commandString << "+ " << hash["PresetName"] << ": "
1309         
1310     #Video encoder
1311     if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
1312       commandString << " -e "
1313       case hash["VideoEncoder"]
1314       when /x264/
1315         commandString << "x264 "
1316       when /XviD/
1317         commandString << "xvid "
1318       end
1319     end
1320
1321     #VideoRateControl
1322     case hash["VideoQualityType"]
1323     when 0
1324       commandString << " -S " << hash["VideoTargetSize"]
1325     when 1
1326       commandString << " -b " << hash["VideoAvgBitrate"]
1327     when 2
1328       commandString << " -q " << hash["VideoQualitySlider"].to_s
1329     end
1330
1331     #FPS
1332     if hash["VideoFramerate"] != "Same as source"
1333       if hash["VideoFramerate"] == "23.976 (NTSC Film)"
1334         commandString << " -r " << "23.976"
1335       elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
1336         commandString << " -r " << "29.97"
1337       elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
1338         commandString << " -r " << "25"
1339       else
1340         commandString << " -r " << hash["VideoFramerate"]
1341       end
1342     end
1343     
1344     #Audio tracks
1345     commandString << " -a "
1346     commandString << hash["Audio1Track"].to_s
1347     if hash["Audio2Track"]
1348       commandString << "," << hash["Audio2Track"].to_s
1349     end
1350     if hash["Audio3Track"]
1351       commandString << "," << hash["Audio3Track"].to_s
1352     end
1353     if hash["Audio4Track"]
1354       commandString << "," << hash["Audio4Track"].to_s
1355     end
1356     
1357     #Audio encoders
1358     commandString << " -E "
1359     case hash["Audio1Encoder"]
1360     when /AC3/
1361       commandString << "ac3"
1362     when /AAC/
1363       commandString << "faac"
1364     when /Vorbis/
1365       commandString << "vorbis"
1366     when /MP3/
1367       commandString << "lame"
1368     end
1369     case hash["Audio2Encoder"]
1370     when /AC3 /
1371       commandString << ",ac3"
1372     when /AAC/
1373       commandString << ",faac"
1374     when /Vorbis/
1375       commandString << ",vorbis"
1376     when /MP3/
1377       commandString << ",lame"
1378     end
1379     case hash["Audio3Encoder"]
1380     when /AC3 /
1381       commandString << ",ac3"
1382     when /AAC/
1383       commandString << ",faac"
1384     when /Vorbis/
1385       commandString << ",vorbis"
1386     when /MP3/
1387       commandString << ",lame"
1388     end
1389     case hash["Audio4Encoder"]
1390     when /AC3 /
1391       commandString << ",ac3"
1392     when /AAC/
1393       commandString << ",faac"
1394     when /Vorbis/
1395       commandString << ",vorbis"
1396     when /MP3/
1397       commandString << ",lame"
1398     end
1399
1400     #Audio bit rate
1401     commandString << " -B "
1402     commandString << hash["Audio1Bitrate"]
1403     if hash["Audio2Bitrate"]
1404       if hash["Audio2Encoder"] != "AC3 Passthru"
1405         commandString << "," << hash["Audio2Bitrate"]
1406       else
1407         commandString << "," << "auto"
1408       end
1409     end
1410     if hash["Audio3Bitrate"]
1411       if hash["Audio3Encoder"] != "AC3 Passthru"
1412         commandString << "," << hash["Audio3Bitrate"]
1413       else
1414         commandString << "," << "auto"
1415       end
1416     end
1417     if hash["Audio4Bitrate"]
1418       if hash["Audio4Encoder"] != "AC3 Passthru"
1419         commandString << "," << hash["Audio4Bitrate"]
1420       else
1421         commandString << "," << "auto"
1422       end
1423     end
1424
1425     #Audio sample rate
1426     commandString << " -R "
1427     commandString << hash["Audio1Samplerate"]
1428     if hash["Audio2Samplerate"]
1429       commandString << "," << hash["Audio2Samplerate"]
1430     end
1431     if hash["Audio3Samplerate"]
1432       commandString << "," << hash["Audio3Samplerate"]
1433     end
1434     if hash["Audio4Samplerate"]
1435       commandString << "," << hash["Audio4Samplerate"]
1436     end
1437     
1438     #Audio Mixdown
1439     commandString << " -6 "
1440     case hash["Audio1Mixdown"]
1441     when /Mono/
1442       commandString << "mono"
1443     when /Stereo/
1444       commandString << "stereo"
1445     when /Dolby Surround/
1446       commandString << "dpl1"
1447     when /Dolby Pro Logic II/
1448       commandString << "dpl2"
1449     when /discrete/
1450       commandString << "6ch"
1451     when /Passthru/
1452       commandString << "auto"
1453     end
1454     
1455     if hash["Audio2Mixdown"]
1456       case hash["Audio2Mixdown"]
1457       when /Mono/
1458         commandString << ",mono"
1459       when /Stereo/
1460         commandString << ",stereo"
1461       when /Dolby Surround/
1462         commandString << ",dpl1"
1463       when /Dolby Pro Logic II/
1464         commandString << ",dpl2"
1465       when /discrete/
1466         commandString << ",6ch"
1467       when /Passthru/
1468         commandString << ",auto"
1469       end
1470     end
1471     
1472     if hash["Audio3Mixdown"]
1473       case hash["Audio3Mixdown"]
1474       when /Mono/
1475         commandString << ",mono"
1476       when /Stereo/
1477         commandString << ",stereo"
1478       when /Dolby Surround/
1479         commandString << ",dpl1"
1480       when /Dolby Pro Logic II/
1481         commandString << ",dpl2"
1482       when /discrete/
1483         commandString << ",6ch"
1484       when /Passthru/
1485         commandString << ",auto"
1486       end
1487     end
1488     
1489     if hash["Audio4Mixdown"]
1490       case hash["Audio4Mixdown"]
1491       when /Mono/
1492         commandString << ",mono"
1493       when /Stereo/
1494         commandString << ",stereo"
1495       when /Dolby Surround/
1496         commandString << ",dpl1"
1497       when /Dolby Pro Logic II/
1498         commandString << ",dpl2"
1499       when /discrete/
1500         commandString << ",6ch"
1501       when /Passthru/
1502         commandString << ",auto"
1503       end
1504     end
1505     
1506     #Container
1507     commandString << " -f "
1508     case hash["FileFormat"]
1509     when /MP4/
1510       commandString << "mp4"
1511     when /AVI/
1512       commandString << "avi"
1513     when /OGM/
1514       commandString << "ogm"
1515     when /MKV/
1516       commandString << "mkv"
1517     end
1518     
1519     #iPod MP4 atom
1520     if hash["Mp4iPodCompatible"].to_i == 1
1521       commandString << " -I"
1522     end
1523     
1524     # 64-bit files
1525     if hash["Mp4LargeFile"] == 1
1526       commandString << " -4"
1527     end
1528     
1529     #Cropping
1530     if hash["PictureAutoCrop"] == 0
1531       commandString << " --crop "
1532       commandString << hash["PictureTopCrop"].to_s
1533       commandString << ":"
1534       commandString << hash["PictureBottomCrop"].to_s
1535       commandString << ":"
1536       commandString << hash["PictureLeftCrop"].to_s
1537       commandString << ":"
1538       commandString << hash["PictureRightCrop"].to_s
1539     end
1540     
1541     #Dimensions
1542     if hash["PictureWidth"] != 0
1543       commandString << " -X "
1544       commandString << hash["PictureWidth"].to_s
1545     end
1546     if hash["PictureHeight"] != 0
1547       commandString << " -Y "
1548       commandString << hash["PictureHeight"].to_s
1549     end
1550     
1551     #Subtitles
1552     if hash["Subtitles"] != "None"
1553       if hash["Subtitles"] == "Autoselect"
1554         commandString << " --subtitle-scan"
1555       else
1556         commandString << " -s "
1557         commandString << hash["Subtitles"]
1558       end
1559     end
1560     
1561     #Video Filters
1562     if hash["UsesPictureFilters"] == 1
1563       
1564       case hash["PictureDeinterlace"]
1565       when 1
1566         commandString << " --deinterlace=\\\"fast\\\""
1567       when 2
1568         commandString << " --deinterlace=\\\slow\\\""
1569       when 3
1570         commandString << " --deinterlace=\\\"slower\\\""
1571       when 4
1572         commandString << " --deinterlace=\\\"slowest\\\""
1573       end
1574       
1575       case hash["PictureDenoise"]
1576       when 1
1577         commandString << " --denoise=\\\"weak\\\""
1578       when 2
1579         commandString << " --denoise=\\\"medium\\\""
1580       when 3
1581         commandString << " --denoise=\\\"strong\\\""
1582       end
1583       
1584       if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
1585       if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
1586       if hash["VFR"].to_i == 1 then commandString << " --vfr" end
1587       if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
1588     end
1589     
1590     #Anamorphic
1591     if hash["PicturePAR"] == 1
1592       commandString << " -p"
1593     elsif hash["PicturePAR"] == 2
1594       commandString << " -P"
1595     end
1596     
1597     #Booleans
1598     if hash["ChapterMarkers"] == 1 then commandString << " -m" end
1599     if hash["VideoGrayScale"] == 1 then commandString << " -g" end
1600     if hash["VideoTwoPass"] == 1 then commandString << " -2" end
1601     if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
1602     
1603       #x264 Options
1604       if hash["x264Option"] != ""
1605         commandString << " -x "
1606         commandString << hash["x264Option"]
1607       end
1608     
1609     commandString << "\\n\");"
1610     
1611     # That's it, print to screen now
1612     puts commandString
1613     puts  "\n"
1614   end
1615   
1616 end
1617
1618 # First grab the specified CLI options
1619 options = readOptions
1620
1621 # Only run if one of the useful CLI flags have been passed
1622 if options.cliraw == true || options.cliparse == true || options.api == true || options.apilist == true
1623   # This line is the ignition -- generates hashes of
1624   # presets and then displays them to the screen
1625   # with the options the user selects on the CLI. 
1626   Display.new( Presets.new.hashMasterList, options )
1627 else
1628   # Direct the user to the help
1629   puts "\n\tUsage: manicure.rb [options]"
1630   puts "\tSee help with -h or --help"
1631 end