X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=scripts%2Fmanicure.rb;h=317ea05aa784648ca661c84a125a4fee0eacba7b;hb=f93c2a10768843b2f8900695bb1ab276ffc168ab;hp=0f9d6b50f0a93f70cb67592b1c8ecccc6ee3326f;hpb=a0b441414fc73296870b9e9bff111c5303ef5935;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/scripts/manicure.rb b/scripts/manicure.rb index 0f9d6b50..317ea05a 100755 --- a/scripts/manicure.rb +++ b/scripts/manicure.rb @@ -11,6 +11,8 @@ # For handling command line arguments to the script require 'optparse' require 'ostruct' +require 'rubygems' +require 'plist' # CLI options: (code based on http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/index.html ) def readOptions @@ -78,103 +80,15 @@ class Presets # and display output. def initialize - # Grab input from the user's presets .plist - rawPresets = readPresetPlist - - # Store all the presets in here - presetStew = [] - - # Each item in the array is one line from the .plist - presetStew = rawPresets.split("\n") - - # Now get rid of white space - presetStew = cleanStew(presetStew) - - # This stores the offsets between presets. - presetBreaks = findPresetBreaks(presetStew) - - # Now it's time to use that info to store each - # preset individually, in the master list. - @presetMasterList = [] - i = 0 - while i <= presetBreaks.size - if i == 0 #first preset - # Grab the stew, up to the 1st offset. - @presetMasterList[i] = presetStew.slice(0..presetBreaks[i].to_i) - elsif i < presetBreaks.size #middle presets - # Grab the stew from the last offset to the current.. - @presetMasterList[i] = presetStew.slice(presetBreaks[i-1].to_i..presetBreaks[i].to_i) - else #final preset - # Grab the stew, starting at the last offset, all the way to the end. - @presetMasterList[i] = presetStew.slice(presetBreaks[i-1].to_i..presetStew.length) - end - i += 1 - end - + # Grab the user's home path + homeLocation = `echo $HOME`.chomp + + # Use that to build a path to the presets .plist + inputFile = homeLocation+'/Library/Application Support/HandBrake/UserPresets.plist' + # Parse the presets into hashes - @hashMasterList = [] - - buildPresetHash - - end - - def readPresetPlist # Grab the .plist and store it in presets - - # Grab the user's home path - homeLocation = `echo $HOME`.chomp - - # Use that to build a path to the presets .plist - inputFile = homeLocation+'/Library/Application\ Support/HandBrake/UserPresets.plist' - - # Builds a command that inputs the .plist, but not before stripping all the XML gobbledygook. - parseCommand = 'cat '+inputFile+' | sed -e \'s/<[a-z]*>//\' -e \'s/<\/[a-z]*>//\' -e \'/<[?!]/d\' ' - - puts "\n\n" - - # Run the command, return the raw presets - rawPresets = `#{parseCommand}` - end - - def cleanStew(presetStew) #remove tabbed white space - presetStew.each do |oneline| - oneline.strip! - end - end - - def findPresetBreaks(presetStew) #figure out where each preset starts and ends - i = 0 - j = 0 - presetBreaks =[] - presetStew.each do |presetLine| - if presetLine =~ /Audio1Bitrate/ # This is the first line of a new preset. - presetBreaks[j] = i-1 # So mark down how long the last one was. - j += 1 - end - i += 1 - end - return presetBreaks - end - - def buildPresetHash #fill up @hashMasterList with hashes of all key/value pairs - j = 0 + @hashMasterList = Plist::parse_xml( inputFile ) - # Iterate through all presets, treating each in turn as singleServing - @presetMasterList.each do |singleServing| - - # Initialize the hash for preset j (aka singleServing) - @hashMasterList[j] = Hash.new - - # Each key and value are on sequential lines. - # Iterating through by twos, use that to build a hash. - # Each key, on line i, paired with its value, on line i+1 - i = 1 - while i < singleServing.length - @hashMasterList[j].store( singleServing[i], singleServing[i+1] ) - i += 2 - end - - j += 1 - end end end @@ -182,7 +96,6 @@ end # This class displays the presets to stdout in various formats. class Display - def initialize(hashMasterList, options) @hashMasterList = hashMasterList @@ -201,34 +114,59 @@ class Display # Iterate through the hashes. @hashMasterList.each do |hash| - # Check to make there are valid contents - if hash.key?("PresetName") - - if @options.header == true - # First throw up a header to make each preset distinct - displayHeader(hash) - end - - if @options.cliraw == true - # Show the preset's full CLI string equivalent - generateCLIString(hash) - end - - if @options.cliparse == true - generateCLIParse(hash) - end - - if @options.api == true - # Show the preset as code for test/test.c, HandBrakeCLI - generateAPIcalls(hash) - end - - if @options.apilist == true - # Show the preset as print statements, for CLI wrappers to parse. - generateAPIList(hash) + # Check to see whether we've got a preset or afolder + if !hash["Folder"] + # It's a top-level preset + displayIndividualPreset(hash, 0) + else + # It's a folder, yay + displayFolder( hash, 0 ) + hash["ChildrenArray"].each do |subhash| + # Drill down to see its contents + if !subhash["Folder"] + # It's a preset + displayIndividualPreset(subhash, 1) + else + # It's a folder + displayFolder( subhash, 1 ) + subhash["ChildrenArray"].each do |subsubhash| + # At this point we're far enough down we won't try to drill further + if !subsubhash["Folder"] + displayIndividualPreset(subsubhash, 2) + end + end + displayFolderCloser( 1 ) + end end + displayFolderCloser( 0 ) end - end + end + end + + def displayIndividualPreset(hash, depth) + if @options.header == true + # First throw up a header to make each preset distinct + displayHeader(hash) + end + + if @options.cliraw == true + # Show the preset's full CLI string equivalent + generateCLIString(hash, depth) + end + + if @options.cliparse == true + generateCLIParse(hash, depth) + end + + if @options.api == true + # Show the preset as code for test/test.c, HandBrakeCLI + generateAPIcalls(hash) + end + + if @options.apilist == true + # Show the preset as print statements, for CLI wrappers to parse. + generateAPIList(hash, depth) + end end def displayHeader(hash) # A distinct banner to separate each preset @@ -252,12 +190,12 @@ class Display puts "#{hash["FileCodecs"]}".center(@columnWidth) # Note if the preset isn't built-in - if hash["Type"].to_i == 1 + if hash["Type"] == 1 puts "Custom Preset".center(@columnWidth) end # Note if the preset is marked as default. - if hash["Default"].to_i == 1 + if hash["Default"] == 1 puts "This is your default preset.".center(@columnWidth) end @@ -266,18 +204,77 @@ class Display end - def generateCLIString(hash) # Makes a full CLI equivalent of a preset + def displayFolder( hash, depth ) + + if @options.cliraw == true + # Show the folder's full in a format that matches the CLI equivalents + generateCLIFolderString(hash, depth) + end + + if @options.cliparse == true + # Show the folder in a format that matches the CLI wrapper equivalents + generateCLIFolderParse(hash, depth) + end + + if @options.apilist == true + # Show the folder as print statements, for CLI wrappers to parse. + generateAPIFolderList(hash, depth) + end + + end + + def displayFolderCloser( depth ) + if @options.cliraw == true + # Show the folder's full in a format that matches the CLI equivalents + generateCLIFolderCloserString( depth ) + end + + if @options.cliparse == true + # Show the folder in a format that matches the CLI wrapper equivalents + generateCLIFolderCloserParse( depth ) + end + + if @options.apilist == true + # Show the folder as print statements, for CLI wrappers to parse. + generateAPIFolderCloserList( depth ) + end + end + + def generateCLIFolderString( hash, depth ) # Shows the folder for the CLI equivalents + commandString = "" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << "<" + end + commandString << " " << hash["PresetName"] << "\n\n" + puts commandString + end + + def generateCLIFolderCloserString( depth ) + commandString = "" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << ">" + end + commandString << "\n\n" + puts commandString + end + + def generateCLIString(hash, depth) # Makes a full CLI equivalent of a preset commandString = "" + depth.times do + commandString << " " + end commandString << './HandBrakeCLI -i DVD -o ~/Movies/movie.' #Filename suffix case hash["FileFormat"] when /MP4/ commandString << "mp4 " - when /AVI/ - commandString << "avi " - when /OGM/ - commandString << "ogm " when /MKV/ commandString << "mkv " end @@ -288,19 +285,19 @@ class Display case hash["VideoEncoder"] when /x264/ commandString << "x264" - when /XviD/ - commandString << "xvid" + when /Theora/ + commandString << "theora" end end #VideoRateControl - case hash["VideoQualityType"].to_i + case hash["VideoQualityType"] when 0 commandString << " -S " << hash["VideoTargetSize"] when 1 commandString << " -b " << hash["VideoAvgBitrate"] when 2 - commandString << " -q " << hash["VideoQualitySlider"] + commandString << " -q " << hash["VideoQualitySlider"].to_s end #FPS @@ -309,182 +306,87 @@ class Display commandString << " -r " << "23.976" elsif hash["VideoFramerate"] == "29.97 (NTSC Video)" commandString << " -r " << "29.97" + elsif hash["VideoFramerate"] == "25 (PAL Film/Video)" + commandString << " -r " << "25" else commandString << " -r " << hash["VideoFramerate"] end end #Audio tracks - commandString << " -a " - commandString << hash["Audio1Track"] - if hash["Audio2Track"] - commandString << "," << hash["Audio2Track"] - end - if hash["Audio3Track"] - commandString << "," << hash["Audio3Track"] - end - if hash["Audio4Track"] - commandString << "," << hash["Audio4Track"] - end - - #Audio encoders - commandString << " -E " - case hash["Audio1Encoder"] - when /AC3 / - commandString << "ac3" - when /AAC/ - commandString << "faac" - when /Vorbis/ - commandString << "vorbis" - when /MP3/ - commandString << "lame" - end - case hash["Audio2Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio3Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio4Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - - #Audio bit rate - commandString << " -B " - commandString << hash["Audio1Bitrate"] - if hash["Audio2Bitrate"] - if hash["Audio2Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio2Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio3Bitrate"] - if hash["Audio3Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio3Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio4Bitrate"] - if hash["Audio4Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio4Bitrate"] - else - commandString << "," << "auto" - end - end + audioBitrates = "" + audioEncoders = "" + audioMixdowns = "" + audioSamplerates = "" + audioTracks = "" + audioTrackDRCs = "" + audioCount = hash["AudioList"].size + + hash["AudioList"].each do |audioTrack| + audioCount = audioCount - 1 - #Audio sample rate - commandString << " -R " - commandString << hash["Audio1Samplerate"] - if hash["Audio2Samplerate"] - commandString << "," << hash["Audio2Samplerate"] - end - if hash["Audio3Samplerate"] - commandString << "," << hash["Audio3Samplerate"] - end - if hash["Audio4Samplerate"] - commandString << "," << hash["Audio4Samplerate"] - end - - #Audio Mixdown - commandString << " -6 " - case hash["Audio1Mixdown"] - when /Mono/ - commandString << "mono" - when /Stereo/ - commandString << "stereo" - when /Dolby Surround/ - commandString << "dpl1" - when /Dolby Pro Logic II/ - commandString << "dpl2" - when /discrete/ - commandString << "6ch" - when /Passthru/ - commandString << "auto" - end - - if hash["Audio2Mixdown"] - case hash["Audio2Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + #Bitrates + audioBitrates << audioTrack["AudioBitrate"] + + #Encoders + case audioTrack["AudioEncoder"] + when /AC3 / + audioEncoders << "ac3" + when /AAC/ + audioEncoders << "faac" + when /Vorbis/ + audioEncoders << "vorbis" + when /MP3/ + audioEncoders << "lame" end - end - - if hash["Audio3Mixdown"] - case hash["Audio3Mixdown"] + + #Mixdowns + case audioTrack["AudioMixdown"] when /Mono/ - commandString << ",mono" + audioMixdowns << "mono" when /Stereo/ - commandString << ",stereo" + audioMixdowns << "stereo" when /Dolby Surround/ - commandString << ",dpl1" + audioMixdowns << "dpl1" when /Dolby Pro Logic II/ - commandString << ",dpl2" + audioMixdowns << "dpl2" when /discrete/ - commandString << ",6ch" + audioMixdowns << "6ch" when /Passthru/ - commandString << ",auto" + audioMixdowns << "auto" end - end - - if hash["Audio4Mixdown"] - case hash["Audio4Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + + #Samplerates + audioSamplerates << audioTrack["AudioSamplerate"] + + #Tracks + audioTracks << audioTrack["AudioTrack"].to_s + + #DRC + audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s + + if audioCount > 0 + audioBitrates << "," + audioEncoders << "," + audioMixdowns << "," + audioSamplerates << "," + audioTracks << "," + audioTrackDRCs << "," end + end - + commandString << " -a " << audioTracks + commandString << " -E " << audioEncoders + commandString << " -B " << audioBitrates + commandString << " -6 " << audioMixdowns + commandString << " -R " << audioSamplerates + commandString << " -D " << audioTrackDRCs + #Container commandString << " -f " case hash["FileFormat"] when /MP4/ commandString << "mp4" - when /AVI/ - commandString << "avi" - when /OGM/ - commandString << "ogm" when /MKV/ commandString << "mkv" end @@ -495,72 +397,85 @@ class Display end # 64-bit files - if hash["Mp4LargeFile"].to_i == 1 + if hash["Mp4LargeFile"] == 1 commandString << " -4" end #Cropping - if !hash["PictureAutoCrop"].to_i + if hash["PictureAutoCrop"] == 0 commandString << " --crop " - commandString << hash["PictureTopCrop"] + commandString << hash["PictureTopCrop"].to_s commandString << ":" - commandString << hash["PictureBottomCrop"] + commandString << hash["PictureBottomCrop"].to_s commandString << ":" - commandString << hash["PictureLeftCrop"] + commandString << hash["PictureLeftCrop"].to_s commandString << ":" - commandString << hash["PictureRightCrop"] + commandString << hash["PictureRightCrop"].to_s end #Dimensions - if hash["PictureWidth"].to_i != 0 - commandString << " -w " - commandString << hash["PictureWidth"] + if hash["PictureWidth"] != 0 + commandString << " -X " + commandString << hash["PictureWidth"].to_s end - if hash["PictureHeight"].to_i != 0 - commandString << " -l " - commandString << hash["PictureHeight"] + if hash["PictureHeight"] != 0 + commandString << " -Y " + commandString << hash["PictureHeight"].to_s end #Subtitles - if hash["Subtitles"] != "None" - commandString << " -s " - commandString << hash["Subtitles"] + if hash["Subtitles"] && hash["Subtitles"] != "None" + if hash["Subtitles"] == "Autoselect" + commandString << " --subtitle-scan" + else + commandString << " -s " + commandString << hash["Subtitles"] + end end #Video Filters - if hash["UsesPictureFilters"].to_i == 1 + if hash["UsesPictureFilters"] == 1 - case hash["PictureDeinterlace"].to_i - when 1 - commandString << " --deinterlace=\"fast\"" + case hash["PictureDeinterlace"] when 2 - commandString << " --deinterlace=\slow\"" + commandString << " --deinterlace=\"fast\"" when 3 - commandString << " --deinterlace=\"slower\"" + commandString << " --deinterlace=\slow\"" when 4 + commandString << " --deinterlace=\"slower\"" + when 5 commandString << " --deinterlace=\"slowest\"" end - case hash["PictureDenoise"].to_i - when 1 - commandString << " --denoise=\"weak\"" + case hash["PictureDenoise"] when 2 - commandString << " --denoise=\"medium\"" + commandString << " --denoise=\"weak\"" when 3 + commandString << " --denoise=\"medium\"" + when 4 commandString << " --denoise=\"strong\"" end - if hash["PictureDetelecine"].to_i == 1 then commandString << " --detelecine" end - if hash["PictureDeblock"].to_i == 1 then commandString << " --deblock" end - if hash["VFR"].to_i == 1 then commandString << " --vfr" end + if hash["PictureDetelecine"] == 2 then commandString << " --detelecine" end + if hash["PictureDeblock"] != 0 then commandString << " --deblock=" << hash["PictureDeblock"].to_s end + if hash["PictureDecomb"] == 2 then commandString << " --decomb" end + + end + + #Anamorphic + if hash["PicturePAR"] == 1 + commandString << " --strict-anamorphic" + elsif hash["PicturePAR"] == 2 + commandString << " --loose-anamorphic" + elsif hash["PicturePAR"] == 3 + commandString << " --custom-anamorphic" end #Booleans - if hash["ChapterMarkers"].to_i == 1 then commandString << " -m" end - if hash["PicturePAR"].to_i == 1 then commandString << " -p" end - if hash["VideoGrayScale"].to_i == 1 then commandString << " -g" end - if hash["VideoTwoPass"].to_i == 1 then commandString << " -2" end - if hash["VideoTurboTwoPass"].to_i == 1 then commandString << " -T" end + if hash["ChapterMarkers"] == 1 then commandString << " -m" end + if hash["VideoGrayScale"] == 1 then commandString << " -g" end + if hash["VideoTwoPass"] == 1 then commandString << " -2" end + if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end #x264 Options if hash["x264Option"] != "" @@ -575,9 +490,36 @@ class Display puts "\n" end - - def generateCLIParse(hash) # Makes a CLI equivalent of all user presets, for wrappers to parse + + def generateCLIFolderParse( hash, depth ) # Shows the folder for wrappers to parse + commandString = "" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << "<" + end + commandString << " " << hash["PresetName"] << "\n\n" + puts commandString + end + + def generateCLIFolderCloserParse( depth ) + commandString = "" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << ">" + end + commandString << "\n\n" + puts commandString + end + + def generateCLIParse(hash, depth) # Makes a CLI equivalent of all user presets, for wrappers to parse commandString = "" + depth.times do + commandString << " " + end commandString << '+ ' << hash["PresetName"] << ":" #Video encoder @@ -586,19 +528,19 @@ class Display case hash["VideoEncoder"] when /x264/ commandString << "x264" - when /XviD/ - commandString << "xvid" + when /Theora/ + commandString << "theora" end end #VideoRateControl - case hash["VideoQualityType"].to_i + case hash["VideoQualityType"] when 0 commandString << " -S " << hash["VideoTargetSize"] when 1 commandString << " -b " << hash["VideoAvgBitrate"] when 2 - commandString << " -q " << hash["VideoQualitySlider"] + commandString << " -q " << hash["VideoQualitySlider"].to_s end #FPS @@ -607,183 +549,87 @@ class Display commandString << " -r " << "23.976" elsif hash["VideoFramerate"] == "29.97 (NTSC Video)" commandString << " -r " << "29.97" + elsif hash["VideoFramerate"] == "25 (PAL Film/Video)" + commandString << " -r " << "25" else commandString << " -r " << hash["VideoFramerate"] end end #Audio tracks - commandString << " -a " - commandString << hash["Audio1Track"] - if hash["Audio2Track"] - commandString << "," << hash["Audio2Track"] - end - if hash["Audio3Track"] - commandString << "," << hash["Audio3Track"] - end - if hash["Audio4Track"] - commandString << "," << hash["Audio4Track"] - end - - #Audio encoders - commandString << " -E " - case hash["Audio1Encoder"] - when /AC3/ - commandString << "ac3" - when /AAC/ - commandString << "faac" - when /Vorbis/ - commandString << "vorbis" - when /MP3/ - commandString << "lame" - end - case hash["Audio2Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio3Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio4Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - - #Audio bit rate - commandString << " -B " - commandString << hash["Audio1Bitrate"] - if hash["Audio2Bitrate"] - if hash["Audio2Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio2Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio3Bitrate"] - if hash["Audio3Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio3Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio4Bitrate"] - if hash["Audio4Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio4Bitrate"] - else - commandString << "," << "auto" - end - end + audioBitrates = "" + audioEncoders = "" + audioMixdowns = "" + audioSamplerates = "" + audioTracks = "" + audioTrackDRCs = "" + audioCount = hash["AudioList"].size + + hash["AudioList"].each do |audioTrack| + audioCount = audioCount - 1 - #Audio sample rate - commandString << " -R " - commandString << hash["Audio1Samplerate"] - if hash["Audio2Samplerate"] - commandString << "," << hash["Audio2Samplerate"] - end - if hash["Audio3Samplerate"] - commandString << "," << hash["Audio3Samplerate"] - end - if hash["Audio4Samplerate"] - commandString << "," << hash["Audio4Samplerate"] - end - - #Audio Mixdown - commandString << " -6 " - case hash["Audio1Mixdown"] - when /Mono/ - commandString << "mono" - when /Stereo/ - commandString << "stereo" - when /Dolby Surround/ - commandString << "dpl1" - when /Dolby Pro Logic II/ - commandString << "dpl2" - when /discrete/ - commandString << "6ch" - when /Passthru/ - commandString << "auto" - end - - if hash["Audio2Mixdown"] - case hash["Audio2Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + #Bitrates + audioBitrates << audioTrack["AudioBitrate"] + + #Encoders + case audioTrack["AudioEncoder"] + when /AC3 / + audioEncoders << "ac3" + when /AAC/ + audioEncoders << "faac" + when /Vorbis/ + audioEncoders << "vorbis" + when /MP3/ + audioEncoders << "lame" end - end - - if hash["Audio3Mixdown"] - case hash["Audio3Mixdown"] + + #Mixdowns + case audioTrack["AudioMixdown"] when /Mono/ - commandString << ",mono" + audioMixdowns << "mono" when /Stereo/ - commandString << ",stereo" + audioMixdowns << "stereo" when /Dolby Surround/ - commandString << ",dpl1" + audioMixdowns << "dpl1" when /Dolby Pro Logic II/ - commandString << ",dpl2" + audioMixdowns << "dpl2" when /discrete/ - commandString << ",6ch" + audioMixdowns << "6ch" when /Passthru/ - commandString << ",auto" + audioMixdowns << "auto" end - end - - if hash["Audio4Mixdown"] - case hash["Audio4Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + + #Samplerates + audioSamplerates << audioTrack["AudioSamplerate"] + + #Tracks + audioTracks << audioTrack["AudioTrack"].to_s + + #DRC + audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s + + if audioCount > 0 + audioBitrates << "," + audioEncoders << "," + audioMixdowns << "," + audioSamplerates << "," + audioTracks << "," + audioTrackDRCs << "," end + end - + commandString << " -a " << audioTracks + commandString << " -E " << audioEncoders + commandString << " -B " << audioBitrates + commandString << " -6 " << audioMixdowns + commandString << " -R " << audioSamplerates + commandString << " -D " << audioTrackDRCs #Container commandString << " -f " case hash["FileFormat"] when /MP4/ commandString << "mp4" - when /AVI/ - commandString << "avi" - when /OGM/ - commandString << "ogm" when /MKV/ commandString << "mkv" end @@ -794,72 +640,84 @@ class Display end # 64-bit files - if hash["Mp4LargeFile"].to_i == 1 + if hash["Mp4LargeFile"] == 1 commandString << " -4" end #Cropping - if !hash["PictureAutoCrop"].to_i + if hash["PictureAutoCrop"] == 0 commandString << " --crop " - commandString << hash["PictureTopCrop"] + commandString << hash["PictureTopCrop"].to_s commandString << ":" - commandString << hash["PictureBottomCrop"] + commandString << hash["PictureBottomCrop"].to_s commandString << ":" - commandString << hash["PictureLeftCrop"] + commandString << hash["PictureLeftCrop"].to_s commandString << ":" - commandString << hash["PictureRightCrop"] + commandString << hash["PictureRightCrop"].to_s end #Dimensions - if hash["PictureWidth"].to_i != 0 - commandString << " -w " - commandString << hash["PictureWidth"] + if hash["PictureWidth"] != 0 + commandString << " -X " + commandString << hash["PictureWidth"].to_s end - if hash["PictureHeight"].to_i != 0 - commandString << " -l " - commandString << hash["PictureHeight"] + if hash["PictureHeight"] != 0 + commandString << " -Y " + commandString << hash["PictureHeight"].to_s end #Subtitles - if hash["Subtitles"] != "None" - commandString << " -s " - commandString << hash["Subtitles"] + if hash["Subtitles"] && hash["Subtitles"] != "None" + if hash["Subtitles"] == "Autoselect" + commandString << " --subtitle-scan" + else + commandString << " -s " + commandString << hash["Subtitles"] + end end #Video Filters - if hash["UsesPictureFilters"].to_i == 1 + if hash["UsesPictureFilters"] == 1 - case hash["PictureDeinterlace"].to_i - when 1 - commandString << " --deinterlace=\"fast\"" + case hash["PictureDeinterlace"] when 2 - commandString << " --deinterlace=\slow\"" + commandString << " --deinterlace=\"fast\"" when 3 - commandString << " --deinterlace=\"slower\"" + commandString << " --deinterlace=\slow\"" when 4 + commandString << " --deinterlace=\"slower\"" + when 5 commandString << " --deinterlace=\"slowest\"" end - case hash["PictureDenoise"].to_i - when 1 - commandString << " --denoise=\"weak\"" + case hash["PictureDenoise"] when 2 - commandString << " --denoise=\"medium\"" + commandString << " --denoise=\"weak\"" when 3 + commandString << " --denoise=\"medium\"" + when 4 commandString << " --denoise=\"strong\"" end - if hash["PictureDetelecine"].to_i == 1 then commandString << " --detelecine" end - if hash["PictureDeblock"].to_i == 1 then commandString << " --deblock" end - if hash["VFR"].to_i == 1 then commandString << " --vfr" end + if hash["PictureDetelecine"] == 2 then commandString << " --detelecine" end + if hash["PictureDeblock"] != 0 then commandString << " --deblock=" << hash["PictureDeblock"].to_s end + if hash["PictureDecomb"] == 2 then commandString << " --decomb" end end + #Anamorphic + if hash["PicturePAR"] == 1 + commandString << " --strict-anamorphic" + elsif hash["PicturePAR"] == 2 + commandString << " --loose-anamorphic" + elsif hash["PicturePAR"] == 3 + commandString << " --custom-anamorphic" + end + #Booleans - if hash["ChapterMarkers"].to_i == 1 then commandString << " -m" end - if hash["PicturePAR"].to_i == 1 then commandString << " -p" end - if hash["VideoGrayScale"].to_i == 1 then commandString << " -g" end - if hash["VideoTwoPass"].to_i == 1 then commandString << " -2" end - if hash["VideoTurboTwoPass"].to_i == 1 then commandString << " -T" end + if hash["ChapterMarkers"] == 1 then commandString << " -m" end + if hash["VideoGrayScale"] == 1 then commandString << " -g" end + if hash["VideoTwoPass"] == 1 then commandString << " -2" end + if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end #x264 Options if hash["x264Option"] != "" @@ -880,25 +738,25 @@ class Display commandString = "if (!strcmp(preset_name, \"" << hash["PresetName"] << "\"))\n{\n " #Filename suffix + commandString << "if( !mux )\n " + commandString << "{\n " + case hash["FileFormat"] when /MP4/ - commandString << "mux = " << "HB_MUX_MP4;\n " - when /AVI/ - commandString << "mux = " << "HB_MUX_AVI;\n " - when /OGM/ - commandString << "mux = " << "HB_MUX_OGM;\n " + commandString << " mux = " << "HB_MUX_MP4;\n " when /MKV/ - commandString << "mux = " << "HB_MUX_MKV;\n " + commandString << " mux = " << "HB_MUX_MKV;\n " end + commandString << "}\n " #iPod MP4 atom if hash["Mp4iPodCompatible"].to_i == 1 - commandString << "job->ipod_atom = 1;\n " + commandString << "job->ipod_atom = 1;\n " end # 64-bit files - if hash["Mp4LargeFile"].to_i == 1 - commandString << "job->largeFileSize = 1;\n" + if hash["Mp4LargeFile"] == 1 + commandString << "job->largeFileSize = 1;\n " end #Video encoder @@ -907,20 +765,19 @@ class Display case hash["VideoEncoder"] when /x264/ commandString << "HB_VCODEC_X264;\n " - when /XviD/ - commandString << "HB_VCODEC_XVID;\n " + when /Theora/ + commandString << "HB_VCODEC_THEORA;\n " end end #VideoRateControl - case hash["VideoQualityType"].to_i + case hash["VideoQualityType"] when 0 commandString << "size = " << hash["VideoTargetSize"] << ";\n " when 1 commandString << "job->vbitrate = " << hash["VideoAvgBitrate"] << ";\n " when 2 - commandString << "job->vquality = " << hash["VideoQualitySlider"] << ";\n " - commandString << "job->crf = 1;\n " + commandString << "job->vquality = " << hash["VideoQualitySlider"].to_s << ";\n " end #FPS @@ -929,251 +786,203 @@ class Display commandString << "job->vrate_base = " << "1126125;\n " elsif hash["VideoFramerate"] == "29.97 (NTSC Video)" commandString << "job->vrate_base = " << "900900;\n " + elsif hash["VideoFramerate"] == "25 (PAL Film/Video)" + commandString << "job->vrate_base = " << "1080000\n " # Gotta add the rest of the framerates for completion's sake. end commandString << "job->cfr = 1;\n " end #Audio tracks - commandString << "atracks = \"" - commandString << hash["Audio1Track"] - if hash["Audio2Track"] - commandString << "," << hash["Audio2Track"] - end - if hash["Audio3Track"] - commandString << "," << hash["Audio3Track"] - end - if hash["Audio4Track"] - commandString << "," << hash["Audio4Track"] - end - commandString << "\";\n " - - # Audio bitrate - commandString << "abitrates = \"" - if hash["Audio1Encoder"] != "AC3 Passthru" - commandString << hash["Audio1Bitrate"] - else - commandString << "auto" - end - if hash["Audio2Bitrate"] - if hash["Audio2Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio2Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio3Bitrate"] - if hash["Audio3Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio3Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio4Bitrate"] - if hash["Audio4Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio4Bitrate"] - else - commandString << "," << "auto" - end - end - commandString << "\";\n " - - #Audio samplerate - commandString << "arates = \"" - commandString << hash["Audio1Samplerate"] - if hash["Audio2Samplerate"] - commandString << "," << hash["Audio2Samplerate"] - end - if hash["Audio3Samplerate"] - commandString << "," << hash["Audio3Samplerate"] - end - if hash["Audio4Samplerate"] - commandString << "," << hash["Audio4Samplerate"] - end - commandString << "\";\n " - - #Audio encoder - commandString << "acodecs = \"" - case hash["Audio1Encoder"] - when /AC3/ - commandString << "ac3" - when /AAC/ - commandString << "faac" - when /Vorbis/ - commandString << "vorbis" - when /MP3/ - commandString << "lame" - end - case hash["Audio2Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio3Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio4Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - commandString << "\";\n " - - #Audio mixdowns - commandString << "mixdowns = \"" - case hash["Audio1Mixdown"] - when /Mono/ - commandString << "mono" - when /Stereo/ - commandString << "stereo" - when /Dolby Surround/ - commandString << "dpl1" - when /Dolby Pro Logic II/ - commandString << "dpl2" - when /discrete/ - commandString << "6ch" - when /Passthru/ - commandString << "auto" - end - if hash["Audio2Mixdown"] - case hash["Audio2Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + audioBitrates = "" + audioEncoders = "" + audioMixdowns = "" + audioSamplerates = "" + audioTracks = "" + audioTrackDRCs = "" + audioCount = hash["AudioList"].size + + hash["AudioList"].each do |audioTrack| + audioCount = audioCount - 1 + + #Bitrates + audioBitrates << audioTrack["AudioBitrate"] + + #Encoders + case audioTrack["AudioEncoder"] + when /AC3 / + audioEncoders << "ac3" + when /AAC/ + audioEncoders << "faac" + when /Vorbis/ + audioEncoders << "vorbis" + when /MP3/ + audioEncoders << "lame" end - end - if hash["Audio3Mixdown"] - case hash["Audio3Mixdown"] + + #Mixdowns + case audioTrack["AudioMixdown"] when /Mono/ - commandString << ",mono" + audioMixdowns << "mono" when /Stereo/ - commandString << ",stereo" + audioMixdowns << "stereo" when /Dolby Surround/ - commandString << ",dpl1" + audioMixdowns << "dpl1" when /Dolby Pro Logic II/ - commandString << ",dpl2" + audioMixdowns << "dpl2" when /discrete/ - commandString << ",6ch" + audioMixdowns << "6ch" when /Passthru/ - commandString << ",auto" + audioMixdowns << "auto" end - end - if hash["Audio4Mixdown"] - case hash["Audio4Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + + #Samplerates + audioSamplerates << audioTrack["AudioSamplerate"] + + #Tracks + audioTracks << audioTrack["AudioTrack"].to_s + + #DRC + audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s + + if audioCount > 0 + audioBitrates << "," + audioEncoders << "," + audioMixdowns << "," + audioSamplerates << "," + audioTracks << "," + audioTrackDRCs << "," end + end - commandString << "\";\n " + commandString << "if( !atracks )\n " + commandString << "{\n " + commandString << " atracks = strdup(\"" << audioTracks + commandString << "\");\n " + commandString << "}\n " + + commandString << "if( !acodecs )\n " + commandString << "{\n " + commandString << " acodecs = strdup(\"" << audioEncoders + commandString << "\");\n " + commandString << "}\n " + + commandString << "if( !abitrates )\n " + commandString << "{\n " + commandString << " abitrates = strdup(\"" << audioBitrates + commandString << "\");\n " + commandString << "}\n " + + commandString << "if( !mixdowns )\n " + commandString << "{\n " + commandString << " mixdowns = strdup(\"" << audioMixdowns + commandString << "\");\n " + commandString << "}\n " + + commandString << "if( !arates )\n " + commandString << "{\n " + commandString << " arates = strdup(\"" << audioSamplerates + commandString << "\");\n " + commandString << "}\n " + + commandString << "if( !dynamic_range_compression )\n " + commandString << "{\n " + commandString << " dynamic_range_compression = strdup(\"" << audioTrackDRCs + commandString << "\");\n " + commandString << "}\n " #Cropping - if !hash["PictureAutoCrop"].to_i - commandString << "job->crop[0] = " << hash["PictureTopCrop"] << ";\n " - commandString << "job->crop[1] = " << hash["PictureBottomCrop"] << ";\n " - commandString << "job->crop[2] = " << hash["PictureLeftCrop"] << ";\n " - commandString << "job->crop[4] - " << hash["PictureRightCrop"] << ";\n " + if hash["PictureAutoCrop"] == 0 + commandString << "job->crop[0] = " << hash["PictureTopCrop"].to_s << ";\n " + commandString << "job->crop[1] = " << hash["PictureBottomCrop"].to_s << ";\n " + commandString << "job->crop[2] = " << hash["PictureLeftCrop"].to_s << ";\n " + commandString << "job->crop[4] = " << hash["PictureRightCrop"].to_s << ";\n " end #Dimensions - if hash["PictureWidth"].to_i != 0 - commandString << "job->width = " - commandString << hash["PictureWidth"] << ";\n " + if hash["PictureWidth"] != 0 + commandString << "maxWidth = " + commandString << hash["PictureWidth"].to_s << ";\n " end - if hash["PictureHeight"].to_i != 0 - commandString << "job->height = " - commandString << hash["PictureHeight"] << ";\n " + if hash["PictureHeight"] != 0 + commandString << "maxHeight = " + commandString << hash["PictureHeight"].to_s << ";\n " end #Subtitles if hash["Subtitles"] != "None" - commandString << "job->subtitle = " - commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n " + if hash["Subtitles"] == "Autoselect" + commandString << "subtitle_scan = 1;\n " + else + commandString << "job->subtitle = " + commandString << ( hash["Subtitles"].to_i - 1).to_s << ";\n " + end end #x264 Options if hash["x264Option"] != "" - commandString << "x264opts = strdup(\"" + commandString << "if( !x264opts )\n " + commandString << "{\n " + commandString << " x264opts = strdup(\"" commandString << hash["x264Option"] << "\");\n " + commandString << "}\n " end #Video Filters - if hash["UsesPictureFilters"].to_i == 1 + if hash["UsesPictureFilters"] == 1 - case hash["PictureDeinterlace"].to_i - when 1 + case hash["PictureDeinterlace"] + when 2 commandString << "deinterlace = 1;\n " commandString << "deinterlace_opt = \"-1\";\n " - when 2 + when 3 commandString << "deinterlace = 1;\n " commandString << "deinterlace_opt = \"2\";\n " - when 3 + when 4 commandString << "deinterlace = 1;\n " commandString << "deinterlace_opt = \"0\";\n " - when 4 + when 5 commandString << "deinterlace = 1;\n " commandString << "deinterlace_opt = \"1:-1:1\";\n " end - case hash["PictureDenoise"].to_i - when 1 + case hash["PictureDenoise"] + when 2 commandString << "denoise = 1;\n " commandString << "denoise_opt = \"2:1:2:3\";\n " - when 2 + when 3 commandString << "denoise = 1;\n " commandString << "denoise_opt = \"3:2:2:3\";\n " - when 3 + when 4 commandString << "denoise = 1;\n " commandString << "denoise_opt = \"7:7:5:5\";\n " end - if hash["PictureDetelecine"].to_i == 1 then commandString << "detelecine = 1;\n " end - if hash["PictureDeblock"].to_i == 1 then commandString << "deblock = 1;\n " end - if hash["VFR"].to_i == 1 then commandString << "vfr = 1;\n " end + if hash["PictureDetelecine"] == 2 then commandString << "detelecine = 1;\n " end + if hash["PictureDeblock"] != 0 + then + commandString << "deblock = 1;\n " + commandString << "deblock_opt = \"" << hash["PictureDeblock"].to_s << "\";\n " + end + if hash["PictureDecomb"] == 2 then commandString << "decomb = 1;\n " end + end - #Booleans - if hash["ChapterMarkers"].to_i == 1 then commandString << "job->chapter_markers = 1;\n " end - if hash["PicturePAR"].to_i == 1 then commandString << "pixelratio = 1;\n " end - if hash["VideoGrayScale"].to_i == 1 then commandString << "job->grayscale = 1;\n " end - if hash["VideoTwoPass"].to_i == 1 then commandString << "twoPass = 1;\n " end - if hash["VideoTurboTwoPass"].to_i == 1 then commandString << "turbo_opts_enabled = 1;\n" end + #Anamorphic + if hash["PicturePAR"] == 1 + commandString << "anamorphic_mode = 1;\n " + elsif hash["PicturePAR"] == 2 + commandString << "anamorphic_mode = 2;\n " + elsif hash["PicturePAR"] == 3 + commandString << "anamorphic_mode = 3;\n " + end + #Booleans + if hash["ChapterMarkers"] == 1 then commandString << "job->chapter_markers = 1;\n " end + if hash["VideoGrayScale"] == 1 then commandString << "job->grayscale = 1;\n " end + if hash["VideoTwoPass"] == 1 then commandString << "twoPass = 1;\n " end + if hash["VideoTurboTwoPass"] == 1 then commandString << "turbo_opts_enabled = 1;\n" end + commandString << "\n" commandString << "}" # That's it, print to screen now @@ -1181,10 +990,44 @@ class Display #puts "*" * @columnWidth puts "\n" end - - def generateAPIList(hash) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse + + def generateAPIFolderList( hash, depth ) + commandString = "" + + commandString << " printf(\"\\n" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << "<" + end + commandString << " " << hash["PresetName"] + commandString << "\\n\");\n\n" + puts commandString + end + + def generateAPIFolderCloserList( depth ) commandString = "" - commandString << " printf(\"\\n+ " << hash["PresetName"] << ": " + + commandString << " printf(\"\\n" + depth.times do + commandString << " " + end + (depth+1).times do + commandString << ">" + end + commandString << "\\n\");\n\n" + puts commandString + end + + def generateAPIList(hash, depth) # Makes a list of the CLI options a built-in CLI preset uses, for wrappers to parse + commandString = "" + commandString << " printf(\"\\n" + depth.times do + commandString << " " + end + + commandString << "+ " << hash["PresetName"] << ": " #Video encoder if hash["VideoEncoder"] != "MPEG-4 (FFmpeg)" @@ -1192,19 +1035,19 @@ class Display case hash["VideoEncoder"] when /x264/ commandString << "x264 " - when /XviD/ - commandString << "xvid " + when /Theora/ + commandString << "theora " end end #VideoRateControl - case hash["VideoQualityType"].to_i + case hash["VideoQualityType"] when 0 commandString << " -S " << hash["VideoTargetSize"] when 1 commandString << " -b " << hash["VideoAvgBitrate"] when 2 - commandString << " -q " << hash["VideoQualitySlider"] + commandString << " -q " << hash["VideoQualitySlider"].to_s end #FPS @@ -1213,182 +1056,87 @@ class Display commandString << " -r " << "23.976" elsif hash["VideoFramerate"] == "29.97 (NTSC Video)" commandString << " -r " << "29.97" + elsif hash["VideoFramerate"] == "25 (PAL Film/Video)" + commandString << " -r " << "25" else commandString << " -r " << hash["VideoFramerate"] end end #Audio tracks - commandString << " -a " - commandString << hash["Audio1Track"] - if hash["Audio2Track"] - commandString << "," << hash["Audio2Track"] - end - if hash["Audio3Track"] - commandString << "," << hash["Audio3Track"] - end - if hash["Audio4Track"] - commandString << "," << hash["Audio4Track"] - end - - #Audio encoders - commandString << " -E " - case hash["Audio1Encoder"] - when /AC3/ - commandString << "ac3" - when /AAC/ - commandString << "faac" - when /Vorbis/ - commandString << "vorbis" - when /MP3/ - commandString << "lame" - end - case hash["Audio2Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio3Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end - case hash["Audio4Encoder"] - when /AC3 / - commandString << ",ac3" - when /AAC/ - commandString << ",faac" - when /Vorbis/ - commandString << ",vorbis" - when /MP3/ - commandString << ",lame" - end + audioBitrates = "" + audioEncoders = "" + audioMixdowns = "" + audioSamplerates = "" + audioTracks = "" + audioTrackDRCs = "" + audioCount = hash["AudioList"].size + + hash["AudioList"].each do |audioTrack| + audioCount = audioCount - 1 - #Audio bit rate - commandString << " -B " - commandString << hash["Audio1Bitrate"] - if hash["Audio2Bitrate"] - if hash["Audio2Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio2Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio3Bitrate"] - if hash["Audio3Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio3Bitrate"] - else - commandString << "," << "auto" - end - end - if hash["Audio4Bitrate"] - if hash["Audio4Encoder"] != "AC3 Passthru" - commandString << "," << hash["Audio4Bitrate"] - else - commandString << "," << "auto" - end - end - - #Audio sample rate - commandString << " -R " - commandString << hash["Audio1Samplerate"] - if hash["Audio2Samplerate"] - commandString << "," << hash["Audio2Samplerate"] - end - if hash["Audio3Samplerate"] - commandString << "," << hash["Audio3Samplerate"] - end - if hash["Audio4Samplerate"] - commandString << "," << hash["Audio4Samplerate"] - end - - #Audio Mixdown - commandString << " -6 " - case hash["Audio1Mixdown"] - when /Mono/ - commandString << "mono" - when /Stereo/ - commandString << "stereo" - when /Dolby Surround/ - commandString << "dpl1" - when /Dolby Pro Logic II/ - commandString << "dpl2" - when /discrete/ - commandString << "6ch" - when /Passthru/ - commandString << "auto" - end - - if hash["Audio2Mixdown"] - case hash["Audio2Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + #Bitrates + audioBitrates << audioTrack["AudioBitrate"] + + #Encoders + case audioTrack["AudioEncoder"] + when /AC3 / + audioEncoders << "ac3" + when /AAC/ + audioEncoders << "faac" + when /Vorbis/ + audioEncoders << "vorbis" + when /MP3/ + audioEncoders << "lame" end - end - - if hash["Audio3Mixdown"] - case hash["Audio3Mixdown"] + + #Mixdowns + case audioTrack["AudioMixdown"] when /Mono/ - commandString << ",mono" + audioMixdowns << "mono" when /Stereo/ - commandString << ",stereo" + audioMixdowns << "stereo" when /Dolby Surround/ - commandString << ",dpl1" + audioMixdowns << "dpl1" when /Dolby Pro Logic II/ - commandString << ",dpl2" + audioMixdowns << "dpl2" when /discrete/ - commandString << ",6ch" + audioMixdowns << "6ch" when /Passthru/ - commandString << ",auto" + audioMixdowns << "auto" end - end - - if hash["Audio4Mixdown"] - case hash["Audio4Mixdown"] - when /Mono/ - commandString << ",mono" - when /Stereo/ - commandString << ",stereo" - when /Dolby Surround/ - commandString << ",dpl1" - when /Dolby Pro Logic II/ - commandString << ",dpl2" - when /discrete/ - commandString << ",6ch" - when /Passthru/ - commandString << ",auto" + + #Samplerates + audioSamplerates << audioTrack["AudioSamplerate"] + + #Tracks + audioTracks << audioTrack["AudioTrack"].to_s + + #DRC + audioTrackDRCs << audioTrack["AudioTrackDRCSlider"].to_s + + if audioCount > 0 + audioBitrates << "," + audioEncoders << "," + audioMixdowns << "," + audioSamplerates << "," + audioTracks << "," + audioTrackDRCs << "," end + end + commandString << " -a " << audioTracks + commandString << " -E " << audioEncoders + commandString << " -B " << audioBitrates + commandString << " -6 " << audioMixdowns + commandString << " -R " << audioSamplerates + commandString << " -D " << audioTrackDRCs #Container commandString << " -f " case hash["FileFormat"] when /MP4/ commandString << "mp4" - when /AVI/ - commandString << "avi" - when /OGM/ - commandString << "ogm" when /MKV/ commandString << "mkv" end @@ -1399,72 +1147,84 @@ class Display end # 64-bit files - if hash["Mp4LargeFile"].to_i == 1 + if hash["Mp4LargeFile"] == 1 commandString << " -4" end #Cropping - if !hash["PictureAutoCrop"].to_i + if hash["PictureAutoCrop"] == 0 commandString << " --crop " - commandString << hash["PictureTopCrop"] + commandString << hash["PictureTopCrop"].to_s commandString << ":" - commandString << hash["PictureBottomCrop"] + commandString << hash["PictureBottomCrop"].to_s commandString << ":" - commandString << hash["PictureLeftCrop"] + commandString << hash["PictureLeftCrop"].to_s commandString << ":" - commandString << hash["PictureRightCrop"] + commandString << hash["PictureRightCrop"].to_s end #Dimensions - if hash["PictureWidth"].to_i != 0 - commandString << " -w " - commandString << hash["PictureWidth"] + if hash["PictureWidth"] != 0 + commandString << " -X " + commandString << hash["PictureWidth"].to_s end - if hash["PictureHeight"].to_i != 0 - commandString << " -l " - commandString << hash["PictureHeight"] + if hash["PictureHeight"] != 0 + commandString << " -Y " + commandString << hash["PictureHeight"].to_s end #Subtitles - if hash["Subtitles"] != "None" - commandString << " -s " - commandString << hash["Subtitles"] + if hash["Subtitles"] && hash["Subtitles"] != "None" + if hash["Subtitles"] == "Autoselect" + commandString << " --subtitle-scan" + else + commandString << " -s " + commandString << hash["Subtitles"] + end end #Video Filters - if hash["UsesPictureFilters"].to_i == 1 + if hash["UsesPictureFilters"] == 1 - case hash["PictureDeinterlace"].to_i - when 1 - commandString << " --deinterlace=\\\"fast\\\"" + case hash["PictureDeinterlace"] when 2 - commandString << " --deinterlace=\\\slow\\\"" + commandString << " --deinterlace=\\\"fast\\\"" when 3 - commandString << " --deinterlace=\\\"slower\\\"" + commandString << " --deinterlace=\\\slow\\\"" when 4 + commandString << " --deinterlace=\\\"slower\\\"" + when 5 commandString << " --deinterlace=\\\"slowest\\\"" end - case hash["PictureDenoise"].to_i - when 1 - commandString << " --denoise=\\\"weak\\\"" + case hash["PictureDenoise"] when 2 - commandString << " --denoise=\\\"medium\\\"" + commandString << " --denoise=\\\"weak\\\"" when 3 + commandString << " --denoise=\\\"medium\\\"" + when 4 commandString << " --denoise=\\\"strong\\\"" end - if hash["PictureDetelecine"].to_i == 1 then commandString << " --detelecine" end - if hash["PictureDeblock"].to_i == 1 then commandString << " --deblock" end - if hash["VFR"].to_i == 1 then commandString << " --vfr" end + if hash["PictureDetelecine"] == 2 then commandString << " --detelecine" end + if hash["PictureDeblock"] != 0 then commandString << " --deblock=" << hash["PictureDeblock"].to_s end + if hash["PictureDecomb"] == 2 then commandString << " --decomb" end + end + + #Anamorphic + if hash["PicturePAR"] == 1 + commandString << " --strict-anamorphic" + elsif hash["PicturePAR"] == 2 + commandString << " --loose-anamorphic" + elsif hash["PicturePAR"] == 3 + commandString << " --custom-anamorphic" end #Booleans - if hash["ChapterMarkers"].to_i == 1 then commandString << " -m" end - if hash["PicturePAR"].to_i == 1 then commandString << " -p" end - if hash["VideoGrayScale"].to_i == 1 then commandString << " -g" end - if hash["VideoTwoPass"].to_i == 1 then commandString << " -2" end - if hash["VideoTurboTwoPass"].to_i == 1 then commandString << " -T" end + if hash["ChapterMarkers"] == 1 then commandString << " -m" end + if hash["VideoGrayScale"] == 1 then commandString << " -g" end + if hash["VideoTwoPass"] == 1 then commandString << " -2" end + if hash["VideoTurboTwoPass"] == 1 then commandString << " -T" end #x264 Options if hash["x264Option"] != "" @@ -1494,4 +1254,4 @@ else # Direct the user to the help puts "\n\tUsage: manicure.rb [options]" puts "\tSee help with -h or --help" -end \ No newline at end of file +end