Cannot capture system audio output with Electron desktopcapturer in Ubuntu

佐手、 提交于 2021-01-05 06:37:26

问题


I want to capture OS system audio output with Electron desktopcapturer, it works well in Windows as following:

        constraints = {
        // audio: false,
        audio: {
            mandatory: {
                chromeMediaSource: 'desktop'
            }
        },
        video: {
            mandatory: {
                chromeMediaSource: 'desktop'
                //maxFrameRate: 15
            },
        }

then, I use: navigator.webkitGetUserMedia(constraints, function(dstream) {...

However, in Ubuntu, it always shows "could not start audio source". Can anyone tell me how to do? Thanks for your help.


回答1:


Leaving my answer here for the record, it may or may not work for you. I ran into this error while testing my Electron app, while being in a Google Meet at the same time (i.e. Chrome had a lock on my microphone). The error stopped happening once I ended the Meet.




回答2:


Because of a patch merged in Chromium, it's not possible to access system audio without much low-level tinkering. Here is an issue raised on Electron's github page but is left un-resolved since 6yrs. Quoting a reply from the issue, that seems to be of little hope:

I was searching through the Chromium issue tracker, and found this: https://bugs.chromium.org/p/chromium/issues/detail?id=1143761&q=linux%20streaming&can=2 This may be worth keeping an eye on, since it seems related to this issue. It's possible that this issue may see resolution when the Chromium team starts pushing fixes.

Here is the pulseaudio patch submitted to chromium, which is the root cause of this issue. Comming to a potential solution you can revert back before this commit and audio capture should work fine then. But, I haven't tried out this solution. Let me know if someone manages to fix this, or try this.



来源:https://stackoverflow.com/questions/62317022/cannot-capture-system-audio-output-with-electron-desktopcapturer-in-ubuntu

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!