4

Pipeline architecture I'm trying to implement

The script works well when both the queues are linked together before setting the pipeline to PLAYING, but I'm having a hard time understanding Gstreamer dynamic pipelines and their implementation. Also the lack of documentation/examples for gstreamer 1.0 python isn't helping.

Here is the working script that uses tee to record to a file and also stream to a RTMP server

import gi
import time
from gi.repository import GObject, Gst
gi.require_version('Gst', '1.0')

Gst.init(None)

Gst.debug_set_active(True)
Gst.debug_set_default_threshold(3)
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")
h264parse2 = Gst.ElementFactory.make("h264parse", "enh2642")

flvmux = Gst.ElementFactory.make("flvmux", "flv")
mp4mux = Gst.ElementFactory.make("mp4mux", "mp4")

filesink = Gst.ElementFactory.make("filesink", "fsink")
filesink.set_property("location", "specific2.mp4")

rtmpsink = Gst.ElementFactory.make("rtmpsink", "rsink")
rtmpsink.set_property("location", "rtmp://<server>/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(h264parse2)
pipeline.add(flvmux)
pipeline.add(mp4mux)

rpicamsrc.link(rCamCapsFilt)
rCamCapsFilt.link(tee)

queueCloud.link(h264parse)
h264parse.link(flvmux)
flvmux.link(rtmpsink)

queueFile.link(h264parse2)
h264parse2.link(mp4mux)
mp4mux.link(filesink)

tee.link(queueCloud)
tee.link(queueFile)


pipeline.set_state(Gst.State.PLAYING)
time.sleep(5)
#
# pipeline.set_state(Gst.State.NULL)

What I'm trying to do:

  • initially start with just one queue to tee (queueFile) that record to a file (always running)
  • dynamically add and remove a queue to tee (queueCloud) on demand that streams to a server

Not a lot of documentation out there for gstreamer 1.0 and gi python, any help is greatly appreciated.

declension
  • 3,764
  • 19
  • 23

0 Answers0