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"
255 def generateCLIFolderCloserString( depth )
263 commandString << "\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 "
278 when /Matroska/, /MKV/
279 commandString << "mkv "
283 commandString << " -e "
284 case hash["VideoEncoder"]
286 commandString << "x264"
288 commandString << "theora"
290 commandString << "ffmpeg4"
292 commandString << "ffmpeg2"
296 case hash["VideoQualityType"]
298 commandString << " -S " << hash["VideoTargetSize"]
300 commandString << " -b " << hash["VideoAvgBitrate"]
302 commandString << " -q " << hash["VideoQualitySlider"].to_s
306 if hash["VideoFramerate"] != "Same as source"
307 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
308 commandString << " -r " << "23.976"
309 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
310 commandString << " -r " << "29.97"
311 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
312 commandString << " -r " << "25"
314 commandString << " -r " << hash["VideoFramerate"]
316 # not same as source: pfr, else default (cfr)
317 if hash["VideoFramerateMode"] == "pfr"
318 commandString << " --pfr "
320 # same as source: cfr, else default (vfr)
321 elsif hash["VideoFramerateMode"] == "cfr"
322 commandString << " --cfr "
329 audioSamplerates = ""
332 audioCount = hash["AudioList"].size
334 hash["AudioList"].each do |audioTrack|
335 audioCount = audioCount - 1
338 audioBitrates << audioTrack["AudioBitrate"]
341 case audioTrack["AudioEncoder"]
343 audioEncoders << "copy:ac3"
345 audioEncoders << "ac3"
347 audioEncoders << "copy:dts"
349 audioEncoders << "copy:dtshd"
351 audioEncoders << "copy:aac"
352 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
353 audioEncoders << "av_aac"
355 audioEncoders << "fdk_aac"
357 audioEncoders << "fdk_haac"
358 when "AAC (CoreAudio)"
359 audioEncoders << "ca_aac"
360 when "HE-AAC (CoreAudio)"
361 audioEncoders << "ca_haac"
363 audioEncoders << "vorbis"
365 audioEncoders << "copy:mp3"
367 audioEncoders << "mp3"
368 when "FLAC (ffmpeg)", "FLAC 16-bit"
369 audioEncoders << "flac16"
370 when "FLAC (24-bit)", "FLAC 24-bit"
371 audioEncoders << "flac24"
373 audioEncoders << "copy"
377 case audioTrack["AudioMixdown"]
378 when "Mono (Left Only)"
379 audioMixdowns << "left_only"
380 when "Mono (Right Only)"
381 audioMixdowns << "right_only"
383 audioMixdowns << "mono"
385 audioMixdowns << "stereo"
386 when /Dolby Surround/
387 audioMixdowns << "dpl1"
388 when /Dolby Pro Logic II/
389 audioMixdowns << "dpl2"
390 when /5.1/, /discrete/
391 audioMixdowns << "5point1"
393 audioMixdowns << "6point1"
394 when "7.1 (5F/2R/LFE)"
395 audioMixdowns << "5_2_lfe"
397 audioMixdowns << "7point1"
399 audioMixdowns << "none"
403 audioSamplerates << audioTrack["AudioSamplerate"]
406 audioTracks << audioTrack["AudioTrack"].to_s
409 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
415 audioSamplerates << ","
417 audioTrackDRCs << ","
421 commandString << " -a " << audioTracks
422 commandString << " -E " << audioEncoders
423 commandString << " -B " << audioBitrates
424 commandString << " -6 " << audioMixdowns
425 commandString << " -R " << audioSamplerates
426 commandString << " -D " << audioTrackDRCs
431 if hash["AudioAllowAACPass"].to_i == 1
432 audioCopyMask << "aac"
434 if hash["AudioAllowAC3Pass"].to_i == 1
435 if audioCopyMask.size > 0
438 audioCopyMask << "ac3"
440 if hash["AudioAllowDTSHDPass"].to_i == 1
441 if audioCopyMask.size > 0
444 audioCopyMask << "dtshd"
446 if hash["AudioAllowDTSPass"].to_i == 1
447 if audioCopyMask.size > 0
450 audioCopyMask << "dts"
452 if hash["AudioAllowMP3Pass"].to_i == 1
453 if audioCopyMask.size > 0
456 audioCopyMask << "mp3"
459 if audioCopyMask.size > 0
460 commandString << " --audio-copy-mask " << audioCopyMask
463 #Auto Passthru Fallback
464 audioEncoderFallback = ""
466 case hash["AudioEncoderFallback"]
468 audioEncoderFallback << "ac3"
469 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
470 audioEncoderFallback << "av_aac"
472 audioEncoderFallback << "fdk_aac"
474 audioEncoderFallback << "fdk_haac"
475 when "AAC (CoreAudio)"
476 audioEncoderFallback << "ca_aac"
477 when "HE-AAC (CoreAudio)"
478 audioEncoderFallback << "ca_haac"
480 audioEncoderFallback << "vorbis"
482 audioEncoderFallback << "mp3"
483 when "FLAC (ffmpeg)", "FLAC 16-bit"
484 audioEncoderFallback << "flac16"
485 when "FLAC (24-bit)", "FLAC 24-bit"
486 audioEncoderFallback << "flac24"
489 if audioEncoderFallback.size > 0
490 commandString << " --audio-fallback " << audioEncoderFallback
494 commandString << " -f "
495 case hash["FileFormat"]
496 when "MPEG-4 (mp4v2)"
497 commandString << "mp4v2"
499 commandString << "mp4"
500 when "Matroska (libmkv)"
501 commandString << "libmkv"
503 commandString << "mkv"
507 if hash["Mp4iPodCompatible"].to_i == 1
508 commandString << " -I"
511 #MP4 Optimize for HTTP Streaming
512 if hash["Mp4HttpOptimize"].to_i == 1
513 commandString << " -O"
517 if hash["PictureAutoCrop"] == 0
518 commandString << " --crop "
519 commandString << hash["PictureTopCrop"].to_s
521 commandString << hash["PictureBottomCrop"].to_s
523 commandString << hash["PictureLeftCrop"].to_s
525 commandString << hash["PictureRightCrop"].to_s
529 if hash["PictureWidth"] != 0
530 commandString << " -X "
531 commandString << hash["PictureWidth"].to_s
533 if hash["PictureHeight"] != 0
534 commandString << " -Y "
535 commandString << hash["PictureHeight"].to_s
539 if hash["Subtitles"] && hash["Subtitles"] != "None"
540 if hash["Subtitles"] == "Autoselect"
541 commandString << " --subtitle-scan"
543 commandString << " -s "
544 commandString << hash["Subtitles"]
549 if hash["UsesPictureFilters"] == 1
551 case hash["PictureDeinterlace"]
553 commandString << " --deinterlace=" << hash["PictureDeinterlaceCustom"].to_s
555 commandString << " --deinterlace=fast"
557 commandString << " --deinterlace=slow"
559 commandString << " --deinterlace=slower"
561 commandString << " --deinterlace=bob"
564 case hash["PictureDenoise"]
566 commandString << " --denoise=" << hash["PictureDenoiseCustom"].to_s
568 commandString << " --denoise=weak"
570 commandString << " --denoise=medium"
572 commandString << " --denoise=strong"
575 case hash["PictureDecomb"]
577 commandString << " --decomb=" << hash["PictureDecombCustom"].to_s
579 commandString << " --decomb"
581 commandString << " --decomb=fast"
583 commandString << " --decomb=bob"
586 case hash["PictureDetelecine"]
588 commandString << " --detelecine=" << hash["PictureDetelecineCustom"].to_s
590 commandString << " --detelecine"
593 if hash["PictureDeblock"] != 0
594 commandString << " --deblock=" << hash["PictureDeblock"].to_s
600 if hash["PicturePAR"] == 1
601 commandString << " --strict-anamorphic"
602 elsif hash["PicturePAR"] == 2
603 commandString << " --loose-anamorphic"
604 elsif hash["PicturePAR"] == 3
605 commandString << " --custom-anamorphic"
609 if hash["PictureModulus"]
610 commandString << " --modulus " << hash["PictureModulus"].to_s
614 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
615 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
616 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
617 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
620 if hash["x264UseAdvancedOptions"] != 1
621 if hash["x264Preset"] != ""
622 commandString << " --x264-preset "
623 commandString << hash["x264Preset"]
625 if hash["x264Tune"] != "" && hash["x264Tune"] != "none"
626 commandString << " --x264-tune "
627 commandString << hash["x264Tune"]
629 if hash["h264Profile"] != "" && hash["h264Profile"] != "auto"
630 commandString << " --h264-profile "
631 commandString << hash["h264Profile"]
633 if hash["h264Level"] != "" && hash["h264Level"] != "auto"
634 commandString << " --h264-level "
635 commandString << hash["h264Level"]
637 if hash["x264OptionExtra"] != ""
638 commandString << " -x "
639 commandString << hash["x264OptionExtra"]
641 elsif hash["x264Option"] != ""
642 commandString << " -x "
643 commandString << hash["x264Option"]
646 # That's it, print to screen now
650 def generateCLIFolderParse( hash, depth ) # Shows the folder for wrappers to parse
658 commandString << " " << hash["PresetName"] << "\n"
662 def generateCLIFolderCloserParse( depth )
670 commandString << "\n"
674 def generateCLIParse(hash, depth) # Makes a CLI equivalent of all user presets, for wrappers to parse
679 commandString << '+ ' << hash["PresetName"] << ":"
682 commandString << " -e "
683 case hash["VideoEncoder"]
685 commandString << "x264"
687 commandString << "theora"
689 commandString << "ffmpeg4"
691 commandString << "ffmpeg2"
695 case hash["VideoQualityType"]
697 commandString << " -S " << hash["VideoTargetSize"]
699 commandString << " -b " << hash["VideoAvgBitrate"]
701 commandString << " -q " << hash["VideoQualitySlider"].to_s
705 if hash["VideoFramerate"] != "Same as source"
706 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
707 commandString << " -r " << "23.976"
708 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
709 commandString << " -r " << "29.97"
710 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
711 commandString << " -r " << "25"
713 commandString << " -r " << hash["VideoFramerate"]
715 # not same as source: pfr, else default (cfr)
716 if hash["VideoFramerateMode"] == "pfr"
717 commandString << " --pfr "
719 # same as source: cfr, else default (vfr)
720 elsif hash["VideoFramerateMode"] == "cfr"
721 commandString << " --cfr "
728 audioSamplerates = ""
731 audioCount = hash["AudioList"].size
733 hash["AudioList"].each do |audioTrack|
734 audioCount = audioCount - 1
737 audioBitrates << audioTrack["AudioBitrate"]
740 case audioTrack["AudioEncoder"]
742 audioEncoders << "copy:ac3"
744 audioEncoders << "ac3"
746 audioEncoders << "copy:dts"
748 audioEncoders << "copy:dtshd"
750 audioEncoders << "copy:aac"
751 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
752 audioEncoders << "av_aac"
754 audioEncoders << "fdk_aac"
756 audioEncoders << "fdk_haac"
757 when "AAC (CoreAudio)"
758 audioEncoders << "ca_aac"
759 when "HE-AAC (CoreAudio)"
760 audioEncoders << "ca_haac"
762 audioEncoders << "vorbis"
764 audioEncoders << "copy:mp3"
766 audioEncoders << "mp3"
767 when "FLAC (ffmpeg)", "FLAC 16-bit"
768 audioEncoders << "flac16"
769 when "FLAC (24-bit)", "FLAC 24-bit"
770 audioEncoders << "flac24"
772 audioEncoders << "copy"
776 case audioTrack["AudioMixdown"]
777 when "Mono (Left Only)"
778 audioMixdowns << "left_only"
779 when "Mono (Right Only)"
780 audioMixdowns << "right_only"
782 audioMixdowns << "mono"
784 audioMixdowns << "stereo"
785 when /Dolby Surround/
786 audioMixdowns << "dpl1"
787 when /Dolby Pro Logic II/
788 audioMixdowns << "dpl2"
789 when /5.1/, /discrete/
790 audioMixdowns << "5point1"
792 audioMixdowns << "6point1"
793 when "7.1 (5F/2R/LFE)"
794 audioMixdowns << "5_2_lfe"
796 audioMixdowns << "7point1"
798 audioMixdowns << "none"
802 audioSamplerates << audioTrack["AudioSamplerate"]
805 audioTracks << audioTrack["AudioTrack"].to_s
808 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
814 audioSamplerates << ","
816 audioTrackDRCs << ","
820 commandString << " -a " << audioTracks
821 commandString << " -E " << audioEncoders
822 commandString << " -B " << audioBitrates
823 commandString << " -6 " << audioMixdowns
824 commandString << " -R " << audioSamplerates
825 commandString << " -D " << audioTrackDRCs
830 if hash["AudioAllowAACPass"].to_i == 1
831 audioCopyMask << "aac"
833 if hash["AudioAllowAC3Pass"].to_i == 1
834 if audioCopyMask.size > 0
837 audioCopyMask << "ac3"
839 if hash["AudioAllowDTSHDPass"].to_i == 1
840 if audioCopyMask.size > 0
843 audioCopyMask << "dtshd"
845 if hash["AudioAllowDTSPass"].to_i == 1
846 if audioCopyMask.size > 0
849 audioCopyMask << "dts"
851 if hash["AudioAllowMP3Pass"].to_i == 1
852 if audioCopyMask.size > 0
855 audioCopyMask << "mp3"
858 if audioCopyMask.size > 0
859 commandString << " --audio-copy-mask " << audioCopyMask
862 #Auto Passthru Fallback
863 audioEncoderFallback = ""
865 case hash["AudioEncoderFallback"]
867 audioEncoderFallback << "ac3"
868 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
869 audioEncoderFallback << "av_aac"
871 audioEncoderFallback << "fdk_aac"
873 audioEncoderFallback << "fdk_haac"
874 when "AAC (CoreAudio)"
875 audioEncoderFallback << "ca_aac"
876 when "HE-AAC (CoreAudio)"
877 audioEncoderFallback << "ca_haac"
879 audioEncoderFallback << "vorbis"
881 audioEncoderFallback << "mp3"
882 when "FLAC (ffmpeg)", "FLAC 16-bit"
883 audioEncoderFallback << "flac16"
884 when "FLAC (24-bit)", "FLAC 24-bit"
885 audioEncoderFallback << "flac24"
888 if audioEncoderFallback.size > 0
889 commandString << " --audio-fallback " << audioEncoderFallback
893 commandString << " -f "
894 case hash["FileFormat"]
895 when "MPEG-4 (mp4v2)"
896 commandString << "mp4v2"
898 commandString << "mp4"
899 when "Matroska (libmkv)"
900 commandString << "libmkv"
902 commandString << "mkv"
906 if hash["Mp4iPodCompatible"].to_i == 1
907 commandString << " -I"
910 #MP4 Optimize for HTTP Streaming
911 if hash["Mp4HttpOptimize"].to_i == 1
912 commandString << " -O"
916 if hash["PictureAutoCrop"] == 0
917 commandString << " --crop "
918 commandString << hash["PictureTopCrop"].to_s
920 commandString << hash["PictureBottomCrop"].to_s
922 commandString << hash["PictureLeftCrop"].to_s
924 commandString << hash["PictureRightCrop"].to_s
928 if hash["PictureWidth"] != 0
929 commandString << " -X "
930 commandString << hash["PictureWidth"].to_s
932 if hash["PictureHeight"] != 0
933 commandString << " -Y "
934 commandString << hash["PictureHeight"].to_s
938 if hash["Subtitles"] && hash["Subtitles"] != "None"
939 if hash["Subtitles"] == "Autoselect"
940 commandString << " --subtitle-scan"
942 commandString << " -s "
943 commandString << hash["Subtitles"]
948 if hash["UsesPictureFilters"] == 1
950 case hash["PictureDeinterlace"]
952 commandString << " --deinterlace=" << hash["PictureDeinterlaceCustom"].to_s
954 commandString << " --deinterlace=fast"
956 commandString << " --deinterlace=slow"
958 commandString << " --deinterlace=slower"
960 commandString << " --deinterlace=bob"
963 case hash["PictureDenoise"]
965 commandString << " --denoise=" << hash["PictureDenoiseCustom"].to_s
967 commandString << " --denoise=weak"
969 commandString << " --denoise=medium"
971 commandString << " --denoise=strong"
974 case hash["PictureDecomb"]
976 commandString << " --decomb=" << hash["PictureDecombCustom"].to_s
978 commandString << " --decomb"
980 commandString << " --decomb=fast"
982 commandString << " --decomb=bob"
985 case hash["PictureDetelecine"]
987 commandString << " --detelecine=" << hash["PictureDetelecineCustom"].to_s
989 commandString << " --detelecine"
992 if hash["PictureDeblock"] != 0
993 commandString << " --deblock=" << hash["PictureDeblock"].to_s
999 if hash["PicturePAR"] == 1
1000 commandString << " --strict-anamorphic"
1001 elsif hash["PicturePAR"] == 2
1002 commandString << " --loose-anamorphic"
1003 elsif hash["PicturePAR"] == 3
1004 commandString << " --custom-anamorphic"
1008 if hash["PictureModulus"]
1009 commandString << " --modulus " << hash["PictureModulus"].to_s
1013 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
1014 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
1015 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
1016 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
1019 if hash["x264UseAdvancedOptions"] != 1
1020 if hash["x264Preset"] != ""
1021 commandString << " --x264-preset "
1022 commandString << hash["x264Preset"]
1024 if hash["x264Tune"] != "" && hash["x264Tune"] != "none"
1025 commandString << " --x264-tune "
1026 commandString << hash["x264Tune"]
1028 if hash["h264Profile"] != "" && hash["h264Profile"] != "auto"
1029 commandString << " --h264-profile "
1030 commandString << hash["h264Profile"]
1032 if hash["h264Level"] != "" && hash["h264Level"] != "auto"
1033 commandString << " --h264-level "
1034 commandString << hash["h264Level"]
1036 if hash["x264OptionExtra"] != ""
1037 commandString << " -x "
1038 commandString << hash["x264OptionExtra"]
1040 elsif hash["x264Option"] != ""
1041 commandString << " -x "
1042 commandString << hash["x264Option"]
1045 # That's it, print to screen now
1049 def generateAPIcalls(hash) # Makes a C version of the preset ready for coding into the CLI
1051 commandString = "if (!strcasecmp(preset_name, \"" << hash["PresetName"] << "\"))\n{\n "
1054 commandString << "if( !mux )\n "
1055 commandString << "{\n "
1057 case hash["FileFormat"]
1058 when "MPEG-4 (mp4v2)"
1059 commandString << " mux = " << "HB_MUX_MP4V2;\n "
1061 commandString << " mux = " << "HB_MUX_MP4;\n "
1062 when "Matroska (libmkv)"
1063 commandString << " mux = " << "HB_MUX_LIBMKV;\n "
1065 commandString << " mux = " << "HB_MUX_MKV;\n "
1067 commandString << "}\n "
1070 if hash["Mp4iPodCompatible"].to_i == 1
1071 commandString << "job->ipod_atom = 1;\n "
1074 #MP4 Optimize for HTTP Streaming
1075 if hash["Mp4HttpOptimize"].to_i == 1
1076 commandString << "job->mp4_optimize = 1;\n "
1080 commandString << "vcodec = "
1081 case hash["VideoEncoder"]
1083 commandString << "HB_VCODEC_X264;\n "
1085 commandString << "HB_VCODEC_THEORA;\n "
1087 commandString << "HB_VCODEC_FFMPEG_MPEG4;\n "
1089 commandString << "HB_VCODEC_FFMPEG_MPEG2;\n "
1093 case hash["VideoQualityType"]
1095 commandString << "size = " << hash["VideoTargetSize"] << ";\n "
1097 commandString << "job->vbitrate = " << hash["VideoAvgBitrate"] << ";\n "
1099 commandString << "job->vquality = " << hash["VideoQualitySlider"].to_s << ";\n "
1103 if hash["VideoFramerate"] != "Same as source"
1104 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
1105 commandString << "filter_vrate_base = " << "1126125;\n "
1106 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
1107 commandString << "filter_vrate_base = " << "900900;\n "
1108 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
1109 commandString << "filter_vrate_base = " << "1080000;\n "
1111 commandString << "filter_vrate_base = " << (27000000 / hash["VideoFramerate"].to_i).to_s << ";\n "
1113 # not same as source: pfr, else default (cfr)
1114 if hash["VideoFramerateMode"] == "pfr"
1115 commandString << "filter_cfr = 2;\n "
1117 commandString << "filter_cfr = 1;\n "
1119 # same as source: cfr, else default (vfr)
1120 elsif hash["VideoFramerateMode"] == "cfr"
1121 commandString << "filter_cfr = 1;\n "
1128 audioSamplerates = ""
1131 audioCount = hash["AudioList"].size
1133 hash["AudioList"].each do |audioTrack|
1134 audioCount = audioCount - 1
1137 audioBitrates << audioTrack["AudioBitrate"]
1140 case audioTrack["AudioEncoder"]
1142 audioEncoders << "copy:ac3"
1144 audioEncoders << "ac3"
1146 audioEncoders << "copy:dts"
1148 audioEncoders << "copy:dtshd"
1150 audioEncoders << "copy:aac"
1151 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
1152 audioEncoders << "av_aac"
1154 audioEncoders << "fdk_aac"
1156 audioEncoders << "fdk_haac"
1157 when "AAC (CoreAudio)"
1158 audioEncoders << "ca_aac"
1159 when "HE-AAC (CoreAudio)"
1160 audioEncoders << "ca_haac"
1162 audioEncoders << "vorbis"
1164 audioEncoders << "copy:mp3"
1166 audioEncoders << "mp3"
1167 when "FLAC (ffmpeg)", "FLAC 16-bit"
1168 audioEncoders << "flac16"
1169 when "FLAC (24-bit)", "FLAC 24-bit"
1170 audioEncoders << "flac24"
1172 audioEncoders << "copy"
1176 case audioTrack["AudioMixdown"]
1177 when "Mono (Left Only)"
1178 audioMixdowns << "left_only"
1179 when "Mono (Right Only)"
1180 audioMixdowns << "right_only"
1182 audioMixdowns << "mono"
1184 audioMixdowns << "stereo"
1185 when /Dolby Surround/
1186 audioMixdowns << "dpl1"
1187 when /Dolby Pro Logic II/
1188 audioMixdowns << "dpl2"
1189 when /5.1/, /discrete/
1190 audioMixdowns << "5point1"
1192 audioMixdowns << "6point1"
1193 when "7.1 (5F/2R/LFE)"
1194 audioMixdowns << "5_2_lfe"
1196 audioMixdowns << "7point1"
1198 audioMixdowns << "none"
1202 audioSamplerates << audioTrack["AudioSamplerate"]
1205 audioTracks << audioTrack["AudioTrack"].to_s
1208 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
1211 audioBitrates << ","
1212 audioEncoders << ","
1213 audioMixdowns << ","
1214 audioSamplerates << ","
1216 audioTrackDRCs << ","
1220 commandString << "if( !atracks )\n "
1221 commandString << "{\n "
1222 commandString << " atracks = strdup(\"" << audioTracks
1223 commandString << "\");\n "
1224 commandString << "}\n "
1226 commandString << "if( !acodecs )\n "
1227 commandString << "{\n "
1228 commandString << " acodecs = strdup(\"" << audioEncoders
1229 commandString << "\");\n "
1230 commandString << "}\n "
1232 commandString << "if( !abitrates )\n "
1233 commandString << "{\n "
1234 commandString << " abitrates = str_split(\"" << audioBitrates
1235 commandString << "\", ',');\n "
1236 commandString << "}\n "
1238 commandString << "if( !mixdowns )\n "
1239 commandString << "{\n "
1240 commandString << " mixdowns = strdup(\"" << audioMixdowns
1241 commandString << "\");\n "
1242 commandString << "}\n "
1244 commandString << "if( !arates )\n "
1245 commandString << "{\n "
1246 commandString << " arates = strdup(\"" << audioSamplerates
1247 commandString << "\");\n "
1248 commandString << "}\n "
1250 commandString << "if( !dynamic_range_compression )\n "
1251 commandString << "{\n "
1252 commandString << " dynamic_range_compression = strdup(\"" << audioTrackDRCs
1253 commandString << "\");\n "
1254 commandString << "}\n "
1257 if hash["AudioAllowAACPass"]
1258 commandString << "if( allowed_audio_copy == -1 )\n "
1259 commandString << "{\n "
1260 commandString << " allowed_audio_copy = 0;\n "
1261 if hash["AudioAllowAACPass"].to_i == 1
1262 commandString << " allowed_audio_copy |= HB_ACODEC_AAC_PASS;\n "
1264 if hash["AudioAllowAC3Pass"].to_i == 1
1265 commandString << " allowed_audio_copy |= HB_ACODEC_AC3_PASS;\n "
1267 if hash["AudioAllowDTSHDPass"].to_i == 1
1268 commandString << " allowed_audio_copy |= HB_ACODEC_DCA_HD_PASS;\n "
1270 if hash["AudioAllowDTSPass"].to_i == 1
1271 commandString << " allowed_audio_copy |= HB_ACODEC_DCA_PASS;\n "
1273 if hash["AudioAllowMP3Pass"].to_i == 1
1274 commandString << " allowed_audio_copy |= HB_ACODEC_MP3_PASS;\n "
1276 commandString << " allowed_audio_copy &= HB_ACODEC_PASS_MASK;\n "
1277 commandString << "}\n "
1280 #Auto Passthru Fallback
1281 audioEncoderFallback = ""
1283 case hash["AudioEncoderFallback"]
1285 audioEncoderFallback << "ac3"
1286 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
1287 audioEncoderFallback << "av_aac"
1289 audioEncoderFallback << "fdk_aac"
1291 audioEncoderFallback << "fdk_haac"
1292 when "AAC (CoreAudio)"
1293 audioEncoderFallback << "ca_aac"
1294 when "HE-AAC (CoreAudio)"
1295 audioEncoderFallback << "ca_haac"
1297 audioEncoderFallback << "vorbis"
1299 audioEncoderFallback << "mp3"
1300 when "FLAC (ffmpeg)", "FLAC 16-bit"
1301 audioEncoderFallback << "flac16"
1302 when "FLAC (24-bit)", "FLAC 24-bit"
1303 audioEncoderFallback << "flac24"
1306 if audioEncoderFallback.size > 0
1307 commandString << "if( acodec_fallback == NULL )\n "
1308 commandString << "{\n "
1309 commandString << " acodec_fallback = \"" << audioEncoderFallback << "\";\n "
1310 commandString << "}\n "
1314 if hash["PictureAutoCrop"] == 0
1315 commandString << "job->crop[0] = " << hash["PictureTopCrop"].to_s << ";\n "
1316 commandString << "job->crop[1] = " << hash["PictureBottomCrop"].to_s << ";\n "
1317 commandString << "job->crop[2] = " << hash["PictureLeftCrop"].to_s << ";\n "
1318 commandString << "job->crop[4] = " << hash["PictureRightCrop"].to_s << ";\n "
1322 if hash["PictureWidth"] != 0
1323 commandString << "maxWidth = "
1324 commandString << hash["PictureWidth"].to_s << ";\n "
1326 if hash["PictureHeight"] != 0
1327 commandString << "maxHeight = "
1328 commandString << hash["PictureHeight"].to_s << ";\n "
1332 if hash["Subtitles"] != "None"
1333 if hash["Subtitles"] == "Autoselect"
1334 commandString << "subtitle_scan = 1;\n "
1336 commandString << "job->subtitle = "
1337 commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n "
1342 if hash["x264UseAdvancedOptions"] != 1
1343 if hash["x264Preset"] != ""
1344 commandString << "if (x264_preset == NULL)\n "
1345 commandString << "{\n "
1346 commandString << " x264_preset = strdup(\""
1347 commandString << hash["x264Preset"] << "\");\n "
1348 commandString << "}\n "
1350 if hash["x264Tune"] != "" && hash["x264Tune"] != "none"
1351 commandString << "if (x264_tune == NULL)\n "
1352 commandString << "{\n "
1353 commandString << " x264_tune = strdup(\""
1354 commandString << hash["x264Tune"]
1355 commandString << "\");\n "
1356 commandString << "}\n "
1358 if hash["h264Profile"] != "" && hash["h264Profile"] != "auto"
1359 commandString << "if (h264_profile == NULL)\n "
1360 commandString << "{\n "
1361 commandString << " h264_profile = strdup(\""
1362 commandString << hash["h264Profile"] << "\");\n "
1363 commandString << "}\n "
1365 if hash["h264Level"] != "" && hash["h264Level"] != "auto"
1366 commandString << "if (h264_level == NULL)\n "
1367 commandString << "{\n "
1368 commandString << " h264_level = strdup(\""
1369 commandString << hash["h264Level"] << "\");\n "
1370 commandString << "}\n "
1372 if hash["x264OptionExtra"] != ""
1373 commandString << "if (advanced_opts == NULL)\n "
1374 commandString << "{\n "
1375 commandString << " advanced_opts = strdup(\""
1376 commandString << hash["x264OptionExtra"] << "\");\n "
1377 commandString << "}\n "
1379 elsif hash["x264Option"] != ""
1380 commandString << "if (advanced_opts == NULL)\n "
1381 commandString << "{\n "
1382 commandString << " advanced_opts = strdup(\""
1383 commandString << hash["x264Option"] << "\");\n "
1384 commandString << "}\n "
1388 if hash["UsesPictureFilters"] == 1
1390 if hash["PictureDeinterlace"].to_i != 0
1391 commandString << "deinterlace = 1;\n "
1394 case hash["PictureDeinterlace"]
1396 commandString << "deinterlace_opt = \"" << hash["PictureDeinterlaceCustom"].to_s << "\";\n "
1398 commandString << "deinterlace_opt = \"0\";\n "
1400 commandString << "deinterlace_opt = \"1\";\n "
1402 commandString << "deinterlace_opt = \"3\";\n "
1404 commandString << "deinterlace_opt = \"15\";\n "
1407 if hash["PictureDenoise"].to_i != 0
1408 commandString << "denoise = 1;\n "
1411 case hash["PictureDenoise"]
1413 commandString << "denoise_opt = \"" << hash["PictureDenoiseCustom"].to_s << "\";\n "
1415 commandString << "denoise_opt = \"2:1:1:2:3:3\";\n "
1417 commandString << "denoise_opt = \"3:2:2:2:3:3\";\n "
1419 commandString << "denoise_opt = \"7:7:7:5:5:5\";\n "
1422 if hash["PictureDecomb"].to_i != 0
1423 commandString << "decomb = 1;\n "
1426 case hash["PictureDecomb"]
1428 commandString << "decomb_opt = \"" << hash["PictureDecombCustom"].to_s << "\";\n "
1430 commandString << "decomb_opt = \"7:2:6:9:1:80\";\n "
1432 commandString << "decomb_opt = \"455\";\n "
1435 if hash["PictureDetelecine"].to_i != 0
1436 commandString << "detelecine = 1;\n "
1439 case hash["PictureDetelecine"]
1441 commandString << "detelecine_opt = \"" << hash["PictureDetelecineCustom"].to_s << "\";\n "
1444 if hash["PictureDeblock"] != 0
1445 commandString << "deblock = 1;\n "
1446 commandString << "deblock_opt = \"" << hash["PictureDeblock"].to_s << "\";\n "
1452 if hash["PicturePAR"] != 0
1453 commandString << "if( !anamorphic_mode )\n "
1454 commandString << "{\n "
1455 if hash["PicturePAR"] == 1
1456 commandString << " anamorphic_mode = 1;\n "
1457 elsif hash["PicturePAR"] == 2
1458 commandString << " anamorphic_mode = 2;\n "
1459 elsif hash["PicturePAR"] == 3
1460 commandString << " anamorphic_mode = 3;\n "
1462 commandString << "}\n "
1466 if hash["PictureModulus"]
1467 commandString << "modulus = " << hash["PictureModulus"].to_s << ";\n "
1471 if hash["ChapterMarkers"] == 1
1472 commandString << "job->chapter_markers = 1;\n "
1475 if hash["VideoGrayScale"] == 1
1476 commandString << "job->grayscale = 1;\n "
1479 if hash["VideoTwoPass"] == 1
1480 commandString << "twoPass = 1;\n "
1483 if hash["VideoTurboTwoPass"] == 1
1484 commandString << "turbo_opts_enabled = 1;\n "
1488 commandString = commandString.rstrip
1489 commandString << "\n}"
1491 # That's it, print to screen now
1495 def generateAPIFolderList( hash, depth )
1498 commandString << " printf(\"\\n"
1500 commandString << " "
1503 commandString << "<"
1505 commandString << " " << hash["PresetName"]
1506 commandString << "\\n\");\n"
1510 def generateAPIFolderCloserList( depth )
1513 commandString << " printf(\"\\n"
1515 commandString << " "
1518 commandString << ">"
1520 commandString << "\\n\");\n"
1524 def generateAPIList(hash, depth) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse
1526 commandString << " printf(\"\\n"
1528 commandString << " "
1531 commandString << "+ " << hash["PresetName"] << ": "
1534 commandString << " -e "
1535 case hash["VideoEncoder"]
1537 commandString << "x264 "
1539 commandString << "theora "
1541 commandString << "ffmpeg4 "
1543 commandString << "ffmpeg2 "
1547 case hash["VideoQualityType"]
1549 commandString << " -S " << hash["VideoTargetSize"]
1551 commandString << " -b " << hash["VideoAvgBitrate"]
1553 commandString << " -q " << hash["VideoQualitySlider"].to_s
1557 if hash["VideoFramerate"] != "Same as source"
1558 if hash["VideoFramerate"] == "23.976 (NTSC Film)"
1559 commandString << " -r " << "23.976"
1560 elsif hash["VideoFramerate"] == "29.97 (NTSC Video)"
1561 commandString << " -r " << "29.97"
1562 elsif hash["VideoFramerate"] == "25 (PAL Film/Video)"
1563 commandString << " -r " << "25"
1565 commandString << " -r " << hash["VideoFramerate"]
1567 # not same as source: pfr, else default (cfr)
1568 if hash["VideoFramerateMode"] == "pfr"
1569 commandString << " --pfr "
1571 # same as source: cfr, else default (vfr)
1572 elsif hash["VideoFramerateMode"] == "cfr"
1573 commandString << " --cfr "
1580 audioSamplerates = ""
1583 audioCount = hash["AudioList"].size
1585 hash["AudioList"].each do |audioTrack|
1586 audioCount = audioCount - 1
1589 audioBitrates << audioTrack["AudioBitrate"]
1592 case audioTrack["AudioEncoder"]
1594 audioEncoders << "copy:ac3"
1596 audioEncoders << "ac3"
1598 audioEncoders << "copy:dts"
1600 audioEncoders << "copy:dtshd"
1602 audioEncoders << "copy:aac"
1603 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
1604 audioEncoders << "av_aac"
1606 audioEncoders << "fdk_aac"
1608 audioEncoders << "fdk_haac"
1609 when "AAC (CoreAudio)"
1610 audioEncoders << "ca_aac"
1611 when "HE-AAC (CoreAudio)"
1612 audioEncoders << "ca_haac"
1614 audioEncoders << "vorbis"
1616 audioEncoders << "copy:mp3"
1618 audioEncoders << "mp3"
1619 when "FLAC (ffmpeg)", "FLAC 16-bit"
1620 audioEncoders << "flac16"
1621 when "FLAC (24-bit)", "FLAC 24-bit"
1622 audioEncoders << "flac24"
1624 audioEncoders << "copy"
1628 case audioTrack["AudioMixdown"]
1629 when "Mono (Left Only)"
1630 audioMixdowns << "left_only"
1631 when "Mono (Right Only)"
1632 audioMixdowns << "right_only"
1634 audioMixdowns << "mono"
1636 audioMixdowns << "stereo"
1637 when /Dolby Surround/
1638 audioMixdowns << "dpl1"
1639 when /Dolby Pro Logic II/
1640 audioMixdowns << "dpl2"
1641 when /5.1/, /discrete/
1642 audioMixdowns << "5point1"
1644 audioMixdowns << "6point1"
1645 when "7.1 (5F/2R/LFE)"
1646 audioMixdowns << "5_2_lfe"
1648 audioMixdowns << "7point1"
1650 audioMixdowns << "none"
1654 audioSamplerates << audioTrack["AudioSamplerate"]
1657 audioTracks << audioTrack["AudioTrack"].to_s
1660 audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s
1663 audioBitrates << ","
1664 audioEncoders << ","
1665 audioMixdowns << ","
1666 audioSamplerates << ","
1668 audioTrackDRCs << ","
1672 commandString << " -a " << audioTracks
1673 commandString << " -E " << audioEncoders
1674 commandString << " -B " << audioBitrates
1675 commandString << " -6 " << audioMixdowns
1676 commandString << " -R " << audioSamplerates
1677 commandString << " -D " << audioTrackDRCs
1682 if hash["AudioAllowAACPass"].to_i == 1
1683 audioCopyMask << "aac"
1685 if hash["AudioAllowAC3Pass"].to_i == 1
1686 if audioCopyMask.size > 0
1687 audioCopyMask << ","
1689 audioCopyMask << "ac3"
1691 if hash["AudioAllowDTSHDPass"].to_i == 1
1692 if audioCopyMask.size > 0
1693 audioCopyMask << ","
1695 audioCopyMask << "dtshd"
1697 if hash["AudioAllowDTSPass"].to_i == 1
1698 if audioCopyMask.size > 0
1699 audioCopyMask << ","
1701 audioCopyMask << "dts"
1703 if hash["AudioAllowMP3Pass"].to_i == 1
1704 if audioCopyMask.size > 0
1705 audioCopyMask << ","
1707 audioCopyMask << "mp3"
1710 if audioCopyMask.size > 0
1711 commandString << " --audio-copy-mask " << audioCopyMask
1714 #Auto Passthru Fallback
1715 audioEncoderFallback = ""
1717 case hash["AudioEncoderFallback"]
1719 audioEncoderFallback << "ac3"
1720 when "AAC (ffmpeg)", "AAC (avcodec)", "AAC (faac)"
1721 audioEncoderFallback << "av_aac"
1723 audioEncoderFallback << "fdk_aac"
1725 audioEncoderFallback << "fdk_haac"
1726 when "AAC (CoreAudio)"
1727 audioEncoderFallback << "ca_aac"
1728 when "HE-AAC (CoreAudio)"
1729 audioEncoderFallback << "ca_haac"
1731 audioEncoderFallback << "vorbis"
1733 audioEncoderFallback << "mp3"
1734 when "FLAC (ffmpeg)", "FLAC 16-bit"
1735 audioEncoderFallback << "flac16"
1736 when "FLAC (24-bit)", "FLAC 24-bit"
1737 audioEncoderFallback << "flac24"
1740 if audioEncoderFallback.size > 0
1741 commandString << " --audio-fallback " << audioEncoderFallback
1745 commandString << " -f "
1746 case hash["FileFormat"]
1747 when "MPEG-4 (mp4v2)"
1748 commandString << "mp4v2"
1750 commandString << "mp4"
1751 when "Matroska (libmkv)"
1752 commandString << "libmkv"
1754 commandString << "mkv"
1758 if hash["Mp4iPodCompatible"].to_i == 1
1759 commandString << " -I"
1762 #MP4 Optimize for HTTP Streaming
1763 if hash["Mp4HttpOptimize"].to_i == 1
1764 commandString << " -O"
1768 if hash["PictureAutoCrop"] == 0
1769 commandString << " --crop "
1770 commandString << hash["PictureTopCrop"].to_s
1771 commandString << ":"
1772 commandString << hash["PictureBottomCrop"].to_s
1773 commandString << ":"
1774 commandString << hash["PictureLeftCrop"].to_s
1775 commandString << ":"
1776 commandString << hash["PictureRightCrop"].to_s
1780 if hash["PictureWidth"] != 0
1781 commandString << " -X "
1782 commandString << hash["PictureWidth"].to_s
1784 if hash["PictureHeight"] != 0
1785 commandString << " -Y "
1786 commandString << hash["PictureHeight"].to_s
1790 if hash["Subtitles"] && hash["Subtitles"] != "None"
1791 if hash["Subtitles"] == "Autoselect"
1792 commandString << " --subtitle-scan"
1794 commandString << " -s "
1795 commandString << hash["Subtitles"]
1800 if hash["UsesPictureFilters"] == 1
1802 case hash["PictureDeinterlace"]
1804 commandString << " --deinterlace=" << hash["PictureDeinterlaceCustom"].to_s
1806 commandString << " --deinterlace=fast"
1808 commandString << " --deinterlace=slow"
1810 commandString << " --deinterlace=slower"
1812 commandString << " --deinterlace=bob"
1815 case hash["PictureDenoise"]
1817 commandString << " --denoise=" << hash["PictureDenoiseCustom"].to_s
1819 commandString << " --denoise=weak"
1821 commandString << " --denoise=medium"
1823 commandString << " --denoise=strong"
1826 case hash["PictureDecomb"]
1828 commandString << " --decomb=" << hash["PictureDecombCustom"].to_s
1830 commandString << " --decomb"
1832 commandString << " --decomb=fast"
1834 commandString << " --decomb=bob"
1837 case hash["PictureDetelecine"]
1839 commandString << " --detelecine=" << hash["PictureDetelecineCustom"].to_s
1841 commandString << " --detelecine"
1844 if hash["PictureDeblock"] != 0
1845 commandString << " --deblock=" << hash["PictureDeblock"].to_s
1851 if hash["PicturePAR"] == 1
1852 commandString << " --strict-anamorphic"
1853 elsif hash["PicturePAR"] == 2
1854 commandString << " --loose-anamorphic"
1855 elsif hash["PicturePAR"] == 3
1856 commandString << " --custom-anamorphic"
1860 if hash["PictureModulus"]
1861 commandString << " --modulus " << hash["PictureModulus"].to_s
1865 if hash["ChapterMarkers"] == 1 then commandString << " -m" end
1866 if hash["VideoGrayScale"] == 1 then commandString << " -g" end
1867 if hash["VideoTwoPass"] == 1 then commandString << " -2" end
1868 if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end
1871 if hash["x264UseAdvancedOptions"] != 1
1872 if hash["x264Preset"] != ""
1873 commandString << " --x264-preset "
1874 commandString << hash["x264Preset"]
1876 if hash["x264Tune"] != "" && hash["x264Tune"] != "none"
1877 commandString << " --x264-tune "
1878 commandString << hash["x264Tune"]
1880 if hash["h264Profile"] != "" && hash["h264Profile"] != "auto"
1881 commandString << " --h264-profile "
1882 commandString << hash["h264Profile"]
1884 if hash["h264Level"] != "" && hash["h264Level"] != "auto"
1885 commandString << " --h264-level "
1886 commandString << hash["h264Level"]
1888 if hash["x264OptionExtra"] != ""
1889 commandString << " -x "
1890 commandString << hash["x264OptionExtra"]
1892 elsif hash["x264Option"] != ""
1893 commandString << " -x "
1894 commandString << hash["x264Option"]
1897 commandString << "\\n\");"
1899 # That's it, print to screen now
1905 # CLI invocation only
1908 # First grab the specified CLI options
1909 options = readOptions
1911 # Only run if one of the useful CLI flags have been passed
1912 if options.cliraw == true || options.cliparse == true || options.api == true || options.apilist == true
1913 # This line is the ignition -- generates hashes of
1914 # presets and then displays them to the screen
1915 # with the options the user selects on the CLI.
1916 Display.new( Presets.new.hashMasterList, options )
1918 # Direct the user to the help
1919 puts "\n\tUsage: manicure.rb [options]"
1920 puts "\tSee help with -h or --help"