windows +QT 打开文件失败
来源:5-8 FFmpeg打印音视频Meta信息
慕田峪8333269
2024-02-26
#include <stdio.h>
#include <libavutil/log.h>
#include <libavformat/avformat.h>
#include <libavdevice/avdevice.h>
int main()
{
int ret;
AVFormatContext *fmt_ctx = NULL;
av_log_set_level(AV_LOG_INFO);
av_register_all();
avdevice_register_all();
ret = avformat_open_input(&fmt_ctx,"./test.mp4",NULL,NULL);//这里第三个参数为输入文件的格式,默认为空,此时ffmpeg会自己根据参数二选择输入格式
//第四个参数默认为空
if(ret < 0)
{
//av_log(NULL,AV_LOG_ERROR,"failed open file:%s\n",av_err2str(ret));
av_log(NULL,AV_LOG_ERROR,"failed open file\n");
return -1;
}
av_dump_format(fmt_ctx,0,"./test.mp4",0);//这里参数二默认为0,参数三为输入文件地址,参数四是0或者1,
//如果是ffmpeg自己生成的文件做分析,为1,外部文件为0
avformat_close_input(&fmt_ctx);
return 0;
// av_log_set_level(AV_LOG_INFO);
// av_log(NULL,AV_LOG_DEBUG,"%d\n",10);
// av_log(NULL,AV_LOG_INFO,"HELLO WORLD:%s","this is char");//由此可见,av_log函数可打印字符串,也打印整数
// //printf("Hello World!\n");
// return 0;
}显示打开文件失败,为啥啊
写回答
1回答
-
李超
2024-02-27
在你程序的目录下有test.mp4 这个文件吗?
022024-02-28
相似问题