Using opencv to open a IP Cam http stream on Windows

asked 2018-04-14 16:25:11 -0600

I wrote the following Python code:

import cv2

cap = cv2.VideoCapture()
cap.open("http://<user>:<password>@<ip>/mjpeg.cgi?user=<user>&password=<password&channel=0")

while (cap.isOpened()):
    ret, frame = cap.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

The code works fine on Linux, but on Windows, I got the following error:

$ python renderer.py
warning: Error opening file (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:808)
warning: http://<user>:<password>@<ip>/mjpeg.cgi?user=<user>&password=<password&channel=0 (/build/opencv/modules/videoio/src/cap_ffmpeg_impl.hpp:809)

I suspect there's something wrong with my Windows opencv build, but couldn't figure out what. Please let me know if you have any ideas. Thanks.

edit retag flag offensive close merge delete

Comments

make sure, opencv_ffmpeg64.dll is on your PATH

berak gravatar imageberak ( 2018-04-15 04:00:27 -0600 )edit

I do have opencv_ffmpeg340_64.dll in my path. Also, the code works on Windows if I specify a mp4 file instead of an URL. It also works with the built-in webcam if I specify an index of 0 instead of the URL. Thanks.

crocodile gravatar imagecrocodile ( 2018-04-16 14:00:41 -0600 )edit

Do you have the solution for this? I also face similar issue

ghifarahadian gravatar imageghifarahadian ( 2018-10-25 01:55:40 -0600 )edit