Sha256: f408407bc5e344567493b4b230332cf1acf0e9657c864eb7c0ff7e747fbde8d3

Contents?: true

Size: 1.73 KB

Versions: 15

Compression:

Stored size: 1.73 KB

Contents

module EDL
  # Represents a timewarp. Will be placed in EDL::Event#timewarp
  # For a reversed clip, the source start we get from the EDL in the src start
  # is the LAST used frame. For a pos rate clip, the source start is the bona fide source start. Nice eh? 
  class Timewarp
  
    # What is the actual framerate of the clip (float)
    attr_accessor :actual_framerate
    attr_accessor :clip #:nodoc:
    
    # Does this timewarp reverse the clip?
    def reverse?
      @actual_framerate < 0
    end
    
    # Get the speed in percent
    def speed_in_percent
      (@actual_framerate / @clip.rec_start_tc.fps) * 100
    end
    alias_method :speed, :speed_in_percent
    
    # Compute the length of the clip we need to capture. The length is computed in frames and
    # is always rounded up (better one frame more than one frame less!)
    def actual_length_of_source
      # First, get the length of the clip including a transition. This is what we are scaled to.
      target_len = @clip.rec_length_with_transition.to_f
      # Determine the framerate scaling factor, this is the speed
      factor = @actual_framerate / @clip.rec_start_tc.fps
      (target_len * factor).ceil.abs
    end
    
    # What is the starting frame for the captured clip? If we are a reverse, then the src start of the
    # clip is our LAST frame, otherwise it's the first
    def source_used_from
      # TODO: account for the 2 frame deficiency which is suspicious
      compensation = 2
      reverse? ? (@clip.src_start_tc - actual_length_of_source + compensation) : @clip.src_start_tc
    end
    
    # Where to end the capture? This is also dependent on whether we are a reverse or not
    def source_used_upto
      source_used_from + actual_length_of_source
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
julik-edl-0.0.8 lib/edl/timewarp.rb
edl-0.1.5 lib/edl/timewarp.rb
edl-0.1.4 lib/edl/timewarp.rb
edl-0.1.3 lib/edl/timewarp.rb
edl-0.1.2 lib/edl/timewarp.rb
edl-0.1.1 lib/edl/timewarp.rb
edl-0.1.0 lib/edl/timewarp.rb
edl-0.0.9 lib/edl/timewarp.rb
edl-0.0.2 lib/edl/timewarp.rb
edl-0.0.3 lib/edl/timewarp.rb
edl-0.0.4 lib/edl/timewarp.rb
edl-0.0.5 lib/edl/timewarp.rb
edl-0.0.6 lib/edl/timewarp.rb
edl-0.0.7 lib/edl/timewarp.rb
edl-0.0.8 lib/edl/timewarp.rb