Skip to contentSkip to navigationSkip to topbar

Specifying a Video Format - Android 6.x


You can customize a VideoCapturer by setting a VideoFormat when creating a LocalVideoTrack. You can set the video dimensions and frame rate of your choice and the capturer is responsible for capturing as close as possible to your specified format. The VideoFormat provided to LocalVideoTrack.create(...) takes highest priority over the format returned by VideoCapturer.getCaptureFormat(). The default format for video tracks is 640x480 at 30 FPS. Note that your VideoFormat is used to select a capture format, but the actual video sent to Participants may be cropped and/or downscaled in response to network and device conditions.

1
// Create camera capturer
2
CameraCapturer cameraCapturer = new CameraCapturer(context, CameraCapturer.CameraSource.FRONT_CAMERA);
3
4
// Setup video format
5
VideoFormat videoFormat = new VideoFormat(VideoDimensions.HD_720P_VIDEO_DIMENSIONS, 30);
6
7
// Add a video track with the format
8
LocalVideoTrack localVideoTrack = LocalVideoTrack.create(context, true, cameraCapturer, videoFormat);
9
10
// If the format is not satisfied a null track will be returned
11
if (localVideoTrack == null) {
12
Log.e(TAG, "Unable to satisfy the format");
13
}

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.