What is the right tool to encode an h264 video with small file size


I’m working on a project on Xavier nx. the goal is to record a h264 video from frames after inference with 10fps. I use, for now, a gstreamer pipeline with opencv to save the video. But my problem is that the file size for a 5min video is more than 2G which is too much for my application.

My question is: how can I do the recording process with less CPU usage and have small file size at the end? From what I learned ffmpeg accelerated lib is not suppoted for encoding on NX yet.

Here is the pipeline I use for opencv.
appsrc ! queue ! videoconvert ! omxh264enc profile=1 bitrate = 4500000 ! mp4mux ! filesink location= record_btw_12:05_13:00_camera_id_0_0.mp4 sync=false

the frame size is 960x512