Class: EDL::Grabber
- Inherits:
-
Object
- Object
- EDL::Grabber
- 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
-
#ffmpeg_bin ⇒ Object
:nodoc:.
-
#offset ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #generate_grab(_evt, at, to_file) ⇒ Object
- #grab(edl) ⇒ Object
-
#initialize(with_file) ⇒ Grabber
constructor
A new instance of Grabber.
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_bin ⇒ Object
:nodoc:
8 9 10 |
# File 'lib/edl/grabber.rb', line 8 def ffmpeg_bin @ffmpeg_bin end |
#offset ⇒ Object
: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 |