Fix crash when avformat_open_input fails (Fixes #1522)