My version of FFmpeg is 4.4. There is a logic in my code that calls avformat_find_stream_info() twice continuously, but I don't understand why it crashed here. I tried single-step debugging but it didn't work out. Here is my simply code that can be run directly:
#include <libavutil/timestamp.h>
#include <libavformat/avformat.h>
int main()
{
av_log_set_level(AV_LOG_DEBUG);
const char* in_filename_a = "aoutput.aac";
AVFormatContext* ifmt_ctx_a = NULL;
int ret = avformat_open_input(&ifmt_ctx_a, in_filename_a, 0, 0);
if (ret < 0)
{
fprintf(stderr, "Could not open input_a %s", in_filename_a);
return -1;
}
fprintf(stderr, "before ifmt_ctx_a=0x%x\n", ifmt_ctx_a->streams[0]);
ret = avformat_find_stream_info(ifmt_ctx_a, 0);
if (ret < 0)
{
fprintf(stderr, "Could not find input_a stream info");
return -1;
}
fprintf(stderr, "after ifmt_ctx_a=0x%x\n", ifmt_ctx_a->streams[0]);
/// crashed here
ret = avformat_find_stream_info(ifmt_ctx_a, 0);
if (ret < 0)
{
fprintf(stderr, "Could not find input_a stream info");
return -1;
}
}
