Fix crash when audio encoder is not initalized.

In some cases, audio encoder is not initalized (as explained in ticket #14298).
Merge pull request #2671 from fabio81/master

Fixes crash when audio encoder is not initalized.