VideoCapture open vedio file fail
来源:互联网 发布:钥匙扣淘宝 编辑:程序博客网 时间:2024/06/07 09:13
在Linux(readhat)系统下,以下程序程序编译可以完成,但是运行时则不能打开视频文件,运行时没有提示出现任何错误。
首先确认的是文件的路径没问题,使用绝对路径也测试了还是不行的。
在网上查了没有查到类似的,希望各位帮忙看下,谢谢。
int main(int argc, char** argv)
{
string input_name = argc == 2 ? argv[1]:"./filename.mp4";
Mat frame;
VideoCapture cap;
cap.open(input_name);
if(!cap.isOpened()) //执行到这返回false
{
cerr << "cannot open video or the specified"<<input_name<<"does not exist in this directory!"<<endl;
return 1;
}
cap.read(frame);
if(frame.empty())
{
cerr <<"the video may be broken!"<<endl;
return 1;
}
cap.release();
cout << "the video is read successfully!" << endl;
return 0;
首先确认的是文件的路径没问题,使用绝对路径也测试了还是不行的。
在网上查了没有查到类似的,希望各位帮忙看下,谢谢。
int main(int argc, char** argv)
{
string input_name = argc == 2 ? argv[1]:"./filename.mp4";
Mat frame;
VideoCapture cap;
cap.open(input_name);
if(!cap.isOpened()) //执行到这返回false
{
cerr << "cannot open video or the specified"<<input_name<<"does not exist in this directory!"<<endl;
return 1;
}
cap.read(frame);
if(frame.empty())
{
cerr <<"the video may be broken!"<<endl;
return 1;
}
cap.release();
cout << "the video is read successfully!" << endl;
return 0;
}
经过几天查找终于找到原因了,是没有找到ffmpeg解码器:
在编译openCV时,
设置环境变量PKG_CONFIG_PATH,在~/.bashre中添加如下一行,即可
export PKG_CONFIG_PATH=/usr/local/ffmpeg/lib/pkgconfig : $PKG_CONFIG_PATH
source ~/.bashre
0 0
- VideoCapture open vedio file fail
- opecv VideoCapture open avi file failed
- OpenCV2.4.13 Python VideoCapture Fail 解决办法
- vedio
- opencv2.4.4 VideoCapture::open()的运用
- fail to crunch file
- VideoCapture
- Open source audio/vedio conferen…
- android studio 一直在提示 fail to open zip file,而且刚一clean就终止报错了
- File#open
- file open
- Open File and Open Path
- 虚拟机报错:fail to lock file
- gstreamer vedio
- vedio PICS
- FileStream Open File [C#]
- linux open file
- 汇编open file
- xamarin c#开发ios/android 应用
- 70、Climbing Stairs
- Golang语言的学习资料
- 进程之间如何通信
- Hello Tez
- VideoCapture open vedio file fail
- SVN 常用命令
- C++内存管理详解
- iOS实现圆形头像
- 《敏捷软件开发》--读书笔记
- 快速矩阵幂-有向图
- Android Studio的艰辛历程
- seajs最常用7个功能、配置
- kernel study web