[How To] OpenWrt - High quality Audio Streaming Server (file playlist or USB audio input) over local lan and/or internet

Tested on Barrier Breaker, LEDE 17.01, OpenWrt 18.06.x and 19.07.2 (does not work on newer releases, see below)

WARNING: DO NOT upgrade from libopenssl 1,0 to 1.1 or ICES won't work anymore.

note: USB /overlay extra space is needed to locally store the ".ogg" music files or else you need to mount an external network storage for this (adapt music path in config files for this case).

See the end of this post for instructions how to stream Audio from the USB dongle input (microphone).

  • install software:
opkg update
opkg install libshout ices libtheora libspeex alsa-lib kmod-sound-core kmod-input-core icecast libxslt libcurl libvorbisidec librt
opkg install wget openssl-util 
opkg install libustream-openssl ca-certificates
  • disable icecast autostart at boot:
/etc/init.d/icecast disable
/etc/init.d/icecast stop
  • create local user (icecast does not start as user root)
opkg install shadow-useradd
useradd pilovis
passwd pilovis
mkdir /home
mkdir /home/pilovis
chown pilovis /home/pilovis
  • remove icecast default configuration file:
cp /etc/icecast.xml /etc/icecast.xml.orig
rm  /etc/icecast.xml
  • edit new icecast configuration file:
nano /etc/icecast.xml
<icecast>

  <!-- LIMITS -->
  <limits>
    <clients>10</clients>
    <sources>10</sources>
    <threadpool>5</threadpool>
    <queue-size>524288</queue-size>
    <client-timeout>30</client-timeout>
    <header-timeout>15</header-timeout>
    <source-timeout>10</source-timeout>
    <burst-on-connect>1</burst-on-connect>
    <burst-size>65535</burst-size>
  </limits>

  <!-- GENRIC -->
  <authentication>
    <source-password>changeme!</source-password>
    <admin-user>admin</admin-user>
    <admin-password>changeme!</admin-password>
  </authentication>
  <hostname>localhost</hostname>
  <listen-socket>
    <port>8000</port>
  </listen-socket>
  <fileserve>1</fileserve>

  <!-- PATHES -->
<paths>
        <!-- basedir is only used if chroot is enabled -->
        <basedir>/usr/share/icecast</basedir>

        <!-- Note that if <chroot> is turned on below, these paths must both
             be relative to the new root, not the original root -->
        <logdir>/tmp</logdir>
        <webroot>/usr/share/icecast/web</webroot>
        <adminroot>/usr/share/icecast/admin</adminroot>
        <!-- <pidfile>/usr/share/icecast/icecast.pid</pidfile> -->

        <!-- Aliases: treat requests for 'source' path as being for 'dest' path
             May be made specific to a port or bound address using the "port"
             and "bind-address" attributes.
          -->
        <!--
        <alias source="/foo" destination="/bar"/>
        -->
        <!-- Aliases: can also be used for simple redirections as well,
             this example will redirect all requests for http://server:port/ to
             the status page
        -->
        <alias source="/" destination="/status.xsl"/>
        <!-- The certificate file needs to contain both public and private part.
             Both should be PEM encoded.
        <ssl-certificate>/usr/share/icecast/icecast.pem</ssl-certificate>
        -->
    </paths>

  <!-- LOG -->
  <logging>
    <accesslog>access.log</accesslog>
    <errorlog>error.log</errorlog>
    <playlistlog>playlist.log</playlistlog>
    <loglevel>1</loglevel>
    <logsize>10000</logsize>
    <logarchive>1</logarchive>
  </logging>

  <!-- SECURITY -->
  <security>
    <chroot>0</chroot>
    <changeowner>
      <user>pilovis</user>
      <group>nogroup</group>
    </changeowner>
  </security>

</icecast>
  • create and edit ices configuration file:
nano /etc/ices.xml
<ices>

  <!-- GENERIC -->
  <background>1</background>
  <pidfile>/var/run/icecast/ices1.pid</pidfile>

  <!-- LOGGING -->
  <logpath>/tmp</logpath>
  <logfile>ices1.log</logfile>
  <logsize>2048</logsize>
  <loglevel>3</loglevel>
  <consolelog>0</consolelog>

  <!-- STREAM -->
  <stream>
    <metadata>
      <name>Radio88</name>
      <genre>Varios</genre>
      <description>OpenWRT Test Radio</description>
      <url>http://openwrt:8000/</url>;
    </metadata>
    <input>
      <param name="type">basic</param>
      <param name="file">/root/playlist1.txt</param>
      <param name="random">1</param>
      <param name="once">0</param>
      <param name="restart-after-reread">1</param>
    </input>
    <instance>
      <hostname>localhost</hostname>
      <port>8000</port>
      <password>changeme!</password>
      <mount>/Radio88</mount>
    </instance>
  </stream>

</ices>
  • download some free .ogg music files in /root/music directory:

https://patrickdearteaga.com/royalty-free-music/

mkdir /root/music
cd /root/music
wget https://patrickdearteaga.com/audio/Not%20Giving%20Up.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Spring%20Village.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/La%20Llamada%20de%20Ile.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Las%20Dos%20Fronteras.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Vals%20de%20su%20jard%C3%ADn%20A.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Voices%20From%20Heaven.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/No%20Place%20For%20Straw%20Cowboys.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Lyonesse.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Friends.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/I%20Miss%20You.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Kiss%20And%20Goodbye.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/2nd%20Sonata%20-%20Malign%20Chords.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Anguish.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Blues.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/El%20Postre.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/My%20Memory%20Lane.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Meitpower.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Lord%20Mavras.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/La%20Verdad.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Helplessness%20in%20Kowasni.ogg --no-check-certificate
wget https://patrickdearteaga.com/audio/Happy%20Ending.ogg --no-check-certificate

  • create playlist file (you need to regenerate it every time you add or remove files in music directory):

Note: playlist ices repeat option with only one Ogg file listed won’t work

rm /root/playlist1.txt
find /root/music -name "*.ogg" > /root/playlist1.txt

  • reboot the router

  • start icecast and ices:
/usr/bin/icecast -b -c /etc/icecast.xml
/usr/bin/ices /etc/ices.xml
  • test icecast streaming server from your PC:

http://router-ipaddress:8000

cpu and memory usage - OpenWrt @300 Mhz CPU & 64 Mbytes RAM (32 is enough)

 PID  PPID USER     STAT   VSZ %VSZ %CPU COMMAND
 5479     1 pilovis  S     6904  11%   1% /usr/bin/icecast -b -c /etc/icecast.xml
 5489     1 root     S     6960  12%   1% /usr/bin/ices /etc/ices.xml

note that icecast runs as normal user "pilovis" and ices as user "root"

If you have a router with just 32 Mbytes of ram memory, I would suggest you to install zram-swap package to virtually increase the available ram:

opkg update
opkg install zram-swap

ZRAM is a script to activate swaping on a compressed zram partition.
This could be used to increase the available memory, by using compressed memory.

Streaming server autostart at boot

nano /etc/rc.local


# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/usr/bin/icecast -b -c /etc/icecast.xml
/bin/sleep 3
/usr/bin/ices /etc/ices.xml
/bin/sleep 3
exit 0

note: icecast and ices need some delay when launched at startup by rc.local

beautiful OpenWrt embedded web player (using uhttpd) for your Streaming server,
no client required to listen to the music, just use Firefox browser on your PC/Smartphone/Tablet to open this page and enjoy listening to the music.
This web player page has integrated start/stop and volume controls.

note. it needs an internet connection to work since the skin and the player are hosted on an external site.

thanks to: https://sourceforge.net/projects/ffmp3/ and https://www.muses.org

note that the text at the bottom between the two bars is continuously scrolling from right to left.


Instructions:

cd /www
cp index.html luci.html
rm index.html
nano index.html
<html>
 <head>
  <title>OpenWrt Radio</title>
 </head>
<body>
<hr>
<h1><i>* You're listening to OpenWrt Radio *</i></h1>
<p>
<hr>

<!-- BEGINS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->
<script type="text/javascript" src="https://hosted.muses.org/mrp.js"></script>
<script type="text/javascript">
MRP.insert({
'url':'http://192.168.1.1:8000/Radio88',
'lang':'en',
'codec':'ogg',
'volume':75,
'autoplay':true,
'jsevents':true,
'buffering':0,
'title':'Openwrt Radio',
'welcome':'Welcome',
'wmode':'transparent',
'skin':'combat',
'width':675,
'height':247
});
</script>
<!-- ENDS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->

<p>
<hr>
<marquee behavior="scroll" direction="left">OpenWrt Free Radio, only royalty free music ! </marquee>
<hr>

<iframe src="http://free.timeanddate.com/clock/i5zx8pk0/n254/tlit6/fs20/ftb/tt0/td2/th1" frameborder="0" width="369" height="24"></iframe>

</body></html>

Notes:
on the above code change http://192.168.1.1:8000/Radio88 with your OpenWrt streaming router IP address
to get access to luci control panel use : http://yourRouterIP/luci.html
to get access to this player page use: http://yourRouterIP!

if you prefere hosting all files, including skin and flash player directly on the router (eg. for local streaming without internet connection), here are the files and the modified html code you need:

https://downloads.sourceforge.net/project/ffmp3/Version%201.2/muses-1.2.zip
https://www.muses.org/skins/combat.zip

unzip the above two files and put all extracted files in the /www directory of your OpenWrt router

nano /www/index.html

<html>
 <head>
  <title>OpenWrt Free Radio</title>
 </head>
<body>

<hr>
<h1><i>* You're listening to OpenWrt Free Radio *</i></h1>

<p>
<hr>

<!-- BEGINS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="760" height="280">
<param name="movie" value="muses.swf" />
<param name="flashvars" value="url=http://192.168.1.1:8000/Radio88&lang=auto&codec=ogg&volume=75&introurl=&autoplay=true&tracking=true&jsevents=true&skin=ffmp3-combat.xml&title=OpenWrt%20Radio&welcome=welcome" />
<param name="wmode" value="transparent" />
<param name="allowscriptaccess" value="always" />
<param name="scale" value="noscale" />
<embed src="muses.swf" flashvars="url=http://192.168.1.1:8000/Radio88&lang=auto&codec=ogg&volume=75&introurl=&autoplay=true&tracking=true&jsevents=true&skin=ffmp3-combat.xml&title=OpenWrt%20Radio&welcome=welcome" width="760" scale="noscale" height="280" wmode="transparent" allowscriptaccess="always" type="application/x-shockwave-flash" />
</object>
<!-- ENDS: AUTO-GENERATED MUSES RADIO PLAYER CODE -->

<hr>
<marquee behavior="scroll" direction="left">OpenWrt Free Radio, only royalty free music ! </marquee>
<hr>

<iframe src="http://free.timeanddate.com/clock/i5zx8pk0/n254/tlit6/fs20/ftb/tt0/td2/th1" frameborder="0" width="369" height="24"></iframe>
</body></html>

hello,
could you help?

set up the icecast and running but songs not showing up

<ices>

  <!-- GENERIC -->
  <background>1</background>
  <pidfile>/var/run/icecast/ices1.pid</pidfile>

  <!-- LOGGING -->
  <logpath>/tmp</logpath>
  <logfile>ices1.log</logfile>
  <logsize>2048</logsize>
  <loglevel>3</loglevel>
  <consolelog>0</consolelog>

  <!-- STREAM -->
  <stream>
    <metadata>
      <name>Vicinity Radio</name>
      <genre>Various</genre>
      <description>Local Vicinity Music</description>
      <url>http://freeaccess.vicinity:8000/mizik/songs</url>;
    </metadata>
    <input>
      <param name="type">basic</param>
      <param name="file">/mnt/sda1/vicinityweb/mizik/songs/playlist1.txt</param>
      <param name="random">1</param>
      <param name="once">0</param>
      <param name="restart-after-reread">1</param>
    </input>
    <instance>
      <hostname>FreeAccess.Vicinity</hostname>
      <port>8000</port>
      <password>lololo</password>
      <mount>/Radio88</mount>
    </instance>
  </stream>

</ices>
<icecast>

  <!-- LIMITS -->
  <limits>
    <clients>10</clients>
    <sources>10</sources>
    <threadpool>5</threadpool>
    <queue-size>524288</queue-size>
    <client-timeout>30</client-timeout>
    <header-timeout>15</header-timeout>
    <source-timeout>10</source-timeout>
    <burst-on-connect>1</burst-on-connect>
    <burst-size>65535</burst-size>
  </limits>

  <!-- GENRIC -->
  <authentication>
    <source-password>lololo</source-password>
    <admin-user>admin</admin-user>
    <admin-password>lololo</admin-password>
  </authentication>
  <hostname>freeaccess.vicinity</hostname>
  <listen-socket>
    <port>8000</port>
  </listen-socket>
  <fileserve>1</fileserve>

  <!-- PATHES -->
<paths>
        <!-- basedir is only used if chroot is enabled -->
        <basedir>/usr/share/icecast</basedir>

        <!-- Note that if <chroot> is turned on below, these paths must both
             be relative to the new root, not the original root -->
        <logdir>/tmp</logdir>
        <webroot>/usr/share/icecast/web</webroot>
        <adminroot>/usr/share/icecast/admin</adminroot>
        <!-- <pidfile>/usr/share/icecast/icecast.pid</pidfile> -->

        <!-- Aliases: treat requests for 'source' path as being for 'dest' path
             May be made specific to a port or bound address using the "port"
             and "bind-address" attributes.
          -->
        <!--
        <alias source="/foo" destination="/bar"/>
        -->
        <!-- Aliases: can also be used for simple redirections as well,
             this example will redirect all requests for http://server:port/ to
             the status page
        -->
        <alias source="/" destination="/status.xsl"/>
        <!-- The certificate file needs to contain both public and private part.
             Both should be PEM encoded.
        <ssl-certificate>/usr/share/icecast/icecast.pem</ssl-certificate>
        -->
    </paths>

  <!-- LOG -->
  <logging>
    <accesslog>access.log</accesslog>
    <errorlog>error.log</errorlog>
    <playlistlog>playlist.log</playlistlog>
    <loglevel>1</loglevel>
    <logsize>10000</logsize>
    <logarchive>1</logarchive>
  </logging>

  <!-- SECURITY -->
  <security>
    <chroot>0</chroot>
    <changeowner>
      <user>music</user>
      <group>nogroup</group>
    </changeowner>
  </security>

</icecast>
/mnt/sda1/vicinityweb/mizik/songs/06. Something Human.mp3
/mnt/sda1/vicinityweb/mizik/songs/14. Propaganda (Acoustic Version).mp3
/mnt/sda1/vicinityweb/mizik/songs/09. Blockades.mp3
/mnt/sda1/vicinityweb/mizik/songs/15. Something Human (Acoustic Version).mp3
/mnt/sda1/vicinityweb/mizik/songs/10. Dig Down.mp3
/mnt/sda1/vicinityweb/mizik/songs/04. Propaganda.mp3
/mnt/sda1/vicinityweb/mizik/songs/03. Pressure.mp3
/mnt/sda1/vicinityweb/mizik/songs/13. The Dark Side (Alternate Reality Version).mp3
/mnt/sda1/vicinityweb/mizik/songs/16. Dig Down (Acoustic Gospel Version).mp3
/mnt/sda1/vicinityweb/mizik/songs/11. The Void.mp3
/mnt/sda1/vicinityweb/mizik/songs/05. Break it to Me.mp3
/mnt/sda1/vicinityweb/mizik/songs/02. The Dark Side.mp3
/mnt/sda1/vicinityweb/mizik/songs/08. Get Up and Fight.mp3
/mnt/sda1/vicinityweb/mizik/songs/01.Algorithm.mp3
/mnt/sda1/vicinityweb/mizik/songs/07. Thought Contagion.mp3
/mnt/sda1/vicinityweb/mizik/songs/12. Algorithm (Alternate Reality Version).mp3

have you created the playlist file?

Also note that the new IceS 2.x supports sending only Ogg Vorbis stream to an Icecast server, unfortunately it does not support MP3 streams anymore :frowning:

Yes, thats what ive found while documenting the issue.
thanks.

must amend the title
how-to-openwrt-icecast-oggfiles-streaming-server-over-local-lan-and-or-internet

Audio Volume Normalization

Sometimes some of the .ogg files have bad audio volume, too low or too high.

An interesting solution to normalize volume to all .ogg fle (prior to be stored into openwrt):

ubuntu/debian required:

sudo apt-get install normalize-audio

nano normalize.sh

for audio_file in *.ogg; do
    normalize-ogg $audio_file;
done

chmod 755 normalize.sh

sh normalize.sh

or else

sudo apt-get install vorbisgain

vorbisgain *.ogg

Why not libopus and perhaps (if you have the requisite disk space) libflac? Opus is the more modern successor to the two codecs you mentioned. It covers both full-band music and low-band VoIP use cases. It's basically the swiss army knife of lossy audio, and then FLAC is for lossless.

Script to convert .mp3 audio files in .ogg

required ubuntu linux

sudo apt-get install ffmpeg vorbis-tools libvorbis-dev

cd to mp3 direcory and do the followings:

nano mp3toogg.sh

# script to convert mp3 to ogg audio files
for file in *.mp3;
   do ffmpeg -i "${file}" -acodec libvorbis "${file/%mp3/ogg}"; 
done

chmod 755 mp3toogg.sh

./mp3toogg.sh

If you have music files with spaces in filename, it is better to rename the files removing spaces, this is the shell command (replace space with underscore):

for f in *\ *; do mv "$f" "${f// /_}"; done

To remove all weird characters in filename except underscore:

for file in *; do mv "$file" $(echo "$file" | sed -e 's/[^A-Za-z0-9._-]/_/g'); done &

Because flash player is not anymore supported, this is a simple html5 player to be hosted in the openwrt icecast router (in /www directory)

Assuming your router IP address is 192.168.1.164 (change it in the above code):

nano player.html

<head>
    <meta charset="utf-8">
    <title>Web4Radio Player</title>
    <meta content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no" name="viewport">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/normalize/2.1.1/normalize.css">
    <link rel="stylesheet" href="//cdn.jsdelivr.net/jplayer/2.4.0/skin/blue.monday/jplayer.blue.monday.css">
    <style>
        div.jp-audio {
            width:275px;
        }

        div.jp-audio div.jp-type-single a.jp-mute,
        div.jp-audio div.jp-type-single a.jp-unmute {
            margin-left:50px;
        }
        div.jp-audio div.jp-volume-bar {
            left:130px;
        }

        .hidden {
            display: none;
        }
    </style>
    <!--[if lt IE 9]>
    <script src="//cdn.jsdelivr.net/html5shiv/3.6.1/html5shiv.min.js"></script>
    <![endif]-->
    <script>
        "use strict";
        // Start Web4Radio options
        var streamName = "Radio88"; // Station name
        var streamAddress = "192.168.1.164"; // Streaming server address
        var streamPort  = 8000; // Streaming server port
        var mp3Mount = "Radio88"; // Leave empty if shoutcast; no /
        var oggMount = "Radio88"; // Leave empty if you don't have an ogg stream; no /
        var autoPlay = true; // Automatic play - true of false - does not work for Android browsers
        // End Web4radio options
    </script>
</head>
    <body>
        <div id="web4radio_1" class="jp-jplayer"></div>
        <div id="jp_container_1" class="jp-audio">
            <div class="jp-type-single">
                <div class="jp-gui jp-interface">
                    <ul class="jp-controls">
                        <li><a href="javascript:;" class="jp-play" tabindex="1">play</a></li>
                        <li><a href="javascript:;" class="jp-pause" tabindex="1">pause</a></li>
                        <li><a href="javascript:;" class="jp-mute" tabindex="1" title="mute">mute</a></li>
                        <li><a href="javascript:;" class="jp-unmute" tabindex="1" title="unmute">unmute</a></li>
                        <li><a href="javascript:;" class="jp-volume-max" tabindex="1" title="max volume">max volume</a></li>
                    </ul>
                </div>
                <div class="jp-volume-bar">
                    <div class="jp-volume-bar-value"></div>
                </div>
                <div class="jp-time-holder">
                    <div class="jp-current-time"></div>
                </div>
                <div class="jp-title">
                    <ul>
                        <li id="title"></li>
                        <li id="current_song"></li>
                    </ul>
                </div>
                <div class="jp-no-solution">
                    <span>Update Required</span>
                    To play the media you will need to either update your browser to a recent version or update your <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash plugin</a>.
                </div> <!-- End #jp_container_1 -->
            </div> <!-- End .jp-type-single -->
        </div> <!-- End .jp-gui .jp-interface -->
        <p id="android" class="hidden">Android users need to press play</p>
        <div id="old-android" class="hidden">
            <p>Your browser is not compatible with the plaver. Mozilla Firefox for Android is.</p>
            <a href="https://play.google.com/store/apps/details?id=org.mozilla.firefox">Get Firefox</a>
        </div>

    <script src="//cdn.jsdelivr.net/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <script src="//cdn.jsdelivr.net/jplayer/2.4.0/jquery.jplayer.min.js"></script>
    <script>
        "use strict";
        $(document).ready(function(){
            var android = navigator.userAgent.indexOf("Android") !== -1;
            var baseUrl = "http://" + streamAddress + ":" + streamPort + "/";
            var formats = "";

            if (mp3Mount === "" && oggMount === "")
            {
                // We have a shoutcast stream, override UA detection
                mp3Mount = ";";
            }

            if (mp3Mount != "")
            {
                formats = "mp3";

                if (oggMount != "")
                {
                    formats += ", oga";
                }
            }

            else if (oggMount != "")
            {
                formats = "oga";
            }

            $("title").text(streamName + " Player");
            $("#title").text(streamName);

            $("#web4radio_1").bind($.jPlayer.event.play, function(event) {
                if (android) {$("#android").hide();}
                setTimeout(function() {
                    var time = $("#web4radio_1").data("jPlayer").status.currentTime
                    if (android && time === 0) {
                        // If playback didn't start by now, it's probably a stock browser on Android < 4.1
                        $("#web4radio_1").jPlayer("stop");
                        $("#old-android").show();
                    }
                }, 6000)
            });

            if (android) {$("#android").show();}

            $("#web4radio_1").jPlayer({
                ready: function () {
                    $(this).jPlayer("setMedia", {
                        oga: baseUrl + oggMount,
                        mp3: baseUrl + mp3Mount

                    })

                    if (autoPlay) {$(this).jPlayer("play");}
                },
                ended: function(event) {
                    $(this).jPlayer("play");
                },
                swfPath: "//cdn.jsdelivr.net/jplayer/2.4.0",
                supplied: formats, // Prefer MP3 because OGG with metadata is buggy in Google Chrome
                solution: "flash, html" // HTML5 does not recover from a broken connection in most browsers
            });
        });
        </script>
    </body>
</html>

Screenshot 2021-10-21 at 15-54-48 Radio88 Player


credits: https://github.com/seanthegeek/Web4Radio/

to get the current playing song:

tail -f /tmp/playlist.log

the result in my case is the following:

root@OpenWrt:~# tail -f /tmp/playlist.log 
21/Oct/2021:17:36:40 +0200|/Radio88|1|Crash Test Dummies - Mmm Mmm Mmm Mmm
21/Oct/2021:17:40:14 +0200|/Radio88|1|Toni Braxton - I Don't Want To
21/Oct/2021:17:44:21 +0200|/Radio88|1|Abba - Eagle
21/Oct/2021:17:54:00 +0200|/Radio88|1|Neil Diamond - Forgotten
21/Oct/2021:17:58:10 +0200|/Radio88|1|Govi - Voices In The Wind
21/Oct/2021:18:02:28 +0200|/Radio88|1|Dolly Parton - In The Ghetto
21/Oct/2021:18:05:04 +0200|/Radio88|1|Tina Turner - On Silent Wings
21/Oct/2021:18:09:02 +0200|/Radio88|1|Paul McCartney - No More Lonely Nights
21/Oct/2021:18:13:17 +0200|/Radio88|1|MNEK - Head & Heart (feat. MNEK)
21/Oct/2021:18:15:55 +0200|/Radio88|1|Shania Twain - GOD AIN'T GONNA GETCHA FOR THAT

to get just the current song name:

tail -1 /tmp/playlist.log | cut -d " " -f "2-" | cut -c 18- 

to get the current playing file:

tail -1 /tmp/ices1.log  | cut -d " " -f "6-"

This is my OpenWRT Internet Radio Receiver:

I want to pipe from librespot to sox and then into my icecast but something went wrong all the time.
This cmd worked to create a mp3 file wich sound fine.

./librespot --limit-sink-write --disable-audio-cache --backend pipe | sox -t s16 -r 44100 -c 2 - -t mp3 - | tee song.mp3

But how is the way to pipe something like this into icecast or ices?
I thought I need to do it with stdinpcm as input....

  • To stream audio from USB audio device (microphone input) to your LAN or to Internet.

5oOBA

note: you need at least 600 MHz CPU and 48 MB of ram (and enough USB overlay space).

  • prerequsites in addition to Icecast (see above)
opkg update
opkg install kmod-sound-core kmod-usb-audio
opkg install kmod-sound-i8x0 kmod-sound-soc-core
opkg install alsa-lib alsa-utils lame mpg123
opkg install ffmpeg
  • command (single line) to pipe audio from microphone input (USB audio dongle) to Icecast:

/usr/bin/ffmpeg -ac 1 -f alsa -acodec pcm_s16le -ar 22000 -vol 1500 -i hw:0,0 -acodec mp3 -content_type audio/mpeg -f mp3 icecast://source:CHANGEME@localhost:8000/Radio88 &

note: change "CHANGEME" with the Icecast source password you set in the file /etc/icecast.xml (see above).
You can modify the parameter -vol 1500 on the above command to change the audio input volume (increase or decrease the value)
You can also send the audio pipe to an external Icecast server, to do so put the IP address of the server at place of "localhost" (with its password).

note: change "yourIPaddress" with the local IP address of your Icecast OpenWrt router (or the IP of the external Icecast server)

Please note the streaming audio is not a really realtime, the audio delay depends on many factors, in this case is about 4 - 5 seconds.