Skip to content

Instantly share code, notes, and snippets.

@altanai
Created November 12, 2016 10:25
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save altanai/51fdad98449ea7f45ff2a1e28121687b to your computer and use it in GitHub Desktop.
Save altanai/51fdad98449ea7f45ff2a1e28121687b to your computer and use it in GitHub Desktop.
import gi
import time
from gi.repository import GObject, Gst
gi.require_version('Gst', '1.0')
Gst.init(None)
pipeline = Gst.Pipeline()
rpicamsrc = Gst.ElementFactory.make("rpicamsrc", "rpicam")
h264parse = Gst.ElementFactory.make("h264parse", "h264")
flvmux = Gst.ElementFactory.make("flvmux", "flv")
filesink = Gst.ElementFactory.make("filesink", "fsink")
filesink.set_property("location", "sample.flv")
rpicamsrc.set_property("bitrate", 500000)
rpicaps = Gst.caps_from_string('video/x-h264,width=360,height=240,framerate=10/1')
rCamCapsFilt = Gst.ElementFactory.make("capsfilter", "rCamCapsFilt")
rCamCapsFilt.set_property("caps", rpicaps)
pipeline.add(rpicamsrc)
pipeline.add(rCamCapsFilt)
pipeline.add(h264parse)
pipeline.add(flvmux)
pipeline.add(filesink)
rpicamsrc.link(rCamCapsFilt)
rCamCapsFilt.link(h264parse)
h264parse.link(flvmux)
flvmux.link(filesink)
pipeline.set_state(Gst.State.PLAYING)
time.sleep(5)
pipeline.set_state(Gst.State.NULL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment