How to capture live object detection output to .txt or .csv

I am Using deep stream fo 4RTSP streams for object detection on jetson Nano. How to Capture the inference of all 4 streams into a CSV or TXT

The result is put in metadata. You may check tiler_src_pad_buffer_probe() in deepstream-test3 to understand how to extract the result and make customization to save to a local file.