Frame drops while recording with gstreamer in Python

I am using gstreamer in Python to record 4 camera streams at the same time (IMX390 from Leopard Imaging). I had success with recording 2 cameras, but when switching to 4 cameras I see that frames are dropped in all the cameras (maybe one every four to five frames).
This happens both with OpenCV VideoCapture and pure gstreamer in Python, while if I use gstreamer directly from the command line everything works fine and there are no frames dropped.

These are my gstreamer pipelines as loaded into Python, for each camId from 0 to 3:

    gst_in =  ('nvarguscamerasrc sensor-id={} ! ' 
    'video/x-raw(memory:NVMM), height=1080, width=1920, framerate=(fraction)30/1, format=NV12 ! ' 
    'nvvidconv ! video/x-raw, height=1080, width=1920, format=BGRx ! '
    'videoconvert ! video/x-raw, format=BGR ! '
    'appsink').format(cam_id)

    gst_out =('appsrc ! autovideoconvert ! '
    'omxh265enc ! video/x-h265, stream-format=byte-stream ! '
    'h265parse ! filesink location=video_{}.h265 ').format(cam_id)

And this is the set of commands that I used from the terminal, that showed no frame drops

gst-launch-1.0 \
nvarguscamerasrc sensor-id=0 num-buffers=1000 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! 'video/x-h265, stream-format=(string)byte-stream' ! h265parse ! qtmux ! filesink location=test0.mp4 -e \
nvarguscamerasrc sensor-id=1 num-buffers=1000 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! 'video/x-h265, stream-format=(string)byte-stream' ! h265parse ! qtmux ! filesink location=test1.mp4 -e \
nvarguscamerasrc sensor-id=2 num-buffers=1000 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! 'video/x-h265, stream-format=(string)byte-stream' ! h265parse ! qtmux ! filesink location=test2.mp4 -e \
nvarguscamerasrc sensor-id=3 num-buffers=1000 ! 'video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1' ! nvv4l2h265enc control-rate=1 bitrate=8000000 ! 'video/x-h265, stream-format=(string)byte-stream' ! h265parse ! qtmux ! filesink location=test3.mp4 -e

Any pointers on what the issue might be? Would loading the pipeline into Python adding this much overhead to cause the frame drop? Could it be due to the intermediate conversion and encoding steps instead?

Could you boost the system by below command to verify.

sudo nvpmodel -m 2
sudo jetson_clocks

Thank you, I just tried again after using your commands but the results are the same, still dropping frames when recording through Python

Could you try if not write file maybe use fakesink to try.

How would I be able to check if frames are dropped using fakesink?

You can use fpsdisplaysink to show the frame counts.