Streaming to icecast/shoutcast from linux

Streaming to icecast/shoutcast from linux

Audio Streaming technology can be of different protocols but mostly Icecast and Shoutcast, while this post does not want to highlight the pro and cons of one versus the other, we want to share a solution for streaming clients running in Linux, via a terminal. 

Linux is an operating system not easy, but with a lot of features and solutions. And it’s free so it is worth spending a little bit more time (I mean hours and days) trying to find a good solution for your needs. My need was a client streaming mp3 audio from a server without a user interface to an Icecast server and to a Shoutcast server.

I need a Linux client that can stream a playlist of files to Icecast and/or Shoutcast 

There are multiple solutions that can do this:

  • Ezstream is a Linux client, but it works only with the Icecast server
  • Liquidsoap can handle both Icecast and Shoutcast, but the installation process can be tricky (more tricky than I expected) on a CentoOS machine
  • Darkice can stream both Icecast and Shoutcast but does not allow the stream of a playlist
  • mpd/mpc solution can be done, but it’s not so easy to configure
  • Butt is a graphical tool and the terminal command can not do everything we need. And it doesn’t allow the streaming of a playlist

But I have some constraints: first of all the Operating System is a Linux CentOS distro, and this can not be changed. Then I need something that can handle a playlist of files, in fact, my use case is the summer/holiday stop a web radio (https://www.radiocittaperta.it where I have also a show Katzenjammer). The files are the podcast of all the shows recorded during the year, and the server is the computer where the website is. 

So after digging, searching, and googling, I’ve found that the perfect and easiest solution is to use VLC. VLC is a well-known software for playing almost any kind of files but maybe not everyone knows that it can be used also to stream to an Icecast or Shoutcast server and, also, that can be used without a user interface. So here is the command line used to stream.


cvlc --color dshow://dshow-adev="" "/path/playlist.m3u" --sout-keep --sout  "#std{access=shout{name=your radio name,description=your radio description,url=https://www.yourwebsite.com,mp3=1,bitrate=128},mux=mp3,dst=source:admin@your-icecast-host:your-icecast-port/your-endpoint}"

Where:

cvlc is the headless version of vlc binary

playlist.m3u is the playlist of files

looploop the playlist when last file ended

sout-keep it means “do not stop after a file is played (continuously play)

name=your radio name is your radio name

description=your description your radio description

url=https://www.yourwebsite.com a website, if your radio has one

mp3=1 this is needed if you want to stream mp3 files

bitrate=128 this is the bitrate of the stream

dst=source:admin@your-icecast-host:your-icecast-port/your-endpoint these are all the host, port, endpoint, username and password of your icecast server.

This will simply stream to a server, suppose it is an Icecast server, so if you also want to stream to an icecast server you should double this command but, lucky for us, there is a more advanced command that can do this for us:

 

/usr/bin/cvlc --color dshow://dshow-adev="" "/home/admin56306114/playlist.m3u" --sout-keep --sout '#duplicate{dst=std{access=shout{name=your radio name,description=your radio description,url=https://www.yourwebsite.com,mp3=1,bitrate=128},mux=mp3,dst=source:admin@your-icecast-host:your-icecast-port/your-icecastcast-endpoint},dst=std{access=shout{name=your radio name,description=your radio description,url=https://www.yourwebsite.com,mp3=1,bitrate=128},mux=mp3,dst=source:admin@your-shoutcast-host:your-shoutcast-port/your-shoutcast-endpoint}}' > /dev/null 2>&1 &

 

> /dev/null 2>&1 & it means: do this in the background and do not bother me with useless log lines! 

 Thanks to the duplicate option we can send the same stream to multiple servers. Options and values are easy to understand and configure.

MiroAdmin