Please provide complete information as applicable to your setup.
• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)
Running a deepstream 6.0 python app for object detection on jetson nano, below is themodified rtsp sink app
def main(args):
# Standard GStreamer initialization
GObject.threads_init()
Gst.init(None)
# Create gstreamer elements
# Create Pipeline element that will form a connection of other elements
print("Creating Pipeline \n ")
pipeline = Gst.Pipeline()
if not pipeline:
sys.stderr.write(" Unable to create Pipeline \n")
# Source element for reading from USB webcam
print("Creating Source \n ")
source = Gst.ElementFactory.make("v4l2src", "usb-cam-source")
if not source:
sys.stderr.write(" Unable to create Source \n")
caps_v4l2src = Gst.ElementFactory.make("capsfilter", "v4l2src_caps")
if not caps_v4l2src:
sys.stderr.write(" Unable to create v4l2src capsfilter \n")
print("Creating Video Converter \n")
# Adding videoconvert -> nvvideoconvert as not all
# raw formats are supported by nvvideoconvert;
# Say YUYV is unsupported - which is the common
# raw format for many logi usb cams
# In case we have a camera with raw format supported in
# nvvideoconvert, GStreamer plugins' capability negotiation
# shall be intelligent enough to reduce compute by
# videoconvert doing passthrough (TODO we need to confirm this)
# videoconvert to make sure a superset of raw formats are supported
vidconvsrc = Gst.ElementFactory.make("videoconvert", "convertor_src1")
if not vidconvsrc:
sys.stderr.write(" Unable to create videoconvert \n")
# nvvideoconvert to convert incoming raw buffers to NVMM Mem (NvBufSurface API)
nvvidconvsrc = Gst.ElementFactory.make("nvvideoconvert", "convertor_src2")
if not nvvidconvsrc:
sys.stderr.write(" Unable to create Nvvideoconvert \n")
caps_vidconvsrc = Gst.ElementFactory.make("capsfilter", "nvmm_caps")
if not caps_vidconvsrc:
sys.stderr.write(" Unable to create capsfilter \n")
# Create nvstreammux instance to form batches from one or more sources.
streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")
if not streammux:
sys.stderr.write(" Unable to create NvStreamMux \n")
# Use nvinfer to run inferencing on decoder's output,
# behaviour of inferencing is set through config file
pgie = Gst.ElementFactory.make("nvinfer", "primary-inference")
if not pgie:
sys.stderr.write(" Unable to create pgie \n")
# Use convertor to convert from NV12 to RGBA as required by nvosd
nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor")
if not nvvidconv:
sys.stderr.write(" Unable to create nvvidconv \n")
# Create OSD to draw on the converted RGBA buffer
nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay")
if not nvosd:
sys.stderr.write(" Unable to create nvosd \n")
nvvidconv_postosd = Gst.ElementFactory.make("nvvideoconvert", "convertor_postosd")
if not nvvidconv_postosd:
sys.stderr.write(" Unable to create nvvidconv_postosd \n")
# Create a caps filter
caps = Gst.ElementFactory.make("capsfilter", "filter")
caps.set_property("caps", Gst.Caps.from_string("video/x-raw(memory:NVMM), format=I420"))
# Make the encoder
if codec == "H264":
encoder = Gst.ElementFactory.make("nvv4l2h264enc", "encoder")
print("Creating H264 Encoder")
elif codec == "H265":
encoder = Gst.ElementFactory.make("nvv4l2h265enc", "encoder")
print("Creating H265 Encoder")
if not encoder:
sys.stderr.write(" Unable to create encoder")
encoder.set_property('bitrate', bitrate)
if is_aarch64():
encoder.set_property('preset-level', 1)
encoder.set_property('insert-sps-pps', 1)
encoder.set_property('bufapi-version', 1)
# Make the payload-encode video into RTP packets
if codec == "H264":
rtppay = Gst.ElementFactory.make("rtph264pay", "rtppay")
print("Creating H264 rtppay")
elif codec == "H265":
rtppay = Gst.ElementFactory.make("rtph265pay", "rtppay")
print("Creating H265 rtppay")
if not rtppay:
sys.stderr.write(" Unable to create rtppay")
# Make the UDP sink
updsink_port_num = 5400
sink = Gst.ElementFactory.make("udpsink", "udpsink")
if not sink:
sys.stderr.write(" Unable to create udpsink")
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)
print("Playing cam %s " %camera_path)
caps_v4l2src.set_property('caps', Gst.Caps.from_string("video/x-raw, framerate=30/1"))
caps_vidconvsrc.set_property('caps', Gst.Caps.from_string("video/x-raw(memory:NVMM)"))
source.set_property('device', camera_path)
streammux.set_property('width', 1280)
streammux.set_property('height', 720)
streammux.set_property('batch-size', 1)
streammux.set_property('batched-push-timeout', 4000000)
# Construct the configuration file path with the specified "graintype" prefix
config_file_path = f"{graintype}_config_infer_primary_yoloV5.txt"
print(config_file_path)
# Set the property with the constructed configuration file path
pgie.set_property('config-file-path', config_file_path)
print("Adding elements to Pipeline \n")
pipeline.add(source)
pipeline.add(caps_v4l2src)
pipeline.add(vidconvsrc)
pipeline.add(nvvidconvsrc)
pipeline.add(caps_vidconvsrc)
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)
# we link the elements together
# v4l2src -> nvvideoconvert -> mux ->
# nvinfer -> nvvideoconvert -> nvosd --> nvvidconv_postosd ->
# caps -> encoder -> rtppay -> udpsink
print("Linking elements in the Pipeline \n")
source.link(caps_v4l2src)
caps_v4l2src.link(vidconvsrc)
vidconvsrc.link(nvvidconvsrc)
nvvidconvsrc.link(caps_vidconvsrc)
sinkpad = streammux.get_request_pad("sink_0")
if not sinkpad:
sys.stderr.write(" Unable to get the sink pad of streammux \n")
srcpad = caps_vidconvsrc.get_static_pad("src")
if not srcpad:
sys.stderr.write(" Unable to get source pad of caps_vidconvsrc \n")
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 mesages to it
global loop
loop = GObject.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect ("message", bus_call, loop)
# Start streaming
rtsp_port_num = 8554
#rtsp_address = "20.204.93.170"
rtsp_address = "0.0.0.0"
server = GstRtspServer.RTSPServer.new()
server.set_address(rtsp_address)
server.props.service = "%d" % rtsp_port_num
server.attach(None)
factory = GstRtspServer.RTSPMediaFactory.new()
#factory.set_launch("( rtspsrc location=rtsp://%s:%d/%s ! rtph264depay ! h264parse ! x264enc ! rtph264pay name=pay0 pt=96 )"
# " udpsink host=%s port=%d" % (rtsp_address, rtsp_port_num, path, rtsp_address, updsink_port_num))
factory.set_launch( "( udpsrc name=pay0 port=%d buffer-size=524288 caps=\"application/x-rtp, media=video, clock-rate=90000, encoding-name=(string)%s, payload=96 \" )" % (updsink_port_num, codec))
factory.set_shared(True)
server.get_mount_points().add_factory("/rgrt", factory)
print("\n *** DeepStream: Launched RTSP Streaming at rtsp://localhost:%d/rgrt ***\n\n" % rtsp_port_num)
# Lets add probe to get informed of the meta data generated, we add probe to
# the sink pad of the osd element, since by that time, the buffer would have
# had got all the metadata.
osdsinkpad = nvosd.get_static_pad("sink")
if not osdsinkpad:
sys.stderr.write(" Unable to get sink pad of nvosd \n")
osdsinkpad.add_probe(Gst.PadProbeType.BUFFER, osd_sink_pad_buffer_probe, 0)
# Register the signal handler for SIGTERM
signal.signal(signal.SIGTERM, sigterm_handler)
# Add a GPIO event callback
GPIO.add_event_detect(GPIO_PIN, GPIO.FALLING, callback=gpio_callback, bouncetime=200)
# Create and start the GMainLoop
#loop = GObject.MainLoop()
print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except KeyboardInterrupt:
stop_and_cleanup(pipeline)
except Exception as e:
print(f"An error occurred: {str(e)}")
stop_and_cleanup(pipeline)
GPIO.cleanup()
# cleanup
pipeline.set_state(Gst.State.NULL)
GPIO.cleanup()
def parse_args():
parser = argparse.ArgumentParser(description='RTSP Output From USB Webcam Custom Application Help ')
parser.add_argument("-i", "--input",
help="Path to input /dev/video* device", required=True)
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("--graintype", default="chana",
help="Prefix for configuration file (graintype)", type=str) # New argument for config prefix
# Check input arguments
if len(sys.argv)==1:
parser.print_help(sys.stderr)
sys.exit(1)
args = parser.parse_args()
global codec
global bitrate
global camera_path
global graintype
global csv_file_name
global experiment_id
codec = args.codec
bitrate = args.bitrate
camera_path = args.input
graintype = args.graintype
experiment_id = read_experiment_id()
#csv_timestamp = datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S-%f')
#csv_file_name = create_csv_file(csv_timestamp, graintype)
return 0
if __name__ == '__main__':
parse_args()
pipeline = None # Declare pipeline here so it's accessible in the signal handler
sys.exit(main(sys.argv))
The app is able to inference and give output over a rtsp server correctly, but after processing 458 frames it stops, with the following error
Frame Number=458 Total Number of Objects=0 Impurity_Counts=0 FM_Count=0
SYNC_IOC_FENCE_INFO ioctl failed with 9
0:03:36.703433577 17129 0x14d3a2d0 WARN nvinfer gstnvinfer.cpp:1376:convert_batch_and_push_to_input_thread:<primary-inference> error: NvBufSurfTransform failed with error -2 while converting buffer
Error: gst-stream-error-quark: NvBufSurfTransform failed with error -2 while converting buffer (1): /dvs/git/dirty/git-master_linux/deepstream/sdk/src/gst-plugins/gst-nvinfer/gstnvinfer.cpp(1376): convert_batch_and_push_to_input_thread (): /GstPipeline:pipeline0/GstNvInfer:primary-inference
Frame Number=459 Total Number of Objects=0 Impurity_Counts=0 FM_Count=0
Error saving frames: local variable 'obj_meta' referenced before assignment
0:03:37.557729022 17129 0x14d3a2d0 WARN nvinfer gstnvinfer.cpp:1376:convert_batch_and_push_to_input_thread:<primary-inference> error: NvBufSurfTransform failed with error -3 while converting buffer
Segmentation fault (core dumped)
Please provide me with a solution to resolve it ?