Class: Ffmprb::Process::Input::Cut
- Inherits:
-
Ffmprb::Process::Input
- Object
- Ffmprb::Process::Input
- Ffmprb::Process::Input::Cut
- Defined in:
- lib/ffmprb/process/input.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #filters_for(lbl, process:, output:, video: true, audio: true) ⇒ Object
-
#initialize(unfiltered, from:, to:) ⇒ Cut
constructor
A new instance of Cut.
Methods inherited from Ffmprb::Process::Input
#audio, #channel?, #crop, #cut, #mute, #options, #video, #volume
Constructor Details
#initialize(unfiltered, from:, to:) ⇒ Cut
Returns a new instance of Cut.
58 59 60 61 62 63 64 |
# File 'lib/ffmprb/process/input.rb', line 58 def initialize(unfiltered, from:, to:) @io = unfiltered @from, @to = from, (to.to_f == 0 ? nil : to) fail Error, "cut from: must be" unless from fail Error, "cut from: must be less than to:" unless !to || from < to end |
Instance Attribute Details
#from ⇒ Object (readonly)
Returns the value of attribute from.
56 57 58 |
# File 'lib/ffmprb/process/input.rb', line 56 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
56 57 58 |
# File 'lib/ffmprb/process/input.rb', line 56 def to @to end |
Instance Method Details
#filters_for(lbl, process:, output:, video: true, audio: true) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ffmprb/process/input.rb', line 66 def filters_for(lbl, process:, output:, video: true, audio: true) # Trimming lbl_aux = "tm#{lbl}" @io.filters_for(lbl_aux, process: process, output: output, video: video, audio: audio) + if to lbl_blk = "bl#{lbl}" lbl_pad = "pd#{lbl}" [ *((video && channel?(:video))? Filter.blank_source(to - from, output.target_resolution, output.target_fps, "#{lbl_blk}:v") + Filter.concat_v(["#{lbl_aux}:v", "#{lbl_blk}:v"], "#{lbl_pad}:v") + Filter.trim(from, to, "#{lbl_pad}:v", "#{lbl}:v") : nil), *((audio && channel?(:audio))? Filter.silent_source(to - from, "#{lbl_blk}:a") + Filter.concat_a(["#{lbl_aux}:a", "#{lbl_blk}:a"], "#{lbl_pad}:a") + Filter.atrim(from, to, "#{lbl_pad}:a", "#{lbl}:a") : nil) ] elsif from == 0 [ *((video && channel?(:video))? Filter.copy("#{lbl_aux}:v", "#{lbl}:v"): nil), *((audio && channel?(:audio))? Filter.anull("#{lbl_aux}:a", "#{lbl}:a"): nil) ] else # !to [ *((video && channel?(:video))? Filter.trim(from, nil, "#{lbl_aux}:v", "#{lbl}:v"): nil), *((audio && channel?(:audio))? Filter.atrim(from, nil, "#{lbl_aux}:a", "#{lbl}:a"): nil) ] end end |