Sha256: 55f3bc17e0080b3ddeca636234a4bc567e07e9630fbd27378e4487c595d31de3

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

module Ffprober
  module Parsers
    class File
      def initialize(file_to_parse)
        unless ::File.exist?(file_to_parse)
          fail ArgumentError.new("File not found #{file_to_parse}")
        end

        @file_to_parse = file_to_parse
      end

      def load
        json_output = `#{ffprobe_finder.path} #{options} '#{@file_to_parse}'`
        Ffprober::Parsers::Json.new(json_output)
      end

      private

      def options
        options = "-v quiet -print_format json -show_format -show_streams"
        options << " -show_chapters" if ffprobe_version.version >= Gem::Version.new("2.0.0")
        options
      end

      def ffprobe_version
        Ffprober::Ffmpeg::Version.new
      end

      def ffprobe_finder
        Ffprober::Ffmpeg::Finder
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffprober-0.4.3 lib/ffprober/parsers/file.rb