FFmpeg avformat_open_input not working: invalid data found during input processing

This is my first time using FFmpeg. Each type of media file that I am trying to open with avformat_open_input, returns "Invalid data found during the processing of the input" . I am using the 32 bit version of FFmpeg Build: 92de2c2. I am setting up a VS2015 project according to this answer: Use FFmpeg in Visual Studio . What could be 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;
    }
}
+4
source share
1 answer

You forgot to call av_register_all, ffmpeg is not registered 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;
    }
}
+8

Source: https://habr.com/ru/post/1656280/


All Articles