8

I would like to record the audio output of a locally running application as mp3 file on my hard disk.

However, I need to record only the audio of one single application, ideally only one single window. All other audio output from different sources should be ignored.

How can this be achieved in Ubuntu 16.04?

1 Answer 1

4

I found a solution for this myself. It requires pavucontrol (PulseAudio Volume Control) to assign the input and output audio streams to specific applications and an audio recording tool which ideally can select its input device manually, including virtual devices. I chose Audio Recorder for that. You will also need to create virtual audio sinks using the command-line tool pactl to be able to separate the audio output streams and record one application independently.

Preparation

First you need to set up a virtual audio sink. It acts as a virtual audio device or virtual audio cable, however you want to call it. You can set it as output device for one application and let the other application record it as input device.

This can be done with pactl on a system using PulseAudio like this:

pactl load-module module-virtual-sink sink_name=sink1

sink1 here is just an arbitrary name for the virtual device.

Set up the audio source application

Second we start the application that is going to play back audio which we want to record.

  • If the source application allows to select the sink1 device we created earlier as audio output device, you can simply do that and skip to the recording section.

  • If the source application doesn't give you an option to select the audio output device, you have to install (if necessary: sudo apt install pavucontrol) and start Pavucontrol.

    Then launch the source application and let it play any audio. While it is making noise, it will appear in the Playback tab of Pavucontrol. Locate its playback on [...] drop-down menu and select Virtual Sink sink1 as target device. You will still hear it because the virtual sink is also connected to your standard output device, but that is okay.

    You can also pause the playback again now and mute the source application, Pavucontrol will remember the configured playback device for a while.

Set up the recorder application

Now launch your recording software (I recommend Audio Recorder from the ppa:audio-recorder/ppa PPA, installation instructions here, for this task).

  • If it allows you to select your virtual sink (or a monitor of the virtual sink) as input device to record, do that.

  • If you can not select the input device (or if only hardware input devices are listed, try to set it to something like "system default"), you have to use Pavucontrol again.

    Let the tool start recording anything. While it is listening, it will appear in Pavucontrol's Recording tab. Locate its from [...] drop-down menu and select something like Monitor of Virtual Sink sink1 as input device.

    You can also pause the recording again now, Pavucontrol again will remember the configured input device for a while.

Record

Now that the source application has our custom virtual sink configured as output device and our recording application is using that same sink (or its monitor) as input device, you can finally start recording.

The recorder will only hear the sounds produced by the source application (actually by all applications outputting their audio to our virtual sink, but it should only be that single one) in this setup. You can have any number of other applications playing back audio to a real audio output device or a different virtual sink at the same time without disturbing your recording.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .