bin/tracksperanto in tracksperanto-2.9.5 vs bin/tracksperanto in tracksperanto-2.9.6

- old
+ new

@@ -15,11 +15,11 @@ require 'rubygems' require 'progressbar' require "update_hints" def disclaimer - "Please consider a small donation to keep Tracksperanto going. http://guerilla-di.org/source-and-license/\n"+ + "Please consider a small donation to keep Tracksperanto going: http://guerilla-di.org/source-and-license/\n"+ "For information and support please contact info#{64.chr}guerilla-di.org" end options = {} $middlewares = [] @@ -27,17 +27,25 @@ readers = Tracksperanto.importer_names writers = Tracksperanto.exporter_names op = OptionParser.new -def mw(name, option, default_value = nil) +def mw(*name_option_and_default_value) Proc.new do |value| + name, option, default_value = name_option_and_default_value v = value.nil? ? default_value : value - $middlewares.push([name, {option => v}]) + mw_tuple = [name] + mw_tuple.push({option => v}) if option + + $middlewares.push(mw_tuple) end end +def mwd(name) + Tracksperanto.get_middleware(name).action_description +end + def list_exporters(dest = $stderr) dest.puts "The following export modules are available:" Tracksperanto.exporters.each do | exporter | dest.puts "\t#{exporter.const_name.downcase.inspect} - #{exporter.human_name}" end @@ -64,36 +72,39 @@ op.on(" -f", "--from TRANSLATOR", String, "Use the specific import translator") { |f| options[:importer] = f } op.on(" -w", "--width WIDTH_IN_PIXELS", Integer, "Absolute input comp width in pixels (will try to autodetect)") { |w| options[:width] = w } op.on(" -h", "--height HEIGHT_IN_PIXELS", Integer, "Absolute input comp height in pixels (will try to autodetect)") {|w| options[:height] = w } op.on(" -o", "--only EXPORTER_NAME", String, "Only export the selected format, format must be one of #{writers.join(", ")}") { |f| writer_class_name = f } -op.on(" -xs", "--xscale X_SCALING_FACTOR", Float, "Scale the result in X by this factor (1.0 is the default)", &mw("Scaler", :x_factor)) +op.on(" -xs", "--xscale X_SCALING_FACTOR", Float, mwd("Scaler"), &mw("Scaler", :x_factor)) -op.on(" -pad", "--pad PAD_FRACTION_VALUES_COMMA_SEPARATED", String, "Pad the comp by these ratios") do | pads| +op.on(" -pad", "--pad PAD_FRACTION_VALUES_COMMA_SEPARATED", String, mwd("Pad")) do | pads| left, right, top, bottom = pads.split(",").map{|e| e.to_f } $middlewares.push(["Pad", {"left_pad" => left, "right_pad"=> right, "top_pad" => top, "bottom_pad" => bottom}]) end -op.on(" -crop", "--crop CROP_VALUES_COMMA_SEPARATED", String, "Crop or unpad the comp by these pixel values") do | pads| +op.on(" -crop", "--crop CROP_VALUES_COMMA_SEPARATED", String, mwd("Crop")) do | pads| left, right, top, bottom = pads.split(",").map{|e| e.to_i } $middlewares.push(["Crop", {"left" => left, "right"=> right, "top" => top, "bottom" => bottom}]) end -op.on(" -ys", "--yscale Y_SCALING_FACTOR", Float, "Scale the result in Y by this factor (1.0 is the default)", &mw("Scaler", :y_factor)) -op.on(" -t", "--trim", "Trim the start frames (do not allow negative frame values)", &mw("StartTrim", :enabled, true)) # Before slip! -op.on(" -s", "--slip FRAMES", Integer, "Slip the result by this number of frames, positive is 'later'", &mw("Slipper", :slip)) +op.on(" -ys", "--yscale Y_SCALING_FACTOR", Float, mwd("Scaler"), &mw("Scaler", :y_factor)) +op.on(" -t", "--trim", Float, mwd("StartTrim"), &mw("StartTrim")) # Before slip! +op.on(" -s", "--slip FRAMES", Integer, mwd("Slipper"), &mw("Slipper", :slip)) +op.on(" -g", "--golden", mwd("Golden"), &mw("Golden")) +op.on(" -m", "--min-length LENGTH_IN_FRAMES", Integer, mwd("LengthCutoff"), &mw("LengthCutoff", :min_length)) +op.on(" -p", "--prefix PREFIX", String, mwd("Prefix"), &mw("Prefix", :prefix)) +op.on("--lerp", mwd("Lerp"), &mw("Lerp")) +op.on("--flip", mwd("Flip"), &mw("Flip")) +op.on("--flop", mwd("Flop"), &mw("Flop")) -op.on(" -g", "--golden", "Reset the residuals of all trackers to 0 (ignore correlation)", &mw("Golden", :enabled, true)) +# TODO - multiparameters op.on(" -rx", "--reformat-x NEW_PIX_WIDTH", Integer, "Reformat the comp to this width and scale all tracks to it", &mw("Reformat", :width)) op.on(" -ry", "--reformat-y NEW_PIX_HEIGHT", Integer, "Reformat the comp to this height and scale all tracks to it", &mw("Reformat", :height)) -op.on(" -m", "--min-length LENGTH_IN_FRAMES", Integer, "Only export trackers having more than X keyframes", &mw("LengthCutoff", :min_length)) op.on(" -xm", "--xshift X_IN_PIXELS", Float, "Move the points left or right", &mw("Shift", :x_shift)) op.on(" -ym", "--yshift Y_IN_PIXELS", Float, "Move the points up or down", &mw("Shift", :y_shift)) -op.on(" -p", "--prefix PREFIX", String, "A prefix to prepend to tracker names in bulk", &mw("Prefix", :prefix)) -op.on("--lerp", "Linearly interpolate missing keyframes", &mw("Lerp", :enabled, true)) -op.on("--flip", "Flip the comp horizontally", &mw("Flip", :enabled, true)) -op.on("--flop", "Flop the comp vertically", &mw("Flop", :enabled, true)) + + op.on("--list-exporters", "Show available export modules") do list_exporters; exit(0) end op.on("--list-importers", "Show available import modules") do list_importers; exit(0) @@ -129,25 +140,24 @@ begin pipe = Tracksperanto::Pipeline::Base.new(:progress_block => progress, :middleware_tuples => $middlewares) pipe.exporters = [Tracksperanto.get_exporter(writer_class_name)] if writer_class_name pipe.run(input_file, options) + pbar.finish + $stdout.puts "Found and converted %d trackers with %d keyframes." % [pipe.converted_points, pipe.converted_keyframes] rescue Tracksperanto::UnknownExporterError => damn $stderr.puts damn.message list_exporters($stderr) - exit(2) + fail "Unknown exporter" rescue Tracksperanto::UnknownImporterError => damn $stderr.puts damn.message list_importers($stderr) - exit(2) + fail "Unknown importer" rescue Tracksperanto::UnknownMiddlewareError => damn $stderr.puts damn.message - $stderr.puts "This is a bug, please report it" - exit(2) + fail "This is a bug, please report it" rescue Exception => damn fail damn.message -ensure - pbar.finish end puts disclaimer UpdateHints.version_check("tracksperanto", Tracksperanto::VERSION, STDOUT) \ No newline at end of file