You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Desktop audio capture does not work on Mac and Linux #10515
Electron version: 1.6.2, 1.6.5, 1.7.6, 2.0.2, 3.x, 4.0.5
Operating system: Mac OS X Sierra, Linux (Debian Jessie)
Expected behavior
Given the defined DesktopCapture API for capturing both audio and video for the entire desktop, we should get a working audio stream on Windows, Linux and Mac.
Actual behaviour
Electron version 4.0.5: On Mac and Linux, the error callback triggers with the respective messages:
getUserMediaError: DOMException: Could not start audio source // Mac
Failed to query stereo recording // Linux
Electron Version 1.7.6: On Mac and Linux, the error callback triggers with the error:
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
@jasonrudolph Please use GH reactions instead of adding a "+1" comment.
Reacted by Alec, Extarys, Ícar, Yog and Lena
Reacted by Jordan Baucke, Wooooha, WildRabbit, Malak, Charlie Phillips, Uddeshya Agrawal, Niklas Stich, Antonio de Haro, Anthony Oleinik, Pascal Opitz and 36 more
@jasonrudolph Please use GH reactions instead of adding a "+1" comment.
@MarshallOfSound: As someone that got a notification from you for a thread I'm not even participating in, is it helpful for me to say, "Please make sure you're @mentioning the right person."??? 😜
Reacted by Jordan Baucke, Aleks Bykhun, Turtlefight, Ruben Bekaert and TECHNOFAB
ngl this is one of the many reasons why i dont like electron, this issue has existed since september 2017, was fixed for mac and basically ignored for linux, absolutely terrible. This issue is not resolved so it shouldnt have been closed
ngl this is one of the many reasons why i dont like electron, this issue has existed since september 2017, was fixed for mac and basically ignored for linux, absolutely terrible. This issue is not resolved so it shouldnt have been closed
@sniff122
To be fair to Electron, this issue is blocked by Chromium itself. And they don't seem to be in a hurry to ever fix it. It should theoretically be possible for Electron to roll their own fix in, but that's largely outside the scope of the project.
A kludgy sort of "fix" (at least for PulseAudio-based systems) would be to expose a virtual sink when capturing and leave it as an exercise for the user to get the application/system audio into it (likely via a combination of module-loopback and module-combine-sink), but that's very user-unfriendly.
The idea of exposing a virtual sink the user can bind their application to is still light years better than nothing. At least the audio can be shared in some way.
// Move the specified recording stream (identified by its numerical index)
// to the specified source (identified by its symbolic name or numerical index).
// e.g. "pacmd move-source-output ID alsa_output.pci-0000_02_02.0.analog-stereo.monitor"
Then the corresponding deviceId can be used in the audio constraints and mixed with the video stream to get a video-with-audio stream. But a simpler solution would of course be better.
@AmarBouchibane Hi, I am also stuck with the system audio not recording in Linux, could you show me how you achieved it? Like where have you added this code? Thank you, it's really urgent.
Yes, for Linux I used pulse audio to redirect the system audio to my application and thence use it. If you need the command to create the virtual sink and source I can share it. You can execute the command in the pre-loader of the electron app. For mac, there is an alternative (sound flower). I was mostly concerned with linux and windows so never bothered about mac.
Yes, for Linux I used pulse audio to redirect the system audio to my application and thence use it. If you need the command to create the virtual sink and source I can share it. You can execute the command in the pre-loader of the electron app. For mac, there is an alternative (sound flower). I was mostly concerned with linux and windows so never bothered about mac.
I'd like to see your solution, I have the same problem, but don't have an experience with Linux to understand how to use PulsAudio.
Yes, for Linux I used pulse audio to redirect the system audio to my application and thence use it. If you need the command to create the virtual sink and source I can share it. You can execute the command in the pre-loader of the electron app. For mac, there is an alternative (sound flower). I was mostly concerned with linux and windows so never bothered about mac.
I'd like to see your solution, I have the same problem, but don't have an experience with Linux to understand how to use PulsAudio.
this actually checks if there is already a monitor or not (simple way we need to create this monitor if its not present, there is one default monitor but its of no use, so to route the system audio we need to create this, I'll reference it as user monitor hence forth to explain other steps"
This simply checks the if the user monitor already created (monitors refresh/reset after a system restart, if its already present then no need to create it). (to get more idea about this simply run the commands in step1 followed by step2 and find it your self, do it for 5-6 times and you will be comfortable with what we are doing)
Step 3:
Once the monitor is created, we can use this in the frontend (webRTC call) and it will be listed as one of the sources. This source will acts a way to get the system audio.
Step 4:
Once this is done, you can take the microphone audio source as well (two webRTC calls) then you'll have to combine these two sources (if you need help regarding this I would be happy to help, this too can be done with vanilla javascript without any packages)
I've recently had this issue on Mac, though I'm a little bit late in the comments, I have to say I bypassed it using Sound flower. Here is a detailed blog post about my solution: This include every code snippet to record system audio on MacOS and even video and then combine both streams to make audio and video together.
I know it's been quite a time, but were you able to build a package with the SoundFlower solution?
Activity
welcome commentedon Sep 14, 2017
👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.
To help make it easier for us to investigate your issue, please follow the contributing guidelines.
jordanbaucke commentedon Nov 8, 2017
+1 - confirmed on
Electron V 1.7.9MarshallOfSound commentedon Nov 8, 2017
@jasonrudolph Please use GH reactions instead of adding a "+1" comment.
jordanbaucke commentedon Nov 8, 2017
@MarshallOfSound what is a "GH Reaction"? Why is it not mentioned in https://github.com/electron/electron/blob/master/CONTRIBUTING.md#submitting-issues?
MarshallOfSound commentedon Nov 8, 2017
GH reaction == GitHub reaction, you used one just now to thumbs down my comment asking you to use them 🤔
jordanbaucke commentedon Nov 8, 2017
@MarshallOfSound which emoji should I use for confirming the version? since we're getting specific.
MarshallOfSound commentedon Nov 8, 2017
Your initial comment did not contain a version number and therefore could have simply been replaced with a thumbs up on the original issue
jasonrudolph commentedon Nov 8, 2017
@MarshallOfSound: As someone that got a notification from you for a thread I'm not even participating in, is it helpful for me to say, "Please make sure you're @mentioning the right person."??? 😜
MarshallOfSound commentedon Nov 9, 2017
Haha, sorry Jason. Been doing this from my phone and didn't check the at mention, my bad 😸
roy2651 commentedon Mar 8, 2018
how to fix it
64 remaining items
cybe42 commentedon Mar 26, 2022
The same issue is still in Linux. Please reopen.
Spark61 commentedon Apr 3, 2022
I have also the same issue
weedsboy commentedon Jun 7, 2022
same issue on linux
ubuntu 22.04
electron 9.4.0
sniff122 commentedon Jun 21, 2022
ngl this is one of the many reasons why i dont like electron, this issue has existed since september 2017, was fixed for mac and basically ignored for linux, absolutely terrible. This issue is not resolved so it shouldnt have been closed
ApeironTsuka commentedon Jun 21, 2022
@sniff122
To be fair to Electron, this issue is blocked by Chromium itself. And they don't seem to be in a hurry to ever fix it. It should theoretically be possible for Electron to roll their own fix in, but that's largely outside the scope of the project.
A kludgy sort of "fix" (at least for PulseAudio-based systems) would be to expose a virtual sink when capturing and leave it as an exercise for the user to get the application/system audio into it (likely via a combination of module-loopback and module-combine-sink), but that's very user-unfriendly.
mattia-moffa commentedon Jun 22, 2022
The idea of exposing a virtual sink the user can bind their application to is still light years better than nothing. At least the audio can be shared in some way.
Hrishabh17 commentedon Apr 7, 2023
@AmarBouchibane Hi, I am also stuck with the system audio not recording in Linux, could you show me how you achieved it? Like where have you added this code? Thank you, it's really urgent.
mehdignu commentedon Aug 16, 2023
Is this fixed? I still have the same error.
Hrishabh17 commentedon Aug 16, 2023
Yes, for Linux I used pulse audio to redirect the system audio to my application and thence use it. If you need the command to create the virtual sink and source I can share it. You can execute the command in the pre-loader of the electron app. For mac, there is an alternative (sound flower). I was mostly concerned with linux and windows so never bothered about mac.
KonstantinBel commentedon Sep 14, 2023
I'd like to see your solution, I have the same problem, but don't have an experience with Linux to understand how to use PulsAudio.
kerberizer commentedon Sep 14, 2023
Some possibly good news. Apparently, work on the upstream issue in Chromium has started on Aug 18, 2023.
Hrishabh17 commentedon Sep 15, 2023
sure, what I did is:
I used spawn to run the commands as follow:
Step 1:
const monitorProcess = spawn('pacmd list-sources | grep -B 1 analog-stereo.monitor | grep name:', {
shell: true
});
this actually checks if there is already a monitor or not (simple way we need to create this monitor if its not present, there is one default monitor but its of no use, so to route the system audio we need to create this, I'll reference it as user monitor hence forth to explain other steps"
Step 2:
monitorProcess.stdout.on('data', function (data) {
const output = data.toString();
const l = output.split('\n')
if(l.length <= 2){
const regex = /name:\s*<(.+)>/i;
const match = output.match(regex);
let monitorName
if (match && match.length > 1) {
monitorName = match[1];
}
const moduleGenerate = spawn(
pactl load-module module-remap-source master=${monitorName} source_properties=device.description=Computer-sound, {shell:true
})
moduleGenerate.stdout.on('end', ()=>{
})
}
});
This simply checks the if the user monitor already created (monitors refresh/reset after a system restart, if its already present then no need to create it). (to get more idea about this simply run the commands in step1 followed by step2 and find it your self, do it for 5-6 times and you will be comfortable with what we are doing)
Step 3:
Once the monitor is created, we can use this in the frontend (webRTC call) and it will be listed as one of the sources. This source will acts a way to get the system audio.
Step 4:
Once this is done, you can take the microphone audio source as well (two webRTC calls) then you'll have to combine these two sources (if you need help regarding this I would be happy to help, this too can be done with vanilla javascript without any packages)
GitHubCloud commentedon Mar 6, 2024
I know it's been quite a time, but were you able to build a package with the SoundFlower solution?
benkingcode commentedon May 3, 2024
Chromium has apparently fixed this now: https://issues.chromium.org/issues/40155218
Will Electron be gaining this functionality?