Class: FLV::Edit::Processor::Cut

Inherits:
Base
  • Object
show all
Includes:
Filter
Defined in:
lib/flvedit/processor/cut.rb

Overview

Cut is a Processor class (see Base and desc)

Instance Method Summary collapse

Methods included from Filter

#each

Methods included from Base

#getters, included, #is?, #size, #to_hash

Instance Method Details

#before_filterObject



13
14
15
16
17
# File 'lib/flvedit/processor/cut.rb', line 13

def before_filter
  @from, @to = options[:cut].begin, options[:cut].end
  @wait_for_keyframe = options[:keyframe_mode]
  @first_timestamp = nil
end

#filter(tag) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/flvedit/processor/cut.rb', line 19

def filter(tag)
  return if tag.is_a? Header
  if tag.timestamp > @to
    stop
  elsif (tag.timestamp < @from) || (@wait_for_keyframe &&= !tag.body.is?(:keyframe))
    :skip
  else
    @first_timestamp ||= tag.timestamp
    tag.timestamp -= @first_timestamp
  end
end