Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to record sound to mp3

85 views
Skip to first unread message

Long Wind

unread,
Mar 25, 2021, 7:40:04 AM3/25/21
to
i use mplayer to play sound
i urgently want a program that can record sound being played to mp3
which package shall i install?
Thanks!

to...@tuxteam.de

unread,
Mar 25, 2021, 7:50:04 AM3/25/21
to
On Thu, Mar 25, 2021 at 11:37:53AM +0000, Long Wind wrote:
> i use mplayer to play soundi urgently want a program that can record sound being played to mp3which package shall i install?Thanks!

Command line? (from simple to complex) arecord, sox, ffmpeg

GUI? I don't know. Perhaps snd, audacity (those are actually sound
editors, but you can /also/ do recording)

There are many, many programs in the Debian repository which can
record sound. Which one is good for you will depend a lot on your
needs and preferences.

If you have a desktop environment installed, there will be some kind
of "standard" sound handling app already there. For example, for
Gnome there is "Gnome sound recorder" (package gnome-sound-recorder).

Cheers
- t
signature.asc

Alexander V. Makartsev

unread,
Mar 25, 2021, 8:00:04 AM3/25/21
to
I recommend "audacity" sound editor. It can record audio and export to mp3 or other formats.

-- 
With kindest regards, Alexander.

⢀⣴⠾⠻⢶⣦⠀ 
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀ 

Nicolas George

unread,
Mar 25, 2021, 8:00:04 AM3/25/21
to
to...@tuxteam.de (12021-03-25):
> > i use mplayer to play soundi urgently want a program that can record sound being played to mp3
>
> Command line? (from simple to complex) arecord, sox, ffmpeg
>
> GUI? I don't know. Perhaps snd, audacity (those are actually sound
> editors, but you can /also/ do recording)

I am quite sure (and certain in the case of FFmpeg) that none of them
can record the sound being played.

Regards,

--
Nicolas George
signature.asc

Susmita/Rajib

unread,
Mar 25, 2021, 8:10:05 AM3/25/21
to
Please install (if not already) gnome-sound-recorder and set up
settings there itself. You could even record on the fastest recording
option feasible for your system, and then use soundconverter to
convert the sound to mp3.
Best.

Long Wind

unread,
Mar 25, 2021, 8:30:04 AM3/25/21
to
Thanks to all that reply!

now i modify my requirement to
how to use arecord to record sound being played to wav file

i use buster, how to set default sound recording source?
in early debian distro(stretch?) sound mixer can be used to set recording source

PS: i use twm, i'm afraid that gnome recorder isn't good choice for me

to...@tuxteam.de

unread,
Mar 25, 2021, 8:40:05 AM3/25/21
to
On Thu, Mar 25, 2021 at 12:20:56PM +0000, Long Wind wrote:
> Thanks to all that reply!
> now i modify my requirement tohow to use arecord to record sound being played to wav file
> i use buster, how to set default sound recording source?in early debian distro(stretch?) sound mixer can be used to set recording source
> PS: i use twm, i'm afraid that gnome recorder isn't good choice for me

Ah -- twm. Fond memories. I upgraded to Fvwm :-)

Back on topic: I see you have a minimalistic setup. Perhaps
you need alsamixer/amixer to learn about your sources and
get the sound routing right.

Sorry, I'm a bit tight on time, otherwise I'd play a bit around
to see whether it works.

If you are playing something with mplayer, perhaps you don't need
a recording app at all -- (see mplayer's "-ao" option, for "audio
output". Something around

mplayer ... -ao "mp3:file=foo.mp3"

might just work for you).

Cheers
- t
signature.asc

Victor A. Stoichita

unread,
Mar 25, 2021, 8:50:05 AM3/25/21
to

Le 25 Mar 2021, Nicolas George <geo...@nsup.org> a écrit :
> I am quite sure (and certain in the case of FFmpeg) that none of
> them
> can record the sound being played.

If it’s about playing a file and recording its audio to mp3, the
following will work:

ffmpeg -i your-file.avi your-file.mp3

Change your-file.mp3 to your-file.wav if you prefer wav output.
Works with any input format ffmpeg can play.

Regards,
Victor

Darac Marjal

unread,
Mar 25, 2021, 9:10:05 AM3/25/21
to

IF you're using pulseaudio as your sound server, there are some neat solutions on the AskUbuntu site[1]. In particular, the idea of a "combined sink" sounds good.


[1]: https://askubuntu.com/questions/60837/record-a-programs-output-with-pulseaudio


Thanks!
OpenPGP_signature

David Wright

unread,
Mar 25, 2021, 12:10:05 PM3/25/21
to
On Thu 25 Mar 2021 at 12:20:56 (+0000), Long Wind wrote:

> now i modify my requirement to how to use arecord to record sound being played to wav file

That makes it easier as there's less work for the CPU to do.

> i use buster, how to set default sound recording source?

One way is to run alsamixer in an xterm.
Help is in the top-right corner.

$ arecord -l will give you a list of capture devices.

To record, you could type, for example, in another xterm:

$ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav

where 10 gives you ten seconds; 0 gives you infinite (^C to stop),
cd gives higher quality (44100) than the default,
dat would give you the more modern 48000,
-v … gives a crude VU meter,
0,0 is the bit you have to determine from arecord -l
⮤ device
⮤ card (usually 0, but matters if you have, say, PCH and HDMI).

While arecord is running, you can play with the sliders for levels,
including monitoring with speakers/headphones, and changing the
capture device with <SPACE BAR>.

> in early debian distro (stretch?) sound mixer can be used to set recording source

Yes, I used to use aumix, but that's OSS (passé), not ALSA.

> PS: i use twm, i'm afraid that gnome recorder isn't good choice for me

If you can't get ALSA to work, you might have to use pulseaudio instead.
I believe that can overcome a card's limitations through software.

Cheers,
David.

Nicolas George

unread,
Mar 25, 2021, 12:50:05 PM3/25/21
to
David Wright (12021-03-25):
> > now i modify my requirement to how to use arecord to record sound being played to wav file

> To record, you could type, for example, in another xterm:
>
> $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav

This command does not record the sound being played.

Regards,

--
Nicolas George
signature.asc

ghe2001

unread,
Mar 25, 2021, 1:00:07 PM3/25/21
to
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256



‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Thursday, March 25, 2021 10:40 AM, Nicolas George <geo...@nsup.org> wrote:

> David Wright (12021-03-25):
>
> > > now i modify my requirement to how to use arecord to record sound being played to wav file
>
> > To record, you could type, for example, in another xterm:
> > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav

Have you tried Audacity? GUI, but works good (you need to install the mp3 library to save to mp3).

--
Glenn English
-----BEGIN PGP SIGNATURE-----
Version: ProtonMail

wsBzBAEBCAAGBQJgXMENACEJEJ/XhjGCrIwyFiEELKJzD0JScCVjQA2Xn9eG
MYKsjDKEdwgAl0gm+YUMCCknEjtCKj3i6iZloZtoKYwoxUEcRlxPEsbWPaDe
EA0AqwGH5kXz+hrgdcAIQmEiDq3Pc+cHOq0vLX9fAvTbwW9mSdcyGfCti5DU
awM7S8rmEj5lDTbn8veMdEr0hnM8c9mmTFEF0hmyTtYm4krnk/RXj/73zJso
a8dVHL1GvPa09xR7oQQeRcyrvCQgjvCSiu+6AygapmzWl4yHuxZcWjPciYgZ
j9uL3/Hwzxy7tZVHa9AGR9O1J09IgOdM4VghepJcDowO3KVGDYJfiryjActY
sjZ7XJ7PQbnGGxhGNpR/I23qyCGwfA2ebsfVfYcCn+u1euNNYoXFag==
=QEOi
-----END PGP SIGNATURE-----

Long Wind

unread,
Mar 25, 2021, 2:40:04 PM3/25/21
to
zhou@debian:~$ arecord -l
**** List of CAPTURE Hardware Devices ****
card 0: Intel [HDA Intel], device 0: ALC662 rev1 Analog [ALC662 rev1 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: Intel [HDA Intel], device 2: ALC662 rev1 Alt Analog [ALC662 rev1 Alt Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0


Thank David and Nicolas!
but Nicolas is right, David's command doesn't work
i think keyword here is playback
to get David's instruction to work, i need audio cable to connect sound card's output to sound card's input, (this isn't perfect solution) , but i can't find such cable right now

i may try pulseaudio 

i ask other question: which command can merge two mp3 file?
this command is mp3 file version of DOS command "copy file1+file2 file3"




Greg Wooledge

unread,
Mar 25, 2021, 2:50:05 PM3/25/21
to
On Thu, Mar 25, 2021 at 06:29:43PM +0000, Long Wind wrote:
> i ask other question: which command can merge two mp3 file?this command is mp3 file version of DOS command "copy file1+file2 file3"

The Unix version of that is: cat file1 file2 > file3

However, this is NOT something you can do with MP3 files. They are not
designed to be concatenated. (Ogg Vorbis files *are*. MP3 files aren't.)

I tried this:

unicorn:~$ apt-cache search concatenate mp3
poc-streamer - MP3/Ogg multicast/HTTP streamer and MP3 cutting tool

You can check that out, or try your own searches. Or wait for other
people to respond with suggestions.

Nicolas George

unread,
Mar 25, 2021, 3:00:05 PM3/25/21
to
Greg Wooledge (12021-03-25):
> However, this is NOT something you can do with MP3 files. They are not
> designed to be concatenated. (Ogg Vorbis files *are*. MP3 files aren't.)

It's the other way around. Pure MP3 files are just a concatenation of
self-delimited packets, concatenation will just work.

MP3 files will usually have ID3 and/or XING packets for metadata at the
beginning or the end, concatenation will include them, and the metadata
will be invalid, but it will not prevent the file from being played.

On the other hand, Ogg files are NOT concatenable, even those that
contain only Vorbis audio. Some player will ignore the discontinuity at
the concatenation points, but not all.

Also, let it be said that: decoding playing, recording and encoding
audio files to concatenate them is a terrible idea, because it will lose
quality both because of the decoding-encoding step and because of the
numeric-analog-numeric step.

Regards,

--
Nicolas George
signature.asc

Greg Wooledge

unread,
Mar 25, 2021, 3:20:04 PM3/25/21
to
On Thu, Mar 25, 2021 at 07:51:42PM +0100, Nicolas George wrote:
> On the other hand, Ogg files are NOT concatenable, even those that
> contain only Vorbis audio. Some player will ignore the discontinuity at
> the concatenation points, but not all.

I was told *by the developer* (Monty, in #vorbis IRC long ago) that
Ogg Vorbis files were designed for this.

A few Google searches to provide supporting evidence:

https://linux.die.net/man/1/oggz-merge

If you want to create a file containing some Ogg files sequenced one after
another, then you should simply concatenate them together using cat. In Ogg
this is called "chaining". If you cat Ogg Vorbis I audio files together, then
the result will also be a compliant Ogg Vorbis file.

https://hydrogenaud.io/index.php?topic=114262.0

Chaining in an ogg container is as simple as it gets. Just concatenate two
separate ogg files together, the result is a chained file.


However, I will note that there *are* players that don't handle
chained Ogg Vorbis files properly. So, make sure you test with the
actual player you intend to use.

Nicolas George

unread,
Mar 25, 2021, 4:00:04 PM3/25/21
to
Greg Wooledge (12021-03-25):
> I was told *by the developer* (Monty, in #vorbis IRC long ago) that
> Ogg Vorbis files were designed for this.

Yes, I know concatenation is supposed to be a feature, but they messed
it up.

You may not know, but the expert consensus is that, although the codec
Vorbis was excellent, and Opus even better, the design of the format Ogg
was terrible. The non-working concatenation is not the worse part. The
worse part is probably that supporting any new codec in Ogg requires
code, and non-trivial code even. Look at this:

http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=blob;f=libavformat/oggparseopus.c

Compare to what it takes to support the same codec in Matroska:

http://git.videolan.org/gitweb.cgi/ffmpeg.git/?p=ffmpeg.git;a=commit;h=30549294ef0f796d48b1ffa482bd9315d4dbb83c

> However, I will note that there *are* players that don't handle
> chained Ogg Vorbis files properly. So, make sure you test with the
> actual player you intend to use.

If concatenation really did work, it would work with all players,
because they would not even be able to detect it happened.

But it is worse than that, it is not weird players not handling the
format correctly that do not work. Concatenation works with players that
play it fast and loose with the format and fails with players that
support it completely, because they take the serial id of the streams
into account.

Regards,

--
Nicolas George
signature.asc

Celejar

unread,
Mar 25, 2021, 4:30:04 PM3/25/21
to
The FFmpeg wiki has some very useful information on concatenating media
files where a simple 'cat' won't work - I use its 'concat demuxer'
regularly to contatenate MP4 files (Android starts a new video file when
a 4GB limit is hit):

https://trac.ffmpeg.org/wiki/Concatenate

Celejar

David Wright

unread,
Mar 25, 2021, 6:00:04 PM3/25/21
to
… on your machine. That's why I wrote "If you can't get ALSA to work…".
You're a candidate for pulseaudio, I assume.

AFAICT, this recording facility is getting harder to find on most
computers, if you're not prepared to fork out for a sound card.
I've been fortunate, in that just as my ancient Pentium III expired,
I have acquired a Dell Precision T3500 which has a well endowed
(integrated) sound card.

I'm still finding my way round it: for example, it also has HDMI
playback, but I haven't yet worked out how to exploit it. The machine
has one DVI output and two DisplayPorts, so I need to find a
DisplayPort/HDMI adapter to see if that would yield anything.

It also has two Capture devices, and I don't know whether that means
there are two independent sound paths. If so, then I should be able to
record from the browser to one file, and from a TV (my UK one has
headphone output) or the Roku remote control to another file at the
same time.

Anyway, I just recorded a bit of audio from Abbey Road (the live webcam¹,
not the album), and printed the settings of all the controls (attached).
AIUI at present, the critical section is at the end, specifically:

Simple mixer control 'Input Source',0
Capabilities: cenum
Items: 'Mic' 'Line' 'Stereo Mix'
Item0: 'Stereo Mix'

IOW, I'm recording from the mixer.

¹ https://www.abbeyroad.com/Crossing

Cheers,
David.
recording-abbey-road

Nicolas George

unread,
Mar 25, 2021, 6:30:05 PM3/25/21
to
David Wright (12021-03-25):
> > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > This command does not record the sound being played.
> … on your machine.

On no machine, unless specifically configured, which is not trivial at
all.

It would be helpful if people around here learned to read carefully the
questions before trying to answer them. If they did, they would have
noticed that the question was not to record the ambient sound but the
sound BEING PLAYED. To achieve it requires either a hardware connection
between the output and the input of the sound controller or the
collaboration of the sound driver.

Regards,

--
Nicolas George
signature.asc

Linux-Fan

unread,
Mar 25, 2021, 7:20:04 PM3/25/21
to
David Wright writes:

> On Thu 25 Mar 2021 at 17:40:51 (+0100), Nicolas George wrote:
> > David Wright (12021-03-25):

[...]

> > > To record, you could type, for example, in another xterm:
> > >
> > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> >
> > This command does not record the sound being played.
>
> … on your machine. That's why I wrote "If you can't get ALSA to work…".
> You're a candidate for pulseaudio, I assume.

Not sure about that command above (no means to try it just now), but _with_
PulseAudio, I can record the sound that is being played back just fine by
means of "monitor" audio devices. E.g. I have the following command to
record my screen (`0:v`), the "monitor" device (`1:a`) and a microphone
(`2:a`):

exec ffmpeg -video_size 1600x1200 -framerate 12 -f x11grab -i :0.0+0,0 -f pulse -ac 2 -i 0 -f pulse -i 1 -c:v libvpx-vp9 -deadline realtime -b:v 2M -c:a libvorbis -map 0:v -map 1:a -map 2:a "recording.webm"

adapted from these two sources:

-> https://trac.ffmpeg.org/wiki/Capture/Desktop
-> https://askubuntu.com/questions/682144/capturing-only-desktop-audio-with-ffmpeg

It may of course be true that the hardware _does_ support/accellerate this
monitoring capability, but it does not seem to be entirely uncommon a
feature? Here, it even works inside virtual machines :)

Btw. the existence of monitor devices can be checked in `pavucontrol` where
under "Output" it lists two monitor devices here: One for the HDMI output
and one for the "Built-in Analog Stereo" Output.

> AFAICT, this recording facility is getting harder to find on most
> computers, if you're not prepared to fork out for a sound card.
> I've been fortunate, in that just as my ancient Pentium III expired,
> I have acquired a Dell Precision T3500 which has a well endowed
> (integrated) sound card.
>
> I'm still finding my way round it: for example, it also has HDMI
> playback, but I haven't yet worked out how to exploit it. The machine
> has one DVI output and two DisplayPorts, so I need to find a
> DisplayPort/HDMI adapter to see if that would yield anything.

[...]

As far as I can tell, DisplayPort can transport audio without the need for
an HDMI adapter. Here, a Radeon Pro W5500 graphics card is connected to a
Dell U2713HM display which has one HDMI, DP, VGA and DVI input each. The
W5500 is connected to the DisplayPort and if I play sound to the "HDMI"
output, the display outputs that sound through its headphones socket.

Similar to your case, there are no HDMI ports on the graphics card.
In my case, it is only DisplayPorts.

HTH
Linux-Fan

öö

to...@tuxteam.de

unread,
Mar 26, 2021, 3:40:05 AM3/26/21
to
On Thu, Mar 25, 2021 at 11:22:35PM +0100, Nicolas George wrote:
> David Wright (12021-03-25):
> > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > This command does not record the sound being played.
> > … on your machine.
>
> On no machine, unless specifically configured, which is not trivial at
> all.

No idea about pulse. For ALSA, there's alsaloop, which comes with a
man page. Part of alsa-utils. No need of playing with cable loops.

> It would be helpful if people around here learned to read carefully the
> questions before trying to answer them [...]

(I was on the verge of making a snarky comment to that, but I'll bite
my tongue).

Cheers
- t
signature.asc

Michael Lange

unread,
Mar 26, 2021, 4:50:04 AM3/26/21
to
Hi,

On Fri, 26 Mar 2021 08:38:02 +0100
<to...@tuxteam.de> wrote:

> On Thu, Mar 25, 2021 at 11:22:35PM +0100, Nicolas George wrote:
> > David Wright (12021-03-25):
> > > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > > This command does not record the sound being played.
> > > … on your machine.
> >
> > On no machine, unless specifically configured, which is not trivial at
> > all.
>
> No idea about pulse. For ALSA, there's alsaloop, which comes with a
> man page. Part of alsa-utils. No need of playing with cable loops.

another possibility: when the snd-mixer-oss module is loaded, (at least
here) when using the OSS mixer device there is a "Vol" control which
roughly appears to be the OSS equivalent to Alsa's "Master" control,
however the "Vol" control has an additional "Capture" switch. Now, when I
set "Vol" as capture device, the audio output will be used as input for
recording. Recording level can be adjusted with the "PCM" mixer control.
Of course, the presence of this "Vol" control may depend on the sound
card / driver in use.
Oddly, there seems to be no such easy way to achieve the same result with
alsamixer/amixer. Plus, I don't know how to switch the OSS capture device
programmatically (if this is important for the OP's purpose).

Regards
Michael

.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.

I thought my people would grow tired of killing. But you were right,
they see it is easier than trading. And it has its pleasures. I feel
it myself. Like the hunt, but with richer rewards.
-- Apella, "A Private Little War", stardate 4211.8

Michael Lange

unread,
Mar 26, 2021, 5:20:04 AM3/26/21
to
On Fri, 26 Mar 2021 09:47:28 +0100
Michael Lange <klap...@freenet.de> wrote:

> Plus, I don't know how to switch the OSS capture
> device programmatically (if this is important for the OP's purpose).

uh, got it.

$ aumix -v R

sets "Vol" as capture device.

Regards
Michael

.-.. .. ...- . .-.. --- -. --. .- -. -.. .--. .-. --- ... .--. . .-.

A man either lives life as it happens to him, meets it head-on and
licks it, or he turns his back on it and starts to wither away.
-- Dr. Boyce, "The Menagerie" ("The Cage"), stardate
unknown

David Wright

unread,
Mar 26, 2021, 12:10:05 PM3/26/21
to
On Thu 25 Mar 2021 at 23:22:35 (+0100), Nicolas George wrote:
> David Wright (12021-03-25):
> > > > $ arecord -d 10 -f cd -v -v -v -D plughw:0,0 /tmp/audiofile.wav
> > > This command does not record the sound being played.
> > … on your machine.
>
> On no machine, unless specifically configured, which is not trivial at
> all.

I'm afraid it's my PCs that are making a liar of you.

> It would be helpful if people around here learned to read carefully the
> questions before trying to answer them. If they did, they would have
> noticed that the question was not to record the ambient sound but the
> sound BEING PLAYED.

What, you think that I left the speakers running so that the
microphone could record them?

Or did you think that the sound of Thursday evening traffic in
St John's Wood would carry across six timezones?

Or you think that's it's impossible that I should have been able to
record sound the computer is playing (from whatever source, external
or internal) on an OOTB PC for over twenty years?

Is that why you're shouting?

Anyway, back to talking about PCs.

> To achieve it requires either a hardware connection
> between the output and the input of the sound controller

That's my understanding. Using the terminology of the High Definition
Audio Specification (Revision 1.0a June 17, 2010), there is presumably
a link from the § 7.2.3.4 Mixer (Summing Amp) Widget output to the
§ 7.2.3.5 Selector (Multiplexer) Widget. This link in inside the
Widget Interconnection "Cloud" of Figure 49, Module-Based Codec
Architecture.

"The exact number of possible inputs to each widget is determined by
design;" (§ 7.1.1), which is why you can't just conjure up any facility
on any PC.

But the machine is no more "specifically" configured than any PC which
has HDA and a mobo: the vendor (Intel on my old one, Dell on the new)
decides how much of the architecture they will implement. And the
modern way seems to be to go cheap, particularly with consumer-grade.
OK, this one's a decent machine, but it's still a 10-yr old cast off.

Perhaps take a look at the specification and see how much is left open
to the vendor. Hence the need for scripts like alsa-info to tell you
exactly what you've bought with any given "sound card".

This PC was not cheap when it was bought, largely because it's
supposed to be fast: it was bought for students to run geophysics
programs on. You can now pick them up for just over $100. If I ever
have to hand it back, I might just do that. It'll be the first
computer I've ever bought.

> or the
> collaboration of the sound driver.

I assume by this that you're talking about pulseaudio. That's why
I've mentioned it each and every time. (This is the third—should
I put it in my signature?) I can't advise how the OP might use it,
because *I* don't¹. But perhaps that's not expected here—one just
replies "pulseaudio" like the people saying "audacity"
or "sox" or whatever.

Finally, who's the audio expert round here? I posted what I think
is a determining factor for just vanilla ALSA and the card to work
with my command line. Presumably there's a definitive answer to
this? Do *you* have it?

¹ self-imposed simplicity: no PA, no OSS.

Cheers,
David.
0 new messages