Class: Frames::Analyzer

Inherits:
Object
  • Object
show all
Defined in:
lib/frames/analyzer.rb

Overview

Public: Run ffprobe on a file and analyze the frames from the output.

file - The file to be anaylzed

Examples

analyzer = Anaylzer.new("/Users/bmckim/Desktop/sample.avi")
analyzer.frames
# => [...]

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ Analyzer

Returns a new instance of Analyzer.



14
15
16
# File 'lib/frames/analyzer.rb', line 14

def initialize(file)
  @file = String(file)
end

Instance Method Details

#constructorObject

Internal: Create FrameConstructor from ffprobe raw output.



37
38
39
# File 'lib/frames/analyzer.rb', line 37

def constructor
  FrameConstructor.new(probe)
end

#framesObject

Public: Returns the Array of Frames.



19
20
21
# File 'lib/frames/analyzer.rb', line 19

def frames
  @frames ||= constructor.frames
end

#probeObject

Public: Probe the video file.

Returns String of raw output from ffprobe.



26
27
28
29
30
31
32
33
34
# File 'lib/frames/analyzer.rb', line 26

def probe
  output = `ffprobe -show_frames "#{@file}" 2>/dev/null`

  if $? == 0
    output
  else
    raise FileError, "File does not exist or ffprobe was unable to read it"
  end
end