Class: Thwomp::Renderers::FFMPEG

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/thwomp/renderers/ffmpeg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#frame_number, #sort

Constructor Details

#initialize(url) ⇒ FFMPEG

Returns a new instance of FFMPEG.



10
11
12
# File 'lib/thwomp/renderers/ffmpeg.rb', line 10

def initialize(url)
  @filename = Downloader.new(url).filename
end

Instance Attribute Details

#filenameObject (readonly)

Returns the value of attribute filename.



8
9
10
# File 'lib/thwomp/renderers/ffmpeg.rb', line 8

def filename
  @filename
end

Instance Method Details

#executableObject



23
24
25
# File 'lib/thwomp/renderers/ffmpeg.rb', line 23

def executable
  Thwomp.ffmpeg_path || "ffmpeg"
end

#framesObject



14
15
16
17
18
19
20
21
# File 'lib/thwomp/renderers/ffmpeg.rb', line 14

def frames
  timestamp = Time.now.to_i
  output_file_name = "#{Dir.tmpdir}/frame_#{timestamp}_%d.png"

  Command.exec("#{executable} -i #{filename} -f image2 -r 1 -vf scale=128:-1 #{output_file_name} &> /dev/null")

  sort Dir.glob("#{Dir.tmpdir}/frame_#{timestamp}_*.png")
end