Joh*_*res 5 ffmpeg visual-c++ visual-studio-2015
这是我第一次使用FFmpeg.我尝试打开的每种类型的媒体文件都avformat_open_input
返回"处理输入时找到的无效数据".我使用的是32位FFmpeg Build版本:92de2c2.我根据这个答案设置我的VS2015项目:在Visual Studio中使用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;
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;
}
}
Run Code Online (Sandbox Code Playgroud)
小智 12
你忘了打电话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;
}
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4160 次 |
最近记录: |