Class: Ffprober::Wrapper

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/ffprober/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Wrapper

Returns a new instance of Wrapper.

Raises:



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ffprober/wrapper.rb', line 15

def initialize(json)
  raise FfprobeError, json[:error] if json[:error]

  @json = json
  @format = T.let(Format.new(json[:format]), Ffprober::Format)
  @video_streams = T.let(nil, T.nilable(T::Array[Ffprober::VideoStream]))
  @audio_streams = T.let(nil, T.nilable(T::Array[Ffprober::AudioStream]))
  @data_streams = T.let(nil, T.nilable(T::Array[Ffprober::DataStream]))
  @subtitle_streams = T.let(nil, T.nilable(T::Array[Ffprober::SubtitleStream]))
  @chapters = T.let(nil, T.nilable(T::Array[Ffprober::Chapter]))
end

Instance Attribute Details

#formatObject (readonly)

Returns the value of attribute format.



11
12
13
# File 'lib/ffprober/wrapper.rb', line 11

def format
  @format
end

#jsonObject (readonly)

Returns the value of attribute json.



8
9
10
# File 'lib/ffprober/wrapper.rb', line 8

def json
  @json
end

Instance Method Details

#audio_streamsObject



36
37
38
39
40
# File 'lib/ffprober/wrapper.rb', line 36

def audio_streams
  @audio_streams ||= stream_by_codec('audio').map do |data|
    AudioStream.new(data)
  end
end

#chaptersObject



50
51
52
# File 'lib/ffprober/wrapper.rb', line 50

def chapters
  @chapters ||= json[:chapters].map { |chapter| Chapter.new(chapter) }
end

#data_streamsObject



43
44
45
46
47
# File 'lib/ffprober/wrapper.rb', line 43

def data_streams
  @data_streams ||= stream_by_codec('data').map do |data|
    DataStream.new(data)
  end
end

#subtitle_streamsObject



55
56
57
58
59
# File 'lib/ffprober/wrapper.rb', line 55

def subtitle_streams
  @subtitle_streams ||= stream_by_codec('subtitle').map do |stream|
    SubtitleStream.new(stream)
  end
end

#video_streamsObject



29
30
31
32
33
# File 'lib/ffprober/wrapper.rb', line 29

def video_streams
  @video_streams ||= stream_by_codec('video').map do |data|
    VideoStream.new(data)
  end
end