Forcing the pipeline to send message with nvmsgconv and nsmsgbroker to send exactly 1 message for each frame

• Hardware Platform (Jetson / GPU) dGPU
• DeepStream Version nvcr.io/nvidia/deepstream:7.1-gc-triton-devel
• JetPack Version (valid for Jetson only) N/A
• TensorRT Version N/A
• NVIDIA GPU Driver Version (valid for GPU only) 565.57.01
• Issue Type( questions, new requirements, bugs) questions
• 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) N/A
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi All,

I am following the sample nvmsgconv low-level library and trying to create a custom message. For each frame, I process all objects, aggregate them into custom metadata, and send the result to a downstream message queue (Kafka). The goal is to send one aggregated message per frame.

Here’s an example of my implementation:

gpointer nvds_msg2p_generate_new(NvDsMsg2pCtx* ctx, void* metadataInfo) {
    if (!ctx || !metadataInfo) return nullptr;
    
    NvDsMsg2pCtxPrivate* priv = static_cast<NvDsMsg2pCtxPrivate*>(ctx->privData);
    NvDsMsg2pMetaInfo* meta = static_cast<NvDsMsg2pMetaInfo*>(metadataInfo);
    NvDsFrameMeta* frame_meta = (NvDsFrameMeta*)meta->frameMeta;

    g_print("=== frame_meta->frame_num: %d, num_obj_meta: %d\n", frame_meta->frame_num, frame_meta->num_obj_meta);
    
    NvDsPayload* payload = (NvDsPayload*)g_malloc0(sizeof(NvDsPayload));
    gchar* message = nullptr;
    size_t len = 0;
    
    switch (priv->payloadType) {
        case NVDS_PAYLOAD_CUSTOM:
            message = generate_custom_message(priv, frame_meta);
            if (message) {
                len = strlen(message);
                payload->payload = g_memdup2(message, len);
                payload->payloadSize = len;
                g_free(message);
            }
            break;
        default:
            g_free(payload);
            return nullptr;
    }
    
    return payload;
}

gchar* generate_custom_message(void* privData, void* frameMeta) {
    NvDsFrameMeta* frame_meta = (NvDsFrameMeta*)frameMeta;
    gchar* message = nullptr;

    // Show frame number and total number of objects    
    message = g_strdup_printf("Current frame number: %d, Total objects: %d", frame_meta->frame_num, frame_meta->num_obj_meta);
    
    return message;
} 

However, with this approach, a message is generated for each object in each frame, and so does the function is called. For example, if there are 8 objects in a frame, the message is sent 8 times:

=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 3, num_obj_meta: 8
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10
=== frame_meta->frame_num: 4, num_obj_meta: 10

Is there an option to configure the plugin to trigger only once per frame? The frame-interval option doesn’t seem applicable to this scenario. Here’s how I’m setting up the plugin:

g_object_set(G_OBJECT(msgconv),
             "payload-type", 257,  // PAYLOAD_CUSTOM
             "msg2p-newapi", TRUE, // Perform custom framemeta parsing
             "frame-interval", 1,
             "msg2p-lib", "/app/lib/libnvds_nvmsgconv.so",
             nullptr);

Thank you!

please refer to gst_nvmsgconv_transform_ip_video_audio in /opt/nvidia/deepstream/deepstream-7.1/sources/gst-plugins/gst-nvmsgconv/gstnvmsgconv.cpp. msg2p_generate will be called many times when iterating over frame_meta)->obj_meta_list.

Thanks for the reply. Yes, i do reference that example on creating the low-level library. It is iterating on all object, but I want to do it once only for each frame. Of course I can do custom logic to check whether we are still processing the same frame, but it will be easier if such option exist for the plugin.

you can try payload-type =1, which will use one message for each frame. please refer to generate_dsmeta_message_minimal.

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. Thanks

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