Q:

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

A:

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

