phirun has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to divert - that is, "tee-off" - the audio output in my MiniPC to a file. I'm running Debian 10.1.

For example, if I'm in a video conference and take a break, I'll often switch to a music player until the conference resumes. I need both audio feeds, and the easiest way to capture the conference, the music and anything else is to divert the audio stream at the DAC input before it goes to the audio output socket.

I've not tackled this sort of low-level audio data manipulation before and am wondering if there are Perl modules that could be used to write a quick utility to switch the capture facility on and off.

With thanks for any assistance.

Replies are listed 'Best First'.
Re: Diverting audio output to a file.
by Corion (Patriarch) on Feb 27, 2022 at 06:51 UTC

    This is not a Perl solution, but the command is taken from Speech::Recognition::Vosk. ffmpeg can easily record output from various inputs. Assuming that you have PulseAudio on your Debian system, this records from the Pulse device $device.

    ffmpeg -hide_banner -loglevel error -nostats -f pulse -i "$device" -t +30 -ac 1 -ar 44100 -f s16le "$output_file"

    Which device is the correct one, you can find using the following pactl command:

    pactl list short sources
      Hey, that looks interesting. I'll give it a try, and thanks!
Re: Diverting audio output to a file.
by jmlynesjr (Deacon) on Feb 28, 2022 at 01:40 UTC

    Have you looked at PulseAudio Volume Control? Not sure if it's in 10.1. It's not installed by default and would have to be installed from the repositories.

    James

    There's never enough time to do it right, but always enough time to do it over...