Linux – How to record audio from only a specific program on linux

audioaudio recordinglinux

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.

Best Answer

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

Related Question