Class: Ffmprb::Process::Input::Cut
- Inherits:
-
ChainBase
- Object
- Ffmprb::Process::Input
- ChainBase
- Ffmprb::Process::Input::Cut
- Defined in:
- lib/ffmprb/process/input/cut.rb
Instance Attribute Summary collapse
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Attributes inherited from Ffmprb::Process::Input
Instance Method Summary collapse
- #filters_for(lbl, video:, audio:) ⇒ Object
-
#initialize(unfiltered, from:, to:) ⇒ Cut
constructor
A new instance of Cut.
Methods inherited from ChainBase
#chain_copy, #channel, #unfiltered, #unfiltered=
Methods inherited from Ffmprb::Process::Input
#args, #audio, audio_args, #chain_copy, #channel, #channel?, #copy, #crop, #cut, #loop, #mute, #pace, #pp, resolve, #reverse, #temporise_io!, #video, video_args, #volume
Constructor Details
#initialize(unfiltered, from:, to:) ⇒ Cut
Returns a new instance of Cut.
15 16 17 18 19 20 21 22 |
# File 'lib/ffmprb/process/input/cut.rb', line 15 def initialize(unfiltered, from:, to:) super unfiltered @from = from @to = 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.
13 14 15 |
# File 'lib/ffmprb/process/input/cut.rb', line 13 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
13 14 15 |
# File 'lib/ffmprb/process/input/cut.rb', line 13 def to @to end |
Instance Method Details
#filters_for(lbl, video:, audio:) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ffmprb/process/input/cut.rb', line 24 def filters_for(lbl, video:, audio:) fail Error, "cut needs resolution and fps (reorder your filters?)" unless !video || (video.resolution && video.fps) # Trimming lbl_aux = "tm#{lbl}" super(lbl_aux, video: video, audio: audio) + if to lbl_blk = "bl#{lbl}" lbl_pad = "pd#{lbl}" [ *((video && channel?(:video))? Filter.blank_source(to - from, video.resolution, video.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 |