I’m encountering a runtime issue using DeepStream with Python bindings. I’m running two DeepStream pipelines in separate Python threads, and I’m dynamically creating the source using a function called create_uridecode_bin(index, filename)
. One pipeline consistently works, but the second pipeline intermittently gets stuck when calling pipeline.set_state(Gst.State.PLAYING)
— this happens 2 out of 5 times.
There’s no crash or visible error — just a silent hang, likely during an async state transition. It seems to be waiting for a preroll that never completes.
def decodebin_child_added(child_proxy,Object,name,user_data):
print(“Decodebin child added:”, name, “\n”)
if(name.find(“decodebin”) != -1):
Object.connect(“child-added”,decodebin_child_added,user_data)
if(name.find(“nvv4l2decoder”) != -1):
if (platform_info.is_integrated_gpu()):
Object.set_property(“enable-max-performance”, True)
Object.set_property(“drop-frame-interval”, 0)
Object.set_property(“num-extra-surfaces”, 0)
else:
Object.set_property(“gpu_id”, GPU_ID)
def cb_newpad(decodebin,pad,data):
global streammux
print(“In cb_newpad\n”)
caps=pad.get_current_caps()
gststruct=caps.get_structure(0)
gstname=gststruct.get_name()
# Need to check if the pad created by the decodebin is for video and not
# audio.
print("gstname=",gstname)
if(gstname.find("video")!=-1):
source_id = data
pad_name = "sink_%u" % source_id
print(pad_name)
#Get a sink pad from the streammux, link to decodebin
sinkpad = streammux.request_pad_simple(pad_name)
if not sinkpad:
sys.stderr.write("Unable to create sink pad bin \n")
if pad.link(sinkpad) == Gst.PadLinkReturn.OK:
print("Decodebin linked to pipeline")
else:
sys.stderr.write("Failed to link decodebin to pipeline\n")
def create_uridecode_bin(index,filename):
global g_source_id_list
print(“Creating uridecodebin for [%s]” % filename)
# Create a source GstBin to abstract this bin's content from the rest of the
# pipeline
g_source_id_list[index] = index
bin_name="source-bin-%02d" % index
print(bin_name)
# Source element for reading from the uri.
# We will use decodebin and let it figure out the container format of the
# stream and the codec and plug the appropriate demux and decode plugins.
bin=Gst.ElementFactory.make("uridecodebin", bin_name)
if not bin:
sys.stderr.write(" Unable to create uri decode bin \n")
# We set the input uri to the source element
bin.set_property("uri",filename)
# Connect to the "pad-added" signal of the decodebin which generates a
# callback once a new pad for raw data has been created by the decodebin
bin.connect("pad-added",cb_newpad,g_source_id_list[index])
bin.connect("child-added",decodebin_child_added,g_source_id_list[index])
#Set status of the source to enabled
g_source_enabled[index] = True
return bin