Skip to main content
Version: 0.1.x

Custom Video Track - React Native

We have introduced the ability to pass a custom video track for the video of the participants. This feature can be used to add custom video encoder config, 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.

Creating a Custom Video Track

  • You can create a Video Track using createCameraVideoTrack() method of VideoSDK.
  • This method can be used to create video track using different encoding parameters & camera facing mode.

Parameters

  • encoderConfig:

    • type: String
    • required: true
    • default: h480p_w640p
    • Allowed values : h144p_w176p | h240p_w320p | h480p_w640p | h480p_w720p | h720p_w960p | h1080p_w1440p | h720p_w1280p
    • It will be the encoderConfigs you can want to use for the Video Track.
note

Above mentioned encoder configurations are valid for both, landscape as well as portrait mode.

  • facingMode:

    • type: String
    • required: true
    • Allowed values : front | back
    • It will specify wheater to use front or back camera for the video track.
  • optimizationMode

    • type: CustomStreamTrack.VideoMode
    • required: true
    • Allowed values: motion | text | detail
    • It will specify the optimization mode for the video track being generated.
  • context:

    • type: Context
    • required: true
    • Pass the Android Context for this parameter.
  • observer:

    • type: CapturerObserver
    • required: false
    • If you want to use video filter from external SDK(e.g., Banuba) then pass instance of CapturerObserver in this parameter.
note

For Banuba integraion with VideoSDK, please visit Banuba Intergation with VideoSDK

Returns

  • CustomStreamTrack

Example

val videoCustomTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "front", CustomStreamTrack.VideoMode.MOTION, this)

Using Custom Video Track

Custom Track while initializing the meeting

If you are passing webcamEnabled: true in the initMeeting of VideoSDK and want to use custom tracks from start of the meeting, you can pass custom track in the initMeeting as shown below.

override fun onCreate(savedInstanceState: Bundle?) {
//..

val customTracks: MutableMap<String, CustomStreamTrack> = HashMap()
val videoCustomTrack: CustomStreamTrack =
VideoSDK.createCameraVideoTrack("h240p_w320p", "back", false, CustomStreamTrack.VideoMode.MOTION, this)
customTracks["video"] = videoCustomTrack //Key must be "video"

// create a new meeting instance
val meeting = 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,
//Pass the custom tracks here
customTracks
)
}

Custom Track with enableWebcam()

In order to switch tracks during the meeting, you have to pass the CustomStreamTrack in the enableWebcam() method of Meeting.

note

Make sure to call disableWebcam() before you create a new track as it may lead to unexpected behavior.

val customStreamTrack: CustomStreamTrack = VideoSDK.createCameraVideoTrack("h240p_w320p", "back", CustomStreamTrack.VideoMode.MOTION, this)
meeting!!.enableWebcam(customStreamTrack)

Got a Question? Ask us on discord