Gstreamer pipeline doesn't return

Hi All,

I use gstreamer to get video from CSI camera.

It works fine when I run the program by typing in command.

But, when the program is run automatically on TX2 startup, weird thing happens.

Sometimes, video is recorded, but doesn’t return.
Sometimes, video is not recorded at all.

My code is as follows.

Any help would be appreciated!


========================= code ========================

int main()
VideoCapture inputVideo;

while (!"nvcamerasrc fpsRange=\"5.0 5.0\" sensor-id=0 ! video/x-raw(memory:NVMM), width=(int)3864, height=(int)2180, format=(string)I420, framerate=(fraction)5/1 ! nvvidconv ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420 !  tee name=tee0 tee0. ! queue ! omxh264enc ! matroskamux ! filesink location=/home/nvidia/Dev/vidoe.mp4 tee0. ! queue ! nvvidconv ! video/x-raw(memory:NVMM),format=BGRx ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR, width=1920,height=1080,framerate=5/1 ! appsink sync=false",CAP_GSTREAMER))
	printf("Could not open camera\n");

printf("camera connection success\n");

while (true)
	Mat cameraFrame;;

	if (waitKey(10) >= 0)


return 0;


Can you try to run it after some time of startup? You can know the time:

cat /proc/uptime | cut -d '.' -f1

Maybe run it after 60 seconds or more.