Skip to main content
Android
iOS
macOS
Web
Windows
Electron
Flutter
React Native
React JS
Unity
Unreal Engine
Unreal (Blueprint)

Custom video source

Custom video capture refers to the collection of a video stream from a custom source. Unlike the default video capture method, custom video capture enables you to control the capture source, and precisely adjust video attributes. You can dynamically adjust parameters such as video quality, resolution, and frame rate to adapt to various application scenarios. For example, you can capture video from high-definition cameras, and drone cameras.

Agora recommends default video capture for its stability, reliability, and ease of integration. Custom video capture offers flexibility and customization for specific video capture scenarios where default video capture does not fulfill your requirements.

Understand the tech

Video SDK provides support for creating local video tracks by passing in a MediaStreamTrack object to createCustomVideoTrack.

Prerequisites

Ensure that you have implemented the SDK quickstart in your project.

Implement the logic

You implement custom video capture or preprocessing by obtaining the MediaStreamTrack object. For example, you can manually call the getUserMedia method to get the MediaStreamTrack and then use createCustomVideoTrack to create a local video track object that you use in Video SDK.

navigator.mediaDevices.getUserMedia({ video: true, audio: false })
.then((mediaStream) => {
const videoMediaStreamTrack = mediaStream.getVideoTracks()[0];
// Create a custom video track
return AgoraRTC.createCustomVideoTrack({
mediaStreamTrack: videoMediaStreamTrack,
});
})
.then((localVideoTrack) => {
// ...
});
Copy

You can also use HTMLMediaElement.captureStream or HTMLCanvasElement.captureStream to obtain the MediaStreamTrack object.

Information

The MediaStreamTrack object refers to the browser-native supported MediaStreamTrack object. For specific usage and browser support, refer to the MediaStreamTrack API documentation.

Reference

This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.

vundefined