How I run a 24/7 music stream from my Raspberry Pi

Intro, always wanted to have my own radio-like live-stream
I thought this was something I could get done in a matter of minutes, but turned out more challenging than expected to get the livestream the way I wanted it (in terms of stability, features)

What you need

Raspberry Pi
This tutorial is a very lightweight solution (no encoding required) which allows us to run it on a raspberry pi, but you can also use it on your linux home computer or your server.
I use a raspberry Pi 3 B+, but older Pi’s should work just fine.

Rasbian Stretch Lite, but you should be able to use any debian based linux distro

Build FFMPEG from source

What is ffmpeg
In order to use the stream_loop feature (which we need to make our video loop infinitely), which was introduced in FFMPEG 4 (souce?). At the time of writing, the version In Debian repository is 3.2.2, so we are going to compile ffmpeg from source.

Install tools for compiling

Tools for compiling.

cd ffmpeg-4.1.2
./configure --enable-cross-compile --cross-prefix=${CCPREFIX} \
--arch=armel --target-os=linux --prefix=/usr \
--enable-gpl --enable-nonfree \
--extra-cflags="-I/usr/include" \
--extra-ldflags="-L/usr/lib" --extra-libs=-ldl
time make -j 8
cat RELEASE
sudo checkinstall

Download source

I’m going to use ffmpeg 4.1.2 but this tutorial should work for any ffmpeg version higher than 4. I recommend using the latest stable release from the 4.1 relese branch (check here: https://www.ffmpeg.org/download.html)
You can find download links for all releases here: http://ffmpeg.org/releases/

wget https://www.ffmpeg.org/releases/ffmpeg-4.1.2.tar.bz2
tar jxvf ffmpeg-4.1.1.tar.bz2

Compile with custom options

Explain flags

cd ffmpeg-4.1.2
./configure --enable-cross-compile --cross-prefix=${CCPREFIX} \
--arch=armel --target-os=linux --prefix=/usr \
--enable-gpl --enable-nonfree \
--extra-cflags="-I/usr/include" \
--extra-ldflags="-L/usr/lib" --extra-libs=-ldl
time make -j 8
cat RELEASE
sudo checkinstall

Finish installation

Use pkg to install ffmpeg check the output of checkinstall for the filename of the new package. Mine is ffmpeg-4.1.2.deb

sudo dpkg --install ffmpeg-4.1.2.deb

Audio player

Again, you can use an audio player of your choice. I’m going to use mpg123

sudo apt-get install mpg123
Written by noni