1

cv2.Videocapture() works fine while using the camera,but while reading the local video, there is a WARNING: Couldn't read movie file

Here is my test code:

# -*- coding: utf-8 -*-
import numpy as np
import cv2

cap = cv2.VideoCapture('test2.avi')
print cap.isOpened()

while(cap.isOpened()):
    ret, frame = cap.read()

    cv2.imshow('frame', frame)
    if (cv2.waitKey(1) & 0xFF == ord('q')):
        break
cap.release()
cv2.destroyAllWindows()

The error occurred:

WARNING: Couldn't read movie file test2.avi
False

I found that on Windows, there is a solution about it.I copied all the files in /Users/xxx/opencv/3rdparty/ffmpeg to my python path, and renamed 'opencv_ffmpeg_64.dll' to 'opencv_ffmpeg300_64.dll', but it still didn't work.

Besides, I found that I couldn't open test2.avi by QuickTime Player. Is that a possible factor that caused the error?

Nice.Y
  • 21
  • 2
  • If you can't open a file manually from your video player then I think it's broken. Try a file that you can open in video player and try to use videocapture on it – Arpit Solanki Aug 16 '17 at 03:06
  • Thanks. It works when I use another video file. And I still have a question,why 2 same format video like 'mp4', one can't be opened, but the other can?:) – Nice.Y Aug 16 '17 at 03:15
  • I suppose one of them is broken or there is some encoding issue. – Arpit Solanki Aug 16 '17 at 03:16
  • Install ffmpeg command tool utils and run "ffmpeg -i badvideo.mp4". Than post results to your question – Dmitrii Z. Aug 16 '17 at 12:11

0 Answers0