fix media encoding crash issue