OSDN Git Service

Scripts: Updates manicure to handle peak framerate.
[handbrake-jp/handbrake-jp-git.git] / scripts / manicure.rb
index 32ea30e..f808b27 100755 (executable)
@@ -275,10 +275,6 @@ class Display
     case hash["FileFormat"]
     when /MP4/
       commandString << "mp4 "
-    when /AVI/
-      commandString << "avi "
-    when /OGM/
-      commandString << "ogm "
     when /MKV/
       commandString << "mkv "
     end
@@ -289,8 +285,8 @@ class Display
       case hash["VideoEncoder"]
       when /x264/
         commandString << "x264"
-      when /XviD/
-        commandString << "xvid"
+      when /Theora/
+        commandString << "theora"
       end
     end
 
@@ -315,6 +311,10 @@ class Display
       else
         commandString << " -r " << hash["VideoFramerate"]
       end
+      
+      if hash["VideoFrameratePFR"] == 1
+        commandString << " --pfr "
+      end
     end
     
     #Audio tracks
@@ -391,10 +391,6 @@ class Display
     case hash["FileFormat"]
     when /MP4/
       commandString << "mp4"
-    when /AVI/
-      commandString << "avi"
-    when /OGM/
-      commandString << "ogm"
     when /MKV/
       commandString << "mkv"
     end
@@ -432,7 +428,7 @@ class Display
     end
     
     #Subtitles
-    if hash["Subtitles"] != "None"
+    if hash["Subtitles"] && hash["Subtitles"] != "None"
       if hash["Subtitles"] == "Autoselect"
         commandString << " --subtitle-scan"
       else
@@ -445,29 +441,28 @@ class Display
     if hash["UsesPictureFilters"] == 1
       
       case hash["PictureDeinterlace"]
-      when 1
-        commandString << " --deinterlace=\"fast\""
       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"]
-      when 1
-        commandString << " --denoise=\"weak\""
       when 2
-        commandString << " --denoise=\"medium\""
+        commandString << " --denoise=\"weak\""
       when 3
+        commandString << " --denoise=\"medium\""
+      when 4
         commandString << " --denoise=\"strong\""
       end
       
-      if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
-      if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
-      if hash["VFR"].to_i == 1 then commandString << " --vfr" end
-      if hash["PictureDecomb"] == 1 then commandString << " --decomb" 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
     
@@ -476,6 +471,8 @@ class Display
       commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
       commandString << " --loose-anamorphic"
+    elsif hash["PicturePAR"] == 3
+      commandString << " --custom-anamorphic"
     end
 
     #Booleans
@@ -535,8 +532,8 @@ class Display
       case hash["VideoEncoder"]
       when /x264/
         commandString << "x264"
-      when /XviD/
-        commandString << "xvid"
+      when /Theora/
+        commandString << "theora"
       end
     end
 
@@ -561,6 +558,10 @@ class Display
       else
         commandString << " -r " << hash["VideoFramerate"]
       end
+      
+      if hash["VideoFrameratePFR"] == 1
+        commandString << " --pfr "
+      end
     end
     
     #Audio tracks
@@ -637,10 +638,6 @@ class Display
     case hash["FileFormat"]
     when /MP4/
       commandString << "mp4"
-    when /AVI/
-      commandString << "avi"
-    when /OGM/
-      commandString << "ogm"
     when /MKV/
       commandString << "mkv"
     end
@@ -678,7 +675,7 @@ class Display
     end
     
     #Subtitles
-    if hash["Subtitles"] != "None"
+    if hash["Subtitles"] && hash["Subtitles"] != "None"
       if hash["Subtitles"] == "Autoselect"
         commandString << " --subtitle-scan"
       else
@@ -691,29 +688,28 @@ class Display
     if hash["UsesPictureFilters"] == 1
       
       case hash["PictureDeinterlace"]
-      when 1
-        commandString << " --deinterlace=\"fast\""
       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"]
-      when 1
-        commandString << " --denoise=\"weak\""
       when 2
-        commandString << " --denoise=\"medium\""
+        commandString << " --denoise=\"weak\""
       when 3
+        commandString << " --denoise=\"medium\""
+      when 4
         commandString << " --denoise=\"strong\""
       end
       
-      if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
-      if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
-      if hash["VFR"].to_i == 1 then commandString << " --vfr" end
-      if hash["PictureDecomb"] == 1 then commandString << " --decomb" 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
@@ -721,6 +717,8 @@ class Display
       commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
       commandString << " --loose-anamorphic"
+    elsif hash["PicturePAR"] == 3
+      commandString << " --custom-anamorphic"
     end
     
     #Booleans
@@ -754,10 +752,6 @@ class Display
     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    "
     when /MKV/
       commandString << "    mux = " << "HB_MUX_MKV;\n    "
     end
@@ -765,7 +759,7 @@ class Display
     
     #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
@@ -779,8 +773,8 @@ 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
 
@@ -792,7 +786,6 @@ class Display
       commandString << "job->vbitrate = " << hash["VideoAvgBitrate"] << ";\n    "
     when 2
       commandString << "job->vquality = " << hash["VideoQualitySlider"].to_s << ";\n    "
-      commandString << "job->crf = 1;\n    "
     end
 
     #FPS
@@ -805,7 +798,12 @@ class Display
         commandString << "job->vrate_base = " << "1080000\n    "
       # Gotta add the rest of the framerates for completion's sake.
       end
-      commandString << "job->cfr = 1;\n    "
+      
+      if hash["VideoFrameratePFR"] == 1
+        commandString << "job->cfr = 2;\n    "
+      else
+        commandString << "job->cfr = 1;\n    "
+      end
     end
     
     #Audio tracks
@@ -911,7 +909,7 @@ class Display
       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    "
+      commandString << "job->crop[4] = " << hash["PictureRightCrop"].to_s << ";\n    "
     end
     
     #Dimensions
@@ -947,44 +945,54 @@ class Display
     if hash["UsesPictureFilters"] == 1
       
       case hash["PictureDeinterlace"]
-      when 1
+      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"]
-      when 1
+      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"] == 1 then commandString << "detelecine = 1;\n    " end
-      if hash["PictureDeblock"] == 1 then commandString << "deblock = 1;\n    " end
-      if hash["VFR"].to_i == 1 then commandString << "vfr = 1;\n    " end
-      if hash["PictureDecomb"] == 1 then commandString << "decomb = 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
     
     #Anamorphic
-    if hash["PicturePAR"] == 1
-      commandString << "anamorphic_mode = 1;\n    "
-    elsif hash["PicturePAR"] == 2
-      commandString << "anamorphic_mode = 2;\n    "
+    if hash["PicturePAR"] != 0
+      commandString << "if( !anamorphic_mode )\n    "
+      commandString << "{\n    "
+      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
+      commandString << "}\n    "
     end
     
     #Booleans
@@ -992,7 +1000,7 @@ class Display
     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
@@ -1045,8 +1053,8 @@ class Display
       case hash["VideoEncoder"]
       when /x264/
         commandString << "x264 "
-      when /XviD/
-        commandString << "xvid "
+      when /Theora/
+        commandString << "theora "
       end
     end
 
@@ -1071,6 +1079,10 @@ class Display
       else
         commandString << " -r " << hash["VideoFramerate"]
       end
+      
+      if hash["VideoFrameratePFR"] == 1
+        commandString << " --pfr "
+      end
     end
     
     #Audio tracks
@@ -1147,10 +1159,6 @@ class Display
     case hash["FileFormat"]
     when /MP4/
       commandString << "mp4"
-    when /AVI/
-      commandString << "avi"
-    when /OGM/
-      commandString << "ogm"
     when /MKV/
       commandString << "mkv"
     end
@@ -1188,7 +1196,7 @@ class Display
     end
     
     #Subtitles
-    if hash["Subtitles"] != "None"
+    if hash["Subtitles"] && hash["Subtitles"] != "None"
       if hash["Subtitles"] == "Autoselect"
         commandString << " --subtitle-scan"
       else
@@ -1201,29 +1209,28 @@ class Display
     if hash["UsesPictureFilters"] == 1
       
       case hash["PictureDeinterlace"]
-      when 1
-        commandString << " --deinterlace=\\\"fast\\\""
       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"]
-      when 1
-        commandString << " --denoise=\\\"weak\\\""
       when 2
-        commandString << " --denoise=\\\"medium\\\""
+        commandString << " --denoise=\\\"weak\\\""
       when 3
+        commandString << " --denoise=\\\"medium\\\""
+      when 4
         commandString << " --denoise=\\\"strong\\\""
       end
       
-      if hash["PictureDetelecine"] == 1 then commandString << " --detelecine" end
-      if hash["PictureDeblock"] == 1 then commandString << " --deblock" end
-      if hash["VFR"].to_i == 1 then commandString << " --vfr" end
-      if hash["PictureDecomb"] == 1 then commandString << " --decomb" 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
@@ -1231,6 +1238,8 @@ class Display
       commandString << " --strict-anamorphic"
     elsif hash["PicturePAR"] == 2
       commandString << " --loose-anamorphic"
+    elsif hash["PicturePAR"] == 3
+      commandString << " --custom-anamorphic"
     end
     
     #Booleans
@@ -1267,4 +1276,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