DeepStream 4: how to find the NvDsFrameMeta for the current GstBuffer?

When a NvDsBatchMeta is attached to a GstBuffer, how do I know which NvDsFrameMeta corresponds to the buffer to which the batch is attached?

I tried checking whether NvDsFrameMeta::buf_pts matches the PTS of the GstBuffer, but that didn’t work (i.e. they never exactly match).

I wish we had the source to nvstreamdemux, so I could see how it does this.

I’ve discovered that, downstream of nvstreammux, buffers are not 1-per-frame, but rather 1-per-batch. Therefore, it should be expected that there will be one, unique NvDsBatchMeta attached to each GstBuffer (no matter the batch size). Presumably, nvstreamdemux reverts buffers to 1-per-frame, though I haven’t tried it.

Now, what I don’t know is, if I needed to access the video frame data for each frame in the batch, how I’d go about that. The buffer sizes all seem to be 56 bytes, no matter what batch size I use. I assume this is some struct, as the values mostly look like 64-bit pointers. However, for now, I just need to consume NvDsFrameMeta.

In my defense, the reason I assumed the buffers still contained individual frames is that the caps are:

video/x-raw(memory:NVMM), format=(string)NV12, width=(int)1280, height=(int)720, ...

Obviously, I wasn’t paying enough attention to that “(memory:NVMM)”, which is clearly how DeepStream gets away with making these batch-buffers.

If any moderators see this, perhaps you could move it to the DeepStream forum? I hadn’t previously noticed it:

https://devtalk.nvidia.com/default/board/209/deepstream-sdk/