Using opencv to open a IP Cam http stream on Windows

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

I wrote the following Python code:

import cv2

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

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

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

$ python
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


make sure, opencv_ffmpeg64.dll is on your PATH

berak gravatar imageberak ( 2018-04-15 04:00:27 -0500 )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 -0500 )edit

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

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