Redirect audio ouput to MP3 file


I would like to redirect the audio output (that goes to speakers) to a simple MP3 file, in order to keep the quality of the signal.

How can I do that ?


Stuff like this?

No need to redirect audio output if there is only one audio stream playing to an audio device

PulseAudio and PipeWire audio output sinks have a sink monitor to record audio playback

Check audio playback sinks and capture sources to find name of the sink and corresponding monitor

pactl list sinks short; pactl list sources short

response will show a sink name similar to this:


and corresponding monitor name like this:


To record audio in .mp3 format from the monitor source in PulseAudio

parecord --device=alsa_output.pci-0000_0a_00.4.analog-stereo.monitor /path/to/recording.mp3

pacat — Arch manual pages
(--device option is not needed if there is only one audio source available)

PipeWire has a similar command: pw-record
pw-cat — Arch manual pages

Or use an audio recorder (audacity, gnome-sound-recorder, krecord, ocenaudioAUR…) configured to record from Monitor of [Output device]

Or use packages like yt-dlp or clipgrab if audio file is available online
Or record audio streams with VLC (turn on Advanced Controls for the recording button)

If you wish to maintain the relative quality of the audio output stream, I’d suggest not capturing it as mp3, or any mpeg derivative, for that matter; these formats are typically very lossy.

Instead, capture it as a wav, or perhaps a flac file, which are both lossless in terms of audio quality. Also, be mindful that the quality will already be degraded simply by using a typical computer audio output as the capture/recording source, so you’ll probably want the best quality achievable for the initial capture.

Once you have that original and lossless master, you can then proceed to convert a copy to mp3 or any format you wish.

I hope this is helpful. Cheers.

1 Like

OP was asking for a specific file format

To get a list of all supported formats:

parecord --list-file-formats

For best quality I would get the original audio source (if possible):

yt-dlp -x --audio-format best [url]

yt-dlp — Arch manual pages

For live audio streams, VLC file output records to .wav by default
Audacious FileWriter records to .mp3 by default but can be changed to .wav