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

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

Instance Attribute Summary collapse

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 Attribute Details

#fadeObject (readonly)

Returns the value of attribute fade.



3
4
5
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 3

def fade
  @fade
end

#indexObject (readonly)

Returns the value of attribute index.



3
4
5
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 3

def index
  @index
end

#is_lastObject (readonly)

Returns the value of attribute is_last.



3
4
5
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 3

def is_last
  @is_last
end

#orientationObject (readonly)

Returns the value of attribute orientation.



3
4
5
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 3

def orientation
  @orientation
end

#paddingObject (readonly)

Returns the value of attribute padding.



3
4
5
# File 'lib/bagel/video/ffmpeg/overlay_filter.rb', line 3

def padding
  @padding
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