muaz-khan / RecordRTC

RecordRTC is WebRTC JavaScript library for audio/video as well as screen activity recording. It supports Chrome, Firefox, Opera, Android, and Microsoft Edge. Platforms: Linux, Mac and Windows.
https://www.webrtc-experiment.com/RecordRTC/
MIT License
6.52k stars 1.75k forks source link

Video+Screen Demo is Flawed #697

Open JoshuaPerk opened 3 years ago

JoshuaPerk commented 3 years ago

The Video+Screen Demo/Example found here (source code) gets distored when a window beyond the full screen is shared.

The reason being is below. We're telling the screen track to take on the height / width of the users screen (even when the full screen isn't shared. Consequently, the video gets distorted if so.

screen.width = window.screen.width;
screen.height = window.screen.height;
screen.fullcanvas = true;
camera.width = 320;
camera.height = 240;
camera.top = screen.height - camera.height;
camera.left = screen.width - camera.width;

Is there a way to dynamically know the height/width of the element that was shared or otherwise solve for the distortion issue while still rendering the camera on the canvas?

antoBit commented 3 years ago

I don't know if someone still needs this, but what I did was check if the displaySurface is browser or monitor:

    const { displaySurface } = stream.getVideoTracks()[0].getSettings()

    if (displaySurface === "browser") {
      screen.width = window.innerWidth
      screen.height = window.innerHeight
    }

Hope this helps :)