红联Linux门户
Linux帮助

ffmpeg调用avformat_open_input失败,返回-2

发布时间:2016-03-25 10:22:37来源:linux网站作者:Bobsweetie

系统环境ubuntu12.04,开发环境Qt。


执行程序卡在如下代码段:

if(avformat_open_input(&pFormatCtx,filepath,NULL,NULL)!=0){//打开输入视频文件 
printf("Couldn't open input stream.\n"); 
return -1; 


插入下面的代码分析:

char buf[] = ""; 
int err_code = avformat_open_input(&pFormatCtx,filepath,NULL,NULL);//打开输入视频文件 
av_strerror(err_code, buf, 1024); 
printf("Couldn't open file %s: %d(%s)\n",filepath, err_code, buf); 


打印出错误代码是-2,错误原因是no file or directory


我是将视频文件放在了Qt的工程目录下,但是找不到,于是我将视频移动到debug目录下,或者将当前路径视为debug路径时,编译正确,程序执行成功!


本文永久更新地址:http://www.linuxdiyf.com/linux/19228.html