High CPU usage when main stream

Hello Guys, I’m trying to run a code to show image and get motion detect but when I set to main stream my CPU usage goes to 100% and the image starts freezing frequently but when I set to extra stream, the images runs normally, what could I doing wrong ? I’m trying to run using a Pentium(R) Dual-Core CPU E6700 @ 3.20GHz 3.20 GHz, 6,00 GB, NVIDIA Quadro K660, Windows 10 x64, protocol RTSP. Thanks.

import cv2

cap = cv2.VideoCapture(“rtsp://admin:a10b20c30d40@192.168.0.116:554/cam/realmonitor?channel=1&subtype=0”)

while cap.isOpened():
ret, frame = cap.read()
resized = cv2.resize(frame, (600,400))
cv2.imshow(‘frame’, resized)
if cv2.waitKey(1) & 0xFF == ord(‘q’):
break

What are the resolutions of your two streams?

Main stream 1920x1080, Stream extra 640x480

The main stream has nearly 7 times the number of pixels and will require substantially more resources, decoding/network etc. With out any extra information I would suggest this is the issue.

If the CPU is @100% then the rtsp stream will stall, you won’t be able to process the stream as fast as it is being sent resulting in the os buffer dropping bits from the rtsp stream before you can read and decode them. This generally manifest itself in decoding errors and ultimately the stream timing out.