Search code examples
python-2.7opencvimage-processingvideo-capturevideo-processing

Read after Videocapture on opencv always returns false


I cant figure out what the problem is.

I am using

  • Ubuntu 17.04
  • Python 2.7.13
  • OpenCV Version: 3.3.0

I have gone through all the related problems on internet but have not got the solution for the problem yet. 'v.mp4' file is in the same directory in which my python file is present.

CODE

import cv2
vidcap = cv2.VideoCapture('v.mp4')
success,image = vidcap.read()
count = 0; 
print success
while success:
    success,image = vidcap.read()
    cv2.imwrite("frame%d.jpg" % count, image)     # save frame as JPEG file
    if cv2.waitKey(10) == 27:                     # exit if Escape is hit
        break
    count += 1

Solution

  • The opencv-python package does not have VideoCapture() support outside of Windows. See my answer here or the PyPI opencv-python documentation, which states:

    IMPORTANT NOTE

    MacOS and Linux packages do not support video related functionality (not compiled with FFmpeg).