Call av_find_stream_info() immediately after opening an input file.