gpt4 book ai didi

visual-c++ - FFmpeg avformat_open_input 不工作 : Invalid data found when processing input

转载 作者:行者123 更新时间:2023-12-03 15:26:44 30 4
gpt4 key购买 nike

这是我第一次使用 FFmpeg。我尝试使用 avformat_open_input 打开的每种媒体文件, 返回 “处理输入时发现无效数据” .我正在使用 32 位 FFmpeg 构建版本:92de2c2。我根据这个答案设置了我的 VS2015 项目:Use FFmpeg in Visual Studio .这段代码可能出了什么问题?

#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;
}
}

最佳答案

您忘记调用 av_register_all , ffmpeg 没有注册 demuxer/muxer。

#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;
}
}

关于visual-c++ - FFmpeg avformat_open_input 不工作 : Invalid data found when processing input,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39778605/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com