avformat_open_input函数崩溃

yay*_*yuj 4 c c++ ffmpeg

我正在尝试使用avformat_open_input它来打开文件,即使该文件存在它也会崩溃.

av_register_all();

AVFormatContext *avFormatContext;

if (avformat_open_input(&avFormatContext, argv[1], NULL, NULL) < 0)
{
    av_log(0, AV_LOG_FATAL, "Wasn't possible opening the file: %s", argv[1]);
    return -1;
}
Run Code Online (Sandbox Code Playgroud)

sza*_*ary 6

您必须首先使avFormatContext变量为NULL:

av_register_all();

AVFormatContext *avFormatContext = NULL;

if (avformat_open_input(&avFormatContext, argv[1], NULL, NULL) < 0)
{
    av_log(0, AV_LOG_FATAL, "Wasn't possible opening the file: %s", argv[1]);
    return -1;
}
Run Code Online (Sandbox Code Playgroud)