avformat

mac2025-06-20  6

代码

AVFormatContext *pFormatCtx = NULL; AVCodecContext *pCodecCtx = NULL; AVCodec *pCodec; AVDictionaryEntry *dict = NULL; int iHour, iMinute, iSecond, iTotalSeconds;//HH:MM:SS int videoIndex, audioIndex; const char* fileName = "D:\\code\\ffmpeg\\ffmpeg-20191028-68f623d-win64-dev\\FfmpegDemo\\YY.mp4"; //char *fileName = "Titanic.ts"; av_register_all();//注册所有组件 avformat_network_init(); int ret = 0; ret = avformat_open_input(&pFormatCtx, fileName, NULL, NULL); if (ret != 0)//打开输入视频文件 { char msg[512]; av_make_error_string(msg, 512, ret); printf("Couldn't open input stream. Error(%d)(%s).\n", ret, msg); return -1; }

-2 No such file or directory 原因,很简单就是文件路径错误,如果还不行,可以试试全局路径。

-22 Invalid argument 原因,输入有误,比如在路径中,只写了一个反斜杠,而不是两个,可以参见代码中的路径格式重写。

 

最新回复(0)