class Ffprober::Ffmpeg::Exec

Constants

CHAPTER_SUPPORT

Public Class Methods

new(finder = Ffprober::Ffmpeg::Finder.new) click to toggle source
# File lib/ffprober/ffmpeg/exec.rb, line 14
def initialize(finder = Ffprober::Ffmpeg::Finder.new)
  @finder = finder
  @ffprobe_version_output = T.let(nil, T.nilable(String))
end

Public Instance Methods

ffprobe_options() click to toggle source
# File lib/ffprober/ffmpeg/exec.rb, line 36
def ffprobe_options
  base_options = '-v quiet -print_format json -show_format'\
                 ' -show_streams -show_error'

  options = "#{base_options} -show_chapters" if ffprobe_version.version >= CHAPTER_SUPPORT

  options || base_options
end
ffprobe_version() click to toggle source
# File lib/ffprober/ffmpeg/exec.rb, line 46
def ffprobe_version
  Ffprober::Ffmpeg::Version.new(self)
end
ffprobe_version_output() click to toggle source
# File lib/ffprober/ffmpeg/exec.rb, line 25
def ffprobe_version_output
  @ffprobe_version_output ||= begin
    if @finder.path.nil?
      ''
    else
      `#{@finder.path} -version`
    end
  end
end
json_output(filename) click to toggle source
# File lib/ffprober/ffmpeg/exec.rb, line 20
def json_output(filename)
  `#{@finder.path} #{ffprobe_options} #{Shellwords.escape(filename)}`
end