With gstreamer, you may be able to use x264enc CPU encoder:
gst-launch-1.0 videotestsrc ! video/x-raw,width=640,height=480,framerate=30/1 ! videoconvert ! x264enc ! h264parse ! matroskamux ! filesink location=test_480p_30_h264.mkv -e
# Stop after 10s with Ctrl-C once
# Play back
gst-play-1.0 test_480p_30_h264.mkv
If using argus:
gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! x264enc ! h264parse ! matroskamux ! filesink location=test_nvarguscamera_h264.mkv -e
# Stop after 10s with Ctrl-C once
# Play back
gst-play-1.0 test_nvarguscamera_h264.mkv