Class: Ffmprb::Process::Input
- Inherits:
-
Object
- Object
- Ffmprb::Process::Input
show all
- Defined in:
- lib/ffmprb/process/input.rb,
lib/ffmprb/process/input/cut.rb,
lib/ffmprb/process/input/loud.rb,
lib/ffmprb/process/input/temp.rb,
lib/ffmprb/process/input/cropped.rb,
lib/ffmprb/process/input/looping.rb,
lib/ffmprb/process/input/channeled.rb,
lib/ffmprb/process/input/chain_base.rb
Defined Under Namespace
Modules: Temp
Classes: ChainBase, Channeled, Cropped, Cut, Looping, Loud
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(io, process, **opts) ⇒ Input
Returns a new instance of Input.
27
28
29
30
31
|
# File 'lib/ffmprb/process/input.rb', line 27
def initialize(io, process, **opts)
@io = self.class.resolve(io)
@process = process
@opts = opts
end
|
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
24
25
26
|
# File 'lib/ffmprb/process/input.rb', line 24
def io
@io
end
|
#process ⇒ Object
Returns the value of attribute process.
25
26
27
|
# File 'lib/ffmprb/process/input.rb', line 25
def process
@process
end
|
Class Method Details
.resolve(io) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ffmprb/process/input.rb', line 9
def resolve(io)
return io unless io.is_a? String
case io
when /^\/\w/
File.open(io).tap do |file|
Ffmprb.logger.warn "Input file does no exist (#{file.path}), will probably fail" unless file.exist?
end
else
fail Error, "Cannot resolve input: #{io}"
end
end
|
Instance Method Details
#audio ⇒ Object
11
12
13
|
# File 'lib/ffmprb/process/input/channeled.rb', line 11
def audio
Channeled.new self, video: false
end
|
#chain_copy(src_input) ⇒ Object
72
73
74
|
# File 'lib/ffmprb/process/input.rb', line 72
def chain_copy(src_input)
src_input
end
|
#channel?(medium) ⇒ Boolean
67
68
69
|
# File 'lib/ffmprb/process/input.rb', line 67
def channel?(medium)
io.channel? medium
end
|
#copy(input) ⇒ Object
34
35
36
|
# File 'lib/ffmprb/process/input.rb', line 34
def copy(input)
input.chain_copy self
end
|
#crop(ratio) ⇒ Object
NOTE ratio is either a CROP_PARAMS symbol-ratio hash or a single (global) ratio
7
8
9
|
# File 'lib/ffmprb/process/input/cropped.rb', line 7
def crop(ratio)
Cropped.new self, crop: ratio
end
|
#cut(from: 0, to: nil) ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/cut.rb', line 7
def cut(from: 0, to: nil)
Cut.new self, from: from, to: to
end
|
#filters_for(lbl, video:, audio:) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/ffmprb/process/input.rb', line 49
def filters_for(lbl, video:, audio:)
in_lbl = process.input_label(self)
[
*(if video && channel?(:video)
if video.resolution && video.fps
Filter.scale_pad_fps video.resolution, video.fps, "#{in_lbl}:v", "#{lbl}:v"
elsif video.resolution
Filter.scale_pad video.resolution, "#{in_lbl}:v", "#{lbl}:v"
elsif video.fps
Filter.fps video.fps, "#{in_lbl}:v", "#{lbl}:v"
else
Filter.copy "#{in_lbl}:v", "#{lbl}:v"
end
end),
*(audio && channel?(:audio)? Filter.anull("#{in_lbl}:a", "#{lbl}:a"): nil)
]
end
|
#loop(times = 31) ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/looping.rb', line 7
def loop(times=31)
Looping.new self, times
end
|
#mute ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/loud.rb', line 7
def mute
Loud.new self, volume: 0
end
|
#options ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/ffmprb/process/input.rb', line 39
def options
opts = []
@opts.map do |name, value|
next unless value
opts << "-#{name}"
opts << value unless value == true
end
opts << '-i' << io.path
end
|
#temporise!(extname = nil) ⇒ Object
7
8
9
10
11
12
|
# File 'lib/ffmprb/process/input/temp.rb', line 7
def temporise!(extname=nil)
extname ||= io.extname
self.io = nil
extend Temp
@extname = extname
end
|
#video ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/channeled.rb', line 7
def video
Channeled.new self, audio: false
end
|
#volume(vol) ⇒ Object
11
12
13
|
# File 'lib/ffmprb/process/input/loud.rb', line 11
def volume(vol)
Loud.new self, volume: vol
end
|