Class: Editframe::VideoClip
- Inherits:
-
Object
- Object
- Editframe::VideoClip
- Defined in:
- lib/editframe/video/clip.rb
Instance Attribute Summary collapse
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
Instance Method Summary collapse
- #encode ⇒ Object
- #filter(name, options = {}) ⇒ Object
-
#initialize(source, options = {}) ⇒ VideoClip
constructor
A new instance of VideoClip.
- #mute ⇒ Object
- #resize(resolution) ⇒ Object
- #set_resolution(resolution) ⇒ Object
- #set_volume(volume) ⇒ Object
- #trim(trim_start, trim_end) ⇒ Object
Constructor Details
#initialize(source, options = {}) ⇒ VideoClip
Returns a new instance of VideoClip.
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/editframe/video/clip.rb', line 6 def initialize(source, = {}) @id = Util.uuid @form = {} @filters = [] @layers = [] @options = || { } @resolution = { width: nil, height: nil } @trim = { start: 0, end: nil } @volume = 1.0 configure_source source end |
Instance Attribute Details
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
4 5 6 |
# File 'lib/editframe/video/clip.rb', line 4 def layers @layers end |
Instance Method Details
#encode ⇒ Object
60 61 62 63 |
# File 'lib/editframe/video/clip.rb', line 60 def encode @form[:config] = Faraday::ParamPart.new(generate_config, 'application/json') Editframe::Video.encode_from_clip(@form) end |
#filter(name, options = {}) ⇒ Object
18 19 20 21 |
# File 'lib/editframe/video/clip.rb', line 18 def filter(name, = {}) @filters.push({ :name => name, :options => { ** } }) self end |
#mute ⇒ Object
55 56 57 58 |
# File 'lib/editframe/video/clip.rb', line 55 def mute set_volume 0 self end |
#resize(resolution) ⇒ Object
23 24 25 26 27 |
# File 'lib/editframe/video/clip.rb', line 23 def resize(resolution) return unless !resolution.nil? set_resolution resolution self end |
#set_resolution(resolution) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/editframe/video/clip.rb', line 29 def set_resolution(resolution) return unless !resolution.nil? values = resolution.split('x') @resolution = { width: values[0].to_i, height: values[1].to_i } self end |
#set_volume(volume) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/editframe/video/clip.rb', line 36 def set_volume(volume) @volume = volume.to_f if volume > 1 then @volume = 1.0 end if volume < 1 then @volume = 0.0 end self end |
#trim(trim_start, trim_end) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/editframe/video/clip.rb', line 43 def trim(trim_start, trim_end) @trim[:start] = trim_start @trim[:end] = trim_end if @trim[:start] < 0 @trim[:start] = 0 end if @trim[:end] < 0 @trim.delete(:end) end self end |