Module: CarrierWave::Video::Thumbnailer

Extended by:
ActiveSupport::Concern
Defined in:
lib/carrierwave/video/thumbnailer.rb,
lib/carrierwave/video/thumbnailer/version.rb,
lib/carrierwave/video/thumbnailer/ffmpegthumbnailer.rb,
lib/carrierwave/video/thumbnailer/ffmpegthumbnailer/options.rb

Defined Under Namespace

Modules: ClassMethods Classes: FFMpegThumbnailer, FFMpegThumbnailerOptions, Options

Constant Summary collapse

VERSION =

carrierwave-video-thumbnailer version

"0.1.4"

Instance Method Summary collapse

Instance Method Details

#thumbnail(opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/carrierwave/video/thumbnailer.rb', line 18

def thumbnail opts = {}
  cache_stored_file! if !cached?

  @options = CarrierWave::Video::Thumbnailer::FFMpegThumbnailerOptions.new(opts)
  format = @options.format || 'jpg'

  tmp_path = File.join( File.dirname(current_path), "tmpfile.#{format}" )
  thumbnailer = FFMpegThumbnailer.new(current_path, tmp_path)

  with_thumbnailing_callbacks do
    thumbnailer.run(@options)
    File.rename tmp_path, current_path
  end
end