Connect audio pad created by the rtspsrc plugin to connect it to a splitmuxsink in python
Eric Zerbib
ezerbib at kramerav.com
Tue May 11 09:28:13 UTC 2021
Hello Gstreamer dev
I wanted to know if someone has an idea how to connect the audio pad created by the rtspsrc plugin to connect it to a splitmuxsink in a python program
Here is what I did but only video is working
#!/usr/bin/env python3
import gi
import signal, os
gi.require_version("Gst", "1.0")
gi.require_version("GstAudio", "1.0")
from gi.repository import Gst, GObject, GLib, GstAudio
from time import sleep
Gst.init(None)
scn=0
rtpmp4adepay = Gst.ElementFactory.make("rtpmp4adepay", "rtpmp4adepay0")
def on_rtspsrc_pad_added(rtspsrc, pad, rtph26xdepay):
rtspsrc.link(rtph26xdepay)
rtspsrc.link(rtpmp4adepay)
def with_audio(pipeline,splitmuxsink):
pipeline.add(rtpmp4adepay)
rtpmp4adepay.link(splitmuxsink)
def main(uri):
#pipeline = Gst.Pipeline()
pipeline = Gst.Pipeline()
source = Gst.ElementFactory.make("rtspsrc", "video-source")
source.set_property("location", uri)
source.set_property("latency", 300)
pipeline.add(source)
# Create the rest of your pipeline here and link it
depay_plugin_str ="rtp{}depay".format(encoding_method)
depay = Gst.ElementFactory.make(depay_plugin_str, "depay0")
pipeline.add(depay)
#rtspsrc.link(depay)
source.connect("pad-added", on_rtspsrc_pad_added, depay)
parse_plugin_str = "{}parse".format(encoding_method)
parse = Gst.ElementFactory.make(parse_plugin_str, "parse")
pipeline.add(parse)
depay.link(parse)
queue1 = Gst.ElementFactory.make("queue", "queue1")
queue1.set_property("max-size-buffers", 0)
queue1.set_property("max-size-bytes", 0)
pipeline.add(queue1)
parse.link(queue1)
mpegtsmux = Gst.ElementFactory.make("mpegtsmux", "mpegtsmux0")
splitmuxsink = Gst.ElementFactory.make("splitmuxsink", "splitmuxsink0")
splitmuxsink.set_property("name","smux")
splitmuxsink.set_property("async-handling","true")
splitmuxsink.set_property("muxer",mpegtsmux)
splitmuxsink.set_property("location",storage_file_name)
splitmuxsink.set_property("max-size-time",storage_file_time)
splitmuxsink.set_property("max-size-bytes",storage_file_size)
splitmuxsink.set_property("max-files",storage_max_file)
pipeline.add(splitmuxsink)
queue1.link(splitmuxsink)
with_audio(pipeline,splitmuxsink)
# We will add/link the rest of the pipeline later
loop = GObject.MainLoop()
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
pipeline.set_state(Gst.State.NULL)
if __name__ == "__main__":
uri="rtsp://127.0.0.1:{}/stream".format(rtsp_port)
print(" connect to {}".format(uri))
main(uri)
Thanks in advance
EZ
This message has been scanned for malware by Websense. www.websense.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20210511/7f14354e/attachment-0001.htm>
More information about the gstreamer-devel
mailing list