Skip to contentSkip to navigationSkip to topbar
Rate this page:

SpecifyVideo Constraints for Javascript v1.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.

(warning)

Warning

This document refers to the 1.x version of Twilio Video JS. If you are starting with Twilio Video JS, please use the 2.x version. If you are using a 1.x version of Twilio Video JS, we recommend you to upgrade to the 2.x version.

You can customize the video capture by setting video constraints(link takes you to an external page) on a LocalVideoTrack. 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.


_23
const { connect, createLocalTracks } = require('twilio-video');
_23
_23
// Option 1
_23
createLocalTracks({
_23
audio: true,
_23
video: { width: 640 },
_23
}).then(localTracks => {
_23
return connect('$TOKEN', {
_23
name: 'my-room-name',
_23
tracks: localTracks,
_23
});
_23
}).then(room => {
_23
console.log(`Connected to Room: ${room.name}`);
_23
});
_23
_23
// Option 2
_23
connect('$TOKEN', {
_23
audio: true,
_23
name: 'my-room-name',
_23
video: { width: 640 },
_23
}).then(room => {
_23
console.log(`Connected to Room: ${room.name}`);
_23
});


Rate this page: