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.
7 8 9 |
# File 'lib/edl/grabber.rb', line 7 def initialize(with_file) @source_path = with_file end |
Instance Attribute Details
#ffmpeg_bin ⇒ Object
:nodoc:
6 7 8 |
# File 'lib/edl/grabber.rb', line 6 def ffmpeg_bin @ffmpeg_bin end |
#offset ⇒ Object
: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 |