Raw video with alpha channel

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

Turn on alpha channel mode

Before turning on the alpha channel, call the following:

  • canEnableAlphaChannelMode to check whether the alpha channel mode is already turned on
  • isDeviceSupportAlphaChannelMode to check whether the device hardware capabilities are capable of supporting video alpha mode

To turn on, or off, the alpha channel, call enableAlphaChannelMode.

let videoHelper = ZMVideoSDK.shared().getVideoHelper()
if videoHelper.canEnableAlphaChannelMode()  {
    videoHelper.isDeviceSupportAlphaChannelMode() // Determines whether the device hardware capabilities are capable of supporting video alpha mode.
    videoHelper.enableAlphaChannelMode(true) // TRUE/FALSE to enable/disable alpha channel.
    videoHelper.isAlphaChannelModeEnabled()
}
ZMVideoSDKVideoHelper *videoHelper = [[ZMVideoSDK sharedVideoSDK] getVideoHelper];
if ([videoHelper canEnableAlphaChannelMode]) {
    [videoHelper isDeviceSupportAlphaChannelMode]; // Determines whether the device hardware capabilities are capable of supporting video alpha mode.
    [videoHelper enableAlphaChannelMode:TRUE]; // TRUE/FALSE to enable/disable alpha channel.
    [videoHelper isAlphaChannelModeEnabled];
}

Alpha channel callbacks

The onVideoAlphaChannelStatusChanged callback is triggered when alpha channel mode is turned on or off. After turning on the alpha channel, the raw video data will have two more values, alphaBuffer for the alpha data buffer and alphaBufferLen for the alpha data buffer length, included in the same onRawDataFrameReceived callback.

Now that you've received the data, edit the raw data to suit your use case.

func onVideoAlphaChannelStatusChanged(_ isAlphaModeOn: Bool) {
}
func onRawDataFrameReceived(_ data: ZMVideoSDKYUVRawDataI420) {
    data.alphaBuffer // Only if alpha data exists, then will contain buffer address. Otherwise null.
    data.alphaBufferLen
}
- (void)onVideoAlphaChannelStatusChanged:(BOOL)isAlphaModeOn {
}
- (void)onRawDataFrameReceived:(ZMVideoSDKYUVRawDataI420*)data {
    data.alphaBuffer; // Only if alpha data exists, then will contain buffer address. Otherwise null.
    data.alphaBufferLen;
}