Sha256: 6ca1969e702dad5c0e301cd78fb04a5a2756c684d52b1090fd6a29cb0e38cba1

Contents?: true

Size: 818 Bytes

Versions: 3

Compression:

Stored size: 818 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} #{Shellwords.escape(@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

3 entries across 3 versions & 1 rubygems

Version Path
ffprober-0.4.6 lib/ffprober/parsers/file.rb
ffprober-0.4.5 lib/ffprober/parsers/file.rb
ffprober-0.4.4 lib/ffprober/parsers/file.rb