Hi,
You may try this sample:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL
You can run gst-launc-1.0 command with fakesink to make sure the pipeline works first. For example:
$ gst-launc-1.0 nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! fakesink
And apply the same to cv2.VideoCapture() with replacing fakesink with appsink.