This is my first time using FFmpeg. Every type of media file that I try to open with avformat_open_input
, returns "Invalid data found when processing input". I am using 32bit FFmpeg Build Version: 92de2c2. I setup my VS2015 project according to this answer: Use FFmpeg in Visual Studio. What could be going wrong with this code?
#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;
}
}
You forgot to call av_register_all
, ffmpeg has no demuxer/muxer registered.
#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;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With