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()
- I have faced the same problem when using opencv's VideoCapture [ cap.isOpened() returns False ]
- The standalone executable works fine when capturing from webcam in both cases i.e. cv2.VideoCapture(0) or VideoStream(src=0).start()
- 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.
- The rtsp stream was tested on VLC player and works fine.
- 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.