How to record audio from only a specific program on linux?

2

Is there a way to record the audio from only a specific program, so that other sounds (e.g. notifications) are not recorded?

I'm running Archlinux with pulseaudio.

gandalf3

Posted 2015-02-07T07:12:40.763

Reputation: 443

Something like Jack? with all relative complex background

– Hastur – 2015-02-07T08:58:00.607

More way e.g. the new new way

– Hastur – 2015-02-07T09:06:13.850

Answers

2

You can use pacat which is part of pulseaudio.

First open your application. THen run pactl list and find your device. in my example, I will use chrome

snipet:

Client #229
Driver: protocol-native.c
    Owner Module: 8
    Properties:
        application.name = "Chrome input"
    native-protocol.peer = "UNIX socket client"
        native-protocol.version = "28"
    application.process.id = "16404"
        application.process.user = "robert"
        application.process.host = "HS"
        application.process.binary = "chrome"
        application.language = "en_US.UTF-8"
    window.x11.display = ":0.0"
        application.process.machine_id = "15d4d55cf80e320acb892977520d0894"
        application.process.session_id = "c1"

I'll grab the application name and run pacat.

 pacat -r -n "Chrome input" | sox -t raw -r 44100 -s -L -b 16 -c 2 - "output.wav"

You can also use pacat to capture from a device, etc. the pacat man page has some more info

Rob Calistri

Posted 2015-02-07T07:12:40.763

Reputation: 256

This looks good! I've never used sox before though.. I get sox WARN getopt: option \s' not recognized` when trying to run your example. – gandalf3 – 2015-05-01T23:42:25.493

1@gandalf3 I'll have to test it before I update my answer, but you can probably do away with sox and just use pacat to write to wav files. If you want to stream to a compressed format, you can pipe pacat to your favorite encoder. example: pacat --volume=32768 --format=s16ne --channels=2 --rate=44100 -r -n "Chrome Input" > /home/[user]/Desktop/chrome.wav – Rob Calistri – 2015-05-04T12:04:53.687