Page 1 of 1
Reliable stream playout on raspberry pi
Posted: Fri Sep 05, 2025 12:19 pm
by jvok
Anyone ever use a pi playing out a stream for linking? How did you get it to handle internet drop outs? I've tried both mplayer and vlc and they both just hang if the connection goes out, won't resume when it comes back. If it actually crashed out and returned to console it would be ok cus I could set it playing in a loop. But instead it just sits there doing nothing until I manually restart it
Both vlc and mplayer have --loop as a parameter on command line but it only works if the stream itself ends. If the connection goes down it doesn't see it as the stream ending so just carries on doing nothing
Any ideas?
Re: Reliable stream playout on raspberry pi
Posted: Fri Sep 05, 2025 2:02 pm
by King Croccy
You are correct, VLC is not resilient enough to handle network glitches, mine used to just stop dead and you would have to log in manually. Sometimes it would stop after a week, sometimes an hour. It seems to do it on every platform (rasbian, linux mint even on mobile phone). I have seen a few threads on the net where people have told the developer but he seems to be in denial!
The way I've seen people get round the issue is to use the jack version of stereotool. There is a software called silentjack which is some kind of plugin for jack. It can detect silence and if you write a script, it can be used to refire vlc when it glitches.
It would be nice if there was a plug in for vlc to make things simple but unfortunately I don't think there is any available.
Re: Reliable stream playout on raspberry pi
Posted: Sun Sep 14, 2025 2:33 am
by Albert H
Net drop-outs can be a pain, I wrote a routine for auto-reconnection, and this will normally restore the stream in a couple of seconds. I have a further routine that logs the number of drop-outs, and if they're happening too often, it'll play out a local pre-record for the balance of the hour, then continue with the recordings if a stable connection can't be obtained.
Another trick we've used is to send an hour's programme speeded up so that it gets there in a few seconds. Each programme can be uploaded to the playout Pi, so that programmes can be almost contemporaneous, just an hour or two behind!
Re: Reliable stream playout on raspberry pi
Posted: Sun Sep 14, 2025 5:08 pm
by EFR
Anyone done it with old Android phones? I have sjoebox full of these.
Re: Reliable stream playout on raspberry pi
Posted: Sat Sep 20, 2025 2:58 am
by jvok
So I took Croccy's suggestion and got Silentjack working on the Pi. The hardest part is installing it because you have to build it from source and there's not much instructions. This is how I did it in case anyone wants to copy.
This is for Raspberry Pi OS 6 (based on Debian 12). I haven't tried older versions but it probably won't work because they use a different sound server.
1. Install the packages you need to build Silentjack. Also install VLC because we'll be using it later.
Code: Select all
sudo apt install autoconf libjack-dev vlc
2. Set some environment variables you'll need to build Silentjack.
Code: Select all
export JACK_CFLAGS="-I/usr/local/include"
export JACK_LIBS="-L/usr/local/lib -ljack -lpthread"
3. Get a copy of Silentjack from Github.
Code: Select all
git clone https://github.com/njh/silentjack.git
4. Build and install Silentjack.
Code: Select all
cd silentjack
./autogen.sh
make
sudo make install
cd ..
5. Copy and paste this script into a text editor and save it as a file ending in .sh e.g. radio.sh
Code: Select all
#!/bin/bash
# Constants
STREAM_URL="https://s2.ssl-stream.com/listen/uk_bass_radio/stream" # Replace with your stream URL
SILENCE_TIME="10" # Max allowed silence time in seconds
# Get full path of current script, so we can relaunch it later
SCRIPT_PATH=$(realpath ${BASH_SOURCE})
# Clean up previous session
# (you can remove the -v option if you don't want the results printed to the console - I find it useful for confirmation)
killall -v silentjack
killall -v vlc
killall -v pw-loopback
# Create a loopback audio device to sit between VLC and the soundcard
# This ensures silentjack will have something to listen to before VLC starts
# The capture-props parameter tells pw-loopback not to connect to any input device - we'll let VLC do this
pw-loopback -n FakeDevice --capture-props='media.class=Audio/Sink' &
sleep 1 # Delay allows pw-loopback to do its thing before starting silentjack, otherwise we get errors
# Set our loopback device as the default output, so VLC will use it automatically
pactl set-default-sink input.FakeDevice
# Launch VLC on dummy interface in case we don't have a GUI running
vlc --intf dummy --loop ${STREAM_URL} &
# Tell silentjack to listen to our loopback device. If it goes silent, it will relaunch our script
# We have to run silentjack through pw-jack to get it to play nice with Pipewire
pw-jack silentjack -c FakeDevice:output_FL -p ${SILENCE_TIME} bash ${SCRIPT_PATH}
6. The script uses the UK Bass Radio webstream as an example. You can change STREAM_URL to point to your stream. Also you might want to change SILENCE_TIME to be longer/shorter (default is 10 seconds). Make sure this is longer than any actual silence you might have in your stream.
7. Launch the script with this command. The "&" symbol at the end detaches the script from the console, so you can close the window/log out of SSH and it will keep running.
I've had this running for almost 2 weeks now and it hasn't missed a beat besides the 10 second drop-outs. Before it wouldn't last a day.
Re: Reliable stream playout on raspberry pi
Posted: Sat Sep 20, 2025 9:04 am
by EFR
I have one first model Rpi laying around, need to test this.
Re: Reliable stream playout on raspberry pi
Posted: Mon Sep 22, 2025 8:35 am
by radionortheast
there was meant to be this funny character on a raspberry that could help you do coding, think it was a cat called spratz
Re: Reliable stream playout on raspberry pi
Posted: Sun Oct 05, 2025 10:19 am
by Gigahertz
Came across this on a USA part 15 radio station forum.
https://experiencefm.com/
"Harness the power of the affordable, widely available Raspberry Pi with our zero-config software — no Linux skills required. Just flash, plug in, and you're streaming. Whether you're linking a studio to a remote site, broadcasting audio for holiday light displays, or DJing live to an internet station, our solution makes professional IP audio streaming simple, reliable, and accessible."
Re: Reliable stream playout on raspberry pi
Posted: Sun Oct 05, 2025 8:07 pm
by Unknown
Can you run rds on a pi zero with 192khz dac ?
Re: Reliable stream playout on raspberry pi
Posted: Mon Oct 06, 2025 3:48 am
by Up_North_Radio
If you have good 5G available and can link to the RPI a good way is with ffmpeg over netcat or socat if you need a way to ensure auto reconnect.
Live audio
Code: Select all
ffmpeg -f alsa -i hw:0 -acodec libmp3lame -b:a 320k -f mp3 - | nc rpi_ip 8000
PulseAudio
Code: Select all
ffmpeg -f pulse -i default -acodec libmp3lame -b:a 320k -f mp3 - | nc rpi_ip 8000
On the RPI (receiving audio):
Or to output to audio device:
Code: Select all
nc -l -p 8000 | ffmpeg -i - -f alsa hw:0
One thing about netcat is there is no auto-reconnect if the network drops you can use socat for automated reconnect
Code: Select all
ffmpeg -f pulse -i default -acodec libmp3lame -b:a 320k -f mp3 - | socat - TCP:rpi_ip:8000,retry=10
Using socat (better for 5G - auto-reconnects)
Code: Select all
ffmpeg -f alsa -i hw:1 -acodec libmp3lame -b:a 320k -f mp3 - | socat - TCP:rpi_ip:8000,retry=30,interval=2
Listen and pipe to audio output
Code: Select all
socat TCP-LISTEN:8000,reuseaddr - | aplay -
Or if you need more control over output
Code: Select all
socat TCP-LISTEN:8000,reuseaddr - | ffmpeg -i - -f alsa hw:0
Should be able to do 320kbps with the -b:a 320k option.
If you just want to have some playlist and very light weight then mdp and mpc would be the choice.
Code: Select all
# Install on RPI
sudo apt install mpd mpc
# Copy music to RPI
scp -r /path/to/music/* pi@rpi_ip:/var/lib/mpd/music/
# Update library and play
mpc update
mpc add /
mpc play
Nice opensource project this one. Punching above it's weight I feel
https://github.com/jcorporation/myMPD 
Re: Reliable stream playout on raspberry pi
Posted: Mon Oct 06, 2025 5:16 pm
by King Croccy
Unknown wrote: ↑Sun Oct 05, 2025 8:07 pm
Can you run rds on a pi zero with 192khz dac ?
I have seen it done with this but think the zero was running jmpx (rather than stereotool). I don't recommend using jmpx as the only processing seems to be adding a bit of pre-emphasis on. Most of the rigs I've seen running this setup were highly over deviating. You really need stereotool and someone that knows how to set it up properly with a deviation meter
