• Nvidia 3060
• DeepStream Version 6.3
• Bugs
• Working from deepstream container
I’ve implemented a simple pipeline to read an rtsp stream with rtspsrc element and display it in a window.
However, for some streams, I’m getting an error and the pipeline seems to be blocked. Could you suggest some solutions?
Here are the code and logs :
CODE
import gi
gi.require_version("Gst", "1.0")
from gi.repository import Gst, GObject
import threading
import time
import sys
def cb_newpad(element, element_src_pad, data):
print("IN NEW PAD")
caps = element_src_pad.get_current_caps()
structure = caps.get_structure(0)
name = structure.get_name()
media_type = structure.get_value("media")
print(f"Pad added: {media_type} & {name}")
if media_type == "video" and name == "application/x-rtp":
print("Here we go")
sinkpad = data.get_static_pad("sink") #where data is depay element
print("Source pad capabilities:", element_src_pad.query_caps(None).to_string())
print("Sink pad capabilities:", sinkpad.query_caps(None).to_string())
if element_src_pad.link(sinkpad) != Gst.PadLinkReturn.OK:
print('Elements could not be linked: 1. Exiting.', flush=True)
sys.exit(-1)
def on_error(bus, message):
err, debug = message.parse_error()
print(f"Error: {err}, {debug}")
def main():
GObject.threads_init()
Gst.init(None)
# Set the default debug threshold
Gst.debug_set_default_threshold(3)
pipeline = Gst.Pipeline.new("dstest-sr-pipeline")
source = Gst.ElementFactory.make("rtspsrc", "rtsp-source")
source.set_property("location", "rtsp://x.x.x.x/onvif-media/media.amp")
depay_pre_decode = Gst.ElementFactory.make("rtph264depay", "h264-depay")
parse = Gst.ElementFactory.make("h264parse", "parse")
source.connect("pad-added", cb_newpad, depay_pre_decode)
decoder = Gst.ElementFactory.make("nvv4l2decoder", "nvv4l2-decoder")
convert = Gst.ElementFactory.make("nvvideoconvert", "convert")
caps = Gst.Caps.from_string("video/x-raw,width=1920,height=1080,formate=I420")
filter = Gst.ElementFactory.make("capsfilter", "filter")
filter.set_property("caps", caps)
queue = Gst.ElementFactory.make("queue", "queue")
sink = Gst.ElementFactory.make("nveglglessink", "video-sink")
sink.set_property("window-x", 0)
sink.set_property("window-y", 0)
sink.set_property("window-width", 1280)
sink.set_property("window-height", 720)
# Create a bin and add elements
bin = Gst.Bin.new("my-bin")
bin.add(source)
bin.add(depay_pre_decode)
bin.add(parse)
bin.add(decoder)
if not depay_pre_decode.link(parse):
print('Depay_pre_decode could not be linked to parse. Exiting.')
sys.exit(-1)
if not parse.link(decoder):
print('Parse could not be linked to decoder. Exiting.')
sys.exit(-1)
# Add a ghost pad to the bin
bin.add_pad(Gst.GhostPad.new("src", decoder.get_static_pad("src")))
pipeline.add(bin)
pipeline.add(convert)
pipeline.add(filter)
pipeline.add(queue)
pipeline.add(sink)
# Link bin to the rest of the pipeline
if not bin.link(convert):
print('Bin could not be linked to convert. Exiting.')
sys.exit(-1)
if not convert.link(filter):
print('Convert could not be linked to filter. Exiting.')
sys.exit(-1)
if not filter.link(queue):
print('Filter could not be linked to queue. Exiting.')
sys.exit(-1)
if not queue.link(sink):
print('Queue could not be linked to sink. Exiting.')
sys.exit(-1)
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message::error", on_error)
# Mettre le pipeline en lecture
ret = pipeline.set_state(Gst.State.PLAYING)
if ret == Gst.StateChangeReturn.FAILURE:
print("Unable to set the pipeline to the playing state.", flush=True)
sys.exit(-1)
# Attendre que le pipeline rencontre une erreur ou EOS
print("Running...")
main_loop = GObject.MainLoop()
try:
main_loop.run()
except KeyboardInterrupt:
pass
finally:
pipeline.set_state(Gst.State.NULL)
main_loop.quit()
if __name__ == "__main__":
main()
LOGS
graph-deepstream-deepstream-1 | 0:01:12.551655836 1 0x7f954c007400 WARN rtspmedia rtsp-media.c:3272:wait_preroll: failed to preroll pipeline
graph-deepstream-deepstream-1 | 0:01:12.551715935 1 0x7f954c007400 WARN rtspmedia rtsp-media.c:3652:gst_rtsp_media_prepare: failed to preroll pipeline
graph-deepstream-deepstream-1 | 0:01:12.552460774 1 0x7f954c007400 ERROR rtspclient rtsp-client.c:1077:find_media: client 0x211a130: can't prepare media
graph-deepstream-deepstream-1 | 0:01:12.552631713 1 0x7f954c007400 ERROR rtspclient rtsp-client.c:2963:handle_describe_request: client 0x211a130: no media