Class: CarrierWave::Video::Thumbnailer::FFMpegThumbnailer
- Inherits:
-
Object
- Object
- CarrierWave::Video::Thumbnailer::FFMpegThumbnailer
- Defined in:
- lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb
Instance Attribute Summary collapse
-
#input_path ⇒ Object
readonly
Returns the value of attribute input_path.
-
#output_path ⇒ Object
readonly
Returns the value of attribute output_path.
Class Method Summary collapse
-
.binary ⇒ Object
Tells the thumbnailer binary name.
-
.binary=(bin) ⇒ Object
Sets a required thumbnailer binary.
- .logger ⇒ Object
- .logger=(log) ⇒ Object
Instance Method Summary collapse
-
#initialize(in_path, out_path) ⇒ FFMpegThumbnailer
constructor
A new instance of FFMpegThumbnailer.
- #run(options) ⇒ Object
Constructor Details
#initialize(in_path, out_path) ⇒ FFMpegThumbnailer
Returns a new instance of FFMpegThumbnailer.
37 38 39 40 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 37 def initialize in_path, out_path @input_path = in_path @output_path = out_path end |
Instance Attribute Details
#input_path ⇒ Object (readonly)
Returns the value of attribute input_path.
35 36 37 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 35 def input_path @input_path end |
#output_path ⇒ Object (readonly)
Returns the value of attribute output_path.
35 36 37 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 35 def output_path @output_path end |
Class Method Details
.binary ⇒ Object
Tells the thumbnailer binary name
18 19 20 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 18 def binary @ffmpegthumbnailer.nil? ? 'ffmpegthumbnailer' : @ffmpegthumbnailer end |
.binary=(bin) ⇒ Object
Sets a required thumbnailer binary
13 14 15 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 13 def binary=(bin) @ffmpegthumbnailer = bin end |
.logger ⇒ Object
26 27 28 29 30 31 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 26 def logger return @logger if @logger logger = Logger.new(STDOUT) logger.level = Logger::INFO @logger = logger end |
.logger=(log) ⇒ Object
22 23 24 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 22 def logger= log @logger = log end |
Instance Method Details
#run(options) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb', line 42 def run logger = .logger cmd = %Q{#{CarrierWave::Video::Thumbnailer::FFMpegThumbnailer.binary} -i #{input_path} -o #{output_path} #{.to_cli}}.rstrip logger.info("Running....#{cmd}") if logger outputs = [] exit_code = nil Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| stderr.each("r") do |line| outputs << line end exit_code = wait_thr.value end handle_exit_code(exit_code, outputs, logger) end |