Class: Ffmprb::Process::Input::Cut

Inherits:
Ffmprb::Process::Input show all
Defined in:
lib/ffmprb/process/input.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Ffmprb::Process::Input

#audio, #channel?, #crop, #cut, #options, #video, #volume

Constructor Details

#initialize(unfiltered, from:, to:) ⇒ Cut

Returns a new instance of Cut.

Raises:



53
54
55
56
57
58
# File 'lib/ffmprb/process/input.rb', line 53

def initialize(unfiltered, from:, to:)
  @io = unfiltered
  @from, @to = from, (to.to_f == 0 ? nil : to)

  raise Error, "cut from: cannot be nil"  if from.nil?
end

Instance Attribute Details

#fromObject (readonly)

Returns the value of attribute from.



51
52
53
# File 'lib/ffmprb/process/input.rb', line 51

def from
  @from
end

#toObject (readonly)

Returns the value of attribute to.



51
52
53
# File 'lib/ffmprb/process/input.rb', line 51

def to
  @to
end

Instance Method Details

#filters_for(lbl, process:, video: true, audio: true) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/ffmprb/process/input.rb', line 60

def filters_for(lbl, process:, video: true, audio: true)

  # Trimming

  lbl_aux = "tm#{lbl}"
  @io.filters_for(lbl_aux, process: process, video: video, audio: audio) +
    if from == 0 && !to
      [
        *((video && channel?(:video))? Filter.copy("#{lbl_aux}:v", "#{lbl}:v"): nil),
        *((audio && channel?(:audio))? Filter.anull("#{lbl_aux}:a", "#{lbl}:a"): nil)
      ]
    else
      [
        *((video && channel?(:video))? Filter.trim(from, to, "#{lbl_aux}:v", "#{lbl}:v"): nil),
        *((audio && channel?(:audio))? Filter.atrim(from, to, "#{lbl_aux}:a", "#{lbl}:a"): nil)
      ]
    end
end