Segmentation fault when extracting the frame using a probe

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.2
**• Language ** Python

I get a segmentation fault error when extracting frames from a multi-stream input pipeline using a probe. Complete code to reproduce this issue is attached herewith (refer

probe code is as follows :

def osd_sink_pad_buffer_probe(pad, info, u_data):
    gst_buffer = info.get_buffer()
    if not gst_buffer: 
        print("Unable to get GstBuffer ")

    batch_meta = pyds.gst_buffer_get_nvds_batch_meta(hash(gst_buffer))
    if not batch_meta:
        return Gst.PadProbeReturn.OK

    l_frame = batch_meta.frame_meta_list

    while l_frame is not None:
        print("iterating frames..............")
            frame_meta = pyds.NvDsFrameMeta.cast(
        except StopIteration:

        l_obj = frame_meta.obj_meta_list
        n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
        frame_copy = np.array(n_frame, copy=True, order='C')
        frame_copy  = cv2.cvtColor(frame_copy, cv2.COLOR_RGBA2BGR)

        while l_obj is not None:
                obj_meta = pyds.NvDsObjectMeta.cast(
            except StopIteration:

                l_obj =
            except StopIteration:

            l_frame =
        except StopIteration:

    return Gst.PadProbeReturn.OK

pipeline code is as follows :

pipeline = Gst.Pipeline()

video_list = ['file:///workdir/test.h264',

streammux = Gst.ElementFactory.make("nvstreammux", "Stream-muxer")

streammux.set_property("batched-push-timeout", 25000)
streammux.set_property("batch-size", 30)
streammux.set_property("gpu_id", GPU_ID)

streammux.set_property("live-source", 1)   # need to check

for  id, uri in enumerate(video_list):
    print("Creating source_bin ",uri," \n ")

    #Create first source bin and add to pipeline
    source_bin= create_uridecode_bin((id, uri))
    if not source_bin:
        sys.stderr.write("Failed to create source bin. Exiting. \n")


pgie = Gst.ElementFactory.make("nvinfer", "primary-inference")

nvvidconv = Gst.ElementFactory.make("nvvideoconvert", "convertor")

nvosd = Gst.ElementFactory.make("nvdsosd", "onscreendisplay")

sink = Gst.ElementFactory.make("fakesink", "fakesink")

streammux.set_property('width', 1920)
streammux.set_property('height', 1080)
pgie.set_property('config-file-path', "model_config.txt")
pgie.set_property("gpu_id", GPU_ID)

nvvidconv.set_property("gpu_id", GPU_ID)
nvosd.set_property("gpu_id", GPU_ID)

print("Adding elements to Pipeline \n")

print("Linking elements in the Pipeline \n")

the problem is with frame extraction I assume

        n_frame = pyds.get_nvds_buf_surface(hash(gst_buffer), frame_meta.batch_id)
        frame_copy = np.array(n_frame, copy=True, order='C')
        frame_copy  = cv2.cvtColor(frame_copy, cv2.COLOR_RGBA2BGR) (5.8 KB)

Also, can you tell me the most efficient way to extract frames from a multistream input pipeline, with demux plugin or without it?

Can you share the config file and stream cause crash ?

Use your code with dstest1_pgie_config.txt here

and use sample stream


It’s can run success.

i am still getting segmentation faults with the config and video URL shared by @junshengy , I think the way I extract frames using a probe is not right

Can you check the driver/cuda/trt version ?

nvidia-smi for driver version
nvcc -V for cuda version
dpkg -l | grep nvinfer for trt version

Can you try this sample first ?
This version is recommended

the versions are as follows

Driver Version: 525.105.17 CUDA Version: 12.0
Cuda compilation tools, release 11.5, V11.5.119
Build cuda_11.5.r11.5/compiler.30672275_0

the sample code worked fine

I know where the problem is .You can upgrade the cuda version.

1.Add caps filter after nvvidconv before nvosd,like this.

caps = Gst.Caps.from_string("video/x-raw(memory:NVMM), format=RGBA")
filter = Gst.ElementFactory.make("capsfilter", "filter")
if not filter:
    sys.stderr.write(" Unable to get the caps filter1 \n")
filter.set_property("caps", caps)

modify color format to

frame_copy = cv2.cvtColor(frame_copy, cv2.COLOR_RGBA2BGRA)

2.Use cuda unified memory

if not is_aarch64():
    # Use CUDA unified memory in the pipeline so frames
    # can be easily accessed on CPU in Python.
    mem_type = int(pyds.NVBUF_MEM_CUDA_UNIFIED)
    streammux.set_property("nvbuf-memory-type", mem_type)
    nvvidconv.set_property("nvbuf-memory-type", mem_type)

Please refer to the sample code.


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.