Smart record using encoded output with bounding boxes

Any examples on how to do this?

No such sample codes currently. But we have detailed smart recording interfaces document, you may try to add smart recording bin after encoder and use NvDsSRStart() and NvDsSRStop() to control the recording. The deepstream-app source codes are also good reference for smart recording interfaces.
https://docs.nvidia.com/metropolis/deepstream/dev-guide/index.html#page/DeepStream_Development_Guide/deepstream_smart_video_record.html#