Menu

Expand
Rate this page:

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.

// Create camera capturer
CameraCapturer cameraCapturer = new CameraCapturer(context, 
    CameraCapturer.CameraSource.FRONT_CAMERA);

// Setup video constraints
VideoConstraints videoConstraints = new VideoConstraints.Builder()
    .aspectRatio(VideoConstraints.ASPECT_RATIO_16_9)
    .minVideoDimensions(VideoDimensions.CIF_VIDEO_DIMENSIONS)
    .maxVideoDimensions(VideoDimensions.HD_720P_VIDEO_DIMENSIONS)
    .minFps(5)
    .maxFps(24)
    .build();

// Add a video track with constraints
LocalVideoTrack localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer, videoConstraints);

// If the constraints are not satisfied a null track will be returned
if (localVideoTrack == null) {
    Log.e(TAG, "Unable to satisfy constraints);
}
Rate this page:

Need some help?

We all do sometimes; code is hard. Get help now from our support team, or lean on the wisdom of the crowd by visiting Twilio's Stack Overflow Collective or browsing the Twilio tag on Stack Overflow.

Loading Code Sample...
        
        
        

        Thank you for your feedback!

        Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

        Sending your feedback...
        🎉 Thank you for your feedback!
        Something went wrong. Please try again.

        Thanks for your feedback!

        thanks-feedback-gif