Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ruby-processing: video capture to a file
#!/usr/bin/env ruby
# this is a test of ruby-processing (https://github.com/jashkenas/ruby-processing) where
# captured video is written to a QuickTime file
# use "rp5 unpack library" at a command line to install the video library if you haven't
# tested with Ruby 1.9.2 on OSX with built in web cam
class VideoCaptureToFileTest < Processing::App
load_library :video
include_package "processing.video"
import 'processing.video.MovieMaker'
def setup
smooth
size(720, 576, P2D)
@input = Capture.new(self, width, height, 30)
output_file = "output_#{Time.now.to_i.to_s}.mov"
@output = MovieMaker.new(self, width, height, output_file, 30, MovieMaker::JPEG, MovieMaker::HIGH )
end
def draw
@input.read if @input.available?
image(@input, 0, 0)
@output.addFrame
end
def key_pressed
if (key == ' ')
@output.finish
exit
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment