Custom Video Sources - Android
To deliver high-quality livestreams, it's essential to fine-tune the video tracks being broadcasted. Whether youโre hosting a webinar, or streaming an event, using custom video tracks gives you better control over stream quality and performance.
Custom Video Trackโ
This feature can be used to add custom video encoder configurations, optimization mode (whether you want to focus on motion, text or detail of the video) and background removal & video filter from external SDK(e.g., Banuba)and send it to other participants.
How to Create a Custom Video Track ?
โ
- You can create a Video Track using
createCameraVideoTrack()
method ofVideoSDK
. - This method can be used to create video track using different encoding parameters, camera facing mode, and optimization mode and return
CustomStreamTrack
.
Exampleโ
- Kotlin
- Java
val videoCustomTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack(
// This will accept the resolution (height x width) of video you want to capture.
"h720p_w960p", // "h720p_w960p" | "h720p_w1280p" ... // Default : "h480p_w720p"
// It will specify whether to use front or back camera for the video track.
"front", "back", Default : "front"
// We will discuss this parameter in next step.
CustomStreamTrack.VideoMode.MOTION, // CustomStreamTrack.VideoMode.TEXT, CustomStreamTrack.VideoMode.DETAIL , Default : CustomStreamTrack.VideoMode.MOTION
// multiStream - we will discuss this parameter in next step.
false, // true
// Pass Context
this,
// This is Optional parameter. We will discuss this parameter in next step.
observer)
CustomStreamTrack customStreamTrack = VideoSDK.createCameraVideoTrack(
// This will accept the resolution (height x width) of video you want to capture.
"h480p_w640p", // "h720p_w960p" | "h720p_w1280p" ... // Default : "h480p_w640p"
// It will specify whether to use front or back camera for the video track.
"front", // "back, Default : "front""
// We will discuss this parameter in next step.
CustomStreamTrack.VideoMode.MOTION, // CustomStreamTrack.VideoMode.TEXT, CustomStreamTrack.VideoMode.DETAIL , Default : CustomStreamTrack.VideoMode.MOTION
// multiStream - we will discuss this parameter in next step.
false, // true
// Pass Context
this
// This is Optional parameter. We will discuss this parameter in next step.
observer);
The behavior of custom track configurations is influenced by the capabilities of the device. For example, if you set the encoder configuration to 1080p but the webcam only supports 720p, the encoder configuration will automatically adjust to the highest resolution that the device can handle, which in this case is 720p.
What is optimizationMode
?โ
- This parameter specifies the optimization mode for the video track being generated.
motion
: This type of track focuses more on motion video such as webcam video, movies or video games.- It will degrade
resolution
in order to maintainframe rate
.
- It will degrade
text
: This type of track focuses on significant sharp edges and areas of consistent color that can change frequently such as presentations or web pages with text content.- It will degrade
frame rate
in order to maintainresolution
.
- It will degrade
detail
: This type of track focuses more on the details of the video such as, presentations, painting or line art.- It will degrade
frame rate
in order to maintainresolution
.
- It will degrade
What is multiStream
?โ
- By enabling multiStream, your livestream will broadcast multiple resolutions (e.g., 720p, 480p, 360p), allowing viewers to receive the best stream quality based on their network.
The
multiStream : true
configuration indicates that VideoSDK, by default, sends multiple resolution video streams to the server. For example, if a user's device capability is 720p, VideoSDK sends streams in 720p, 640p, and 480p resolution. This enables VideoSDK to deliver the appropriate stream to each participant based on their network bandwidth.
Setting multiStream : false
restricts VideoSDK to send only one stream, helping to maintain quality by focusing on a single resolution.
The setQuality
parameter will not have any effect if multiStream is set to false
.
How to Setup a Custom Video Track ?
โ
You can plug in your custom video track either before going live or dynamically while the session is ongoing.
1. Setting up a Custom Track during the initialization of a liveStreamโ
If you're starting the stream with the webcam enabled (webcamEnabled: true)
and wish to use a custom track from the beginning, pass it through the config of initMeeting as shown below.
Custom Track will not apply on the webcamEnabled: false
configuration.
Exampleโ
- Kotlin
- Java
override fun onCreate(savedInstanceState: Bundle?) {
//..
val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()
val videoCustomTrack: CustomStreamTrack =
VideoSDK.createCameraVideoTrack("h720p_w960p", "front", CustomStreamTrack.VideoMode.MOTION, false, this)
customTracks["video"] = videoCustomTrack //Key must be "video"
// create a new meeting instance
val liveStream = VideoSDK.initMeeting(
this@MainActivity, meetingId, participantName,
//MicEnabled
true,
//WebcamEnabled , If true, it will use the passed custom track to turn webcam on
true,
// ParticipantId
null,
// Mode
null,
// MultiStream
false,
//Pass the custom tracks here
customTracks,
//MetaData
null
)
}
@Override
protected void onCreate(Bundle savedInstanceState) {
//..
Map<String, CustomStreamTrack> customTracks = new HashMap<>();
CustomStreamTrack videoCustomTrack = VideoSDK.createCameraVideoTrack("h720p_w960p", "front", CustomStreamTrack.VideoMode.MOTION, false, this);
customTracks.put("video", videoCustomTrack); //Key must be "video"
// create a new meeting instance
Meeting liveStream = VideoSDK.initMeeting(
MainActivity.this, meetingId, participantName,
//MicEnabled
true,
//WebcamEnabled , If true, it will use the passed custom track to turn webcam on
true,
// ParticipantId
null,
// Mode
null,
// MultiStream
false,
//Pass the custom tracks here
customTracks,
//MetaData
null
);
}
2. Setting up a Custom Track with methodsโ
In order to switch tracks during the meeting, you have to pass the CustomStreamTrack
in the enableWebcam()
method of Meeting
.
Make sure to call disableWebcam()
before you create a new track as it may lead to unexpected behavior.
Exampleโ
- Kotlin
- Java
val customStreamTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack("h720p_w960p", "back", CustomStreamTrack.VideoMode.MOTION, false, this)
liveStream!!.enableWebcam(customStreamTrack)
CustomStreamTrack customStreamTrack=VideoSDK.createCameraVideoTrack("h720p_w960p", "back", CustomStreamTrack.VideoMode.MOTION, false, this);
liveStream.enableWebcam(customStreamTrack);
Which Configuration is suitable for Device ?
โ
In this section, we will understand participant size wise encoder(Resolution)
and multiStream
configuration.

API Referenceโ
The API references for all the methods and events utilised in this guide are provided below.
Got a Question? Ask us on discord