简体   繁体   中英

"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

I had the same problem, compilation and linking ok, but the same cryptic error occurs at running.

It happened (with Windows) when opencv_videoio_ffmpeg430_64.dll was not accessible (it seems to be silently called by another opencv lib). Either you did not build opencv with the -DWITH_FFMPEG=ON , or alternatively your dll is not in the path.

this error normally pop-up when video_path in functions cap = cv2.VideoCapture("video_path") or cv2.VideoWriter('path_to_folder/output_save.avi') is not correct
Mostly seen in windows

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.

也许你可以在你的路径上附加一个数字,比如“a2.avi”而不是“a.avi”。

我通过将绝对路径传递到VideoCapture并将文件名从example.mov更改为example_1000.mov

我遇到了同样的错误并通过将视频名称更改为“001.avi”来解决它。

在我的情况下缺少文件扩展名:将movie更改为movie.mp4解决了该问题

My use case is probably not what is being asked in the question however since the error message produced by opencv is slightly misleading I'll leave a note for others who might encounter similar problem.

In my case I was receiving following error because the file was corrupted:

OpenCV(4.5.1) cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): /path/to/file.png in function 'icvExtractPattern'

I was receiving files through AWS API gateway and in order to avoid files being corrupted I had to add 'multipart/form-data' within 'Binary Media Types' section of APIGateway app settings.

For me, the problem was the filename needs to have a number on it. So in your case perhaps you can rename your file to a0.avi

For me, the error occurred before I was able to approve access to the camera. After I approved the use of the camera for the application, it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM