In avcodec_open(), set return code to an error value only when an error occurs