Reputation: 2464
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
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