fail reading data from rtsp stream with opencv python [closed]

asked 2017-09-15 04:13:35 -0600

lpplbiubiubiu gravatar image

updated 2017-09-15 09:16:27 -0600

i have problem in useing opencv python when reading rtsp stream, this works fine:

cv::VideoCapture video_cap;
video_cap.open("rtsp://admin:pw@ip//Streaming/Channels/1?tcp");

but when i use python, it doesn't work, my python code is

video_cap = cv2.VideoCapture("rtsp://admin:pw@ip//Streaming/Channels/1?tcp");
print(video_cap.isOpened())

and i had tested this:

video_cap = cv2.VideoCapture(0);
print(video_cap.isOpened())

it works fine too, I don't know why? Anyone can tell me?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by berak
close date 2017-09-15 07:10:57.425702

Comments

os, opencv version ? how did you install it ? (esp. the python version!)

berak gravatar imageberak ( 2017-09-15 04:16:19 -0600 )edit

2.4.13, I moved “cv2.pyd” in (the path python.exe exists)/Lib/site-packages

lpplbiubiubiu gravatar imagelpplbiubiubiu ( 2017-09-15 04:36:55 -0600 )edit

how did you install it ? (if it was via PIP - no ffmpeg support builtin, hence no ip-capture possible)

(and why on earth outdated 2.4 ?)

berak gravatar imageberak ( 2017-09-15 04:45:08 -0600 )edit

no, I didn‘t install it by pip, I just put "cv2.pyd" in python env. and is opencv 2.4.13 outdated? it's just released in 2016... and i run python code

import cv2 ;print(cv2.getBuildInformation())

and i get result like

Video I/O:   FFMPEG: YES
lpplbiubiubiu gravatar imagelpplbiubiubiu ( 2017-09-15 05:09:47 -0600 )edit

oh, that's on win, missed that.

make sure opencv_ffmpeg.dll is on your PATH (or next to where you run the script)

berak gravatar imageberak ( 2017-09-15 05:12:17 -0600 )edit

wow, it works, thanks, bro

lpplbiubiubiu gravatar imagelpplbiubiubiu ( 2017-09-15 05:55:23 -0600 )edit