opencv-python
opencv-python copied to clipboard
how to connect video stream fasterly
env: os windows python 3.8 opencv==4.5.2.52
when I connect video stream ,it cost more than 1 second to connect ,how to make this time less than 0.5 second
ex:
import os
os.environ["OPENCV_VIDEOIO_MSMF_ENABLE_HW_TRANSFORMS"] = "0"
import cv2,datetime
s = "rtsp://128.8.84.224:18554/stream"
print(f"\ncv2.VideoCapture 1 -- time {datetime.datetime.now().strftime('%Y%m%d %H:%M:%S:%f')}")
self.cap = cv2.VideoCapture(s)
print(f"\ncv2.VideoCapture 2 -- time {datetime.datetime.now().strftime('%Y%m%d %H:%M:%S:%f')}")
cv2.VideoCapture 1 -- time 20240220 10:56:10:635229
cv2.VideoCapture 2 -- time 20240220 10:56:11:730034
if the video stream resolution is heigher ,it maybe cost more than 3 second to connect.
RTSP stream with h264/h265 codec is stateful. Decoder starts produce frames, when the first key frame is reached. Please check the camera configuration.