As you build with Twilio Video, you can customize certain aspects of your Participants' audio and video capture to optimize behavior for your specific use case. For example, you can turn on or off features such as noise suppression, or alter the video's frame rate. Below are examples for specifying audio and video constraints for local tracks.
You can customize audio capture by setting audio constraints on a LocalAudioTrack. Note that all the constraints default to true
.
1const { connect, createLocalAudioTrack, createLocalTracks } = require('twilio-video');23// Option 14createLocalTracks({5audio: { noiseSuppression: false, echoCancellation: false },6video: true7}).then(localTracks => {8return connect('$TOKEN', {9name: 'my-room-name',10tracks: localTracks11});12}).then(room => {13console.log(`Connected to Room: ${room.name}`);14});1516// Option 217connect('$TOKEN', {18audio: { noiseSuppression: false, echoCancellation: false },19name: 'my-room-name',20video: true21}).then(room => {22console.log(`Connected to Room: ${room.name}`);23});2425// Option 326createLocalAudioTrack({27noiseSuppression: false,28echoCancellation: false29}).then(localTrack => {30console.log(`Created LocalAudioTrack: ${localTrack.name}`);31});
You can customize video capture by setting video constraints on a LocalVideoTrack. Setting constraints lets you optimize the video track for network and device conditions. You can set the size, frame rate, or aspect ratio constraints of your choice. Note that all the constraints default to true
.
Please keep in mind that video constraints are used to resolve the video capture format, but the actual video sent to other Participants may be downscaled temporally or spatially in response to those Participants' network and device conditions.
1const { connect, createLocalTracks } = require('twilio-video');23// Option 14createLocalTracks({5audio: true,6video: { width: 640 },7}).then(localTracks => {8return connect('$TOKEN', {9name: 'my-room-name',10tracks: localTracks,11});12}).then(room => {13console.log(`Connected to Room: ${room.name}`);14});1516// Option 217connect('$TOKEN', {18audio: true,19name: 'my-room-name',20video: { width: 640 },21}).then(room => {22console.log(`Connected to Room: ${room.name}`);23});