Hi @junshengy,
I will try the approach you suggested. However, while receiving the frames from the pgie
metadata for saving, I am encountering the following error:
arduino
Copy
"Currently we only support RGBA or RGB color format"
To overcome this issue, I added a capsfilter
and tried running the pipeline again. But now, I am getting the following error:
ruby
Copy
0:00:09.779035433 412429 0x5606ffcf93f0 INFO nvinfer gstnvinfer_impl.cpp:343:notifyLoadModelStatus:<primary-inference> [UID 1]: Load new model:/home/dstream/Documents/Deep_Stream_App/configs/cofig_infer_yolov8_forum.txt successfully
Decodebin child added: source
Decodebin child added: decodebin0
Decodebin child added: qtdemux0
Decodebin child added: multiqueue0
Decodebin child added: h264parse0
Decodebin child added: capsfilter0
Decodebin child added: aacparse0
Decodebin child added: avdec_aac0
Decodebin child added: nvv4l2decoder0
New pad callback
Pad type: video/x-raw
New pad callback
Pad type: audio/x-raw
Error: gst-stream-error-quark: Internal data stream error. (1)
Debug info: ../gst/isomp4/qtdemux.c(6760): gst_qtdemux_loop (): /GstPipeline:pipeline0/GstBin:source-bin-00/GstURIDecodeBin:uri-decode-bin/GstDecodeBin:decodebin0/GstQTDemux:qtdemux0:
streaming stopped, reason not-negotiated (-4)
[NvMultiObjectTracker] De-initialized
[8]- Killed python3 app.py
Pipeline Code:
python
Copy
import sys
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GLib', '2.0')
from gi.repository import Gst, GLib, GObject
from data_loading import *
from custom_probe_2 import *
def decodebin_child_added(child_proxy, Object, name, user_data):
print(f"Decodebin child added: {name}")
if "decodebin" in name:
Object.connect("child-added", decodebin_child_added, user_data)
if "source" in name:
source_element = child_proxy.get_by_name("source")
if source_element and source_element.find_property('drop-on-latency') is not None:
source_element.set_property("drop-on-latency", True)
def cb_newpad(decodebin, decoder_src_pad, data):
print("New pad callback")
caps = decoder_src_pad.get_current_caps()
if not caps:
caps = decoder_src_pad.query_caps(None)
gststruct = caps.get_structure(0)
gstname = gststruct.get_name()
source_bin = data
print(f"Pad type: {gstname}")
if "video" in gstname:
bin_ghost_pad = source_bin.get_static_pad("src")
if not bin_ghost_pad.set_target(decoder_src_pad):
sys.stderr.write("Failed to link decoder src pad to source bin ghost pad\n")
def create_source_bin(index, uri):
bin_name = f"source-bin-{index:02d}"
nbin = Gst.Bin.new(bin_name)
if not nbin:
sys.stderr.write("Unable to create source bin\n")
return None
uri_decode_bin = Gst.ElementFactory.make("uridecodebin", "uri-decode-bin")
if not uri_decode_bin:
sys.stderr.write("Unable to create uridecodebin\n")
return None
uri_decode_bin.set_property("uri", uri)
uri_decode_bin.connect("pad-added", cb_newpad, nbin)
uri_decode_bin.connect("child-added", decodebin_child_added, nbin)
Gst.Bin.add(nbin, uri_decode_bin)
if not nbin.add_pad(Gst.GhostPad.new_no_target("src", Gst.PadDirection.SRC)):
sys.stderr.write("Failed to add ghost pad in source bin\n")
return None
return nbin
def main(cfg):
Gst.init(None)
print("Creating DeepStream Face Detection Pipeline")
# Create Pipeline
pipeline = Gst.Pipeline()
if not pipeline:
print("Error: Unable to create pipeline")
sys.exit(1)
else:
print("Pipeline created successfully")
# Create Stream Muxer
streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
pipeline.add(streammux)
set_property(cfg, streammux, "streammux")
# Create and Add Source Bin
sources = cfg['source']
source_bin = create_source_bin(0, list(sources.values())[0])
pipeline.add(source_bin)
# Link Source to Stream Muxer
sinkpad = streammux.get_request_pad("sink_0")
srcpad = source_bin.get_static_pad("src")
if sinkpad is None or srcpad is None:
print("Error: Source or Streammux pad not found!")
else:
print(">>> Linking Source Bin to StreamMuxer")
srcpad.link(sinkpad)
# Create Primary Inference (Face Detection)
caps1 = Gst.Caps.from_string("video/x-raw(memory:NVMM), format=RGBA")
filter1 = Gst.ElementFactory.make("capsfilter", "filter1")
filter1.set_property("caps", caps1)
pipeline.add(filter1)
pgie = Gst.ElementFactory.make("nvinfer", "primary-inference")
pipeline.add(pgie)
set_property(cfg, pgie, "pgie")
tracker = Gst.ElementFactory.make("nvtracker", "tracker")
pipeline.add(tracker)
set_tracker_properties(tracker, cfg['tracker']['config-file-path'])
# Create Tiler
tiler = Gst.ElementFactory.make("nvmultistreamtiler", "nvtiler")
pipeline.add(tiler)
tiler.set_property("rows", 1)
tiler.set_property("columns", 1)
tiler.set_property("width", 1920)
tiler.set_property("height", 1080)
# Create Video Converter
nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor")
pipeline.add(nvvidconv)
# Create On-Screen Display
nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay")
nvosd.set_property("process-mode", 0) # Default mode (draw bounding boxes)
nvosd.set_property("display-text", 1)
pipeline.add(nvosd)
# Create Sink
sink = Gst.ElementFactory.make("nveglglessink", "file-sink")
pipeline.add(sink)
sink.set_property("sync", 0)
print(">>> After creating elements linking of elements is started")
streammux.link(filter1)
filter1.link(pgie)
pgie.link(tracker)
tracker.link(tiler)
tiler.link(nvvidconv)
nvvidconv.link(nvosd)
nvosd.link(sink)
pgie_src_pad = pgie.get_static_pad("src")
if pgie_src_pad:
pgie_src_pad.add_probe(Gst.PadProbeType.BUFFER, pgie_sink_pad_buffer_probe)
loop = GLib.MainLoop()
# Bus Message Handling
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
# Start Pipeline
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except Exception as e:
print(f"Pipeline error: {e}")
finally:
pipeline.set_state(Gst.State.NULL)
def bus_call(bus, message, loop):
t = message.type
if t == Gst.MessageType.EOS:
print("End-of-stream")
loop.quit()
elif t == Gst.MessageType.ERROR:
err, debug = message.parse_error()
print(f"Error: {err}")
print(f"Debug info: {debug}")
loop.quit()
return True
if __name__ == '__main__':
cfg = parse_args(cfg_path="/home/dstream/Documents/Detection_Deep_Stream_App/paths/paths.toml")
main(cfg)
My Question:
Is there anything wrong in my pipeline, especially related to the capsfilter or the overall configuration that might cause the stream error gst-stream-error-quark: Internal data stream error (1)
?