desktopCapturer.getSources({ types: ['screen'] }).then( sources => {
fs.writeFile(`screenshot.jpg`, sources[0].thumbnail.toJPEG(25), (err) => {
if (err) throw err
console.log('Image Saved')
})
})上面的代码在ubuntu 18和20中进行了测试和工作,但它在Ubuntu22LTS和Fedora 34中不起作用。我在电子17中测试了这个应用程序。生成的屏幕截图图像是空的,不能工作(大小为0 kb)。
app.commandLine.appendSwitch('enable-features', 'WebRTCPipeWireCapturer');我还在运行时启用了WebRTCPipeWireCapturer ( main.js )。
https://gitlab.com/seantaylor/electron-17-desktopcapturer-not-working
我在上面的存储库中添加了全部代码。有关安装说明和运行应用程序,请检查自述文件。
我也在电子github上提出了一张票,但没有得到解决办法。https://github.com/electron/electron/issues/33961
提前谢谢你
发布于 2022-10-11 06:35:36
找到解决办法了。在ubuntu中禁用wayland解决了这个问题。
https://stackoverflow.com/questions/72210913
复制相似问题