Visual c++ FFmpeg avformat_open_输入不工作:处理输入时发现无效数据

Visual c++ FFmpeg avformat_open_输入不工作:处理输入时发现无效数据,visual-c++,visual-studio-2015,ffmpeg,Visual C++,Visual Studio 2015,Ffmpeg,这是我第一次使用FFmpeg。我尝试使用avformat\u open\u input打开的每种类型的媒体文件都会返回“处理输入时发现无效数据”。我使用的是32位FFmpeg构建版本:92de2c2。我根据以下答案设置了我的VS2015项目:。这个代码可能出了什么问题 #include "stdafx.h" #include <stdio.h> extern "C" { #include "libavcodec/avcodec.h" #include <lib

这是我第一次使用FFmpeg。我尝试使用
avformat\u open\u input
打开的每种类型的媒体文件都会返回“处理输入时发现无效数据”。我使用的是32位FFmpeg构建版本:92de2c2。我根据以下答案设置了我的VS2015项目:。这个代码可能出了什么问题

#include "stdafx.h"
#include <stdio.h>

extern "C"
{
    #include "libavcodec/avcodec.h"
    #include <libavformat/avformat.h>
    #include <libavutil/avutil.h>
}

int main(int argc, char *argv[])
{
    AVFormatContext *pFormatCtx = NULL;
    avcodec_register_all();

    const char* filename = "d:\\a.mp4";
    int ret = avformat_open_input(&pFormatCtx, filename, NULL, NULL);
    if (ret != 0) {
        char buff[256];
        av_strerror(ret, buff, 256);
        printf(buff);
        return -1;
    }
}
#包括“stdafx.h”
#包括
外部“C”
{
#包括“libavcodec/avcodec.h”
#包括
#包括
}
int main(int argc,char*argv[])
{
AVFormatContext*pFormatCtx=NULL;
avcodec_寄存器_all();
const char*filename=“d:\\a.mp4”;
int-ret=avformat\u open\u输入(&pFormatCtx,filename,NULL,NULL);
如果(ret!=0){
字符buff[256];
av_strerror(ret,buff,256);
printf(buff);
返回-1;
}
}
您忘了呼叫,ffmpeg没有注册解复用器/多路复用器

#include "stdafx.h"
#include <stdio.h>

extern "C"
{
    #include "libavcodec/avcodec.h"
    #include <libavformat/avformat.h>
    #include <libavutil/avutil.h>
}

int main(int argc, char *argv[])
{
    AVFormatContext *pFormatCtx = NULL;
    av_register_all();
    avcodec_register_all();

    const char* filename = "d:\\a.mp4";
    int ret = avformat_open_input(&pFormatCtx, filename, NULL, NULL);
    if (ret != 0) {
        char buff[256];
        av_strerror(ret, buff, 256);
        printf(buff);
        return -1;
    }
}
#包括“stdafx.h”
#包括
外部“C”
{
#包括“libavcodec/avcodec.h”
#包括
#包括
}
int main(int argc,char*argv[])
{
AVFormatContext*pFormatCtx=NULL;
av_寄存器_all();
avcodec_寄存器_all();
const char*filename=“d:\\a.mp4”;
int-ret=avformat\u open\u输入(&pFormatCtx,filename,NULL,NULL);
如果(ret!=0){
字符buff[256];
av_strerror(ret,buff,256);
printf(buff);
返回-1;
}
}

您是否尝试了其他视频文件?有时这个错误意味着输入文件的格式无效。是的,我尝试了几种不同的视频文件和格式,包括mp4、mkv、avi、mp3。我知道这些文件可以工作,因为当我通过ffmpeg.exe处理它们时,它们的处理没有问题。仍然得到相同的错误。我正在从ftp获取文件。对于中小企业来说,它的工作很好