Skip to contentSkip to navigationSkip to topbar

Specify Video Constraints for Javascript v2.x


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.