简体   繁体   English

C ++ / Qt FFmpeg库错误:程序意外完成

[英]C++/Qt FFmpeg library error: program has unexpectedly finished

I am trying to use ffmpeg library on windows in C++/Qt. 我试图在C ++ / Qt的Windows上使用ffmpeg库。 This is my main function: 这是我的主要功能:

#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

#define INT64_C(val) val##LL
#define UINT64_C(val) val##ULL
#include <QtCore>


#include <SDL/SDL.h>
#ifdef __MINGW32__
#undef main
#endif


//--------------- FFMPEG Headers and Libraries ---------------
extern "C"
{
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}

int main(int c, char *args[])
{
    av_register_all();
    AVFormatContext *ctx;

    if(avformat_open_input(&ctx,"salam.avi",NULL,NULL)!=0)
        return -1;
    return 0;
}

It gets compiled & linked fine. 它得到编译和链接罚款。 But I get this error when I try to run it: 但是当我尝试运行它时,我得到了这个错误:
The program has unexpectedly finished 该程序意外完成
This happens on *avformat_open_input* function. 这在* avformat_open_input *函数上发生。 What's the problem? 有什么问题? Is it about my code, or it is a problem with my libraries? 是关于我的代码,还是我的库有问题?
Thanks in advance 提前致谢

Finally I found it. 终于我找到了。 The answer is so simple. 答案很简单。 ctx should be initialized by NULL. ctx应该用NULL初始化。

AVFormatContext *ctx = NULL;

Could be a problem with the AVI. 可能是AVI的问题。 Make sure your avi is supported by FFMPEG. 确保FFMPEG支持您的avi。 use this tool To check what exactly the format is and look up the FFMPEG library help/support to see if the format is supported or not. 使用此工具来检查确切的格式,并查找FFMPEG库的帮助/支持以查看是否支持该格式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM