Class: Ffmprb::Process::Input
- Inherits:
-
Object
- Object
- Ffmprb::Process::Input
- Defined in:
- lib/ffmprb/process/input.rb
Defined Under Namespace
Instance Method Summary collapse
- #audio ⇒ Object
- #channel?(medium, force = false) ⇒ Boolean
-
#crop(ratio) ⇒ Object
NOTE ratio is either a CROP_PARAMS symbol-ratio hash or a single (global) ratio.
- #cut(from: 0, to: nil) ⇒ Object
- #filters_for(lbl, process:, output:, video: true, audio: true) ⇒ Object
-
#initialize(io, only: nil) ⇒ Input
constructor
A new instance of Input.
- #mute ⇒ Object
- #options ⇒ Object
- #video ⇒ Object
- #volume(vol) ⇒ Object
Constructor Details
#initialize(io, only: nil) ⇒ Input
Returns a new instance of Input.
128 129 130 131 132 133 134 |
# File 'lib/ffmprb/process/input.rb', line 128 def initialize(io, only: nil) @io = resolve(io) @channels = [*only] @channels = nil if @channels.empty? raise Error, "Inadequate A/V channels" if [:video, :audio].any?{|medium| !@io.channel?(medium) && channel?(medium, true)} end |
Instance Method Details
#audio ⇒ Object
170 171 172 |
# File 'lib/ffmprb/process/input.rb', line 170 def audio Input.new self, only: :audio end |
#channel?(medium, force = false) ⇒ Boolean
190 191 192 193 194 |
# File 'lib/ffmprb/process/input.rb', line 190 def channel?(medium, force=false) return !!@channels && @channels.include?(medium) && @io.channel?(medium) if force (!@channels || @channels.include?(medium)) && @io.channel?(medium) end |
#crop(ratio) ⇒ Object
NOTE ratio is either a CROP_PARAMS symbol-ratio hash or a single (global) ratio
174 175 176 |
# File 'lib/ffmprb/process/input.rb', line 174 def crop(ratio) # NOTE ratio is either a CROP_PARAMS symbol-ratio hash or a single (global) ratio Cropped.new self, crop: ratio end |
#cut(from: 0, to: nil) ⇒ Object
178 179 180 |
# File 'lib/ffmprb/process/input.rb', line 178 def cut(from: 0, to: nil) Cut.new self, from: from, to: to end |
#filters_for(lbl, process:, output:, video: true, audio: true) ⇒ Object
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/ffmprb/process/input.rb', line 140 def filters_for(lbl, process:, output:, video: true, audio: true) # Channelling if @io.respond_to?(:filters_for) lbl_aux = "au#{lbl}" @io.filters_for(lbl_aux, process: process, output: output, video: video, audio: audio) + [ *((video && @io.channel?(:video))? (channel?(:video)? Filter.copy("#{lbl_aux}:v", "#{lbl}:v"): Filter.nullsink("#{lbl_aux}:v")): nil), *((audio && @io.channel?(:audio))? (channel?(:audio)? Filter.anull("#{lbl_aux}:a", "#{lbl}:a"): Filter.anullsink("#{lbl_aux}:a")): nil) ] else in_lbl = process[self] raise Error, "Data corruption" unless in_lbl [ # XXX this fixup is temporary, leads to resolution loss on crop etc... *(video && @io.channel?(:video) && channel?(:video)? Filter.copy("#{in_lbl}:v", "#{lbl}:v"): nil), *(video && @io.channel?(:video) && channel?(:video)? Filter.scale_pad_fps(output.target_width, output.target_height, output.target_fps, "#{in_lbl}:v", "#{lbl}:v"): nil), *(audio && @io.channel?(:audio) && channel?(:audio)? Filter.anull("#{in_lbl}:a", "#{lbl}:a"): nil) ] end end |
#mute ⇒ Object
182 183 184 |
# File 'lib/ffmprb/process/input.rb', line 182 def mute Loud.new self, volume: 0 end |
#options ⇒ Object
136 137 138 |
# File 'lib/ffmprb/process/input.rb', line 136 def ['-i', @io.path] end |