Class: FFProbe::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/ffprobe/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeResult

Returns a new instance of Result.



47
48
49
50
51
52
53
54
# File 'lib/ffprobe/result.rb', line 47

def initialize
  @file = FileInfo.new
  @frames = []
  @packets = []
  @streams = []
  @tags = TagsInfo.new
  @extra = []
end

Instance Attribute Details

#extraObject

Returns the value of attribute extra.



36
37
38
# File 'lib/ffprobe/result.rb', line 36

def extra
  @extra
end

#fileObject

Returns the value of attribute file.



31
32
33
# File 'lib/ffprobe/result.rb', line 31

def file
  @file
end

#framesObject

Returns the value of attribute frames.



32
33
34
# File 'lib/ffprobe/result.rb', line 32

def frames
  @frames
end

#packetsObject

Returns the value of attribute packets.



33
34
35
# File 'lib/ffprobe/result.rb', line 33

def packets
  @packets
end

#prettyObject Also known as: pretty?

Returns the value of attribute pretty.



38
39
40
# File 'lib/ffprobe/result.rb', line 38

def pretty
  @pretty
end

#streamsObject

Returns the value of attribute streams.



34
35
36
# File 'lib/ffprobe/result.rb', line 34

def streams
  @streams
end

#successObject Also known as: success?

Returns the value of attribute success.



41
42
43
# File 'lib/ffprobe/result.rb', line 41

def success
  @success
end

#tagsObject

Returns the value of attribute tags.



35
36
37
# File 'lib/ffprobe/result.rb', line 35

def tags
  @tags
end

#unitsObject Also known as: units?

Returns the value of attribute units.



44
45
46
# File 'lib/ffprobe/result.rb', line 44

def units
  @units
end

Class Method Details

.from_hash(hash, units = false) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ffprobe/result.rb', line 9

def self.from_hash(hash,units=false)
  target = new
  target.units = units
  hash.each do |key,value|
    case key
    when :FILE
      target.file = FileInfo.from_hash(value[0], units)
    when :FRAME
      target.frames += value.map {|f| FrameInfo.from_hash(f, units) }
    when :PACKET
      target.packets += value.map {|p| PacketInfo.from_hash(p, units) }
    when :STREAM
      target.streams += value.map {|s| StreamInfo.from_hash(s, units) }
    when :TAGS
      target.tags = TagsInfo.from_hash(value[0], units)
    when :EXTRA
      target.extra = Array.new(value)
    end
  end
  target
end

.from_stream(io, units = false) ⇒ Object



5
6
7
# File 'lib/ffprobe/result.rb', line 5

def self.from_stream(io,units=false)
  from_hash(Parser.new.parse_stream(io), units)
end

Instance Method Details

#audio?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/ffprobe/result.rb', line 68

def audio?
  @streams.length == 1 && has_audio?
end

#has_audio?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/ffprobe/result.rb', line 64

def has_audio?
  @streams.first {|s| s.codec_type == "audio" }
end

#has_video?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/ffprobe/result.rb', line 56

def has_video?
  @streams.first {|s| s.codec_type == "video" }
end

#video?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/ffprobe/result.rb', line 60

def video?
  @streams.length == 1 && has_video?
end