Hi,
Looks like it uses software encoding in the sample. You may try to integrate hardware encoding with it. We support hardware encoding in gstreamer and jetson_multimedia_api. Please check
Multimedia — NVIDIA Jetson Linux Developer Guide 1 documentation
Jetson Linux API Reference: Main Page | NVIDIA Docs
If you would like to use OpenCV, may try this:
Displaying to the screen with OpenCV and GStreamer - #9 by DaneLLL