Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python cv2.VideoCapture does not open

I have a few avi files which I'm trying to read frame by frame. I have used opencv 3.1.0 in order to read frames:

import cv2
cap = cv2.VideoCapture(file_path)

and then I just read the frames of cap. This works fine on some of the videos. I took a few more videos recently and the same code comes up empty. I checked:

cap.isOpened() # return False

and it seems like the video is not opened properly. As far as I'm concerned the only thing that changed is that the new videos are in color whereas the old ones were not. I don't know how that would change anything in the code. I checked that the videos open up just fine in other software (imageJ) so I'm confident the video itself is not the issue.

Any ideas why the new videos are not opening properly? I have not been able to find any information on how to debug this issue. Any advice would be greatly appreciated.

like image 421
Eyal S. Avatar asked Feb 11 '26 23:02

Eyal S.


1 Answers

I switched to imageio instead of opencv and everything works well

like image 98
Eyal S. Avatar answered Feb 14 '26 12:02

Eyal S.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!