Skip to content

Commit 5003c52

Browse files
committed
fix: use recommended resolution
1 parent d1843d3 commit 5003c52

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

src/components/footer/icons/webcam/useWebcamPublisher.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,20 @@ const useWebcamPublisher = () => {
7070
let processor: TwilioBackgroundProcessor | undefined;
7171
if (virtualBackground && virtualBackground.type !== 'none') {
7272
processor = createVirtualBackgroundProcessor(virtualBackground);
73+
resolution.height = 480;
74+
resolution.width = 640;
75+
resolution.frameRate = 24;
76+
resolution.aspectRatio = undefined;
7377
}
7478

7579
const track = await createLocalVideoTrack({
7680
deviceId: { exact: deviceId, ideal: deviceId },
7781
resolution,
7882
processor,
7983
});
80-
await room.localParticipant.publishTrack(track);
84+
await room.localParticipant.publishTrack(track, {
85+
source: Track.Source.Camera,
86+
});
8187
} else if (mediaStreamTrack) {
8288
// assuming we are not using virtual background
8389
await room.localParticipant.publishTrack(mediaStreamTrack, {

src/components/footer/modals/webcam/webcamPreview.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import React, { useEffect, useRef } from 'react';
2-
import {
3-
createLocalVideoTrack,
4-
LocalVideoTrack,
5-
VideoPresets,
6-
} from 'livekit-client';
2+
import { createLocalVideoTrack, LocalVideoTrack } from 'livekit-client';
73

84
import { useAppSelector } from '../../../../store';
95
import {
106
createVirtualBackgroundProcessor,
117
TwilioBackgroundProcessor,
128
} from '../../../../helpers/libs/TrackProcessor';
9+
import { getWebcamResolution } from '../../../../helpers/utils';
1310

1411
interface WebcamPreviewProps {
1512
deviceId: string;
@@ -32,13 +29,18 @@ const WebcamPreview = ({ deviceId }: WebcamPreviewProps) => {
3229
}
3330

3431
let processor: TwilioBackgroundProcessor | undefined;
32+
const resolution = getWebcamResolution();
3533
if (virtualBackground.type !== 'none') {
3634
processor = createVirtualBackgroundProcessor(virtualBackground);
35+
resolution.height = 480;
36+
resolution.width = 640;
37+
resolution.frameRate = 24;
38+
resolution.aspectRatio = undefined;
3739
}
3840

3941
createLocalVideoTrack({
4042
deviceId,
41-
resolution: VideoPresets.h720.resolution,
43+
resolution,
4244
processor,
4345
}).then((track) => {
4446
localVideoTrack.current = track;

0 commit comments

Comments
 (0)