Class: Ffprober::FfprobeVersion

Inherits:
Object
  • Object
show all
Defined in:
lib/ffprober/ffprobe_version.rb

Constant Summary collapse

MIN_VERSION =
Gem::Version.new("0.9.0")
MAX_VERSION =
Gem::Version.new("2.0.1")
@@version_regex =
/^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
@@nightly_regex =
/^(ffprobe|avprobe|ffmpeg) version (N|git)-/

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.valid?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/ffprober/ffprobe_version.rb', line 9

def self.valid?
  self.new.valid?
end

Instance Method Details

#nightly?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/ffprober/ffprobe_version.rb', line 32

def nightly?
  !!(version_output =~ @@nightly_regex)
end

#parse_versionObject



17
18
19
20
21
22
23
24
25
26
# File 'lib/ffprober/ffprobe_version.rb', line 17

def parse_version
  @parse_version ||= begin
    _p = version_output.match(@@version_regex)
    if _p.nil?
      [0, 0, 0]
    else
      [_p[2].to_i, _p[3].to_i, _p[4].to_i]
    end
  end
end

#valid?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/ffprober/ffprobe_version.rb', line 13

def valid?
  nightly? || (MIN_VERSION <= version && version <= MAX_VERSION)
end

#versionObject



28
29
30
# File 'lib/ffprober/ffprobe_version.rb', line 28

def version
  @version ||= Gem::Version.new(parse_version.join("."))
end

#version_outputObject



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

def version_output
  return "" if Ffprober.path.nil?
  @version_output ||= `#{Ffprober.path} -version`
end