Class: VCSRuby::LibAVVideoStream

Inherits:
Object
  • Object
show all
Defined in:
lib/libAV/libav_video_stream.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(video_stream) ⇒ LibAVVideoStream

Returns a new instance of LibAVVideoStream.



11
12
13
# File 'lib/libAV/libav_video_stream.rb', line 11

def initialize video_stream
  @raw = video_stream
end

Instance Attribute Details

#rawObject (readonly)

Returns the value of attribute raw.



9
10
11
# File 'lib/libAV/libav_video_stream.rb', line 9

def raw
  @raw
end

Instance Method Details

#aspect_ratioObject



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/libAV/libav_video_stream.rb', line 52

def aspect_ratio
  return nil if @raw['display_aspect_ratio'] == nil

  colon = ":"
  if @raw['display_aspect_ratio'].include? colon
    w,h = @raw['display_aspect_ratio'].split(colon).map { |n| n.to_i }
    Rational(w,h)
  else
    @raw['display_aspect_ratio'].to_f
  end
end

#bit_rateObject



39
40
41
# File 'lib/libAV/libav_video_stream.rb', line 39

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

#codec(short = false) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/libAV/libav_video_stream.rb', line 23

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

#color_spaceObject



31
32
33
34
35
36
37
# File 'lib/libAV/libav_video_stream.rb', line 31

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

#frame_rateObject



44
45
46
47
48
49
50
# File 'lib/libAV/libav_video_stream.rb', line 44

def frame_rate
  if @raw['r_frame_rate']
    @raw['r_frame_rate'].to_r
  elsif @raw['avg_frame_rate']
    @raw['avg_frame_rate'].to_r
  end
end

#heightObject



19
20
21
# File 'lib/libAV/libav_video_stream.rb', line 19

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

#widthObject



15
16
17
# File 'lib/libAV/libav_video_stream.rb', line 15

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