Here’s how to grab a single frame from a live video stream using GStreamer on Linux in Ruby.

The trick is to use the “last_buffer” property on your video sink. That contains the last frame that was displayed to your screen.

You can use RMagick to convert that into something you can use like this:


require 'gst'
require 'RMagick'

@pipe =
@source = Gst::ElementFactory.make("v4l2src")
@sink    = Gst::ElementFactory.make("xvimagesink")
@source >> @sink

[ ... Later ... ]
# This is the actual capture.
capture = Image.from_blob(