gpt4 book ai didi

c++ - OpenCV 无法读取 AVI 文件

转载 作者:太空宇宙 更新时间:2023-11-03 23:02:47 25 4
gpt4 key购买 nike

我知道已经有一堆类似的问题,但不幸的是没有一个能帮上忙。所以,这就是问题所在(我对 OpenCV 还很陌生)。

尝试简单地打开并显示 AVI 文件。文件存在且路径正确。

int main( int argc, char** argv )
{
VideoCapture cap;

if(!cap.open(argv[1]))
{
printf("Failed to open %s\n", argv[1]);
return -1;
}

namedWindow("Video output", 1);

for(;;)
{
Mat curFrame;

cap >> curFrame;

imshow("Video output\n", curFrame);

if(waitKey(30) >= 0)
break;
}

return 0;
}

没有错误出现,open() 返回 false。

我之前用mencode转换过文件。以下是有关该文件的信息:

boris@boris-ubuntu:~$ ffmpeg -i out.avi 
ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
built on Jun 12 2012 16:37:58 with gcc 4.6.3
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from 'out.avi':
Metadata:
encoder : MEncoder svn r34540 (Ubuntu), built with gcc-4.6
Duration: 00:00:01.00, start: 0.000000, bitrate: 265458 kb/s
Stream #0.0: Video: rawvideo, yuv420p, 1280x720, PAR 1:1 DAR 16:9, 24 tbr, 24 tbn, 24 tbc
At least one output file must be specified

据我了解,视频格式yuv420p,OpenCV支持。

有什么建议吗?

谢谢!

最佳答案

好吧,问题在于 OpenCV 是在没有 ffmpeg(或任何其他视频库)支持的情况下编译的。

感谢this great post ,我成功安装了ffmpeg并重新编译了OpenCV,然后一切正常。

关于c++ - OpenCV 无法读取 AVI 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13112168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com