Skip to contentSkip to navigationSkip to topbar

Specify Video Constraints for Android v1.x


You can customize the video capture by setting video constraints on a local video track. Setting constraints, lets you optimize the video track to network and device conditions. You can set size constraints, frame rate constraints or the aspect ratio constraints of your choice. Note that video constraints are used to resolve the capture format, but the actual video sent to Participant may be downscaled temporally or spatially in response to network and device conditions.

1
// Create camera capturer
2
CameraCapturer cameraCapturer = new CameraCapturer(context,
3
CameraCapturer.CameraSource.FRONT_CAMERA);
4
5
// Setup video constraints
6
VideoConstraints videoConstraints = new VideoConstraints.Builder()
7
.aspectRatio(VideoConstraints.ASPECT_RATIO_16_9)
8
.minVideoDimensions(VideoDimensions.CIF_VIDEO_DIMENSIONS)
9
.maxVideoDimensions(VideoDimensions.HD_720P_VIDEO_DIMENSIONS)
10
.minFps(5)
11
.maxFps(24)
12
.build();
13
14
// Add a video track with constraints
15
LocalVideoTrack localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer, videoConstraints);
16
17
// If the constraints are not satisfied a null track will be returned
18
if (localVideoTrack == null) {
19
Log.e(TAG, "Unable to satisfy constraints);
20
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.