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)



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

def actual_framerate
  @actual_framerate
end

#clipObject

:nodoc:



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

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



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

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)


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

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



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

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



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

def source_used_upto
  source_used_from + actual_length_of_source
end

#speed_in_percentObject Also known as: speed

Get the speed in percent



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

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