Skip to content

Commit 7cd385e

Browse files
committed
perf: limit webcam video size to prevent a/v desync on low performance devices
1 parent 42cc23a commit 7cd385e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

public/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ audioInputSelect.onchange = videoSelect.onchange = async (e) => {
245245

246246
const constraints = {
247247
audio: {deviceId: audioSource ? {exact: audioSource} : undefined},
248-
video: {deviceId: videoSource ? {exact: videoSource} : undefined},
248+
video: {deviceId: videoSource ? {exact: videoSource} : undefined, width: {exact: 640}, height: {exact: 480}},
249249
};
250250
const stream = await app.mediasoupClient.getStream(constraints);
251251
const audioTrack = stream.getAudioTracks()[0];

public/mediasoup-client.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class MediasoupClient {
1616
this.producerTransport = await this.initProducerTransport();
1717

1818
try {
19-
this.stream = await this.getStream({audio: true, video: true});
19+
this.stream = await this.getStream({audio: true, video: {width: {exact: 640}, height: {exact: 480}}});
2020

2121
const video = this.stream.getVideoTracks()[0];
2222

@@ -25,9 +25,9 @@ export class MediasoupClient {
2525

2626
// Simulcast
2727
params.encodings = [
28-
{rid: 'r0', maxBitrate: 100000, scalabilityMode: 'S1T3'},
29-
{rid: 'r1', maxBitrate: 300000, scalabilityMode: 'S1T3'},
30-
{rid: 'r2', maxBitrate: 900000, scalabilityMode: 'S1T3'},
28+
{scaleDownResolutionBy: 4, maxBitrate: 100000},
29+
{scaleDownResolutionBy: 2, maxBitrate: 300000},
30+
{scaleDownResolutionBy: 1, maxBitrate: 900000},
3131
];
3232
params.codecOptions = {
3333
videoGoogleStartBitrate: 1000,

0 commit comments

Comments
 (0)