class Recorder

Public Class Methods

new(output_file, startx = 0, starty = 0, endx = nil, endy=nil) click to toggle source
# File bin/gifshouldbedead, line 40
def initialize(output_file, startx = 0, starty = 0, endx = nil, endy=nil)
  @pipeline = Gst::Pipeline.new("my-pipeline")
  desc = "ximagesrc " + "startx=#{startx} starty=#{starty} "
  desc += "endx=#{endx} " if endx
  desc += "endy=#{endy} " if endy
  desc += "name=\"videosrc\" !video/x-raw,framerate=25/1 ! queue ! videoconvert ! queue ! vp8enc ! queue"

  videobin = Gst.parse_bin_from_description(desc, true)
  mux = Gst::ElementFactory.make("webmmux")
  sink = Gst::ElementFactory.make("filesink")
  sink.location = output_file
  @pipeline << videobin << mux << sink
  videopad = mux.get_request_pad("video_%u")
  videobin.get_static_pad("src").link(videopad)
  mux.link(sink)
end

Public Instance Methods

record() click to toggle source
# File bin/gifshouldbedead, line 57
def record
  @pipeline.state = :playing
end
stop_record() click to toggle source
# File bin/gifshouldbedead, line 61
def stop_record
  eos_event = Gst::Event.new
  eos_event.type = Gst::EventType::EOS
  @pipeline.send_event(eos_event)
  @pipeline.state = :null
end