logo
Video Call
On this page

Custom Video Capture

2024-12-09

Feature Overview

Custom video Capture refers to the developer Capturing video by themselves and providing video data to ZEGO Express SDK, which is then encoded and published by ZEGO Express SDK.

When the following situations occur in the developer's business, it is recommended to use SDK's custom video Capture functionality:

  • Ordinary camera Capture cannot meet requirements. For example, it contains a large amount of original business.
  • Live streaming non-camera data. For example, video playback, screen sharing, game live streaming, etc.
  • Using third-party virtual camera external Capture for custom beauty and other video preprocessing.

Example Source Code Download

Please refer to Download Example Source Code to get the source code.

For related source code, please check files in the "src/Examples/AdvancedVideoProcessing/CustomVideoCapture" directory.

Prerequisites

Usage Steps

To publish a stream with a custom video source:

  1. When calling the createZegoStream interface to create a ZegoLocalStream stream instance object, specify the third-party data source by setting the "source" parameter.
  2. Call startPublishingStream to publish the stream.
  • Set third-party media stream

    // Start previewing local video
    previewVideo.srcObject = mediaStream;
    const stream = await zg.createZegoStream({
        custom: {
            video: {
                source: mediaStream
            },
            audio: {
                source: mediaStream // Video original sound, can also be other audio source
            }
        }
    })
    // Publish stream
    zg.startPublishingStream(idName, stream);
  • Set third-party audio and video

Warning
  • Third-party audio and video currently does not support Safari browser publishing, only playing.
  • Since Chrome 86, when publishing third-party audio and video streams, if local audio and video are set to mute, the playing end will not be able to hear the corresponding sound.

When source is a <video> or <audio> object, use its specified video or audio source as preview.

// localVideo is <video> object
const stream = await zg.createZegoStream({
    custom: {
        video: {
            source: localVideo
        },
        audio: {
            source: localAudio // Can be video original sound, can also be other audio source
        }
    }
})
// Publish stream
zg.startPublishingStream(idName, stream);

Previous

Set Video Encoding Attributes

Next

Background Virtualization and Virtual Background

On this page

Back to top