Specifying Video Constraints

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.

const { connect, createLocalTracks } = require('twilio-video');

// Option 1
createLocalTracks({
  audio: true,
  video: { width: 640 },
})
  .then(function(localTracks) {
    return connect('$TOKEN', {
      name: 'my-room-name',
      tracks: localTracks,
    });
  })
  .then(function(room) {
    console.log('Connected to Room:', room.name);
  });

// Option 2
connect('$TOKEN', {
  audio: true,
  name: 'my-room-name',
  video: { width: 640 },
}).then(function(room) {
  console.log('Connected to Room:', room.name);
});

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 browsing the Twilio tag on Stack Overflow.