How can I match frame meta and nvbufsurface?


I use multiple webcams.

I get input buffers from nvbufsurface and infer each surface.

And I draw metas in frame_meta_list in batch_meta.

In case, how can I know which surface matches which frame?

Example codes below.

NvBufSurfTransform(in_surf, memory->surf, transform_params);

for (auto i = 0; i < frame_size; ++i) {

for (NvDsMetaList* l_frame = batch_meta->frame_meta_list; l_frame != nullptr; l_frame = l_frame->next) {
    // How can I match?


Please refer to source code of gst-dsexample. You can enable it by following README at


Should be more clean to add a print in gstdsexample.cpp:

// Using object crops as input to the algorithm. The objects are detected by
// the primary detector
NvDsMetaList * l_obj = NULL;
NvDsObjectMeta *obj_meta = NULL;

for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
  l_frame = l_frame->next)
  frame_meta = (NvDsFrameMeta *) (l_frame->data);
<b>  printf("batch_id %d \n", frame_meta->batch_id);</b>
  for (l_obj = frame_meta->obj_meta_list; l_obj != NULL;
      l_obj = l_obj->next)
    obj_meta = (NvDsObjectMeta *) (l_obj->data);

batch_id matches with sources. For example, if you run source8_1080p_dec_infer-resnet_tracker_tiled_display_fp16_nano.txt, you will see batch_id 0 to 7