deepstream-test2 dump metadata to json file

How can I dump data from test application 2

apps/sample_apps/deepstream-test2
Simple example of how to use DeepStream elements for a single H.264 stream: filesrc → decode → nvstreammux → nvinfer (primary detector) → nvtracker → nvinfer (secondary classifier) → nvosd → renderer.

I need to dump.

  1. Frame number
  2. Object ID
  3. Object Confidence score
  4. Object Bounding Box info
  5. track ID
  6. track bounding box info
  7. track class

You can do all that in the buffer callback (osd_sink_pad_buffer_probe), but I believe you have to be careful not to do anything that blocks. Somebody else might give a better alternative. I know nvidia has some pre-built elements for sending metadata to services like Kafka that are probaly easier to use than trying to roll your own thing for this.