class MovieMasher::Layer

base for all layers

Public Class Methods

new(input, job_input) click to toggle source
# File lib/graph.rb, line 124
def initialize(input, job_input)
  @input = input
  @job_input = job_input # will be different than input if we're in a mash
  raise('no input') unless input
  @range = input[:range]
  @chains = []
  initialize_chains
end

Public Instance Methods

initialize_chains() click to toggle source
# File lib/graph.rb, line 132
def initialize_chains
  if @input[:merger]
    unless @input[:merger][:dimensions]
      @input[:merger][:dimensions] = @input[:dimensions]
    end
    @merger_chain = ChainModule.new(@input[:merger], @job_input, @input)
  else
    @merger_chain = ChainOverlay.new(@job_input)
  end
  if @input[:scaler]
    unless @input[:scaler][:dimensions]
      @input[:scaler][:dimensions] = @input[:dimensions]
    end
    @scaler_chain = ChainModule.new(@input[:scaler], @job_input, @input)
  else
    @scaler_chain = ChainScaler.new @input, @job_input
  end
  @effects_chain = ChainEffects.new @input, @job_input
  @chains << @scaler_chain
  @chains << @effects_chain
end
layer_command(scope) click to toggle source
# File lib/graph.rb, line 158
def layer_command(scope)
  layer_scope(scope)
  cmds = []
  @chains.each do |chain|
    chain_cmd = chain.chain_command(scope)
    cmds << chain_cmd unless chain_cmd.to_s.empty?
  end
  cmds.join(',')
end
layer_scope(scope) click to toggle source
# File lib/graph.rb, line 153
def layer_scope(scope)
  __raise_unless(@input[:length], "no input length #{@input}")
  scope[:mm_duration] = @input[:length]
  scope[:mm_t] = "(t/#{scope[:mm_duration]})"
end
merger_command(scope) click to toggle source
# File lib/graph.rb, line 121
def merger_command(scope)
  @merger_chain.chain_command(scope)
end
range() click to toggle source
# File lib/graph.rb, line 167
def range
  (@input ? @input[:range] : nil)
end
trim_command(render_range) click to toggle source
# File lib/graph.rb, line 170
def trim_command(render_range)
  input_range = range
  # puts "command_range_trim #{input_range}"
  cmd = ''
  if render_range && input_range && !input_range.equals?(render_range)
    # puts "render_range #{render_range.inspect}"
    # puts "input_range #{input_range.inspect}"
    range_start = render_range.start_seconds
    range_end = render_range.end_seconds
    input_start = input_range.start_seconds
    input_end = input_range.end_seconds
    if range_start > input_start || range_end < input_end
      dur = __coerce_if_numeric(render_range.length_seconds)
      cmd += ",trim=duration=#{dur}"
      if range_start > input_start
        start = FloatUtil.precision(range_start - input_start)
        start = __coerce_if_numeric(start)
        cmd += ":start=#{start}"
      end
      cmd += ',setpts=expr=PTS-STARTPTS'
    end
  end
  cmd
end