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.



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

def initialize(with_file)
  @source_path = with_file
end

Instance Attribute Details

#ffmpeg_binObject

:nodoc:



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

def ffmpeg_bin
  @ffmpeg_bin
end

#offsetObject

:nodoc:



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

def offset
  @offset
end

Instance Method Details

#generate_grab(_evt, at, to_file) ⇒ Object



26
27
28
29
# File 'lib/edl/grabber.rb', line 26

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



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

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