Low video quality when sharing screen with audio

Hi!

I’m doing screen sharing with audio (as in the code below). However, the quality of the video (screen) does not follow the quality (HD) configured, it has a much lower quality.

async function publishScreenShare() {
	const screenStream = await navigator.mediaDevices.getDisplayMedia({
		video: {
			cursor: "always"
		  },	
		  audio: true
	  })
            let screenVideoTrack = screenStream.getVideoTracks()[0];
			console.log('video', screenStream.getVideoTracks())
            let screenAudioTrack = screenStream.getAudioTracks()[0];
	var publisherScreen = OVScreen.initPublisher("container-screens", { videoSource: screenVideoTrack, audioSource:  screenAudioTrack, mirror: false });

	publisherScreen.once('accessAllowed', (event) => {
		try {
			publisherScreen.stream.getMediaStream().getVideoTracks()[0].applyConstraints({
				width: 1280,
				height: 720
			});
		} catch (error) {
			console.error('Error applying constraints: ', error);
		}

How can I fix this?

Thanks!

This is really a Web API question. Try using other constraints when initializing your screenStream object like this:

video: {
    width: { ideal: 1920, max: 1920 },
    height: { ideal: 1080, max: 1080 }
}

Try playing with the constraints options until you are satisfied with the result for your specifc use case: MediaTrackConstraints - Web APIs | MDN

Thank you Pablo!

This worked in parts.

When I start sharing the video starts at the ideal setting, but then the quality decreases and after a few minutes it goes back up.

Does this have to do with OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH or OPENVIDU_STREAMS_VIDEO_MIN_RECV_BANDWIDTH?

Since the quality of my internet is great?

That’s a good idea. You can try increasing the default values of configuration properties OPENVIDU_STREAMS_VIDEO_MAX_RECV_BANDWIDTH and OPENVIDU_STREAMS_VIDEO_MAX_SEND_BANDWIDTH

Setting them to 0 means unconstrained (no limit)

I already tested setting 0 for these properties, the result was the same (low quality).

I saw in several sources talking about the bitrate (which affects the quality), which can be due to server or internet capabilities. I’ve already tested it with my internet on other solutions like GoogleMeet and Jitsi and they worked perfectly. I don’t know what else to try ;(

Any further tips on what I can look into?

Thanks!