Sha256: ff7efb67ecf6a01d4caed2af5ac2b0be4d43bdbbcf6f8e1599dac0a023d9af69

Contents?: true

Size: 1.33 KB

Versions: 4

Compression:

Stored size: 1.33 KB

Contents

module WebVideo
  module Adapters
    class AbstractAdapter
      attr_accessor :filepath, :filename, :path, :video_streams
      
      def initialize(filepath, options = {})
        @filepath = filepath
        
        @filename = File.basename(@filepath)
        @path = File.dirname(@filepath)
        
        @options = options.symbolize_keys
        @metadata = parse
      end
      
      def file_exists?
        File.exist?(@filepath)
      end
      
      def size
        File.size(@filepath)
      end
      
      def duration
        @metadata[:duration]
      end
      
      def bitrate
        @metadata[:bitrate]
      end
      
      def streams
        @metadata[:streams]
      end
      
      def video_stream
        video_streams.first
      end
      
      def video_streams
        @video_streams ||= streams.select{ |stream| stream.video? }
      end
      
      def command_name
        ''
      end
      
      def convert_command
        []
      end
      
      def screenshot_command
        []
      end
      
      def installed?
        !WebVideo::Tools.run("which", command_name).blank?
      end
      
      def run(command, options = {})
        WebVideo::Tools.run_with_option(command_name, command, options)
      end
      
      private
        def parse
          return {}
        end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
web_video-1.2.0 lib/web_video/adapters/abstract_adapter.rb
web_video-1.1.2 lib/web_video/adapters/abstract_adapter.rb
web_video-1.1.1 lib/web_video/adapters/abstract_adapter.rb
web_video-1.1.0 lib/web_video/adapters/abstract_adapter.rb