Ask Your Question
0

can not read video using cv2.VideoCapture

asked 2017-06-21 08:42:53 -0600

AndrewGong gravatar image

updated 2017-06-21 09:03:17 -0600

hello, I have one code: import cv2 cv2.VideoCapture(xxx.mp4/avi) print vidcap.isOpened() it still is False. I google for much time and rebuild ffmpeg and opencv. It they do not work. anyone can give some advises? I use ubuntu16.04 anaconda2 thank you very much~~

besides, I have python-opencv3.2 for python, but I install opencv2.4.13 from source. So must I install opencv3.2 from source?

edit retag flag offensive close merge delete

Comments

check cv2.getBuildInformation() to see, if there's support for video files at all.

berak gravatar imageberak ( 2017-06-22 05:38:58 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
0

answered 2017-06-22 16:08:21 -0600

Your url cv2.VideoCapture(xxx.mp4/avi) isn't correct.. .mp4 is already a video type and doing \ means you want to go inside the directory even though xxx.mp4 is not a directory but a file.

edit flag offensive delete link more

Comments

I think OP means he tried both ways .avi and .mp4 and none worked.

Pedro Batista gravatar imagePedro Batista ( 2017-06-23 05:07:28 -0600 )edit
0

answered 2017-06-22 05:00:30 -0600

First thing is to make sure the name and path of the video file is correct.

If there is nothing wrong with the path, than this is almost always a codec problem. OpenCV is trying to find the codec to open the video and is not finding it.

Download a codec package into your system (easy to find on google) and then try to run the same code again. I've seen a lot of people solving this problem just doing this.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-06-21 08:42:53 -0600

Seen: 1,335 times

Last updated: Jun 22 '17