Class: EDL::Timewarp

Inherits:
Object
  • Object
show all
Defined in:
lib/edl/timewarp.rb

Overview

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?

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#actual_framerateObject

What is the actual framerate of the clip (float)



8
9
10
# File 'lib/edl/timewarp.rb', line 8

def actual_framerate
  @actual_framerate
end

#clipObject

:nodoc:



9
10
11
# File 'lib/edl/timewarp.rb', line 9

def clip
  @clip
end

Instance Method Details

#actual_length_of_sourceObject

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!)



24
25
26
27
28
29
30
# File 'lib/edl/timewarp.rb', line 24

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

#reverse?Boolean

Does this timewarp reverse the clip?

Returns:

  • (Boolean)


12
13
14
# File 'lib/edl/timewarp.rb', line 12

def reverse?
  @actual_framerate < 0
end

#source_used_fromObject

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



34
35
36
37
38
# File 'lib/edl/timewarp.rb', line 34

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

#source_used_uptoObject

Where to end the capture? This is also dependent on whether we are a reverse or not



41
42
43
# File 'lib/edl/timewarp.rb', line 41

def source_used_upto
  source_used_from + actual_length_of_source
end

#speed_in_percentObject Also known as: speed

Get the speed in percent



17
18
19
# File 'lib/edl/timewarp.rb', line 17

def speed_in_percent
  (@actual_framerate / @clip.rec_start_tc.fps) * 100
end