Sha256: bd40d90e593ee7bd7932b4d459dd07cc9711a41b62748118cf434bd2671bf3fc
Contents?: true
Size: 942 Bytes
Versions: 2
Compression:
Stored size: 942 Bytes
Contents
# frozen_string_literal: true module EDL # 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. class Grabber #:nodoc: attr_accessor :ffmpeg_bin, :offset def initialize(with_file) @source_path = with_file end def ffmpeg_bin @ffmpeg_bin || 'ffmpeg' end 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 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 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
edl-0.1.7 | lib/edl/grabber.rb |
edl-0.1.6 | lib/edl/grabber.rb |