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/paced.rb,
lib/ffmprb/process/input/cropped.rb,
lib/ffmprb/process/input/looping.rb,
lib/ffmprb/process/input/reversed.rb,
lib/ffmprb/process/input/channeled.rb,
lib/ffmprb/process/input/chain_base.rb,
lib/ffmprb/process/input/postprocessed.rb
Defined Under Namespace
Classes: ChainBase, Channeled, Cropped, Cut, Looping, Loud, Paced, Postprocessed, Reversed
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(io, process, video:, audio:) ⇒ Input
Returns a new instance of Input.
42
43
44
45
46
47
48
49
|
# File 'lib/ffmprb/process/input.rb', line 42
def initialize(io, process, video:, audio:)
@process = process
@io = self.class.resolve(io)
@channels = {
video: video && @io.channel?(:video) && OpenStruct.new(video),
audio: audio && @io.channel?(:audio) && OpenStruct.new(audio)
}
end
|
Instance Attribute Details
#io ⇒ Object
Returns the value of attribute io.
39
40
41
|
# File 'lib/ffmprb/process/input.rb', line 39
def io
@io
end
|
#process ⇒ Object
Returns the value of attribute process.
40
41
42
|
# File 'lib/ffmprb/process/input.rb', line 40
def process
@process
end
|
Class Method Details
.audio_args(audio = nil) ⇒ Object
.resolve(io) ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'lib/ffmprb/process/input.rb', line 9
def resolve(io)
return io unless
io.is_a? String
File.access(io).tap do |file|
Ffmprb.logger.warn "Input file does no exist (#{file.path}), will probably fail" unless file.exist?
end
end
|
.video_args(video = nil) ⇒ Object
TODO! check for unknown options
20
21
22
23
24
25
26
27
28
|
# File 'lib/ffmprb/process/input.rb', line 20
def video_args(video=nil)
video = Process.input_video_options.merge(video.to_h)
[].tap do |args|
fps = nil args.concat %W[-noautorotate] unless video.delete(:auto_rotate)
args.concat %W[-r #{fps}] if (fps = video.delete(:fps))
Util.assert_options_empty! video
end
end
|
Instance Method Details
#args ⇒ Object
57
58
59
60
61
62
63
|
# File 'lib/ffmprb/process/input.rb', line 57
def args
[].tap do |args|
args.concat self.class.video_args(channel :video) if channel? :video
args.concat self.class.audio_args(channel :audio) if channel? :audio
args.concat ['-i', io.path]
end
end
|
#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
98
99
100
|
# File 'lib/ffmprb/process/input.rb', line 98
def chain_copy(src_input)
src_input
end
|
#channel(medium) ⇒ Object
93
94
95
|
# File 'lib/ffmprb/process/input.rb', line 93
def channel(medium)
@channels[medium]
end
|
#channel?(medium) ⇒ Boolean
89
90
91
|
# File 'lib/ffmprb/process/input.rb', line 89
def channel?(medium)
!!channel(medium)
end
|
#copy(input) ⇒ Object
52
53
54
|
# File 'lib/ffmprb/process/input.rb', line 52
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/ffmprb/process/input.rb', line 65
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
elsif video
fail Error, "No video stream to provide ('#{io.path}')"
end),
*(if audio && channel?(:audio)
Filter.anull "#{in_lbl}:a", "#{lbl}:a"
elsif audio
fail Error, "No audio stream to provide ('#{io.path}')"
end)
]
end
|
#loop(times = Util.ffmpeg_inputs_max) ⇒ Object
#mute ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/loud.rb', line 7
def mute
Loud.new self, volume: 0
end
|
#pace(ratio) ⇒ Object
8
9
10
|
# File 'lib/ffmprb/process/input/paced.rb', line 8
def pace(ratio)
Paced.new self, pace: ratio
end
|
#pp ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/postprocessed.rb', line 7
def pp
Postprocessed.new self
end
|
#reverse ⇒ Object
7
8
9
|
# File 'lib/ffmprb/process/input/reversed.rb', line 7
def reverse
Reversed.new self
end
|
#temporise_io!(extname = nil) ⇒ Object
7
8
9
10
11
12
13
|
# File 'lib/ffmprb/process/input/temp.rb', line 7
def temporise_io!(extname=nil)
process.proc_vis_edge @io, process, :remove
@io.tap do
@io = File.temp_fifo(extname || io.extname)
process.proc_vis_edge @io, process
end
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
|