yayuj
yayuj

Reputation: 2464

avformat_open_input function crashing

I'm trying to open a file using avformat_open_input and it crashes even if the file exists.

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;
}

Upvotes: 5

Views: 2469

Answers (1)

szatmary
szatmary

Reputation: 31101

You must NULL the avFormatContext variable first:

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;
}

Upvotes: 7

Related Questions