Sha256: 1cd7833405839426a009fe9f3af0a231e60b5f4ef3a5821bcb341b38597d6151

Contents?: true

Size: 879 Bytes

Versions: 5

Compression:

Stored size: 879 Bytes

Contents

#
# Implementes VideoStream Interface for FFmpeg
#

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

module VCSRuby
  class FFmpegVideoStream
    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/FFmpeg/ffmpeg_video_stream.rb
vcs_ruby-1.1.4 lib/FFmpeg/ffmpeg_video_stream.rb
vcs_ruby-1.1.3 lib/FFmpeg/ffmpeg_video_stream.rb
vcs_ruby-1.1.2 lib/FFmpeg/ffmpeg_video_stream.rb
vcs_ruby-1.1.0 lib/FFmpeg/ffmpeg_video_stream.rb