PHP to check if audio present in stream.

I would like to setup a local system to check Icecast or Shoutcast streams, and if audio is present, it will recheck in ~15-30 minutes. If audio is not present it will send an email to a designated address.

This is a personal script for use of my internet radio station. Just noticed it keeps going offline every so often, figured there has to be a way to do this using PHP.

I also have a player (VLC) installed on the server itself, so that can also be used as a resource. Does anyone have any ideas how this can be accomplished.

this looks like it will do more than enough easily:
http://radiosolution.info/clients/knowledgebase/36/Now-playing-script-for-Shoutcast.html

That script doesn’t appear to actually check the audio stream itself. It appears to just get information from the Shoutcast server it’s connected to. I want to actually check the audio stream itself, and see if audio is present in the stream. If there is no audio, or dead air…it will then trigger an email.

it checks current status, says whether a stream is present (online) or not, how many users, and says what track is currently playing.

if none of those can give you the information you need (as in, the server hangs, pretends to be playing a song and freezes number of listeners, keeps a stream open but doesn’t put any audio through)… then you REALLY should be looking into WHY that is happening, rather than trying to write a script to alert you when it does.

i know that’s not the answer you want, but i really mean it. trying to detect whether an OPEN shoutcast stream is actually playing audio is a very dirty workaround to a properly functioning server. aka i don’t know how to do that.

The reason this system cant be used by me is because i have two seperate computers running the stream. One running the actual encoding software (edcast) and one running the automation software.

So even if the automation software stops running, the streaming servers will remain online. So it will never reflect as offline because the streaming servers are redundant, so they’re always online, always connected.

I appreciate the script link though. It may help someone else. I’m not concerned with difficulty of doing it. I just want to know if it’s possible, and if someone has done it, a code snippet if possible.

yeah i understand then. going in a different direction, if I were you I would be using windows batch scripting to check if the automation software has crashed, or if the processor or disk usage dropped below an expected level. to me the audio bit complicates things.

just fyi, you can implement batch files into your php scripts (advanced, dangerous) via exec, and have php handle the mail function. however you can do it all with bat
[php]exec(“mybatch.bat”);[/php]

I would rather not use batch scripting to do this, only because most other functions already use batch scripting (we have a pretty advanced setup with the automation system). I would prefer to just to use the audio. Seems to me the only way I’ll get a definitive answer from our system in a timely manner. Because the automation system has batch scripts running in the background, and our automation software is very memory and processor hungry, i’m wary about adding any additional systems that will reduce the quality of the station or of the automation software.

I just read sites like TuneIn.com use VLC and PHP to check if streams are running, and if audio is present. So I know it’s possible. I’m just wondering how it can be accomplished.

yeah that i don’t know.

i’m sure you’ve found these, but anyway:


good luck!

I use the BUTT (Broadcast Using This Tool) software (BUTT - Broadcast Using This Tool) on a laptop to broadcast my internet radio station, MemphisWeather.APP, at https://usa10.fastcast4u.com:3210/1. It is has been running for several months without any downtime.

Sponsor our Newsletter | Privacy Policy | Terms of Service