gstreamer 1.0 + python:来自PLAYING管道的动态链接和取消链接队列

时间:2016-11-19 03:39:08

标签: python raspberry-pi gstreamer python-gstreamer gstreamer-1.0

Pipeline architecture I'm trying to implement

在将管道设置为PLAYING之前将两个队列链接在一​​起时脚本运行良好,但我很难理解gstreamer动态管道及其实现。而且缺少gstreamer 1.0 python的文档/示例也无济于事。

这是使用tee记录到文件并流式传输到rtmp服务器的工作脚本

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)

我想做什么:

  • 最初只有一个队列发球( queueFile )记录到一个文件(总是在运行)
  • 根据需要向服务器动态添加和删除队列( queueCloud

gstreamer 1.0和gi python没有很多文档,非常感谢任何帮助。

0 个答案:

没有答案