Sha256: 5efa460bb44daefe3b2586ac4f2b409a52d336159f0331449e078c1eb135a46a

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

require 'digitalfilmtree/util'

module Digitalfilmtree
  module Util
    module Mediainfo
      REGEX = {
        :start_timecode => 
          /Time code of first frame\s+\:\s(.+)\n/
      }

      def mediainfo path, key
        raise "Mediainfo bin path unset" unless Mediainfo.bin
        if Util.platform.windows?
          path = Util.safe_path path
        end
        output = `#{Mediainfo.bin} "#{path}"`

        if key
          output.scan(REGEX[key]).flatten.first
        else
          output
        end
      end

      def self.bin
        @@binpath ||= false
      end

      def self.bin= path
        raise "No such binary #{path}" unless File.exists? path
        @@binpath = path
      end

      def self.autoconfigure
        os = Util.platform
        if os.windows?
          path = Util.vendored_bin(:mediainfo, :windows, 'MediaInfo.exe')
          Mediainfo.bin = Util.safe_path(path)
        elsif os.mac?
          Mediainfo.bin = Util.vendored_bin(:mediainfo, :mac, 'mediainfo')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
digitalfilmtree-util-0.0.1 lib/digitalfilmtree/util/mediainfo.rb