163

Is there a program for Ubuntu that can record sounds of only the output of the speaker and not any voices from outside the PC?

Zanna
  • 70,465
AmirRazoR
  • 3,267

6 Answers6

190

If I'm not wrong, then I guess you are talking about recording "Stereo Mix" or loopback Output.

In layman's terms, Recording Stereo Mix means recording sound from speaker output.

Here's how to do it:

  1. Install pavucontrol from Ubuntu Software Center.
  2. Install audacity from Ubuntu Software Center.
  3. Select pulse* as recording device in Audacity.
  4. Click Record Button.
  5. Open PulseAudio Volume Control (Search For PulseAudio Volume Control in Dash).
  6. Select Recording Tab.
  7. Now You Should see ALSA plug-in [audacity]. If you do not see ALSA plug-in [audacity], make sure you have clicked Record Button in audacity. You should be running recording in audacity while performing next step.
  8. Select "Monitor from *". See screen shot. Screen shot of PulseAudio Volume Control
  9. Now you should be able to record the sound you hear from speaker or headphones.

Note: Tested in Ubuntu 12.10
Reference PulseAudio - Ubuntu Wiki

  • 4
    i did find "pulse" but i couldn't find "pulse:Mix:0" or anything like mix 0. i just went to preferences and then devices and i clicked on recording and it was only pulse there,where can i find pulse:mix:0? – AmirRazoR Dec 16 '12 at 16:47
  • @AmirRazoR Update to reflect current version of Ubuntu. –  Dec 17 '12 at 15:05
  • The Recording tab in puvucontrol is empty and I too could not find how to change to pulse in audacity. – kroiz May 10 '13 at 06:31
  • It works great in Ubuntu 13.04 (amd64), too. Thanks a lot! – conualfy Oct 10 '13 at 01:14
  • 2
    Each step happens as you describe, but ultimately no audio is recorded in Audacity (Ubuntu 14.04). What does the * after pulse* mean? – Drew Noakes Aug 24 '14 at 16:29
  • 1
    Haven't tried it in 14.04. pulse* here means anything that begin with pulse in it's name. –  Aug 24 '14 at 16:34
  • Works great under Ubuntu 14.04 – SunLiWei Nov 12 '14 at 09:49
  • Ubuntu 14 ... works great. Thank you. – beingalex May 02 '15 at 22:45
  • Worked great for me too. Thanks. After doing this, I found that the playback was too fast and following this answer fixed it for me: http://askubuntu.com/a/603616/488727 – the_new_mr Jan 14 '16 at 04:34
  • The recorded sound will contain silence at the beginning since you first start with recording, and then start the playing the sound. Here is a link how to truncate the silence with audacity: http://manual.audacityteam.org/index.php?title=Truncate_Silence – guettli Feb 28 '16 at 19:52
  • It has worked for me on Ubuntu 16.04! Thanks a lot – morhook Aug 19 '16 at 13:02
  • This doesn't appear to record anything from aplay /dev/urandom for me. I just get silence recorded. – Ruslan Feb 18 '17 at 10:34
  • 1
    Works on Linux Mint. – possumkeys Feb 20 '17 at 07:04
  • Works under Lubuntu 17.10. – KO the typo Apr 14 '18 at 21:13
  • In Audacity, if you first start monitoring the recording level (left-click on the Recording Meter to turn monitoring on) that populates the recording tab in PulseAudio's volume control window. Then you can avoid the silence at the beginning, by not starting to record until you're ready ( @guettli ) – Xen2050 Mar 26 '19 at 00:04
  • That was wild! And it works on latest ubuntu 20.04. Thanks – aghArdeshir Aug 04 '20 at 21:41
  • Works in linux Mint. Make sure that during recording from your sound card you have muted Audacity under the playback tab, otherwise you get a feedback loop – Eelco van Vliet Aug 20 '20 at 12:19
111

A very small, bare-bones software that does exactly what you need, is called (rather obviously) "Audio Recorder", installed like this:

sudo add-apt-repository ppa:audio-recorder/ppa
sudo apt-get update && sudo apt-get install audio-recorder

Files are saved automatically to the ~/Audio directory.

Ubuntu audio-recorder

David Foerster
  • 36,264
  • 56
  • 94
  • 147
user78915
  • 1,119
  • 7
    It works like a charm, too! :) – conualfy Oct 10 '13 at 01:41
  • 9
    This is lovely, thank you! Very neat, and though Audacity setup works, if you just need to record audio (to ogg, wav, mp3, etc), this is the solution. – karni Oct 10 '13 at 16:48
  • 1
    Very simple and neat tool! – SunLiWei Nov 12 '14 at 10:02
  • 6
    Why would you go thru all the "hustle" with Audacity when this one does the job you need with a single click ... beats me. – poelinca Jun 11 '15 at 08:22
  • audio-recorder currently doesn't work in Ubuntu 14.04: audio-recorder: symbol lookup error: audio-recorder: undefined symbol: _gst_message_type – Aleksander Alekseev Feb 26 '16 at 08:29
  • Any idea if this can be done from command line (with no GUI)? – max pleaner Oct 23 '16 at 18:09
  • @macsplean I figured it.. Hope it helps :) – b-ak Nov 16 '16 at 16:50
  • 3
    @poelinca because audacity and pulse audio are 2 very powerful and useful softwares, and if I am going to have them installed anyway because I use them for other things, then why would I install a third tool that does something that my current programs can already achieve? Furthermore audacity is better for this because you can cut off any extra audio before and after desired part of recoding. And btw, it's hassle. Hustle means to push or to steal. – Abraham Murciano Benzadon Jun 14 '17 at 22:13
  • @AbrahamMurcianoBenzadon thanks for clarification and sorry for the spelling issues. – poelinca Jun 15 '17 at 13:01
  • Does this work to record Skype too? If I want to record both what I hear other(s) say and what I myself am saying? Preferably in separate channels to be able to adjust the volume mix afterwards. – Albert Veli Aug 20 '19 at 09:10
  • Not working with Built-in analog Stereo (audio output), Kubuntu 18.04. Maybe a problem with pa volcontrol... – Duns Aug 30 '19 at 07:54
  • Analog stereo duplex doesn't work for audio output with audio recorder; output recording is ok only if I select, in PAVolControl, analog stereo output, but so I loss the mic, so to say (losing analog stereo input). I have to choose: either input or output; it seems impossible to get both input and output. – Duns Aug 30 '19 at 09:08
  • It has command line functions. Just do audio-recorder --help. I could not make gui version to save file directly with name i type thouhg. it default always to the YYYY-MM-DD-HH-MM-SS.xyz – ndasusers Sep 08 '19 at 03:25
  • how to uninstall it! – Rubel Apr 08 '21 at 18:30
  • I've successfully installed and recorded, but don't get any playback, neither set as ogg nor as mp3. Found the ogg file, it "plays" but no sound. Otherwise my sound works. Xubuntu 20.04, Dell Latitude E6530 – Hulda Aug 28 '22 at 14:41
  • Worked perfect. Simple, compact and effective however I had to select "Starship/Matisse HD Audio Controller (Audio output)". So my guess is you might have to select your "Audio Controller" and not just "Built-in Audio" or "System default". – shrimpwagon Oct 14 '22 at 16:11
  • Working in Ubuntu 22.04. – user171780 Jul 13 '23 at 20:23
  • Currently, I am using sudo add-apt-repository ppa:ubuntuhandbook1/audio-recorder. – User Mar 17 '24 at 23:17
60

Command Line

  1. Install sudo apt-get install pulseaudio-utils lame mpg123

  2. Search for your speakers and tap into your speaker's monitor stream:

    pacmd list-sinks | grep -e 'name:' -e 'index' -e 'Speakers'

    or

    pacmd list-sources | grep -e 'name:' -e 'index' -e 'Speakers'

enter image description here

  1. Play anything you want to record and type in parec -d alsa_output.pci-0000_00_1f.3.analog-stereo.monitor | lame -r -V0 - out.mp3

  2. Hit ctrl+c to stop recording and play the recorded file mpg123 out.mp3

Minimalistic GUI

A very simple GUI to do this, pull all the files from here and run install.sh Goto Dash and search for Record Speakers

xerostomus
  • 990
  • 9
  • 20
b-ak
  • 4,350
  • 7
    Best solution... <3 – Peque Dec 28 '16 at 23:55
  • Records silence when I do a test aplay /dev/urandom. – Ruslan Feb 18 '17 at 10:41
  • @Ruslan aplay is for playback, it's counterpart for recording is arecord – b-ak Feb 19 '17 at 07:02
  • 1
    Of course it's for playback. It's also useful for testing loopback recording software that the software can intercept what is played back. And parec wasn't able to intercept aplay's playback in my test on Ubuntu 14.04. – Ruslan Feb 19 '17 at 07:37
  • @Ruslan It works for me. Ubuntu 16.04. – b-ak Feb 19 '17 at 08:26
  • @Ruslan play it with mpg123 instead of aplay. Have no idea why, but it worked for me. – max pleaner Mar 29 '17 at 20:09
  • @maxple you're suggesting to fix the wrong side. aplay is just a simple example of a pure ALSA player. There're lots of other pure ALSA sources which parec won't be able to intercept (at least on the system I tested). – Ruslan Mar 29 '17 at 20:11
  • @Ruslan Not sure what you mean by "the wrong side". You mean I should replace parec with arecord? all the command line scripts on this page use parec. – max pleaner Mar 29 '17 at 20:19
  • @maxple I mean that the OP asks "how to record", while you suggest to change player. Player is not something which records. And if a recorder misses some players' output, it's not really good. – Ruslan Mar 29 '17 at 20:21
  • @Ruslan ok I was responding to your first comment, saying that aplay did not work. Perhaps I misunderstood you. But for me personally, aplay did not work to hear the mp3 file i recorded with parec - i had to use mpg123 instead. Like I said, I have no idea why this is the case since they're both supposed to be able to play mp3. But it was unexpected, so I added a comment here so others would have a heads up. At first I didn't think it worked because all I tested with was aplay. – max pleaner Mar 29 '17 at 20:25
  • 12
    Consider removing the | lame [...] pipe and use --file-format=wav output.wav (for example). You can list the supported formats with parec --list-file-formats. Also, consider making a bit more clear the fact that you need to specify the device with the .monitor at the end. ^^ – Peque Apr 05 '17 at 15:53
  • @Peque Should be fine now ? – b-ak Apr 26 '17 at 16:55
  • I get "Stream error: No such entity" – ka3ak Feb 11 '18 at 06:11
  • @ka3ak I could help you out on chat.stackexchange.com. Please visit the site so that I can add you into a chat room – b-ak Feb 23 '18 at 17:41
  • This worked for me (kubuntu 18) but since I have multiple output devices I had to tweak the py script to find the correct one. – Jay Marm Jul 23 '18 at 17:09
  • It'd be great if you could commit the improvements back to the tree.. – b-ak Jul 24 '18 at 18:14
  • 1
    Nice, as this can do stereo playback recording. Looks like audacity can't do that. – Peter Thomassen Sep 21 '18 at 17:07
  • 5
    you don't need necessarily the name of the source... you can also choose the index of the source : parec -d 0 | lame -r -V0 - out.mp3 – and-bri Oct 20 '18 at 15:37
9

I just made a small alias to record the PC audio output with one single command and stored in opus format instead of mp3.

  1. Install the required packages:

    sudo apt-get install pulseaudio-utils opus-tools
    
  2. Edit your .bashrc file:

    nano ~/.bashrc
    

    Copy the line below and append it to the end of your ~.bashrc:

    alias recaudio="parec --monitor-stream="$(pacmd list-sink-inputs | awk '$1 == "index:" {print $2}')" | opusenc --raw - $(xdg-user-dir MUSIC)/recording-$(date +"%F_%H-%M-%S").opus"
    

    Save the file by pressing Ctrl+X (to close nano), then Y (for "Yes") and Enter (to confirm the file name).

  3. Now load the new ~/.bashrc (or simply open a new terminal):

    source $HOME/.bashrc
    

Then try, just type

recaudio

It will create a file in your Music home folder called recording-[DATE].opus.

Enjoy.

Byte Commander
  • 107,489
  • 2
    What does the --monitor-stream=... part do/mean? My list-sink-inputs is zero unless something's actually playing sound, then it would return a number. So this would have to be started after the sound is already playing? – Xen2050 Nov 28 '17 at 04:27
4

For those stumbling over this and using pipewire instead of pulseaudio:

pw-record -P '{ stream.capture.sink=true }' test.flac

This would record from the current audio output. (found at https://www.reddit.com/r/archlinux/comments/x2kej0/recording_output_audio_using_pipewire/ )

delf
  • 401
  • 6
  • 10
2

Note: Okay this answer might seem like a cop-out but it works and its great software, especially if you want to additionally record your speaker output and microphone output at the same time. Or if you also need to video record your computer screen.

Anyways, been pulling my hair out forever googling for an answer that is simple to use and provides everything I need.

Install and use Open Broadcaster Software (OBS). Seriously, that's it. Googling it should bring up installation instructions tailored to your machine.

Just record with OBS and it will just make a video with your audio in it. If you only want to record audio, just record without a video source and it will make a blank video with your recording. If you want to record only speaker output and not the mic, simply mute the microphone with a press of a button. Intuitive.

(Note this gives you a video file. It doesn't bother me but if you need an audio file like an mp3 you would have to figure out how to convert the video file you made into an audio file (I don't know how to do that, but there are plenty of resources out there that tell you).)

  • this is the better answer for nowadays, the audio-recorder ppa does not work, and speaker-recorder requires python 2. audacity only shows mics as inputs. – Ferroao Aug 08 '23 at 18:12