ip camera rtsp流linux延迟

时间:2019-03-08 12:50:23

标签: python stream rtsp ip-camera

我正在尝试使用OpenCV从IP摄像机访问RTSP视频流。 以下代码可在Windows或Mac上正常工作。

import cv2
source = "rtsp://user:pass@ip"
cap=cv2.VideoCapture(source)
while True:
    t1=time.time()
    ret, frame = cap.read()
    print("Read Time:",round((time.time()-t1)*1000,1)) 

当fps = 5或fps = 30时(Windows,Mac);

Read Time 30.2
Read Time 31.8
Read Time 32.1
Read Time 33.2
Read Time 32.2

但是在Linux上,它有点奇怪。首先cap.read()等待很长时间,然后此延迟导致2-10秒的视频延迟。如果fps增加,则延迟减少。我找不到解决方案。你能帮我吗?

当fps = 30时(Linux);

Read Time **1736.5**
Read Time 30.2
Read Time 32.8
Read Time 32.1
Read Time 34.2

当fps = 5时(Linux);

Read Time **10412.8**
Read Time 196.2
Read Time 199.0
Read Time 199.6
Read Time 200.1

0 个答案:

没有答案