Class: FFProbe

Inherits:
Object
  • Object
show all
Defined in:
lib/ffprobe.rb,
lib/ffprobe/unit.rb,
lib/ffprobe/entity.rb,
lib/ffprobe/parser.rb,
lib/ffprobe/result.rb,
lib/ffprobe/file_info.rb,
lib/ffprobe/safe_pipe.rb,
lib/ffprobe/tags_info.rb,
lib/ffprobe/frame_info.rb,
lib/ffprobe/packet_info.rb,
lib/ffprobe/stream_info.rb

Defined Under Namespace

Classes: Entity, FileInfo, FrameInfo, InvalidArgument, PacketInfo, Parser, Result, SafePipe, StreamInfo, TagsInfo, Unit

Constant Summary collapse

FEATURES =
[ :read_packets, :read_frames, :show_files, :show_frames, :show_packets, :show_streams, :show_tags, :pretty ]
DEFAULT_FEATURES =
[:show_streams, :show_tags]

Class Attribute Summary collapse

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*desired_features) ⇒ FFProbe

Returns a new instance of FFProbe.



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

def initialize(*desired_features)
  desired_features = DEFAULT_FEATURES if desired_features.empty?
  self.features = desired_features.reject {|f| f == :units }
  self.units = desired_features.include?(:units)
end

Class Attribute Details

.executableObject

Returns the value of attribute executable.



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

def executable
  @executable
end

Instance Attribute Details

#featuresObject

Returns the value of attribute features.



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

def features
  @features
end

#unitsObject Also known as: units?

Returns the value of attribute units.



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

def units
  @units
end

Instance Method Details

#pretty?Boolean

Returns:

  • (Boolean)


83
84
85
# File 'lib/ffprobe.rb', line 83

def pretty?
  features.include?(:pretty)
end

#probe(filename) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ffprobe.rb', line 70

def probe(filename)
  params = features.map {|f| "-#{f.to_s}" }
  params << filename
  result = nil
  pipe = SafePipe.new(executable,*params)
  pipe.run do |stream|
    result = Result.from_stream(stream, self.units?)
  end
  result.success = pipe.success?
  result.pretty = self.pretty? if result
  result
end