简体   繁体   English

尝试从 opencv 中的 hevc (h265) 视频读取帧时“找不到起始编号(在文件名中)”

[英]"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-python (python3,最新版本)中的hevc(h265) .avi 视频中读取帧,但一直在抛出

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' . OpenCV(4.1.1) C:\projects\opencv-python\opencv\modules\videoio\src\cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: 找不到起始编号(名称中文件):C:\Users\gabri\Desktop\2019-11-22_13\a.avi 在 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.我在ubuntuwindows 10中都尝试过使用opencv-python, opencv-contrib-python and opencv-contrib-python-nonfree ,但它没有用。 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).opencv_videoio_ffmpeg430_64.dll不可访问时(在 Windows 中)它发生了(它似乎被另一个 opencv lib 静默调用)。 Either you did not build opencv with the -DWITH_FFMPEG=ON , or alternatively your dll is not in the path.要么您没有使用-DWITH_FFMPEG=ON构建 opencv,要么您的 dll 不在路径中。

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当函数cap = cv2.VideoCapture("video_path")cv2.VideoWriter('path_to_folder/output_save.avi')中的cv2.VideoWriter('path_to_folder/output_save.avi')不正确时,通常会弹出此错误
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.如果您没有在文件名中指定扩展名,您可能会在 VideoWriter 类中收到此错误,在我的情况下,我忘记写 .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.我的用例可能不是问题中所问的,但是由于 opencv 产生的错误消息有点误导我会为可能遇到类似问题的其他人留下注释。

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.我通过 AWS API 网关接收文件,为了避免文件损坏,我必须在 APIGateway 应用程序设置的“二进制媒体类型”部分添加“multipart/form-data”。

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因此,在您的情况下,也许您可以将文件重命名为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.在我批准将相机用于应用程序后,它就起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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