Adding custom metadata upstream of nvstreammux with Python

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 6.0.1
• Issue Type( questions, new requirements, bugs) Question

I’m trying to translate deepstream_gst_metadata.c into Python code so that I can attach custom metadata in an appsrc element and extract it again after it has been passed through nvinfer. I found this related post which unfortunately doesn’t provide much help other than it should be possible in principle.

I don’t know how I can call pyds.gst_buffer_add_nvds_meta. How do I pass in Python functions for copying and releasing the metadata? My code below (excerpt) fails when pyds.gst_buffer_add_nvds_meta gets called due to incompatible function arguments.

I couldn’t find any example calling pyds.gst_buffer_add_nvds_meta from Python online. The example doesn’t help unfortunately because it’s not showing how you can add metadata before an nvstreammux element.

Could someone please help me with this? I would be grateful for any pointers.

VIDEOSRC_GST_META = pyds.nvds_get_user_meta_type("ORG.VIDEOSRC.GST_USER_META")

def videosrc_meta_copy(data: ctypes.pointer, user_data: ctypes.pointer):

def videosrc_meta_release(data: ctypes.pointer, user_data: ctypes.pointer):

def videosrc_gst_to_nvds_meta_transform(data: ctypes.pointer, user_data: ctypes.pointer):

def videosrc_gst_to_nvds_meta_release(data: ctypes.pointer, user_data: ctypes.pointer):

class VideoSrc(GstApp.AppSrc):
    def __init__(self, url, *args, **kwargs):"Creating VideoSrc element")
        super().__init__(*args, **kwargs)
        self._url = url
        self._buffer_emitted = False

    def do_need_data(self, need):
        if self._buffer_emitted:
        response = requests.get(self._url, allow_redirects=True)
        buffer = Gst.Buffer.new_wrapped(response.content)

        videosrc_meta = GstBufferInfo()
        videosrc_meta.description = self._url.encode("utf-8")

        meta = pyds.gst_buffer_add_nvds_meta(
            buffer, videosrc_meta, None, videosrc_meta_copy, videosrc_meta_release
        meta.meta_type = VIDEOSRC_GST_META
        meta.gst_to_nvds_meta_transform_func = videosrc_gst_to_nvds_meta_transform
        meta.gst_to_nvds_meta_release_func = videosrc_gst_to_nvds_meta_release

        self._buffer_emitted = True

Here is the API doc. What kind of error do you get?

There is no update from you for a period, assuming this is not an issue anymore.
Hence we are closing this topic. If need further support, please open a new one.

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