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:, 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 |
# File 'lib/ffmprb/process/input.rb', line 107 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
148 149 150 |
# File 'lib/ffmprb/process/input.rb', line 148 def audio Input.new self, only: :audio end |
#channel?(medium, force = false) ⇒ Boolean
164 165 166 167 168 |
# File 'lib/ffmprb/process/input.rb', line 164 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
152 153 154 |
# File 'lib/ffmprb/process/input.rb', line 152 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
156 157 158 |
# File 'lib/ffmprb/process/input.rb', line 156 def cut(from: 0, to: nil) Cut.new self, from: from, to: to end |
#filters_for(lbl, process:, video: true, audio: true) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/ffmprb/process/input.rb', line 119 def filters_for(lbl, process:, video: true, audio: true) # Channelling if @io.respond_to?(:filters_for) 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 && @io.channel?(:video) && channel?(:video)? Filter.copy("#{in_lbl}:v", "#{lbl}:v"): nil), *(audio && @io.channel?(:audio) && channel?(:audio)? Filter.anull("#{in_lbl}:a", "#{lbl}:a"): nil) ] end end |
#options ⇒ Object
115 116 117 |
# File 'lib/ffmprb/process/input.rb', line 115 def ['-i', @io.path] end |