Gst_nvvconv_transform: NvBufSurfTransform Failed :

• Hardware Platform (Jetson / GPU) nano
• DeepStream Version 7.0
• JetPack Version (valid for Jetson only) 6.0
• TensorRT Version 8.6.2.3-1+cuda12.2
• NVIDIA GPU Driver Version (valid for GPU only) NVIDIA-SMI 540.2.0
• Issue Type( questions, new requirements, bugs)

Error: gst-stream-error-quark: Internal data stream error. (1): /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(2420): gst_nvinfer_output_loop (): /GstPipeline:pipeline0/GstNvInfer:primary-inference:
streaming stopped, reason not-linked (-1)

Details Error :
Frame Number=0 Number of Objects=1 Person_count=1
Frame Number=0 Number of Objects=0 Person_count=1
gst_nvvconv_transform: NvBufSurfTransform Failed
0:00:15.017257346 7234 0xaaaada692300 WARN nvinfer gstnvinfer.cpp:2420:gst_nvinfer_output_loop: error: Internal data stream error.
0:00:15.017306531 7234 0xaaaada692300 WARN nvinfer gstnvinfer.cpp:2420:gst_nvinfer_output_loop: error: streaming stopped, reason error (-5)
Error: gst-stream-error-quark: Internal data stream error. (1): /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(2420): gst_nvinfer_output_loop (): /GstPipeline:pipeline0/GstNvInfer:primary-inference:
streaming stopped, reason error (-5)
Frame Number=1 Number of Objects=0 Person_count=0
Frame Number=1 Number of Objects=3 Person_count=3

Code :
#!/usr/bin/env python3
import argparse
import sys
sys.path.append(‘…/’)

import gi
gi.require_version(‘Gst’, ‘1.0’)
gi.require_version(‘GstRtspServer’, ‘1.0’)
from gi.repository import GLib, Gst, GstRtspServer
from common.is_aarch_64 import is_aarch64
from common.bus_call import bus_call

import pyds

import os

PGIE_CLASS_ID_PERSON = 0
MUXER_BATCH_TIMEOUT_USEC = 33000

def osd_sink_pad_buffer_probe(pad,info,u_data):
frame_number=0
#Intiallizing object counter with 0.
obj_counter = {
PGIE_CLASS_ID_PERSON:0
}
num_rects=0

gst_buffer = info.get_buffer()
if not gst_buffer:
    print("Unable to get GstBuffer ")
    return

# Retrieve batch metadata from the gst_buffer
# Note that pyds.gst_buffer_get_nvds_batch_meta() expects the
# C address of gst_buffer as input, which is obtained with hash(gst_buffer)
batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
l_frame = batch_meta.frame_meta_list
while l_frame is not None:
    try:
        # Note that l_frame.data needs a cast to pyds.NvDsFrameMeta
        # The casting is done by pyds.NvDsFrameMeta.cast()
        # The casting also keeps ownership of the underlying memory
        # in the C code, so the Python garbage collector will leave
        # it alone.
        frame_meta = pyds.NvDsFrameMeta.cast(l_frame.data)
    except StopIteration:
        break

    frame_number=frame_meta.frame_num
    num_rects = frame_meta.num_obj_meta
    l_obj=frame_meta.obj_meta_list
    while l_obj is not None:
        try:
            # Casting l_obj.data to pyds.NvDsObjectMeta
            obj_meta=pyds.NvDsObjectMeta.cast(l_obj.data)
        except StopIteration:
            break
        obj_counter[obj_meta.class_id] += 1

        # add ssuni------------
        obj_meta.rect_params.border_color.set(0.0, 0.0, 1.0, 0.8) 
        # ---------------------
        
        try: 
            l_obj=l_obj.next
        except StopIteration:
            break

    # Acquiring a display meta object. The memory ownership remains in
    # the C code so downstream plugins can still access it. Otherwise
    # the garbage collector will claim it when this probe function exits.
    display_meta=pyds.nvds_acquire_display_meta_from_pool(batch_meta)
    display_meta.num_labels = 1
    py_nvosd_text_params = display_meta.text_params[0]
    # Setting display text to be shown on screen
    # Note that the pyds module allocates a buffer for the string, and the
    # memory will not be claimed by the garbage collector.
    # Reading the display_text field here will return the C address of the
    # allocated string. Use pyds.get_string() to get the string content.
    py_nvosd_text_params.display_text = "Frame Number={} Number of Objects={} Person_count={}".format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_PERSON])

    # Now set the offsets where the string should appear
    py_nvosd_text_params.x_offset = 10
    py_nvosd_text_params.y_offset = 12

    # Font , font-color and font-size
    py_nvosd_text_params.font_params.font_name = "Serif"
    py_nvosd_text_params.font_params.font_size = 10
    # set(red, green, blue, alpha); set to White
    py_nvosd_text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0)

    # Text background color
    py_nvosd_text_params.set_bg_clr = 1
    # set(red, green, blue, alpha); set to Black
    py_nvosd_text_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0)
    # Using pyds.get_string() to get display_text as string
    print(pyds.get_string(py_nvosd_text_params.display_text))
    pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)
    try:
        l_frame=l_frame.next
    except StopIteration:
        break
		
return Gst.PadProbeReturn.OK	

def main(args):
Gst.init(None)

# Create GStreamer elements
print("Creating Pipeline \n")
pipeline = Gst.Pipeline()
if not pipeline:
    sys.stderr.write("Unable to create Pipeline \n")
    sys.exit(1)

# Create source elements
sources = []
parsers = []
decoders = []

for i, stream_path in enumerate(stream_paths):
    source = Gst.ElementFactory.make("filesrc", f"file-source-{i}")
    if not source:
        sys.stderr.write(f"Unable to create Source {i}\n")
        sys.exit(1)
    source.set_property('location', stream_path)
    sources.append(source)
    
    h264parser = Gst.ElementFactory.make("h264parse", f"h264-parser-{i}")
    if not h264parser:
        sys.stderr.write(f"Unable to create H264 Parser {i}\n")
        sys.exit(1)
    parsers.append(h264parser)
    
    decoder = Gst.ElementFactory.make("nvv4l2decoder", f"nvv4l2-decoder-{i}")
    if not decoder:
        sys.stderr.write(f"Unable to create Decoder {i}\n")
        sys.exit(1)
    decoders.append(decoder)
    
    pipeline.add(source)
    pipeline.add(h264parser)
    pipeline.add(decoder)

    source.link(h264parser)
    h264parser.link(decoder)

# Create nvstreammux instance to form batches from multiple sources
print("Creating Stream Muxer \n")
streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
if not streammux:
    sys.stderr.write("Unable to create Stream Muxer \n")
    sys.exit(1)
streammux.set_property('batch-size', len(stream_paths))
streammux.set_property('width', 1920)
streammux.set_property('height', 1080)
streammux.set_property('batched-push-timeout', MUXER_BATCH_TIMEOUT_USEC)

# Create remaining elements
print("Creating Primary Inference \n")
pgie = Gst.ElementFactory.make("nvinfer", "primary-inference")
if not pgie:
    sys.stderr.write("Unable to create Primary Inference \n")
    sys.exit(1)

print("Creating Video Converter \n")
nvvidconv = Gst.ElementFactory.make("nvvidconv", "convertor")
if not nvvidconv:
    sys.stderr.write("Unable to create Video Converter \n")
    sys.exit(1)

print("Creating OSD \n")
nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay")
if not nvosd:
    sys.stderr.write("Unable to create OSD \n")
    sys.exit(1)

print("Creating Post OSD Video Converter \n")
nvvidconv_postosd = Gst.ElementFactory.make("nvvidconv", "convertor_postosd")
if not nvvidconv_postosd:
    sys.stderr.write("Unable to create Post OSD Video Converter \n")
    sys.exit(1)

print("Creating Caps Filter \n")
caps = Gst.ElementFactory.make("capsfilter", "filter")
caps.set_property("caps", Gst.Caps.from_string("video/x-raw(memory:NVMM), format=I420"))

print(f"Creating {codec} Encoder \n")
# if codec == "H264":
#     #encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
#     encoder = Gst.ElementFactory.make("x265enc", "encoder")
# elif codec == "H265":
#     #encoder = Gst.ElementFactory.make("nvv4l2h265enc", "encoder")
#     encoder = Gst.ElementFactory.make("x265enc", "encoder")
# if not encoder:
#     sys.stderr.write("Unable to create Encoder \n")
#     sys.exit(1)

# Make the encoder
if codec == "H264":
    if enc_type == 0:
        #encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
        encoder = Gst.ElementFactory.make("x264enc", "encoder")
    else:
        encoder = Gst.ElementFactory.make("x264enc", "encoder")
    print("Creating H264 Encoder")
elif codec == "H265":
    if enc_type == 0:
        #encoder = Gst.ElementFactory.make("nvv4l2h265enc", "encoder")
        encoder = Gst.ElementFactory.make("x264enc", "encoder")
    else:
        encoder = Gst.ElementFactory.make("x265enc", "encoder")
    print("Creating H265 Encoder")
if not encoder:
    sys.stderr.write(" Unable to create encoder")    

encoder.set_property('bitrate', bitrate)
# if is_aarch64() and enc_type == 0:
#     encoder.set_property('preset-level', 1)
#     encoder.set_property('insert-sps-pps', 1)

print(f"Creating RTP Payloader for {codec} \n")
rtppay = Gst.ElementFactory.make(f"rtp{codec.lower()}pay", "rtppay")
if not rtppay:
    sys.stderr.write(f"Unable to create RTP Payload for {codec} \n")
    sys.exit(1)

print("Creating UDP Sink \n")
updsink_port_num = 5400
sink = Gst.ElementFactory.make("udpsink", "udpsink")
if not sink:
    sys.stderr.write("Unable to create UDP Sink \n")
    sys.exit(1)
sink.set_property('host', '224.224.255.255')
sink.set_property('port', updsink_port_num)
sink.set_property('async', False)
sink.set_property('sync', 1)

pgie.set_property('config-file-path', "peoplenet_test1_pgie_config.txt")

# Add and link elements
print("Adding elements to Pipeline \n")
pipeline.add(streammux)
pipeline.add(pgie)
pipeline.add(nvvidconv)
pipeline.add(nvosd)
pipeline.add(nvvidconv_postosd)
pipeline.add(caps)
pipeline.add(encoder)
pipeline.add(rtppay)
pipeline.add(sink)

# Link source elements to streammux
for i, decoder in enumerate(decoders):
    sinkpad = streammux.get_request_pad(f"sink_{i}")
    srcpad = decoder.get_static_pad("src")
    srcpad.link(sinkpad)

streammux.link(pgie)
pgie.link(nvvidconv)
nvvidconv.link(nvosd)
nvosd.link(nvvidconv_postosd)
nvvidconv_postosd.link(caps)
caps.link(encoder)
encoder.link(rtppay)
rtppay.link(sink)

# Create an event loop and feed GStreamer bus messages to it
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)

# Start streaming
rtsp_port_num = 554
server = GstRtspServer.RTSPServer.new()
server.props.service = "%d" % rtsp_port_num
#server.set_address("92.168.10.138")
server.attach(None)

factory = GstRtspServer.RTSPMediaFactory.new()
factory.set_launch(f"( udpsrc name=pay0 port={updsink_port_num} buffer-size=524288 caps=\"application/x-rtp, media=video, clock-rate=90000, encoding-name=(string){codec}, payload=96 \" )")
factory.set_shared(True)
server.get_mount_points().add_factory("/ds-test", factory)

print(f"\n *** DeepStream: Launched RTSP Streaming at rtsp://92.168.10.138:{rtsp_port_num}/ds-test ***\n\n")

osdsinkpad = nvosd.get_static_pad("sink")
if not osdsinkpad:
    sys.stderr.write("Unable to get sink pad of nvosd \n")
    sys.exit(1)

osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)

print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
    loop.run()
except KeyboardInterrupt:
    pass
finally:
    pipeline.set_state(Gst.State.NULL)

def parse_args():
parser = argparse.ArgumentParser(description=‘RTSP Output Sample Application Help ‘)
parser.add_argument(“-i”, “–input”, nargs=’+’, required=True,
help=“Paths to input H264 elementary streams”)
parser.add_argument(“-c”, “–codec”, default=“H264”,
help=“RTSP Streaming Codec H264/H265, default=H264”, choices=[‘H264’, ‘H265’])
parser.add_argument(“-b”, “–bitrate”, default=4000000,
help=“Set the encoding bitrate”, type=int)
parser.add_argument(“-e”, “–enc_type”, default=0,
help=“0:Hardware encoder, 1:Software encoder, default=0”, choices=[0, 1], type=int)
args = parser.parse_args()

global codec
global bitrate
global stream_paths
global enc_type
codec = args.codec
bitrate = args.bitrate
stream_paths = args.input
enc_type = args.enc_type
return 0

if name == ‘main’:
parse_args()
sys.exit(main(sys.argv))

Commond to Run : python3 multiple.py -i /home/paymentinapp/Desktop/nus-2024-vision-main/video/busan_video.h264 /home/paymentinapp/Desktop/nus-2024-vision-main/video/smoke_video.h264 -e 1

Could you add GST_DEBUG=3 in front of the command line and attach the log?

Error :

Frame Number=0 Number of Objects=1 Person_count=1
Frame Number=0 Number of Objects=0 Person_count=1
gst_nvvconv_transform: NvBufSurfTransform Failed
0:00:11.637225246 7691 0xaaaaf2c70700 WARN nvinfer gstnvinfer.cpp:2420:gst_nvinfer_output_loop: error: Internal data stream error.
0:00:11.637260542 7691 0xaaaaf2c70700 WARN nvinfer gstnvinfer.cpp:2420:gst_nvinfer_output_loop: error: streaming stopped, reason error (-5)
Frame Number=1 Number of Objects=0 Person_count=0
Frame Number=1 Number of Objects=3 Person_count=3
Error: gst-stream-error-quark: Internal data stream error. (1): /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(2420): gst_nvinfer_output_loop (): /GstPipeline:pipeline0/GstNvInfer:primary-inference:
streaming stopped, reason error (-5)

Commond: GST_DEBUG=3 python3 multiple.py -i /home/paymentinapp/Desktop/nus-2024-vision-main/video/busan_video.h264 /home/paymentinapp/Desktop/nus-2024-vision-main/video/smoke_video.h264 -e 1

Log here:
deepstream_log.txt (6.4 KB)

0:00:00.475492661  7691 0xaaaaf2ce9e90 ERROR             rtspserver rtsp-server.c:1004:gst_rtsp_server_create_socket:<GstRTSPServer@0xaaaaf2ce9560> failed to create socket
0:00:00.475543190  7691 0xaaaaf2ce9e90 ERROR             rtspserver rtsp-server.c:1374:gst_rtsp_server_create_source:<GstRTSPServer@0xaaaaf2ce9560> failed to create socket
0:00:00.475594263  7691 0xaaaaf2ce9e90 ERROR             rtspserver rtsp-server.c:1420:gst_rtsp_server_attach:<GstRTSPServer@0xaaaaf2ce9560> failed to create watch: Error binding to address 0.0.0.0:554: Permission denied

It seems that there are some problems with your rtsp server. You can check that first.