Sha256: 11bf6b349fedec0cb4fd150e635b099d272da86883c15eca7149bc94375fa178

Contents?: true

Size: 1.12 KB

Versions: 15

Compression:

Stored size: 1.12 KB

Contents

module EDL
  # Can chop an offline edit into events according to the EDL
  class Cutter #:nodoc:
    def initialize(source_path)
      @source_path = source_path
    end
    
    def cut(edl)
      source_for_cutting = edl.from_zero #.without_transitions.without_generators
      # We need to use the original length in record
      source_for_cutting.events.each do | evt |
        cut_segment(evt, evt.rec_start_tc, evt.rec_start_tc + evt.length)
      end
    end
    
    def cut_segment(evt, start_at, end_at)
      STDERR.puts "Cutting #{@source_path} from #{start_at} to #{end_at} - #{evt.num}"
    end
  end
  
  class FFMpegCutter < Cutter #:nodoc:
    def cut_segment(evt, start_at, end_at)
      source_dir, source_file = File.dirname(@source_path), File.basename(@source_path)
      dest_segment = File.join(source_dir, ('%s_%s' % [evt.num, source_file]))
    # dest_segment.gsub!(/\.mov$/i, '.mp4')
      
      offset = end_at - start_at
      
      cmd = "/opt/local/bin/ffmpeg -i #{@source_path} -ss #{start_at} -vframes #{offset.total} -vcodec photojpeg -acodec copy #{dest_segment}"
     #puts cmd 
     `#{cmd}`
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
julik-edl-0.0.8 lib/edl/cutter.rb
edl-0.1.5 lib/edl/cutter.rb
edl-0.1.4 lib/edl/cutter.rb
edl-0.1.3 lib/edl/cutter.rb
edl-0.1.2 lib/edl/cutter.rb
edl-0.1.1 lib/edl/cutter.rb
edl-0.1.0 lib/edl/cutter.rb
edl-0.0.9 lib/edl/cutter.rb
edl-0.0.2 lib/edl/cutter.rb
edl-0.0.3 lib/edl/cutter.rb
edl-0.0.4 lib/edl/cutter.rb
edl-0.0.5 lib/edl/cutter.rb
edl-0.0.6 lib/edl/cutter.rb
edl-0.0.7 lib/edl/cutter.rb
edl-0.0.8 lib/edl/cutter.rb