Class: EDL::Grabber

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

Overview

When initialized with a file and passed an EDL, will generate thumbnail images of the first frame of every event. It is assumed that the movie file starts at the same frame as the first EDL event.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(with_file) ⇒ Grabber

Returns a new instance of Grabber.



7
8
9
# File 'lib/edl/grabber.rb', line 7

def initialize(with_file)
  @source_path = with_file
end

Instance Attribute Details

#ffmpeg_binObject

:nodoc:



6
7
8
# File 'lib/edl/grabber.rb', line 6

def ffmpeg_bin
  @ffmpeg_bin
end

#offsetObject

:nodoc:



6
7
8
# File 'lib/edl/grabber.rb', line 6

def offset
  @offset
end

Instance Method Details

#generate_grab(evt, at, to_file) ⇒ Object



24
25
26
27
# File 'lib/edl/grabber.rb', line 24

def generate_grab(evt, at, to_file)
  cmd = "#{ffmpeg_bin} -i #{@source_path} -an -ss #{at.with_frames_as_fraction} -vframes 1 -y #{to_file}%d.jpg"
  `#{cmd}`
end

#grab(edl) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/edl/grabber.rb', line 15

def grab(edl)
  edl.from_zero.events.each do | evt |
    grab_frame_tc = evt.rec_start_tc + (offset || 0 )
    
    to_file = File.dirname(@source_path) + '/' + evt.num + '_' + File.basename(@source_path).gsub(/\.(\w+)$/, '')
    generate_grab(evt.num, grab_frame_tc, to_file)
  end
end