0

Using webRTC I can capture screen

var myMediaStreamConstraints = {
  video: {
    width: { min: 640, ideal: 1920 },
    height: { min: 400, ideal: 1080 },
    aspectRatio: { ideal: 1.7777777778 }
  },
  audio: {
    sampleSize: 16,
    channelCount: 2
  }
}

var promise = navigator.mediaDevices.getDisplayMedia(myMediaStreamConstraints);

This promise that resolves to a MediaStream containing a video track whose contents come from a user-selected screen area, as well as an optional audio track.

I want to capture only some rectangular part of my screen and I do not want to crop using HTML and CSS thing. I am expecting there would be some way by creating right MediaStreamConstraints.

How can I get cropped MediaStream to capture only rectangular part of screen?

oguz ismail
  • 39,105
  • 12
  • 41
  • 62
Alok
  • 6,361
  • 6
  • 43
  • 72
  • 1
    This is not possible currently, it's been discussed a few times, I think https://github.com/WICG/proposals/issues/39 is one of the last proposals around that. Currently you have to draw the video on a canvas and do the cropping there. In Chrome you can avoid having to go through a – Kaiido Oct 08 '21 at 07:50

0 Answers0