Install ffmpeg and pulseaudio
sudo apt install ffmpeg pulseadio
transmit_audio.sh
NOTE: Change 192.168.1.100 to the ip address of the device you want to stream the audio too
#!/bin/bash
if [ -z "$1" ]
then
ffmpeg -f pulse -i "remote.monitor" -ac 2 -acodec pcm_s16le -ar 48000 -f s16le "udp://192.168.1.100:18181"
else
pkill -15 ffmpeg
fi
In your desktop environment setup a login action to start transmit_audio.sh and for the logout action transmit_audio.sh passing stop as an argument.
On the receiving device run this script.
audio_stream.sh
#!/bin/bash
pkill -f "ffplay"
ffplay -nodisp -ch_layout stereo -acodec pcm_s16le -ar 48000 -analyzeduration 0 -probesize 32 -f s16le -i udp://0.0.0.0:18181?listen=1 -threads 2 #&> /dev/null
Leave a Reply