Skip to content

Instantly share code, notes, and snippets.

@altanai
Created November 12, 2016 10:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save altanai/f94ef2e067b3feb0f4eb696879027ee0 to your computer and use it in GitHub Desktop.
Save altanai/f94ef2e067b3feb0f4eb696879027ee0 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")
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)
h264parse = Gst.ElementFactory.make("h264parse", "h264")
flvmux = Gst.ElementFactory.make("flvmux", "flv")
filesink = Gst.ElementFactory.make("filesink", "fsink")
filesink.set_property("location", "specific2.flv")
rtmpsink = Gst.ElementFactory.make("rtmpsink", "rsink")
rtmpsink.set_property("location", "rtmp://<serverip>/live/test")
tee = Gst.ElementFactory.make("tee", "tee")
queueCloud = Gst.ElementFactory.make("queue", "cloud")
queueFile = Gst.ElementFactory.make("queue", "file")
pipeline.add(tee)
pipeline.add(queueCloud)
pipeline.add(queueFile)
pipeline.add(filesink)
pipeline.add(rtmpsink)
pipeline.add(rpicamsrc)
pipeline.add(rCamCapsFilt)
pipeline.add(h264parse)
pipeline.add(flvmux)
rpicamsrc.link(rCamCapsFilt)
rCamCapsFilt.link(h264parse)
h264parse.link(flvmux)
flvmux.link(tee)
queueCloud.link(rtmpsink)
queueFile.link(filesink)
tee.link(queueCloud)
tee.link(queueFile)
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