Class: Ffprober::Ffmpeg::Exec

Inherits:
Object
  • Object
show all
Defined in:
lib/ffprober/ffmpeg/exec.rb

Constant Summary collapse

CHAPTER_SUPPORT =
Gem::Version.new('2.0.0')

Instance Method Summary collapse

Constructor Details

#initialize(finder = Ffprober::Ffmpeg::Finder.new) ⇒ Exec

Returns a new instance of Exec.



11
12
13
14
# File 'lib/ffprober/ffmpeg/exec.rb', line 11

def initialize(finder = Ffprober::Ffmpeg::Finder.new)
  @finder = finder
  @ffprobe_version_output = nil
end

Instance Method Details

#ffprobe_optionsObject



28
29
30
31
32
33
34
35
# File 'lib/ffprober/ffmpeg/exec.rb', line 28

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_versionObject



37
38
39
# File 'lib/ffprober/ffmpeg/exec.rb', line 37

def ffprobe_version
  Ffprober::Ffmpeg::Version.new(self)
end

#ffprobe_version_outputObject



20
21
22
23
24
25
26
# File 'lib/ffprober/ffmpeg/exec.rb', line 20

def ffprobe_version_output
  @ffprobe_version_output ||= if @finder.path.nil?
                                ''
                              else
                                `#{@finder.path} -version`
                              end
end

#json_output(filename) ⇒ Object



16
17
18
# File 'lib/ffprober/ffmpeg/exec.rb', line 16

def json_output(filename)
  `#{@finder.path} #{ffprobe_options} #{Shellwords.escape(filename)}`
end