User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

[UNSOLVED but ...] RPi4 : How to record desktop audio ?

Thu Jan 30, 2020 7:58 am

Hello

I run Raspbian up to date on a RPi4 4GB with ALSA
I don't want to install pulseaudio. I like it but it doesn't work on this board.

Search found 74 matches: record desktop audio
But none gave me a clear answer to this simple question :

How can I record the desktop audio (while surfing the www for example) ?

This means with which software and how to configure it or what is needed for it
Thank you if you can tell this !
Pulsar33

Edit Pulsar33 : Title modification
Last edited by Pulsar33 on Wed Mar 04, 2020 7:47 am, edited 2 times in total.
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

croft
Posts: 54
Joined: Fri Dec 13, 2019 4:58 pm

Re: How to record desktop audio ?

Thu Jan 30, 2020 2:05 pm

hi
try audacity it on the reposity

croft

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: How to record desktop audio ?

Thu Jan 30, 2020 4:33 pm

Thank you but already tried and it fails. Message :
Error opening sound device.
Try changing the audio host, recording device and the project sample rate.

ALSA only choice

bcm2838 ALSA IEC958/HDMI (hw:0,1)
bcm2838 ALSA IEC958/HDMI (hw:0,2)
dmix
Whathever I choose, it crash with no change. Logout/Login, it has changed but same error

Project rate : many choice but same error.

I've already seen Audacity working on RPi4 but with pulseaudio and this one cause other drastic problems, so I don't want it.
Workaround or other solution ?
Pulsar33
Last edited by Pulsar33 on Thu Jan 30, 2020 5:00 pm, edited 1 time in total.
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: How to record desktop audio ?

Thu Jan 30, 2020 4:57 pm

I've just tried Ardour (less easier to use)
Doesn't crash but records nothing.

I've just tried Gnome Audio Recorder too. It says :
Unable to configure pipeline to record state

BR
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: How to record desktop audio ?

Thu Jan 30, 2020 6:57 pm

Pulsar33 wrote:
Thu Jan 30, 2020 4:33 pm
Thank you but already tried and it fails. Message :
Error opening sound device.
Try changing the audio host, recording device and the project sample rate.

ALSA only choice

bcm2838 ALSA IEC958/HDMI (hw:0,1)
bcm2838 ALSA IEC958/HDMI (hw:0,2)
dmix
Whathever I choose, it crash with no change. Logout/Login, it has changed but same error

Project rate : many choice but same error.

I've already seen Audacity working on RPi4 but with pulseaudio and this one cause other drastic problems, so I don't want it.
Workaround or other solution ?
Pulsar33
I just installed Audacity on my Buster Lite Pi4 with only the default Alsa installed (no pulseaudio). It spews out a large number of warnings when it starts up, but I was able to record using my USB Mic with no problem.
AudacityAudio.jpg
Screen shot from Auadacity
AudacityAudio.jpg (94 KiB) Viewed 2056 times

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Thu Jan 30, 2020 7:22 pm

Thank you for this report.

However, I want to record the desktop audio, that is all I ear in the speakers, without the need of external HW, and specially when the sound come from a browser (firefox, chromium, ...). I suspect that the RPi4 isn't able to select the "audio mix" output for recording. I hope I'm wrong !

Audacity displays No Device
Audacity-NoDevice.jpg
Audacity-NoDevice.jpg (98.11 KiB) Viewed 2036 times
BR
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: RPi4 : How to record desktop audio ?

Thu Jan 30, 2020 10:59 pm

Ah, yes, I'm seeing that as well. I haven't had a chance to look at it in depth, but there may be some useful hints here: https://manual.audacityteam.org/man/tut ... linux.html

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Jan 31, 2020 8:56 am

Thanks once more, even if this link seems to confirm that ALSA is not able to select the audio mix for recording :?
As said above, pulseaudio is fine but is not supported by Raspberry Team, and this is a drastic limitation of this board which can't be seen as a desktop replacement for this reason at least :roll:
Audacity Manual wrote:To start alsamixer, type alsamixer in a terminal window. If a Mix device is shown as a capture device, set this as the active device to enable recording sounds that are playing on the computer.
Doing that, THIS DEVICE HAS NO CAPTURE COMMAND is displayed ... :evil:

And this is only a limitation of ALSA because if you install pulseaudio, the audio mix can be found and used (unfortunately, you fall down to mono and you have unacceptable other drawbacks)

However, have a nice day
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

tvjon
Posts: 750
Joined: Mon Jan 07, 2013 9:11 am

Re: RPi4 : How to record desktop audio ?

Fri Jan 31, 2020 2:10 pm

Pulsar33 wrote:
Thu Jan 30, 2020 7:58 am
...
How can I record the desktop audio (while surfing the www for example) ?

...
Pulsar33
Do you want to record ALL your "desktop" audio, clicks, pops, etc., or just browser output, & which browser?

I do roughly what you want, but usually, only for omxplayer output, where I sometimes invoke omxplayer to record, as well as send audio to the jack socket.

Unless you have gigabytes to spare, it's also important to consider the resulting file sizes, so i typically convert to mp3.

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Jan 31, 2020 6:33 pm

For information, Firefox ESR and chromium are installed on my RPi4 but this is off topic.
I want to record ALL the desktop audio, as I am able to do with my Desktop PC running Linux Mint 19.3 and pulseaudio.
This is for me a basic function that all computer should be able to do as well as recording the screen.

Unfortunately, AFAIK, OBS Studio is not available for raspberry. I tried to compile it, but OpenGL isn't available either.

BR
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Thu Feb 06, 2020 3:20 pm

Hello,

I've used the "report" process on my first message to ask the Raspberry Team for a solution or an explanation. There's no answer after several days ...
It seems that it is a strong and drastic limitation of the RPi4 board as pulseaudio isn't available and alsa isn't able to do the job.

As a consequence, the RPi4 board is definitively not able to be a Desktop replacement :roll: :cry:

Sorry
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

lordrunningclam
Posts: 1
Joined: Mon Feb 10, 2020 11:24 am

Re: RPi4 : How to record desktop audio ?

Mon Feb 10, 2020 11:44 am

The problem is ALSA. In theory it can do anything, but in practice there are fewer than 5 beings in the universe who can correctly answer questions about it, and they are all busy. The Manjaro distribution runs on the Pi 4 and uses PulseAudio by default; you might have better luck with that. I tried the KDE variant and it ran very nicely.

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Mon Feb 10, 2020 7:14 pm

Hello,

I've tried Manjaro-ARM-xfce-rpi4-19.08 but didn't insist because I didn't like the Desktop.
I've tried other distribution too but every time I've installed pulseaudio, I've been facing problems.
The sound is fading, has glitches, stereo falls down to mono, and other bugs ...

Are you sure that there's no problem like this with Manjaro ?
Should I give a try to Manjaro-ARM-kde-plasma-rpi4-19.12 ?

BR
Pulsar33
Pi4B-03.jpg
Pi4B-03.jpg (182.95 KiB) Viewed 1238 times
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

tvjon
Posts: 750
Joined: Mon Jan 07, 2013 9:11 am

Re: RPi4 : How to record desktop audio ?

Thu Feb 13, 2020 8:47 pm

Pulsar33 wrote:
Fri Jan 31, 2020 6:33 pm
For information, Firefox ESR and chromium are installed on my RPi4...

You might like to see if this records your "desktop" audio?

I don't have firefox installed currently, so my testing uses the Chromium browser, along with various radio stations.

Attached is a .asoundrc which needs to go into ~/

If such already exists, & it's precious, you can back it up, then overwrite with unzipped attached.

Bear in mind anything which then goes to alsa default will be recorded to (in my example, mp3) file.

Consequently, to avoid re recording a playback listening session, I use the very versatile player, omxplayer, telling it to ignore alsa; rather play back via hdmi or local (audio jack socket) to listen to recordings.
Attachments
.asoundrc.zip
(324 Bytes) Downloaded 16 times

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: RPi4 : How to record desktop audio ?

Thu Feb 13, 2020 11:52 pm

Pulsar33 wrote:
Fri Jan 31, 2020 8:56 am
As said above, pulseaudio is fine but is not supported by Raspberry Team, and this is a drastic limitation of this board which can't be seen as a desktop replacement for this reason at least :roll:
Please provide a reference for pulseaudio not being supported by the Raspberry Pi team. I couldn't locate it. Thx.

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 5:56 am

Hello

@bls : This is just one of several messages where a team member says to avoid installing pulseaudio.

@tvjon : thanks. Will give a try and report here.

BR
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

fruitoftheloom
Posts: 22002
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 6:09 am

bls wrote:
Thu Feb 13, 2020 11:52 pm
Pulsar33 wrote:
Fri Jan 31, 2020 8:56 am
As said above, pulseaudio is fine but is not supported by Raspberry Team, and this is a drastic limitation of this board which can't be seen as a desktop replacement for this reason at least :roll:
Please provide a reference for pulseaudio not being supported by the Raspberry Pi team. I couldn't locate it. Thx.

This change was made when Raspbian Stretch was released:

Bluetooth audio
In Jessie, we used PulseAudio to provide support for audio over Bluetooth, but integrating this with the ALSA architecture used for other audio sources was clumsy. For Stretch, we are using the bluez-alsa package to make Bluetooth audio work with ALSA itself. PulseAudio is therefore no longer installed by default, and the volume plugin on the taskbar will no longer start and stop PulseAudio. From a user point of view, everything should still work exactly as before – the only change is that if you still wish to use PulseAudio for some other reason, you will need to install it yourself.


https://www.raspberrypi.org/blog/raspbian-stretch/
Retired disgracefully.....
......to an uncomplicated life !

Rather than negativity think outside the box !

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 6:22 am

Pulsar33 wrote:
Fri Feb 14, 2020 5:56 am
@bls : This is just one of several messages where a team member says to avoid installing pulseaudio.
Thanks. With apologies to @jamesh if I'm incorrect, but I don't read either his statement or the statement that @fruitoftheloom posted, as statements of "non-support" (not sure what that means, actually). pulseaudio is included in the Raspbian distro, as are a large collection of various bits of software. If it were truly not supported, it wouldn't be included. It's included, which means it at least compiles and, more likely than not, works. It worked the last time I took it for a spin (which I may do again...).

I read @jamesh's comment as not liking pulseaudio, and/or he's aware of some scenarios where it doesn't work, or knows some set of issues with it. I bet that a lot of the more seasoned Linux users of this forum have a software package or two for which they have similar perspectives.

It's included. Try it. If it works for you, great. If it doesn't, oh well, blame it on Linux randomness, which is a Linux "feature" 8-)

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 6:29 am

I have tried it, I had problems, I asked in some subjects about audio and got the same answer of the team people.
pulseaudio doesn't work on Pi4 and is discouraged. pulseaudio works great on every other hardware I've used.
Call that as you want but I call that "not supported".

Now please, this is not the subject of this thread where I'm looking for a solution to walk around this boring limitation.
Have a nice day
Pulsar33
Last edited by Pulsar33 on Fri Feb 14, 2020 6:34 am, edited 2 times in total.
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 6:33 am

Fair enough. I'm hoping to get some time to see if I can find a method that works, because I'm interested in a solution as well. No promises, but will report any success here.

fruitoftheloom
Posts: 22002
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 8:11 am

bls wrote:
Fri Feb 14, 2020 6:22 am
Pulsar33 wrote:
Fri Feb 14, 2020 5:56 am
@bls : This is just one of several messages where a team member says to avoid installing pulseaudio.
Thanks. With apologies to @jamesh if I'm incorrect, but I don't read either his statement or the statement that @fruitoftheloom posted, as statements of "non-support" (not sure what that means, actually). pulseaudio is included in the Raspbian distro, as are a large collection of various bits of software. If it were truly not supported, it wouldn't be included. It's included, which means it at least compiles and, more likely than not, works. It worked the last time I took it for a spin (which I may do again...).

I read @jamesh's comment as not liking pulseaudio, and/or he's aware of some scenarios where it doesn't work, or knows some set of issues with it. I bet that a lot of the more seasoned Linux users of this forum have a software package or two for which they have similar perspectives.

It's included. Try it. If it works for you, great. If it doesn't, oh well, blame it on Linux randomness, which is a Linux "feature" 8-)

There are many packages from Debian ARMHF which have compatibilty issues, it is not feasible for RPT / RPF to test them all.
Retired disgracefully.....
......to an uncomplicated life !

Rather than negativity think outside the box !

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 9:48 am

This is your point of view, not mine.
And this is off topic.

Have a nice day
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 3:11 pm

tvjon wrote:
Thu Feb 13, 2020 8:47 pm
Attached is a .asoundrc which needs to go into ~/
Well, thanks again tvjon, this seems to be a good start to solve the problem. Here is my report :
1° With a raspbian_full distribution, you need to install the "lame frontend" to get the "lame" command
2° With a raspbian_full distribution, I had no .asoundrc file in ~/ so I simply installed yours and reboot
3° Every time some sound is played through my HDMI 0 port, a mp3 file is created in /tmp with good naming convention, thanks to your rc file
4° This works for Chrome and for VLC as well, and confirms that any sound of the desktop is recorded

On the other hand, some problems remain to be solved if we want a generic and user friendly capability :
a) I had to post process the files with Audacity on my Desktop PC to increase the Speed by a 1.088 ratio (48000/44100)
=> Tempo and Height are too low according to this ratio, but the sampling rate must remain at 44.1 kHz
b) It would be nice to have a start/stop feature without rebooting for this tool (maybe as a service or a script ?)

Anyway, this is a good progress.
Best regards
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

bls
Posts: 445
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: RPi4 : How to record desktop audio ?

Fri Feb 14, 2020 11:15 pm

I figured out how to record desktop audio with Audacity using pulseaudio. This was on an RPi4 with Buster-2020-02-05-Full. Here's my abbreviated how to, and a few notes.
  • Execute the following commands

    Code: Select all

    sudo apt install pavucontrol audacity
    pulseaudio --start
    audacity &
    pavucontrol &
    
  • In audacity, select 'pulse' input
  • Start the app you want to record, and have it generate some sound (e.g., browser or vlc playing a video or audio stream)
  • On pavucontrol's Playback tab, change the app's "playback on" setting to be the "built-in audio analog mono" if it is not set to this
  • Start audacity recording, and then on pavucontrol's Recording tab, ensure that ALSA plug-in is set to record from "Monitor of Built-in Analog Mono"
  • Stop audacity's recording. The Recording tab will go blank. That's OK. PulseAudio seems to nicely remember it's settings, and also sets itself up to restart when the current user logs in again.
That's it. A bit of a hassle to set up, but you only need to do the settings in pavucontrol once, unless you change them for another reason.

Notes:
  • I don't have speakers on my Pi. I did export an audacity mp3 and play it on my desktop system, which worked fine. But, I didn't test whether this somehow mucked up the "standard" audio configuration. [update: It might. My alsa configuration seems a bit wonked. Working on it]
  • I havent' investigated why it's only Mono.
  • It uses PulseAudio :| , but it works :) . I'm quite sure there's a way to make it work with alsa, but based on my prior dive into it (which I failed to document. sigh!), I decided sorting out PulseAudio was easier.
  • Using audacity to record audio from a Chromium webpage, audacity consumed about 30% of the CPU, chromium consumed about 37%, and pulseaudio consumed less than 10%.

User avatar
Pulsar33
Posts: 174
Joined: Sun Aug 25, 2019 4:06 pm
Location: Bordeaux France

Re: RPi4 : How to record desktop audio ?

Sat Feb 15, 2020 5:59 am

Pulsar33 wrote:
Thu Jan 30, 2020 4:33 pm
I've already seen Audacity working on RPi4 but with pulseaudio and this one cause other drastic problems, so I don't want it
Pulsar33 wrote:
Fri Feb 14, 2020 6:29 am
I have tried it, I had problems, I asked in some subjects about audio and got the same answer of the team people : pulseaudio doesn't work on Pi4 and is discouraged
bls wrote:
Fri Feb 14, 2020 11:15 pm
I don't have speakers on my Pi. [...] I havent' investigated why it's only Mono
As I said, yes "it works" (pulseaudio and audacity) but normal use of the audio functions is no longer possible.
I'm currently trying to adapt the tvjon solution.

BR
Pulsar33
Pi 4 with 4Gb memory, DVB TV pHAT ------------------- Desktop : Core i5 Linux MINT 19.3

Return to “Graphics, sound and multimedia”