Can Electron capture a window as a video stream?


I want to create an app to capture one window as a video source, so far I am using desktopCapturer get the sources info and using getUserMedia to put it in a . but the video is like a still picture not show any changes on the window, just a mouse moving around. Could any one help me with this problem. thank you so much.

here is my code:

getAllScreenInfo: () => {
let st = new Date();
return new Promise((resolve, reject) => {
desktopCapturer.getSources({types: [‘window’, ‘screen’]}, (error, sources) => {'screen source get end at ', (new Date() - st) / 1000);
if (error) {
} else {

getScreen: (id, obj, rf) => {
return new Promise((resolve, reject) => {
let w = 1920;
let h = 1080;

        audio: false,
        video: {
          mandatory: {
            chromeMediaSource: 'desktop',
            chromeMediaSourceId: id,
            minWidth: w,
            maxWidth: w,
            minHeight: h,
            maxHeight: h
      }, (stream) => {
        obj.src = URL.createObjectURL(stream);
      }, (e) => {


VideoSources.getAllScreenInfo().then(sources => {‘all sources’, sources);
sources = sources.filter(source => {
return ( === ‘Screen 1’ ||‘Word’) >= 0);
this.setState({sources: sources});


When posting code, please make sure that all of it is wrapped in code tags so that it’s easily readable.


Sorry for the mess, new here and cannot find where to edit my. Should I deleted this one and post a new one?


Is there not a little pencil at the bottom of the post? If not, you can make a new reply with the code properly indented.

Also, I don’t have any basis to help with this. I’m just making sure that your question is readable.


Can’t find pencil, I got answer from here:
Hope will help someone who has the same issue.