Cannot open video files in openCV

asked 2017-08-01 03:12:07 -0600

hayk gravatar image

updated 2017-08-01 03:39:23 -0600

berak gravatar image

Please help to fix the video opening issue using opencv on raspberry pi 3. Almost 3 weeks I am fighting with this issue.

This is my code:

import cv2
cap = cv2.VideoCapture("/home/pi/Documents/forRaspberry/small.mp4")
print (cap.isOpened())

And when running, the cap isOpened returns false: (same False result with cap.grab() )

Python 3.4.2 (/usr/bin/python3)

%Run roundBound_modif_withVideo.py
False

I am using 3.2.0 opencv version and 3.4.2 python version.
I assumed the issue is connected with FFMPEG. And put all my efforts to fix it. These are what I have tried so far:
1) I build opencCV with FFMPEG on
WITH_FFMPEG ON
Does not fix the issue
2) FFPMEG is not installed in my raspbain. I read in forums that libav-tools replaces the FFMPEG. So installed libav-tools. Still not helped
3) When I do cmake it prints following:

-- FFMPEG: NO
-- avcodec: NO
-- avformat: NO
-- avutil: NO
-- swscale: NO
-- avresample: YES (ver 2.1.0)
Read in forum that I need to alias ffmpeg to avconv (https://www.raspberrypi.org/forums/vi...). Still does not help

I think should I install ffmpeg in raspbain separately, or may be something connected with gstreamer?

Can this issue be connected with version mismatches of some packages? Can someone please explain how I can know all matching pacakges versions list for my opencv and pyhton versions?

edit retag flag offensive close merge delete