How to tell the source id in Deepstream 4.0 custom plugin


On tx2 4g, we are developing custom plugin that can process data from nvstreammux.

video0 –
. |
. |

This plugin will handle video streams from two different source elements separately. However, we could not tell which surface was from which upstream sink pad in nvstreammux. i.e.

// Map the buffer so that it can be accessed by CPU
if (NvBufSurfaceMap(temp_buf, param->active_sink, -1, NVBUF_MAP_READ_WRITE) != 0) {


NvBufSurfaceUnMap (temp_buf, param->active_sink, -1);

we expected to get video source0 when param->active_sink == 0, and video source 1 when param->active_sink==1. But it did not come out that way, the two video sources came in randomly.

So the question is, how can our plugin tell a surface is from video n in nvstreammux?

You may not configure batch-size correctly. Please refer to

For developing the custom plugin, suggest you refer to dsexample.

Batch-size was not wrong.
the answer lies in this comment of the reference link:

frame_meta->source_id - id of stream
frame_meta->batch_id - id surface of this stream in surfaceList

I should use frame_meta->source_id to tell source id.