2 # manincure.rb version 0.66
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.
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.
11 # For handling command line arguments to the script
17 # CLI options: (code based on http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html )
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
29 options.apilist = false
30 options.header = false
32 opts = OptionParser.new do |opts|
33 opts.banner = "Usage: manicure.rb [options]"
36 opts.separator "Options:"
38 opts.on("-r", "--cli-raw", "Gives example strings for the HB wiki") do |raw|
43 opts.on("-p", "--cli-parse", "Gives presets as wrapper-parseable CLI", " option strings") do |par|
44 options.cliparse = par
47 opts.on("-a", "--api", "Gives preset code for test.c") do |api|
51 opts.on("-A", "--api-list", "Gives code for test.c's --preset-list", " options") do |alist|
52 options.apilist = alist
55 opts.on("-H", "--Header", "Display a banner before each preset") do |head|
59 opts.on_tail("-h", "--help", "Show this message") do
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.
73 # This class parses the user's presets .plist into an array of hashes
76 attr_reader :hashMasterList
78 # Running initialization runs everything.
79 # Calling it will also call the parser
83 # Grab the user's home path
84 homeLocation = `echo $HOME`.chomp
86 # Use that to build a path to the presets .plist
87 inputFile = homeLocation+'/Library/Application Support/HandBrake/UserPresets.plist'
89 # Parse the presets into hashes
90 @hashMasterList = Plist::parse_xml( inputFile )
96 # This class displays the presets to stdout in various formats.
99 def initialize(hashMasterList, options)
101 @hashMasterList = hashMasterList
104 # A width of 40 gives nice, compact output.
108 displayCommandStrings
112 def displayCommandStrings # prints everything to screen
114 # Iterate through the hashes.
115 @hashMasterList.each do |hash|
117 # Check to see whether we've got a preset or afolder
119 # It's a top-level preset
120 displayIndividualPreset(hash, 0)
123 displayFolder( hash, 0 )
124 hash["ChildrenArray"].each do |subhash|
125 # Drill down to see its contents
126 if !subhash["Folder"]
128 displayIndividualPreset(subhash, 1)
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)
138 displayFolderCloser( 1 )
141 displayFolderCloser( 0 )
146 def displayIndividualPreset(hash, depth)
147 if @options.header == true
148 # First throw up a header to make each preset distinct
152 if @options.cliraw == true
153 # Show the preset's full CLI string equivalent
154 generateCLIString(hash, depth)
157 if @options.cliparse == true
158 generateCLIParse(hash, depth)
161 if @options.api == true
162 # Show the preset as code for test/test.c, HandBrakeCLI
163 generateAPIcalls(hash)
166 if @options.apilist == true
167 # Show the preset as print statements, for CLI wrappers to parse.
168 generateAPIList(hash, depth)
172 def displayHeader(hash) # A distinct banner to separate each preset
174 # Print a line of asterisks
175 puts "*" * @columnWidth
177 # Print the name, centered
178 puts '* '+hash["PresetName"].to_s.center(@columnWidth-4)+' *'
180 # Print a line of dashes
181 puts '~' * @columnWidth
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+/)
186 # Print another line of dashes
187 puts '~' * @columnWidth
189 # Print the formats the preset uses
190 puts "#{hash["FileCodecs"]}".center(@columnWidth)
192 # Note if the preset isn't built-in
194 puts "Custom Preset".center(@columnWidth)
197 # Note if the preset is marked as default.
198 if hash["Default"] == 1
199 puts "This is your default preset.".center(@columnWidth)
202 # End with a line of tildes.
203 puts "~" * @columnWidth
207 def displayFolder( hash, depth )
209 if @options.cliraw == true
210 # Show the folder's full in a format that matches the CLI equivalents
211 generateCLIFolderString(hash, depth)
214 if @options.cliparse == true
215 # Show the folder in a format that matches the CLI wrapper equivalents
216 generateCLIFolderParse(hash, depth)
219 if @options.apilist == true
220 # Show the folder as print statements, for CLI wrappers to parse.
221 generateAPIFolderList(hash, depth)
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 )
232 if @options.cliparse == true
233 # Show the folder in a format that matches the CLI wrapper equivalents
234 generateCLIFolderCloserParse( depth )
237 if @options.apilist == true
238 # Show the folder as print statements, for CLI wrappers to parse.
239 generateAPIFolderCloserList( depth )
243 def generateCLIFolderString( hash, depth ) # Shows the folder for the CLI equivalents
251 commandString << " " << hash["PresetName"] << "\n\n"
255 def generateCLIFolderCloserString( depth )
263 commandString << "\n\n"
267 def generateCLIString(hash, depth) # Makes a full CLI equivalent of a preset
272 commandString << './HandBrakeCLI -i DVD -o ~/Movies/movie.'
275 case hash["FileFormat"]
277 commandString << "mp4 "
279 commandString << "avi "
281 commandString << "ogm "
283 commandString << "mkv "
287 if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
288 commandString << " -e "
289 case hash["VideoEncoder"]
291 commandString << "x264"
293 commandString << "xvid"
298 case hash["VideoQualityType"]
300 commandString << " -S " << hash["VideoTargetSize"]
302 commandString << " -b " << hash["VideoAvgBitrate"]
304 commandString << " -q " << hash["VideoQualitySlider"].to_s
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"
316 commandString << " -r " << hash["VideoFramerate"]
324 audioSamplerates = ""
327 audioCount = hash["AudioList"].size
329 hash["AudioList"].each do |audioTrack|
330 audioCount = audioCount - 1
333 audioBitrates << audioTrack["AudioBitrate"]
336 case audioTrack["AudioEncoder"]
338 audioEncoders << "ac3"
340 audioEncoders << "faac"
342 audioEncoders << "vorbis"
344 audioEncoders << "lame"
348 case audioTrack["AudioMixdown"]
350 audioMixdowns << "mono"
352 audioMixdowns << "stereo"
353 when /Dolby Surround/
354 audioMixdowns << "dpl1"
355 when /Dolby Pro Logic II/
356 audioMixdowns << "dpl2"
358 audioMixdowns << "6ch"
360 audioMixdowns << "auto"
364 audioSamplerates << audioTrack["AudioSamplerate"]
367 audioTracks << audioTrack["AudioTrack"].to_s
370 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
376 audioSamplerates << ","
378 audioTrackDRCs << ","
382 commandString << " -a " << audioTracks
383 commandString << " -E " << audioEncoders
384 commandString << " -B " << audioBitrates
385 commandString << " -6 " << audioMixdowns
386 commandString << " -R " << audioSamplerates
387 commandString << " -D " << audioTrackDRCs
390 commandString << " -f "
391 case hash["FileFormat"]
393 commandString << "mp4"
395 commandString << "avi"
397 commandString << "ogm"
399 commandString << "mkv"
403 if hash["Mp4iPodCompatible"].to_i == 1
404 commandString << " -I"
408 if hash["Mp4LargeFile"] == 1
409 commandString << " -4"
413 if hash["PictureAutoCrop"] == 0
414 commandString << " --crop "
415 commandString << hash["PictureTopCrop"].to_s
417 commandString << hash["PictureBottomCrop"].to_s
419 commandString << hash["PictureLeftCrop"].to_s
421 commandString << hash["PictureRightCrop"].to_s
425 if hash["PictureWidth"] != 0
426 commandString << " -X "
427 commandString << hash["PictureWidth"].to_s
429 if hash["PictureHeight"] != 0
430 commandString << " -Y "
431 commandString << hash["PictureHeight"].to_s
435 if hash["Subtitles"] != "None"
436 if hash["Subtitles"] == "Autoselect"
437 commandString << " --subtitle-scan"
439 commandString << " -s "
440 commandString << hash["Subtitles"]
445 if hash["UsesPictureFilters"] == 1
447 case hash["PictureDeinterlace"]
449 commandString << " --deinterlace=\"fast\""
451 commandString << " --deinterlace=\slow\""
453 commandString << " --deinterlace=\"slower\""
455 commandString << " --deinterlace=\"slowest\""
458 case hash["PictureDenoise"]
460 commandString << " --denoise=\"weak\""
462 commandString << " --denoise=\"medium\""
464 commandString << " --denoise=\"strong\""
467 if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
468 if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
469 if hash["VFR"].to_i == 1 then commandString << " --vfr" end
470 if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
475 if hash["PicturePAR"] == 1
476 commandString << " --strict-anamorphic"
477 elsif hash["PicturePAR"] == 2
478 commandString << " --loose-anamorphic"
482 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
483 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
484 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
485 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
488 if hash["x264Option"] != ""
489 commandString << " -x "
490 commandString << hash["x264Option"]
493 # That's it, print to screen now
496 #puts "*" * @columnWidth
501 def generateCLIFolderParse( hash, depth ) # Shows the folder for wrappers to parse
509 commandString << " " << hash["PresetName"] << "\n\n"
513 def generateCLIFolderCloserParse( depth )
521 commandString << "\n\n"
525 def generateCLIParse(hash, depth) # Makes a CLI equivalent of all user presets, for wrappers to parse
530 commandString << '+ ' << hash["PresetName"] << ":"
533 if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
534 commandString << " -e "
535 case hash["VideoEncoder"]
537 commandString << "x264"
539 commandString << "xvid"
544 case hash["VideoQualityType"]
546 commandString << " -S " << hash["VideoTargetSize"]
548 commandString << " -b " << hash["VideoAvgBitrate"]
550 commandString << " -q " << hash["VideoQualitySlider"].to_s
554 if hash["VideoFramerate"] != "Same as source"
555 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
556 commandString << " -r " << "23.976"
557 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
558 commandString << " -r " << "29.97"
559 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
560 commandString << " -r " << "25"
562 commandString << " -r " << hash["VideoFramerate"]
570 audioSamplerates = ""
573 audioCount = hash["AudioList"].size
575 hash["AudioList"].each do |audioTrack|
576 audioCount = audioCount - 1
579 audioBitrates << audioTrack["AudioBitrate"]
582 case audioTrack["AudioEncoder"]
584 audioEncoders << "ac3"
586 audioEncoders << "faac"
588 audioEncoders << "vorbis"
590 audioEncoders << "lame"
594 case audioTrack["AudioMixdown"]
596 audioMixdowns << "mono"
598 audioMixdowns << "stereo"
599 when /Dolby Surround/
600 audioMixdowns << "dpl1"
601 when /Dolby Pro Logic II/
602 audioMixdowns << "dpl2"
604 audioMixdowns << "6ch"
606 audioMixdowns << "auto"
610 audioSamplerates << audioTrack["AudioSamplerate"]
613 audioTracks << audioTrack["AudioTrack"].to_s
616 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
622 audioSamplerates << ","
624 audioTrackDRCs << ","
628 commandString << " -a " << audioTracks
629 commandString << " -E " << audioEncoders
630 commandString << " -B " << audioBitrates
631 commandString << " -6 " << audioMixdowns
632 commandString << " -R " << audioSamplerates
633 commandString << " -D " << audioTrackDRCs
636 commandString << " -f "
637 case hash["FileFormat"]
639 commandString << "mp4"
641 commandString << "avi"
643 commandString << "ogm"
645 commandString << "mkv"
649 if hash["Mp4iPodCompatible"].to_i == 1
650 commandString << " -I"
654 if hash["Mp4LargeFile"] == 1
655 commandString << " -4"
659 if hash["PictureAutoCrop"] == 0
660 commandString << " --crop "
661 commandString << hash["PictureTopCrop"].to_s
663 commandString << hash["PictureBottomCrop"].to_s
665 commandString << hash["PictureLeftCrop"].to_s
667 commandString << hash["PictureRightCrop"].to_s
671 if hash["PictureWidth"] != 0
672 commandString << " -X "
673 commandString << hash["PictureWidth"].to_s
675 if hash["PictureHeight"] != 0
676 commandString << " -Y "
677 commandString << hash["PictureHeight"].to_s
681 if hash["Subtitles"] != "None"
682 if hash["Subtitles"] == "Autoselect"
683 commandString << " --subtitle-scan"
685 commandString << " -s "
686 commandString << hash["Subtitles"]
691 if hash["UsesPictureFilters"] == 1
693 case hash["PictureDeinterlace"]
695 commandString << " --deinterlace=\"fast\""
697 commandString << " --deinterlace=\slow\""
699 commandString << " --deinterlace=\"slower\""
701 commandString << " --deinterlace=\"slowest\""
704 case hash["PictureDenoise"]
706 commandString << " --denoise=\"weak\""
708 commandString << " --denoise=\"medium\""
710 commandString << " --denoise=\"strong\""
713 if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
714 if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
715 if hash["VFR"].to_i == 1 then commandString << " --vfr" end
716 if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
720 if hash["PicturePAR"] == 1
721 commandString << " --strict-anamorphic"
722 elsif hash["PicturePAR"] == 2
723 commandString << " --loose-anamorphic"
727 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
728 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
729 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
730 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
733 if hash["x264Option"] != ""
734 commandString << " -x "
735 commandString << hash["x264Option"]
738 # That's it, print to screen now
741 #puts "*" * @columnWidth
746 def generateAPIcalls(hash) # Makes a C version of the preset ready for coding into the CLI
748 commandString = "if (!strcmp(preset_name, \"" << hash["PresetName"] << "\"))\n{\n "
751 commandString << "if( !mux )\n "
752 commandString << "{\n "
754 case hash["FileFormat"]
756 commandString << " mux = " << "HB_MUX_MP4;\n "
758 commandString << " mux = " << "HB_MUX_AVI;\n "
760 commandString << " mux = " << "HB_MUX_OGM;\n "
762 commandString << " mux = " << "HB_MUX_MKV;\n "
764 commandString << "}\n "
767 if hash["Mp4iPodCompatible"].to_i == 1
768 commandString << "job->ipod_atom = 1;\n "
772 if hash["Mp4LargeFile"] == 1
773 commandString << "job->largeFileSize = 1;\n "
777 if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
778 commandString << "vcodec = "
779 case hash["VideoEncoder"]
781 commandString << "HB_VCODEC_X264;\n "
783 commandString << "HB_VCODEC_XVID;\n "
788 case hash["VideoQualityType"]
790 commandString << "size = " << hash["VideoTargetSize"] << ";\n "
792 commandString << "job->vbitrate = " << hash["VideoAvgBitrate"] << ";\n "
794 commandString << "job->vquality = " << hash["VideoQualitySlider"].to_s << ";\n "
795 commandString << "job->crf = 1;\n "
799 if hash["VideoFramerate"] != "Same as source"
800 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
801 commandString << "job->vrate_base = " << "1126125;\n "
802 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
803 commandString << "job->vrate_base = " << "900900;\n "
804 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
805 commandString << "job->vrate_base = " << "1080000\n "
806 # Gotta add the rest of the framerates for completion's sake.
808 commandString << "job->cfr = 1;\n "
815 audioSamplerates = ""
818 audioCount = hash["AudioList"].size
820 hash["AudioList"].each do |audioTrack|
821 audioCount = audioCount - 1
824 audioBitrates << audioTrack["AudioBitrate"]
827 case audioTrack["AudioEncoder"]
829 audioEncoders << "ac3"
831 audioEncoders << "faac"
833 audioEncoders << "vorbis"
835 audioEncoders << "lame"
839 case audioTrack["AudioMixdown"]
841 audioMixdowns << "mono"
843 audioMixdowns << "stereo"
844 when /Dolby Surround/
845 audioMixdowns << "dpl1"
846 when /Dolby Pro Logic II/
847 audioMixdowns << "dpl2"
849 audioMixdowns << "6ch"
851 audioMixdowns << "auto"
855 audioSamplerates << audioTrack["AudioSamplerate"]
858 audioTracks << audioTrack["AudioTrack"].to_s
861 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
867 audioSamplerates << ","
869 audioTrackDRCs << ","
873 commandString << "if( !atracks )\n "
874 commandString << "{\n "
875 commandString << " atracks = strdup(\"" << audioTracks
876 commandString << "\");\n "
877 commandString << "}\n "
879 commandString << "if( !acodecs )\n "
880 commandString << "{\n "
881 commandString << " acodecs = strdup(\"" << audioEncoders
882 commandString << "\");\n "
883 commandString << "}\n "
885 commandString << "if( !abitrates )\n "
886 commandString << "{\n "
887 commandString << " abitrates = strdup(\"" << audioBitrates
888 commandString << "\");\n "
889 commandString << "}\n "
891 commandString << "if( !mixdowns )\n "
892 commandString << "{\n "
893 commandString << " mixdowns = strdup(\"" << audioMixdowns
894 commandString << "\");\n "
895 commandString << "}\n "
897 commandString << "if( !arates )\n "
898 commandString << "{\n "
899 commandString << " arates = strdup(\"" << audioSamplerates
900 commandString << "\");\n "
901 commandString << "}\n "
903 commandString << "if( !dynamic_range_compression )\n "
904 commandString << "{\n "
905 commandString << " dynamic_range_compression = strdup(\"" << audioTrackDRCs
906 commandString << "\");\n "
907 commandString << "}\n "
910 if hash["PictureAutoCrop"] == 0
911 commandString << "job->crop[0] = " << hash["PictureTopCrop"].to_s << ";\n "
912 commandString << "job->crop[1] = " << hash["PictureBottomCrop"].to_s << ";\n "
913 commandString << "job->crop[2] = " << hash["PictureLeftCrop"].to_s << ";\n "
914 commandString << "job->crop[4] - " << hash["PictureRightCrop"].to_s << ";\n "
918 if hash["PictureWidth"] != 0
919 commandString << "maxWidth = "
920 commandString << hash["PictureWidth"].to_s << ";\n "
922 if hash["PictureHeight"] != 0
923 commandString << "maxHeight = "
924 commandString << hash["PictureHeight"].to_s << ";\n "
928 if hash["Subtitles"] != "None"
929 if hash["Subtitles"] == "Autoselect"
930 commandString << "subtitle_scan = 1;\n "
932 commandString << "job->subtitle = "
933 commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n "
938 if hash["x264Option"] != ""
939 commandString << "if( !x264opts )\n "
940 commandString << "{\n "
941 commandString << " x264opts = strdup(\""
942 commandString << hash["x264Option"] << "\");\n "
943 commandString << "}\n "
947 if hash["UsesPictureFilters"] == 1
949 case hash["PictureDeinterlace"]
951 commandString << "deinterlace = 1;\n "
952 commandString << "deinterlace_opt = \"-1\";\n "
954 commandString << "deinterlace = 1;\n "
955 commandString << "deinterlace_opt = \"2\";\n "
957 commandString << "deinterlace = 1;\n "
958 commandString << "deinterlace_opt = \"0\";\n "
960 commandString << "deinterlace = 1;\n "
961 commandString << "deinterlace_opt = \"1:-1:1\";\n "
964 case hash["PictureDenoise"]
966 commandString << "denoise = 1;\n "
967 commandString << "denoise_opt = \"2:1:2:3\";\n "
969 commandString << "denoise = 1;\n "
970 commandString << "denoise_opt = \"3:2:2:3\";\n "
972 commandString << "denoise = 1;\n "
973 commandString << "denoise_opt = \"7:7:5:5\";\n "
976 if hash["PictureDetelecine"] == 1 then commandString << "detelecine = 1;\n " end
977 if hash["PictureDeblock"] == 1 then commandString << "deblock = 1;\n " end
978 if hash["VFR"].to_i == 1 then commandString << "vfr = 1;\n " end
979 if hash["PictureDecomb"] == 1 then commandString << "decomb = 1;\n " end
984 if hash["PicturePAR"] == 1
985 commandString << "anamorphic_mode = 1;\n "
986 elsif hash["PicturePAR"] == 2
987 commandString << "anamorphic_mode = 2;\n "
991 if hash["ChapterMarkers"] == 1 then commandString << "job->chapter_markers = 1;\n " end
992 if hash["VideoGrayScale"] == 1 then commandString << "job->grayscale = 1;\n " end
993 if hash["VideoTwoPass"] == 1 then commandString << "twoPass = 1;\n " end
994 if hash["VideoTurboTwoPass"] == 1 then commandString << "turbo_opts_enabled = 1;\n" end
998 # That's it, print to screen now
1000 #puts "*" * @columnWidth
1004 def generateAPIFolderList( hash, depth )
1007 commandString << " printf(\"\\n"
1009 commandString << " "
1012 commandString << "<"
1014 commandString << " " << hash["PresetName"]
1015 commandString << "\\n\");\n\n"
1019 def generateAPIFolderCloserList( depth )
1022 commandString << " printf(\"\\n"
1024 commandString << " "
1027 commandString << ">"
1029 commandString << "\\n\");\n\n"
1033 def generateAPIList(hash, depth) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse
1035 commandString << " printf(\"\\n"
1037 commandString << " "
1040 commandString << "+ " << hash["PresetName"] << ": "
1043 if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)"
1044 commandString << " -e "
1045 case hash["VideoEncoder"]
1047 commandString << "x264 "
1049 commandString << "xvid "
1054 case hash["VideoQualityType"]
1056 commandString << " -S " << hash["VideoTargetSize"]
1058 commandString << " -b " << hash["VideoAvgBitrate"]
1060 commandString << " -q " << hash["VideoQualitySlider"].to_s
1064 if hash["VideoFramerate"] != "Same as source"
1065 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
1066 commandString << " -r " << "23.976"
1067 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
1068 commandString << " -r " << "29.97"
1069 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
1070 commandString << " -r " << "25"
1072 commandString << " -r " << hash["VideoFramerate"]
1080 audioSamplerates = ""
1083 audioCount = hash["AudioList"].size
1085 hash["AudioList"].each do |audioTrack|
1086 audioCount = audioCount - 1
1089 audioBitrates << audioTrack["AudioBitrate"]
1092 case audioTrack["AudioEncoder"]
1094 audioEncoders << "ac3"
1096 audioEncoders << "faac"
1098 audioEncoders << "vorbis"
1100 audioEncoders << "lame"
1104 case audioTrack["AudioMixdown"]
1106 audioMixdowns << "mono"
1108 audioMixdowns << "stereo"
1109 when /Dolby Surround/
1110 audioMixdowns << "dpl1"
1111 when /Dolby Pro Logic II/
1112 audioMixdowns << "dpl2"
1114 audioMixdowns << "6ch"
1116 audioMixdowns << "auto"
1120 audioSamplerates << audioTrack["AudioSamplerate"]
1123 audioTracks << audioTrack["AudioTrack"].to_s
1126 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
1129 audioBitrates << ","
1130 audioEncoders << ","
1131 audioMixdowns << ","
1132 audioSamplerates << ","
1134 audioTrackDRCs << ","
1138 commandString << " -a " << audioTracks
1139 commandString << " -E " << audioEncoders
1140 commandString << " -B " << audioBitrates
1141 commandString << " -6 " << audioMixdowns
1142 commandString << " -R " << audioSamplerates
1143 commandString << " -D " << audioTrackDRCs
1146 commandString << " -f "
1147 case hash["FileFormat"]
1149 commandString << "mp4"
1151 commandString << "avi"
1153 commandString << "ogm"
1155 commandString << "mkv"
1159 if hash["Mp4iPodCompatible"].to_i == 1
1160 commandString << " -I"
1164 if hash["Mp4LargeFile"] == 1
1165 commandString << " -4"
1169 if hash["PictureAutoCrop"] == 0
1170 commandString << " --crop "
1171 commandString << hash["PictureTopCrop"].to_s
1172 commandString << ":"
1173 commandString << hash["PictureBottomCrop"].to_s
1174 commandString << ":"
1175 commandString << hash["PictureLeftCrop"].to_s
1176 commandString << ":"
1177 commandString << hash["PictureRightCrop"].to_s
1181 if hash["PictureWidth"] != 0
1182 commandString << " -X "
1183 commandString << hash["PictureWidth"].to_s
1185 if hash["PictureHeight"] != 0
1186 commandString << " -Y "
1187 commandString << hash["PictureHeight"].to_s
1191 if hash["Subtitles"] != "None"
1192 if hash["Subtitles"] == "Autoselect"
1193 commandString << " --subtitle-scan"
1195 commandString << " -s "
1196 commandString << hash["Subtitles"]
1201 if hash["UsesPictureFilters"] == 1
1203 case hash["PictureDeinterlace"]
1205 commandString << " --deinterlace=\\\"fast\\\""
1207 commandString << " --deinterlace=\\\slow\\\""
1209 commandString << " --deinterlace=\\\"slower\\\""
1211 commandString << " --deinterlace=\\\"slowest\\\""
1214 case hash["PictureDenoise"]
1216 commandString << " --denoise=\\\"weak\\\""
1218 commandString << " --denoise=\\\"medium\\\""
1220 commandString << " --denoise=\\\"strong\\\""
1223 if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
1224 if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
1225 if hash["VFR"].to_i == 1 then commandString << " --vfr" end
1226 if hash["PictureDecomb"] == 1 then commandString << " --decomb" end
1230 if hash["PicturePAR"] == 1
1231 commandString << " --strict-anamorphic"
1232 elsif hash["PicturePAR"] == 2
1233 commandString << " --loose-anamorphic"
1237 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
1238 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
1239 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
1240 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
1243 if hash["x264Option"] != ""
1244 commandString << " -x "
1245 commandString << hash["x264Option"]
1248 commandString << "\\n\");"
1250 # That's it, print to screen now
1257 # First grab the specified CLI options
1258 options = readOptions
1260 # Only run if one of the useful CLI flags have been passed
1261 if options.cliraw == true || options.cliparse == true || options.api == true || options.apilist == true
1262 # This line is the ignition -- generates hashes of
1263 # presets and then displays them to the screen
1264 # with the options the user selects on the CLI.
1265 Display.new( Presets.new.hashMasterList, options )
1267 # Direct the user to the help
1268 puts "\n\tUsage: manicure.rb [options]"
1269 puts "\tSee help with -h or --help"