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
XXX? protected.
-
#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:, video: true, audio: true) ⇒ Object
-
#initialize(io, only: nil) ⇒ Input
constructor
A new instance of Input.
- #options ⇒ Object
- #video ⇒ Object
- #volume(vol) ⇒ Object
Constructor Details
#initialize(io, only: nil) ⇒ Input
Returns a new instance of Input.
107 108 109 110 111 112 113 114 |
# File 'lib/ffmprb/process/input.rb', line 107 def initialize(io, only: nil) @io = io @channels = [*only] @channels = nil if @channels.empty? raise Error, "Inadequate A/V channels" if @io.respond_to?(:channel?) && [:video, :audio].any?{|medium| !@io.channel?(medium) && channel?(medium, true)} end |
Instance Method Details
#audio ⇒ Object
149 150 151 |
# File 'lib/ffmprb/process/input.rb', line 149 def audio Input.new self, only: :audio end |
#channel?(medium, force = false) ⇒ Boolean
XXX? protected
167 168 169 170 171 172 |
# File 'lib/ffmprb/process/input.rb', line 167 def channel?(medium, force=false) return @channels && @channels.include?(medium) if force (!@channels || @channels.include?(medium)) && (!@io.respond_to?(:channel?) || @io.channel?(medium)) end |
#crop(ratio) ⇒ Object
NOTE ratio is either a CROP_PARAMS symbol-ratio hash or a single (global) ratio
153 154 155 |
# File 'lib/ffmprb/process/input.rb', line 153 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
157 158 159 |
# File 'lib/ffmprb/process/input.rb', line 157 def cut(from: 0, to: nil) Cut.new self, from: from, to: to end |
#filters_for(lbl, process:, video: true, audio: true) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ffmprb/process/input.rb', line 120 def filters_for(lbl, process:, video: true, audio: true) # Channelling if @io.respond_to?(:filters_for) # NOTE assuming @io.respond_to?(:channel?) lbl_aux = "au#{lbl}" @io.filters_for(lbl_aux, process: process, 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 [ *(video && channel?(:video)? Filter.copy("#{in_lbl}:v", "#{lbl}:v"): nil), *(audio && channel?(:audio)? Filter.anull("#{in_lbl}:a", "#{lbl}:a"): nil) ] end end |
#options ⇒ Object
116 117 118 |
# File 'lib/ffmprb/process/input.rb', line 116 def " -i #{@io.path}" end |