Sha256: 9fc9d665d4bd8332757bc9c735873d74aa61a0c08ca10ee641d6b2058f28dc82

Contents?: true

Size: 1.72 KB

Versions: 8

Compression:

Stored size: 1.72 KB

Contents

#
# Represents the video file
#

require 'vcs'

module VCSRuby
  class Video
    attr_reader :config

    def initialize video
      initialize_filename video
      initialize_capturers
    end

    def valid?
      capturer.file_valid?
    end

    def info
      capturer.info
    end

    def video
      capturer.video_streams.first
    end

    def video_streams
      capturer.video_streams
    end

    def audio
      capturer.audio_streams.first
    end

    def audio_streams
      capturer.audio_streams
    end

    def full_path
      File.join(@path, @filename)
    end

    def contact_sheet
      @contact_sheet ||= ContactSheet.new self, capturer
    end

    def frame time_index
      return Frame.new self, capturer, time_index
    end

private
    def initialize_filename video
      @path = File.dirname(File.absolute_path(video))
      @filename = File.basename(video)
    end

    def initialize_capturers
      @capturers = []

      @capturers << LibAV.new(self)
      @capturers << MPlayer.new(self)
      @capturers << FFmpeg.new(self)

      if Configuration.instance.verbose?
        puts "Available capturers: #{available_capturers.map{ |c| c.to_s }.join(', ')}"
      end
    end

    def available_capturers
      @capturers.select{ |c| c.available? }
    end

    def capturer
      result = nil
      if Configuration.instance.capturer == :any
        result = available_capturers.first
      else
        result = available_capturers.select{ |c| c.name == Configuration.instance.capturer }.first
      end

      unless result
        raise "Selected Capturer (#{Configuration.instance.capturer}) not available. Install one of these: #{@capturers.map{ |c| c.name }.join(', ')}"
      end

      return result
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
vcs_ruby-1.1.8 lib/video.rb
vcs_ruby-1.1.7 lib/video.rb
vcs_ruby-1.1.6 lib/video.rb
vcs_ruby-1.1.5 lib/video.rb
vcs_ruby-1.1.4 lib/video.rb
vcs_ruby-1.1.3 lib/video.rb
vcs_ruby-1.1.2 lib/video.rb
vcs_ruby-1.1.0 lib/video.rb