lib/ffprober/parsers/file.rb in ffprober-0.4.6 vs lib/ffprober/parsers/file.rb in ffprober-0.5.1
- old
+ new
@@ -1,34 +1,18 @@
module Ffprober
module Parsers
class File
- def initialize(file_to_parse)
+ def initialize(file_to_parse, exec=Ffprober::Ffmpeg::Exec.new)
unless ::File.exist?(file_to_parse)
fail ArgumentError.new("File not found #{file_to_parse}")
end
@file_to_parse = file_to_parse
+ @exec = exec
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
+ Ffprober::Parsers::Json.new(@exec.json_output(@file_to_parse))
end
end
end
end