Class: Bagel::Video::FFMPEG::OverlayFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/bagel/video/ffmpeg/overlay_filter.rb

Instance Method Summary collapse

Constructor Details

#initialize(fade:, padding:, orientation:, index:, is_last:) ⇒ OverlayFilter

Returns a new instance of OverlayFilter.



5
6
7
8
9
10
11
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 5

def initialize(fade:, padding:, orientation:, index:, is_last:)
  @fade = fade
  @padding = padding
  @orientation = orientation
  @index = index
  @is_last = is_last
end

Instance Method Details

#to_sObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 13

def to_s
  bottom = LABEL_VIDEO
  bottom += (1..index).map { |n| LABEL_OVERLAY+n.to_s }.join if index > 0
  bottom = "[#{bottom}]"

  top = fade ? "[#{LABEL_OVERLAY}#{index}]" : "[#{index+1}]"

  label_out = "[#{LABEL_VIDEO + (1..index+1).map { |n| LABEL_OVERLAY+n.to_s }.join}]"
  label_out = '' if is_last

  "#{bottom}#{top}overlay=x=(#{position_x}):y=(#{position_y}):shortest=1#{label_out}"
end