Remove backgrounds with an alpha channel

The code on this page works with either the default UI or the custom UI.

Meeting hosts who hold a raw streaming token can enable alpha channel mode, which requests that Zoom send both the original video data and a mask demarking the edge of a participant's body. The SDK can then use the alpha mask and raw data to remove the participant's background and render meeting participants natively in the host's virtual world.

Add new methods

Add a new method to the IMeetingVideoCtrlEvent class.

/// \brief Callback event of alpha channel mode changes.
/// \param isAlphaModeOn true means is in alpha channel mode.
virtual void onVideoAlphaChannelStatusChanged(bool isAlphaModeOn) = 0;

This callback is triggered when alpha channel mode is turned on.

Add these methods to the IMeetingVideoController class.

/// \brief Determine if can enable alpha channel mode.
/// \return true means can enable.
virtual bool CanEnableAlphaChannelMode() = 0;
/// \brief Enable or disable alpha channel mode.
/// \param enable TRUE indicates to enable alpha channel mode. Otherwise, disable it.
/// \return If the function succeeds, the return value is SDKErr_Success.
///Otherwise, the function failed. To get extended error information, see SDKError enum.
virtual SDKError EnableAlphaChannelMode(bool enable) = 0;
/// \brief Determine if is in alpha channel mode.
/// \return TRUE indicates is in alpha channel mode.
virtual bool IsAlphaChannelModeEnabled() = 0;

Enable alpha channel mode

Before enabling the alpha channel, call canEnableAlphaChannelMode to check whether the alpha channel mode is enabled. To enable or disable the alpha channel, call EnableAlphaChannelMode.

Add a new method to the YUVRawDataI420 class.

/// \brief Get video alpha mask data buffer.
/// \return buffer address if alpha data exists, otherwise NULL.
virtual char* GetAlphaBuffer() = 0;
/// \brief Get the alpha buffer length.
/// \return The length of alpha data.
virtual unsigned int GetAlphaBufferLen() = 0;

The raw data will have two more values after performing these steps: GetAlphaBuffer for the alpha data buffer, and another, GetAlphaBufferLen, for the alpha data buffer length.

Now that you've received the data, edit the raw data.