Class: Kithe::FfmpegExtractJpg

Inherits:
Object
  • Object
show all
Defined in:
app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb

Overview

Creates a JPG screen capture using ffmpeg, by default with the thumbnail filter to choose a representative frame from the first minute or so.

Examples:

tempfile = FfmpegExtractJpg.new.call(shrine_uploaded_file)


tempfile = FfmpegExtractJpg.new.call(url)


tempfile = FfmpegExtractJpg.new(start_seconds: 60).call(shrine_uploaded_file)


tempfile = FfmpegExtractJpg.new(start_seconds: 10, width_pixels: 420).call(shrine_uploaded_file)


Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_seconds: 0, frame_sample_size: false, width_pixels: nil) ⇒ FfmpegExtractJpg



32
33
34
35
36
# File 'app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb', line 32

def initialize(start_seconds: 0, frame_sample_size: false, width_pixels: nil)
  @start_seconds = start_seconds
  @frame_sample_size = frame_sample_size
  @width_pixels = width_pixels
end

Instance Attribute Details

#frame_sample_sizeObject (readonly)

Returns the value of attribute frame_sample_size.



13
14
15
# File 'app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb', line 13

def frame_sample_size
  @frame_sample_size
end

#start_secondsObject (readonly)

Returns the value of attribute start_seconds.



13
14
15
# File 'app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb', line 13

def start_seconds
  @start_seconds
end

#width_pixelsObject (readonly)

Returns the value of attribute width_pixels.



13
14
15
# File 'app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb', line 13

def width_pixels
  @width_pixels
end

Instance Method Details

#call(input_arg) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/derivative_transformers/kithe/ffmpeg_extract_jpg.rb', line 46

def call(input_arg)
  if input_arg.kind_of?(Shrine::UploadedFile)
    if input_arg.respond_to?(:url) && input_arg.url&.start_with?(/https?\:/)
      _call(input_arg.url)
    else
      Shrine.with_file(input_arg) do |local_file|
        _call(local_file.path)
      end
    end
  elsif input_arg.respond_to?(:path)
    _call(input_arg.path)
  else
    _call(input_arg.to_s)
  end
end