Skip to contentSkip to navigationSkip to topbar

SpecifyVideo Constraints for Javascript v1.x


(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.

1
const { connect, createLocalTracks } = require('twilio-video');
2
3
// Option 1
4
createLocalTracks({
5
audio: true,
6
video: { width: 640 },
7
}).then(localTracks => {
8
return connect('$TOKEN', {
9
name: 'my-room-name',
10
tracks: localTracks,
11
});
12
}).then(room => {
13
console.log(`Connected to Room: ${room.name}`);
14
});
15
16
// Option 2
17
connect('$TOKEN', {
18
audio: true,
19
name: 'my-room-name',
20
video: { width: 640 },
21
}).then(room => {
22
console.log(`Connected to Room: ${room.name}`);
23
});

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.