I'm using Twilio video and want to record the WebRTC video stream at 720x1280 on the server while showing a lower resolution 360x640 live preview of the user's camera in the browser. This is for layout reasons because I want to fit the video into a smaller div in my HTML. In the code below I've set separate sizes for the video and render dimensions. When I run the code below, Twilio inserts a video element in the DOM matching the dimensions specified in the video parameter. On the server I always receive a recorded video at 360x640 irrespective of what is specified in the video parameter or renderDimensions parameter.
<div class="row">
<div class="columns large-12" style="background-color: blue; width: 640px; height: 360px;">
<div id="local-media" width="640" height="360"></div>
</div>
</div>
function createLocal() {
Twilio.Video.createLocalTracks({
audio: true,
video: { height: 720, frameRate: 24, width: 1280 },
renderDimensions: {
low: { height: 720, frameRate: 24, width: 1280 }
}
}).then(localTracks => {
//DOCUMENTATION
//https://media.twiliocdn.com/sdk/js/video/releases/2.3.0/docs/module-twilio-video.html#.createLocalTracks
var localMediaContainer = document.getElementById('local-media');
localTracks.forEach(function (track) {
localMediaContainer.appendChild(track.attach());
});
return Twilio.Video.connect(token, {
name: rm,
tracks: localTracks
});
}).then(room => {
window.room = room;
console.log(`Connected to Room: ${room.name}`);
});
}
Here's a summary of my test findings when I change the video and renderDimension settings and then check the size of the video inserted into the DOM and recorded on the server.
I'm not sure if this is a Twilio question or a front-end dev question. For example, can I tell the Twilio SDK to show a smaller video preview in the browser while recording something larger on the server? And why is the recorded video always the same size irrespective of the configuration? Or if not a Twilio issue, how do I force the 720x1280 video element that Twilio adds to the DOM into a 360x640 div?
Note - I understand that Twilio will automatically switch to a lower-quality video if the user has a slow connection. My testing is on a 1Gbps fiber connection.