Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Can't find starting number (in the name of file)" when trying to read frames from hevc (h265) video in opencv

I'm trying to read frames from a hevc(h265) .avi video in opencv-python (python3, latest version) but keeps throwing

OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): C:\Users\gabri\Desktop\2019-11-22_13\a.avi in function 'cv::icvExtractPattern'.

I've tried both in ubuntu and windows 10 using opencv-python, opencv-contrib-python and opencv-contrib-python-nonfree, but it didn't work. Thank you in advance.

Code used to read the video:

import cv2
import imutils

cap = cv2.VideoCapture("C:\\Users\\gabri\\Desktop\\2019-11-22_13\\a.avi")


while True:
    ret,frame = cap.read()
    if not ret:
        break
    frame = imutils.resize(frame,width = 960)
    cv2.imshow('image',frame)

    k = cv2.waitKey(1) & 0xff

    if k == 27:
       break
like image 962
Gabriel Macus Avatar asked Dec 04 '19 03:12

Gabriel Macus


1 Answers

Perhaps this is late, but definitely there will be other people who face the same issue.

You can get this error in VideoWriter class if you do not specify your extension in the file name, in my case I have forgotten to write .mp4.

Hopefully this helps.

like image 177
Ghostpunk Avatar answered Oct 29 '22 04:10

Ghostpunk