2
votes

I am trying to embed an html5 audio tag in a page to allow playing a live AAC+ stream coming from an Icecast server.

According to the media formats developer's guide, Android supports playback for several AAC flavors, either inside an MPEG-4 container or in ADTS.

I have successfully played AAC-encoded audio files in an MPEG-4 container, thus:

<audio controls="controls">
  <source src="http://www.example.com/audio/program1.mp4" type="audio/mp4"/>
</audio>

However, I have not been able to play any AAC live stream (which, as far as I understand, is output by Icecast using ADTS) with the audio tag. I have tried setting different types (e.g., "audio/aac", which the player says it can "probably" play) as well as different file extensions for the stream URL. Nothing works. The player, by the way, initializes as if everything is OK, then when you press the play button nothing happens (other than the play button changing to a pause icon).

The only way I have been able to play a live AAC stream is by using a URL pointing to a .sdp manifest containing a link to an RTSP version of the stream. The browser then hands off the stream to the native audio player or another audio app, which plays it after a brief buffering period. This is not an option for us, as we would like to use a simple Icecast server for our stream.

Is there just no way to play a live AAC stream on Android via HTTP? It seems iOS supports it, but not Android.

1
Could you check and make sure what format of AAC Icecast outputs?Danijel
That developers guide is for when using the Android SDK (it has its own media player functionality) and wont apply to an HTML video tag. Does your own link of AAC (with ADTS) work on Android if you use this demo? Also about play button changing... is it possible you need to wait just a bit for download buffer to fill up? And there are no internet data restrictions (like no large media streaming) going on?VC.One
@Danijel: Here is what ffprobe reports for the AAC stream: Duration: N/A, bitrate: 63 kb/s; Stream #0:0: Audio: aac (HE-AACv2), 44100 Hz, stereo, fltp, 63 kb/sEK0
@VC.One: My stream plays fine on a desktop when I load its URL in the suggested demo page, but on Android after clicking play the log says "play, playing, stalled". The same thing happens with the stream in the original demo link. I understand that the developer guide refers to the Android SDK; I was just hoping that both the html5 audio tag and the media API would call the same native player libraries.EK0
@VC.One: The player will say "stalled" when it's buffering (say, an mp3 stream, in which case playback eventually starts). In the case of the AAC streams I tried, it stays that way for several minutes and playback never starts. I don't think there are any bandwidth restrictions (e.g., live streaming video works well with this connection).EK0

1 Answers

0
votes

From the lack of responses to the contrary, I have to conclude that the answer to the original question is, "No, it is not possible to use the HTML5 audio tag to play a live AAC+ stream from an Icecast server".

I am posting an answer to share what I ended up doing.

My first inclination was simply to set up a second Icecast stream using MP3 instead of AAC. This will work, but you must be willing to accept the buffering delay that Android's audio player introduces with MP3 streams. Unfortunately, at 64 kpbs Android makes you wait for over 40 seconds before it will start playing the MP3 stream. Admittedly, 64 kpbs is not very good quality for MP3, but even at 128 kbps the buffering takes over 20 seconds, enough for listeners to conclude that the stream is down. So MP3 is not an option for us.

My eventual solution was to ask our CDN to add a Wowza application that pulls from the AAC+ Icecast stream and transmuxes it using HLS.

Now my audio tag looks like this:

<audio controls="controls">
  <source src="http://www.example.com/wowza/stream.m3u8"/>
  <source src="http://www.example.com/audio/aac"/>
</audio>

Note that I had to list the HLS source first, because otherwise the Android device will actually pick the Icecast stream and try to play it, which it can't (you'd think it would know enough not to do that).

So in the end Android does play a live AAC+ stream with no delay, as long as it is delivered via HLS, and not directly from Icecast. I must say I was very disappointed with Android, both its lack of support for direct Icecast AAC+ and for its poor handling of live MP3 streams, especially since the competition (iOS) handles everything you throw at it without blinking.