avformat_open_input函数崩溃

avformat_open_input function crashing

本文关键字:崩溃 函数 open avformat input      更新时间:2023-10-16

我试图使用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;
}

必须先将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;
}