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) ⇒ Exec



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

def initialize(finder = Ffprober::Ffmpeg::Finder)
  @finder = finder
end

Instance Method Details

#ffprobe_optionsObject



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

def ffprobe_options
  base_options = '-v quiet -print_format json -show_format'\
                 ' -show_streams -show_error'

  if ffprobe_version.version >= CHAPTER_SUPPORT
    options = base_options + ' -show_chapters'
  end

  options
end

#ffprobe_versionObject



39
40
41
# File 'lib/ffprober/ffmpeg/exec.rb', line 39

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

#ffprobe_version_outputObject



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

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

#json_output(filename) ⇒ Object



14
15
16
# File 'lib/ffprober/ffmpeg/exec.rb', line 14

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