Segmentation fault (core dumped) on deepstream-test5-ap

It is of no use to just show some pieces of your codes. Why don’t you refer to deepstream-image-meta-test to understand the interfaces and usage of encoding object jpg image?

Can you refer to Encoding jpeg image after OSD causes segfault - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums first? His codes can work.