Sha256: 99cebd2eaa3f37c7f8e5852b1fb7eedb53a63f1a087d2b20587c45153e3e8334

Contents?: true

Size: 877 Bytes

Versions: 5

Compression:

Stored size: 877 Bytes

Contents

#
# Implementes VideoStream Interface for libAV
#

# VideoStream = Struct.new(:width, :height, :codec, :color_space, :bit_rate, :frame_rate, :aspect_ratio, :raw)

module VCSRuby
  class LibAVVideoStream
    attr_reader :raw

    def initialize video_stream
      @raw = video_stream
    end

    def width
      @raw['width'].to_i
    end

    def height
      @raw['height'].to_i
    end

    def codec short = false
      if short
        @raw['codec_name']
      else
        @raw['codec_long_name']
      end
    end

    def color_space
      if ["unknown", "", nil].include? @raw['color_space']
        @raw['pix_fmt']
      else
        @raw['color_space']
      end
    end

    def bit_rate
      @raw['bit_rate'].to_i
    end


    def frame_rate
      Rational(@raw['r_frame_rate'])
    end

    def aspect_ratio
      @raw['display_aspect_ratio']
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vcs_ruby-1.1.5 lib/libAV/libav_video_stream.rb
vcs_ruby-1.1.4 lib/libAV/libav_video_stream.rb
vcs_ruby-1.1.3 lib/libAV/libav_video_stream.rb
vcs_ruby-1.1.2 lib/libAV/libav_video_stream.rb
vcs_ruby-1.1.0 lib/libAV/libav_video_stream.rb