You are not logged in.

#1 2025-01-21 23:05:17

Diiny
Member
Registered: 2015-05-12
Posts: 22

[SOLVED] Please help me to record sound from computer.

I'm at my wits end trying to record audio from my arch laptop.  I'm hoping someone can help with a solution and not just regurgitate something that worked in the past.

I have tried this page, without success:
https://web.archive.org/web/20240407220 … pplication

I have tried this page, without success:
https://bbs.archlinux.org/viewtopic.php?id=251591

I have tried this page, without success:
https://commandmasters.com/commands/arecord-linux/

I have tried this page, without success:
https://noxz.tech/articles/record_scree … ng_ffmpeg/

All I get is either a file that has no sound, or a video that has no sound.  I am using alsamixer and really don't want pulseaudio on my machine (as it has caused so much grief in the past, it's best not to install it).

Can someone please help me figure this out?

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC255 Analog [ALC255 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

Last edited by Diiny (2025-01-22 17:30:50)

Offline

#2 2025-01-21 23:26:55

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

What "didn't work" exactly? Right now you don't have the snd-aloop module loaded and it's absolutely necessary. What's the output of

arecord -l

?

FWIW pipewire is a new kid on the block and it implements the same interfaces pulseaudio and makes recording from specific applications trivial. And not using something in an as changing landscape as software based on past experience might make you miss out on a bunch of useful features. Pulseaudio was mostly fixed, pipewire is basically fixing the last pain points most people had with pulse.

Last edited by V1del (2025-01-21 23:30:11)

Offline

#3 2025-01-21 23:54:33

Diiny
Member
Registered: 2015-05-12
Posts: 22

Re: [SOLVED] Please help me to record sound from computer.

Ty for your response.

V1del wrote:

What "didn't work" exactly?

Recording audio didn't work.

V1del wrote:

Right now you don't have the snd-aloop module loaded and it's absolutely necessary.

I did when I tried the pages I listed.  But it still didn't help produce any sound on the recordings.  So I set everything back to the way it was, before any of those pages (that didn't work).  The output is how it starts.

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC255 Analog [ALC255 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The pages I listed above lists 2 ways of doing the loopback:

1: modprobe snd-aloop
2: modprobe snd-aloop pcm_substreams=1

Which one should I be using?

EDIT:
Ok it looks like they produce the same results.

$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC255 Analog [ALC255 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7

Last edited by Diiny (2025-01-22 00:09:37)

Offline

#4 2025-01-22 01:14:25

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

Let's take the simplest case: https://trac.ffmpeg.org/wiki/Capture/AL … pplication

How exactly does that "not work"? Note that this is indeed the simplest case, if you setup that config and you start an application "generating audio" you won't hear said audio but should be able to record it with the ffmpeg line. The start is imperative here, ALSA doesn't support on the fly pipeline changes you need to setup that config, then start the application in question, make sure you pick the "default" ALSA PCM for "playback" and then use the ffmpeg line to record.

Last edited by V1del (2025-01-22 01:15:18)

Offline

#5 2025-01-22 02:00:02

Diiny
Member
Registered: 2015-05-12
Posts: 22

Re: [SOLVED] Please help me to record sound from computer.

V1del wrote:

How exactly does that "not work"?

I appreciate your help in this and I am not trying to be irritating, but it gives me a sound file (.wav) with absolutely no sound on it.  No static, no ghosting sounds in the background, nothing.

V1del wrote:

make sure you pick the "default" ALSA PCM for "playback" and then use the ffmpeg line to record.

I was able to do the startup in the order specified, but I don't know how to make firefox  use 'the "default" ALSA PCM for "playback"'.  All that was produced was an empty .wav file with no sound on it.

V1del wrote:

if you setup that config and you start an application "generating audio" you won't hear said audio

I do hear the audio playing when trying to record.

Offline

#6 2025-01-22 11:50:54

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

Firefox is a special case sadly. Firefox will only play to the "default" card if it finds it in a aplay -L listing, which would need some additional configuring.

let's try something more controllable, with the config for the simple case in place

speaker-test -Ddefault -c2 #you will see it attempting to play to 2 channels, you shouldn't be able to hear it
#in a new terminal
ffmpeg -f alsa -channels 2 -sample_rate 44100 -i hw:Loopback,1,0 out.wav
#after a few minutes/seconds ctrl+c the ffmpeg process
aplay -Dhw:0,0 out.wav

do you hear that?

Maybe also elaborate on your end goal, you want to record what, where and how and do you also want to hear what you're recording?

FWIW to give you some context, this entire raindance you do on ALSA, in pulseaudio/pipewire boils down to

parecord --monitor-stream=21 --file-format=wav file.wav

where 21 is the sink of the currently playing firefox/whatever audio stream as listed in "pactl list sink-inputs"

Last edited by V1del (2025-01-22 11:53:01)

Offline

#7 2025-01-22 12:06:02

cryptearth
Member
Registered: 2024-02-03
Posts: 1,429

Re: [SOLVED] Please help me to record sound from computer.

as I have a streaming setup and deal with routing several inputs and outputs: I can recommend qpwgraph
it provides simple drag'n'drop of audio streams from applications "creating" sounds like a game, a browser or some physical input like a mic to targets like recording software as obs or doubling audio to two outputs like hdmi and usb-dac at the same time
as the Q implies its based on qt and hence native to kde - if you're on gnome or anything else other than kde it requires a lot of kde dependencies - maybe there's a more leightweight alternative to it without all this depencies

Offline

#8 2025-01-22 16:03:30

Diiny
Member
Registered: 2015-05-12
Posts: 22

Re: [SOLVED] Please help me to record sound from computer.

V1del wrote:

let's try something more controllable, with the config for the simple case in place

speaker-test -Ddefault -c2 #you will see it attempting to play to 2 channels, you shouldn't be able to hear it

I could hear it switching between both speakers before recording.

V1del wrote:
speaker-test -Ddefault -c2 #you will see it attempting to play to 2 channels, you shouldn't be able to hear it
#in a new terminal
ffmpeg -f alsa -channels 2 -sample_rate 44100 -i hw:Loopback,1,0 out.wav
#after a few minutes/seconds ctrl+c the ffmpeg process
aplay -Dhw:0,0 out.wav

do you hear that?

Nope, another soundless .wav file.

V1del wrote:

Maybe also elaborate on your end goal, you want to record what, where and how and do you also want to hear what you're recording?

The end goal is to record the audio I hear from my speakers while using firefox.  It doesn't matter if there is video or not, I just need the audio.  It doesn't matter if it is captured directly from firefox or somewhere else.

Another day with problem will probably kill my soul.  For the record, I HATE, yes, HATE pulseaudio for all the problems it's caused in the past.  Most of the time, the solution was to remove pulseaudio.  So I'm very gun-shy regarding it's use.  And I'm highly doubtful of it's usefulness, as I'm told it's a layer that sits on top of alsa.

Offline

#9 2025-01-22 16:52:27

cryptearth
Member
Registered: 2024-02-03
Posts: 1,429

Re: [SOLVED] Please help me to record sound from computer.

if you just need the audio stream why not grab the source directly - aka download the m4a from YT cdn ... or whatever source you listening to
recording of a playback instead of just downloading the source seems counter intuitive to me - aside from for both firefox and chrome existing several extensions doing exactly what you want - but just more directly without involving a systems audio system at all
and even using wget/curl or writing some code is rather simple than going your route

Last edited by cryptearth (2025-01-22 16:53:28)

Offline

#10 2025-01-22 16:55:56

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

Your ~/.asoundrc contains /well lets format it)

pcm.!default { type plug 
slave.pcm "hw:Loopback,0,0" 
#FWIW add this
 hint {
   show on
   description "My loopback"
 }
}

? What's your output for

aplay -L

when trying my reproducer with above .asoundrc?


OT (I'm just giving you some opinions and options here, if you're dead set on fixing this in ALSA we can, it will just be somewhat cumbersome):And I'm telling you as someone that has used pulseaudio (and now pipewire) for years and helped most people here resolve their issues, with either of them. it absolutely trivializes this usecase. it sits as a layer on top of ALSA but that allows it to completely ignore ALSA for the usecase of recording application audio. it will just grab the audio, copy it to a file and while doing so pass it off to ALSA for playback. Don't waste energy on the layer think, everything on your computer is built up in layers, by adding loopback modules to try and capture the audio the "ALSA way" you add a different kind of layer, that's evidently not as easy to use.

And as mentioned above, if this is just about YT, then using a downloader to extract the music is likely generally the better approach.

Last edited by V1del (2025-01-22 17:25:13)

Offline

#11 2025-01-22 17:30:28

Diiny
Member
Registered: 2015-05-12
Posts: 22

Re: [SOLVED] Please help me to record sound from computer.

Ty for your help in this matter.  You helped me get through this, tyvm.  It appears with all my trials and frustrations, a filename was screwing things up.

Long story short: I hate all the clutter in my $HOME directory, especially with dot files.  Whenever possible, I try to not use dot files, I only have 3 that are actually needed.  When I started on this problem, I noticed you could either use the `.asoundrc` in your $HOME directory or use the `/etc/asound.conf` file for global use.  Since this is a one user/account machine, setting the global file cured my need to not use a dot file.

Somewhere in my efforts, the `/etc/asound.conf` file was created as `/etc/asoundrc`, creating my hair pulling, wall punching week.  I really didn't think it should be this tough.

Once again, ty for your patients and help with this matter.  I'd buy you a pint if I could!

Offline

#12 2025-01-22 17:35:04

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

So all the options you've found would've worked but you wrote them into /etc/asoundrc instead of /etc/asound.conf ? Well that's a bummer.

In any case if this is [SOLVED] now, please mark it as such by editing the title in your first post and prepending [SOLVED] or so. (Might have to shorten it a little)

Offline

#13 2025-01-22 17:42:32

Diiny
Member
Registered: 2015-05-12
Posts: 22

Re: [SOLVED] Please help me to record sound from computer.

V1del wrote:

So all the options you've found would've worked but you wrote them into /etc/asoundrc instead of /etc/asound.conf ? Well that's a bummer.

As I go through them, yes, yes they do work.

I do believe I marked it solved, but your post came after I changed it, so I'm not sure.  Still says solved to me though.

Offline

#14 2025-01-22 18:23:00

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 24,407

Re: [SOLVED] Please help me to record sound from computer.

yes it worked, I didn't refresh before my reply, all good.

Offline

Board footer

Powered by FluxBB