Class: WGif::Video
- Inherits:
-
Object
- Object
- WGif::Video
- Defined in:
- lib/wgif/video.rb
Instance Attribute Summary collapse
-
#clip ⇒ Object
Returns the value of attribute clip.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, filepath) ⇒ Video
constructor
A new instance of Video.
- #to_frames(options = {}) ⇒ Object
- #trim(start_timestamp, duration) ⇒ Object
Constructor Details
#initialize(name, filepath) ⇒ Video
Returns a new instance of Video.
8 9 10 11 12 13 14 |
# File 'lib/wgif/video.rb', line 8 def initialize(name, filepath) @name = name @clip = FFMPEG::Movie.new(filepath) FileUtils.mkdir_p '/tmp/wgif/' @logger = Logger.new("/tmp/wgif/#{name}.log") FFMPEG.logger = @logger end |
Instance Attribute Details
#clip ⇒ Object
Returns the value of attribute clip.
6 7 8 |
# File 'lib/wgif/video.rb', line 6 def clip @clip end |
#logger ⇒ Object
Returns the value of attribute logger.
6 7 8 |
# File 'lib/wgif/video.rb', line 6 def logger @logger end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/wgif/video.rb', line 6 def name @name end |
Instance Method Details
#to_frames(options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/wgif/video.rb', line 26 def to_frames( = {}) make_frame_dir if [:frames] framerate = [:frames] / @clip.duration else framerate = 24 end transcode(@clip, "/tmp/wgif/frames/\%5d.png", "-vf fps=#{framerate}") open_frame_dir end |
#trim(start_timestamp, duration) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/wgif/video.rb', line 16 def trim(, duration) = { audio_codec: 'copy', video_codec: 'copy', custom: "-ss #{} -t 00:00:#{format('%06.3f', duration)}" } transcode(@clip, "/tmp/wgif/#{@name}-clip.mov", ) WGif::Video.new "#{@name}-clip", "/tmp/wgif/#{@name}-clip.mov" end |