Outputting stream to specific audio device with ffmpeg from a mediasoup stream on mac – help please

I’m working on a webrtc app for handling multiple audio streams. Works ok in a browser but I want to move part of it to a node app.

I’m using mediasoup as the server for this, and a sample they have to record to a file using ffmpeg or gstreamer as the starting point.

The key file in the sample is here https://github.com/Kurento/mediasoup-demos/blob/master/mediasoup-recording/server.js

In this file it saves an audio stream (and optionally video) to a file using ffmpeg.

I simply want to simply send the sound to an audio output device instead. I’m sure it’s really simple but ffmpeg seems like a huge subject in itself and I’ve already spent a lot of time trying to find out how to do this.

The command used to save to a file is (from the source code comments)

 * ffmpeg 
 *     -nostdin 
 *     -protocol_whitelist file,rtp,udp 
 *     -fflags +genpts 
 *     -i recording/input-vp8.sdp 
 *     -map 0:a:0 -c:a copy -map 0:v:0 -c:v copy 
 *     -f webm -flags +global_header 
 *     -y recording/output-ffmpeg-vp8.webm

If anyone could advise how to change this to send to a specific audio device, I’d be really grateful. This is on a mac, and I have multiple sound devices so I also need to be able to find a list of them so I can send specific streams to specific devices. Something else I’ve struggled to do.

Many thanks in advance.