Sha256: f272eb925d58ba80dab5a2c016ae83a922e6f11fcdeaf9b5e696f1da36502b78

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

module Ffprober
  class FfprobeVersion
    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')

    def self.valid?
      new.valid?
    end

    def self.version
      new.version
    end

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

    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

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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffprober-0.4.2 lib/ffprober/ffprobe_version.rb