class MovieMasher::Input
An element in Job#inputs
representing media to be included in the mashup, which is eventually rendered into each Output
format and uploaded. Inputs are generally combined together in the order they appear, though audio can be mixed by specifying start
times.
There are four types of inputs: Type::AUDIO, Type::IMAGE and Type::VIDEO (the three raw types) plus Type::MASH, which allows a Mash
to be included like normal audio/video. Mashes can be generated in a web browser utilizing moviemasher.js or angular-moviemasher and can include raw elements composited on multiple tracks along with titling, effects and transformations over time.
Relevant keys depend on type
, though all inputs have av
, source
and length
keys. After downloading, relevant inputs are probed and will have their duration
set if it's not already. The no_audio
or no_video
keys might change to, as well as av
which relies on them (for instance, from AV::BOTH to AV::VIDEO_ONLY for a video that is found to contain no audio track).
Input.create( type: Type::VIDEO, source: 'video.mp4', fill: 'crop', # remove pixels outside output's aspect ratio gain: 0.8, # reduce volume by 20% offset: 10, # remove first ten seconds length: 50, # remove everything after the first minute )
Constants
- KEYS_AV_GRAPH
Public Class Methods
# File lib/input.rb, line 38 def audio_graphs(inputs) graphs = [] inputs.each do |input| next if input[:no_audio] case input[:type] when Type::VIDEO, Type::AUDIO graph = input.slice(*KEYS_AV_GRAPH) graph[:start] = input[:start] graphs << graph when Type::MASH quantize = input[:mash][:quantize] audio_clips = Mash.clips_having_audio(input[:mash]) audio_clips.each do |clip| media = Mash.media(input[:mash], clip[:id]) unless media raise(Error::JobInput, "couldn't find media #{clip[:id]}") end next if clip[:no_audio] ||= media[:no_audio] raise('could not find cached file') unless media[:cached_file] graph = clip.slice(*KEYS_AV_GRAPH) graph[:start] = input[:start].to_f graph[:start] += (clip[:frame].to_f / quantize) graph[:cached_file] = media[:cached_file] graph[:duration] = media[:duration] graphs << graph end end end graphs end
# File lib/input.rb, line 76 def init_hash(input) _init_time(input, :offset) Hashable._init_key(input, :start, FloatUtil::NEG_ONE) Hashable._init_key(input, :duration, FloatUtil::ZERO) Hashable._init_key(input, :length, 1.0) if Type::IMAGE == input[:type] _init_time(input, :length) # ^ image will be one by default, others zero input[:base_source] = Transfer.create_if(input[:base_source]) input[:module_source] = Transfer.create_if(input[:module_source]) Mash.init_input(input) input end
# File lib/input.rb, line 186 def initialize(hash = nil) # puts "Input#initialize #{hash}" self.class.init_hash(hash) super end
# File lib/input.rb, line 88 def video_graphs(inputs, job) graphs = [] inputs.each do |input| next if input[:no_video] case input[:type] when Type::MASH mash = input[:mash] Mash.video_ranges(mash).each do |range| graphs << __mash_range_graph(input, mash, range, job) end when Type::VIDEO, Type::IMAGE graphs << GraphRaw.new(input) end end graphs end
Public Instance Methods
Transfer
-
Resolves relative URLs.
- Default
- Types
-
Just Type::MASH.
# File lib/input.rb, line 170 def base_source _get(__method__) end
# File lib/input.rb, line 174 def fill _get(__method__) end
- String
-
How to size in relation to
Output#dimensions
. - Constant
-
Fill::CROP, Fill::NONE, Fill::SCALE or Fill::STRETCH.
- Default
-
Fill::STRETCH.
- Types
-
Type::IMAGE and Type::VIDEO.
# File lib/input.rb, line 182 def fill=(value) _set __method__, value end
# File lib/input.rb, line 192 def length _get(__method__) end
# File lib/input.rb, line 202 def mash _get(__method__) end
Mash
-
The mash to include in rendering.
- Default
-
nil
- Types
-
Just Type::MASH.
# File lib/input.rb, line 209 def mash=(value) _set __method__, value end
Transfer
-
Resolves relative font URLs for modules.
- Default
- Types
-
Just Type::MASH.
# File lib/input.rb, line 216 def module_source _get(__method__) end
# File lib/input.rb, line 220 def offset _get(__method__) end
- Float
-
Seconds to remove from beginning of input.
- Default
-
0.0 means nothing removed.
- Types
-
Type::AUDIO and Type::VIDEO.
# File lib/input.rb, line 227 def offset=(value) _set __method__, value end
MovieMasher::Asset#preflight
# File lib/input.rb, line 231 def preflight(job = nil) super mash&.preflight job end
# File lib/input.rb, line 236 def start _get(__method__) end
- Float
-
Seconds from start of mashup to introduce the input.
- Default
-
-1.0 means after previous audio in mashup completes.
- Types
-
Just Type::AUDIO.
# File lib/input.rb, line 243 def start=(value) _set __method__, value end