Capturing RTSP stream fails when the script is tur

2019-05-31 23:10发布

Code:

from imutils.video import VideoStream
import cv2

# Read rtsp stream
rtsp = u"rtsp://admin:admin@10.64.1.31:554/1/h264major"
#vs = VideoStream(src=0).start() # for capturing from webcam
vs = VideoStream(src=rtsp).start()

while True:
    frame = vs.read()

    # show the output frame
    cv2.imshow("Frame", frame)
    key = cv2.waitKey(1) & 0xFF

    # if the `q` key was pressed, break from the loop
    if key == ord("q"):
        break

# do a bit of cleanup
cv2.destroyAllWindows()
vs.stop()   
  1. I have faced the same problem when using opencv's VideoCapture [ cap.isOpened() returns False ]
  2. The standalone executable works fine when capturing from webcam in both cases i.e. cv2.VideoCapture(0) or VideoStream(src=0).start()
  3. The rtsp stream capture works fine in both cases when the script is run in python i.e. without turning it into a standalone executable.
  4. The rtsp stream was tested on VLC player and works fine.
  5. I am using Python 3.6.2 | OpenCV 3.2.0 | Windows

Could this be due to utf-8 etc encoding issues of the RTSP link? Any other alternatives?

Solved: Included opencv_ffmpeg320_64.dll next to my executable.

1条回答
smile是对你的礼貌
2楼-- · 2019-05-31 23:20

Included opencv_ffmpeg320_64.dll next to my executable. Alternatively, copy that dll file to the DLLs folder in python directory

查看更多
登录 后发表回答