Skip to contentSkip to navigationSkip to topbar
Rate this page:

Specify Video Constraints for Android v3.x


(warning)

Warning

This page is for reference only. We are no longer onboarding new customers to Programmable Video. Existing customers can continue to use the product until December 5, 2024(link takes you to an external page).
We recommend migrating your application to the API provided by our preferred video partner, Zoom. We've prepared this migration guide(link takes you to an external page) to assist you in minimizing any service disruption.

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.


_20
// Create camera capturer
_20
CameraCapturer cameraCapturer = new CameraCapturer(context,
_20
CameraCapturer.CameraSource.FRONT_CAMERA);
_20
_20
// Setup video constraints
_20
VideoConstraints videoConstraints = new VideoConstraints.Builder()
_20
.aspectRatio(VideoConstraints.ASPECT_RATIO_16_9)
_20
.minVideoDimensions(VideoDimensions.CIF_VIDEO_DIMENSIONS)
_20
.maxVideoDimensions(VideoDimensions.HD_720P_VIDEO_DIMENSIONS)
_20
.minFps(5)
_20
.maxFps(24)
_20
.build();
_20
_20
// Add a video track with constraints
_20
LocalVideoTrack localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer, videoConstraints);
_20
_20
// If the constraints are not satisfied a null track will be returned
_20
if (localVideoTrack == null) {
_20
Log.e(TAG, "Unable to satisfy constraints);
_20
}


Rate this page: