Class: Ffprober::FfprobeVersion

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

Constant Summary collapse

VERSION_REGEX =
/^(ffprobe|avprobe|ffmpeg) version (\d+)\.?(\d+)\.?(\d+)*/
NIGHTLY_REGEX =
/^(ffprobe|avprobe|ffmpeg) version (N|git)-/
MIN_VERSION =
Gem::Version.new('0.9.0')
MAX_VERSION =
Gem::Version.new('2.5.4')

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?
  new.valid?
end

.versionObject



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

def self.version
  new.version
end

Instance Method Details

#ffprobe_version_outputObject



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

def ffprobe_version_output
  @ffprobe_version_output ||= Ffprober.path.nil? ? '' : `#{Ffprober.path} -version`
end

#nightly?Boolean

Returns:

  • (Boolean)


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

def nightly?
  !!(ffprobe_version_output =~ NIGHTLY_REGEX)
end

#parse_versionObject



21
22
23
24
25
26
27
# File 'lib/ffprober/ffprobe_version.rb', line 21

def parse_version
  @parse_version ||= begin
    ffprobe_version_output.match(VERSION_REGEX) do |match|
      [match[2].to_i, match[3].to_i, match[4].to_i]
    end || [0, 0, 0]
  end
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/ffprober/ffprobe_version.rb', line 17

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

#versionObject



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

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