Opencv videocapture can not access camera

Hi all.

We are using driver for imx477 on jetpack 4.5. We can open camera using gst-launch-1.0, but failed at using cv::videoCapture and appsink. It always said

 [ WARN:0] OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1

The gst command is

gst-launch-1.0 \
nvarguscamerasrc sensor-id=0 bufapi-version='TRUE' ! tee name=c0 \
c0. ! 'video/x-raw(memory:NVMM),width=4032,height=3040,framerate=30/1' ! nvvideoconvert ! queue ! tee 
name=deep \
deep. ! nvvideoconvert ! nvv4l2h264enc insert-sps-pps=true iframeinterval=10 ! tee name=h264 \
h264. ! h264parse ! matroskamux ! filesink location=/home/nvidia/test_4k_video.mkv \
deep. ! nvegltransform ! nveglglessink sync='FALSE' -e

and the code in c++ is

string pipeline0 = "nvarguscamerasrc sensor-id=0 bufapi-version=true ! video/x-raw(memory:NVMM), width=4032, height=3040,framerate=30/1 ! nvvideoconvert ! queue ! video/x-raw, width=4032, height=3040, format=(string)BGRx ! videoconvert ! appsink";

Did you guys encounter this issue?

Best regards

Hi,
Please refer to this sample:
OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL
You can run the default sample first. If it runs successfully, please change to desired resolution/framerate and try again.