AzuraCast uses Icecast (currently Icecast 2.4.0-kh10-ac4) to broadcast live radio.
Icecast has an option to prepend a media file to the live stream when a new listener connects.
This is what the Icecast Documentation has to say about the <intro>
option (my bold):
An optional value which will specify the file those contents will be sent to new listeners when they connect but before the normal stream is sent. Make sure the format of the file specified matches the streaming format. The specified file is appended to webroot before being opened.
Same format
To be absolutely sure the intro file had exactly the same encoding format as the stream, I used a short dump of the stream (mplayer -dumpstream <mountpoint_url>
) to use as an intro file for testing.
Directly editing icecast.xml? No.
Now, the Icecast configuration file for a station is typically located at /var/azuracast/stations/<station_slug>/config/icecast.xml
on the server on which AzuraCast is running (with default settings).
The first problem I encountered is that AzuraCast overwrites the icecast.xml
file everytime it starts or restarts Icecast, so it can't be edited directly.
Changing Icecast settings from within AzuraCast
I luckily managed to override (some of) the Icecast settings by entering JSON in the Custom Configuration field (found under Edit Profile > Broadcasting). Here is an example:
{
"location" : "Overrides location",
"mount" : [{
"intro" : "/intro-128.mp3"
},{
"intro" : "/intro-64.aac"
}],
"paths" : {
"webroot" : "/usr/local/share/icecast/web"
},
"directory" : {
"yp-url-timeout" : "15",
"yp-url" : "http://dir.xiph.org/cgi-bin/yp-cgi"
}
}
And this successfully translates into XML inside icecast.xml
when Icecast is restarted (just keeping relevant tags):
<icecast>
<location>Overrides location</location>
...
<mount type="normal">
<mount-name>/radio.mp3</mount-name>
...
<intro>/intro-128.mp3</intro>
</mount>
<mount type="normal">
<mount-name>/radio.aac</mount-name>
...
<intro>/intro-64.aac</intro>
</mount>
<paths>
<basedir>/usr/local/share/icecast</basedir>
<webroot>/usr/local/share/icecast/web</webroot>
...
</paths>
...
<directory>
<yp-url-timeout>15</yp-url-timeout>
<yp-url>http://dir.xiph.org/cgi-bin/yp-cgi</yp-url>
</directory>
</icecast>
But no, it won't play...
But I can't figure out a combination of <intro>
and <webroot>
settings to make it work.
Hey! Webroot doesn't exist!
Weird thing: the default <webroot>
value doesn't even exist on the server. I tried creating the path and putting the intro file there, but it wouldn't play (even after restarting Icecast), nor would it show when you requested http://<host:port>/intro-128.mp3
directly (which you would expect since it sits right in the web root).
And when I changed the value of <webroot>
to another directory, the Icecast web frontend stopped working (although the streams still worked), and requesting directly the intro file didn't work neither.
It makes me suspect that AzuraCast somehow "redirects" Icecast's requests to the filesystem in some way.
Docker? In or out?
My AzuraCast is running in a Docker installation, within a VPS. Of course, all these paths and files do reside inside the Docker volume. But just to be sure, I also tried creating the paths directly on the host server, with no success so far.
(Yep, changes are in effect.)
I confirm that the changes in icecast.xml
are in effect, since I can see the overriden location on Icecast and the stream gets registered on dir.xiph.org.