2

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.

Community
  • 1
  • 1
  • Just to ask all the obvious questions... No firewalls that would block binaries but not python? Nothing like SELinux getting in the way? Are you testing the binary from the same machine as the script? – Basic Nov 24 '17 at 14:39
  • @Basic Yes, I am testing the binary from the same machine as the script. Just to play safe, opened up the port and firewall for the executable and tried again, but that did not work. – Kshitij Dhoble Nov 24 '17 at 15:05
  • 1
    Solved: Included opencv_ffmpeg320_64.dll next to my executable. – Kshitij Dhoble Nov 24 '17 at 16:06
  • That'll do it... You may want to post that as an answer and accept it... Will let others know this question has been answered – Basic Nov 24 '17 at 17:02

1 Answers1

2

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

  • where to find that .dll? When I run exe file I have the same issue. I have built in on conda env with opencv-python=3.4.3, ffmpeg=2.7. But I am not use which .dll I should put next to my executable. What if I want to run the .exe on another PC where ffmpeg is different or doesn't exist? – bit_scientist Nov 15 '18 at 09:33