Understanding HLS Streams, and an issue with Volumio

Hi,

TL;DR - I’ve found an issue when trying add a HLS stream within Volumio frontends. Jump to the bottom for details. Otherwise, read on for a primer on HLS streams…

HLS streams in the UK are used by providers such as the BBC, in essence they operate in the following way (for the curious!).

You make a request to a URL, which usually ends in .m3u8 to indicate a playlist. These playlists are text based, and contain references to the underlying media files. For example, here’s on running in my house:

root@volumio:/var/log# curl http://nas:8888/index.m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:5061897
#EXT-X-TARGETDURATION:7
#EXTINF:6.400,Kaizo HLS Relay
bbc_6music-audio=320000-250524399.ts
#EXTINF:6.400,Kaizo HLS Relay
bbc_6music-audio=320000-250524400.ts
#EXTINF:6.400,Kaizo HLS Relay
bbc_6music-audio=320000-250524401.ts
#EXTINF:6.400,Kaizo HLS Relay
bbc_6music-audio=320000-250524402.ts
#EXTINF:6.400,Kaizo HLS Relay
bbc_6music-audio=320000-250524403.ts

A media play starts with the first file, then moves on to the second, until it reaches the end. It then makes another request for the playlist again, and loops around ad infinitum.

So what are these .ts files? Well, they’re simply chunks of underlying media. In the above example, lets’ download one and check it.

wget http://nas:8888/bbc_6music-audio=320000-250524454.ts
....
mediainfo bbc_6music-audio=320000-250524454.ts
....
General
ID                                       : 16727 (0x4157)
Complete name                            : bbc_6music-audio=320000-250524454.ts
Format                                   : MPEG-TS
File size                                : 262 KiB
Duration                                 : 6 s 379 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 333 kb/s

Audio
ID                                       : 34 (0x22)
Menu ID                                  : 16727 (0x4157)
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Format version                           : Version 4
Muxing mode                              : ADTS
Codec ID                                 : 15-2
Duration                                 : 6 s 314 ms
Maximum bit rate                         : 320 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy

So, we can see these are just small sized and short duration Advanced Audio Coding (AAC) files, which are pretty vanilla and supported by most media players (including Volumio).

The Issue

If I add the playlist to the Volumio interface (i.e add a new radio stream) Volumio refuses to add it, and displays the following in the pop up notification box:

Failed to Decode http://nas:8888/bbc_6music-audio=320000-250524454.ts; Invalid sample rate : 0

Adding it via the volumio command line doesn’t return a failure, but it does result in the same error message appearing in the web GUI.

Looking to the underlying logs with MPD, we can see the following incorrect behavior.

Oct 22 09:03 : ffmpeg/mp1: Header missing
Oct 22 09:03 : ffmpeg/mp1: Header missing
Oct 22 09:03 : ffmpeg/mpeg: max_analyze_duration 5000000 reached
Oct 22 09:03 : ffmpeg/mpeg: Estimating duration from bitrate, this may be inaccurate
Oct 22 09:03 : exception: Failed to decode http://nas:8888/bbc_6music-audio=320000-250524592.ts
Oct 22 09:03 : exception: nested: Invalid sample rate: 0
Oct 22 09:03 : player: played "http://nas:8888/bbc_6music-audio=320000-250524592.ts"

It appears as though the MPD is trying to decode the underlying media as mp1 (presumably making a guess.

However, clearing out the playlist via MPD, then adding it does work - an lo, it also plays glorious music.

volumio@volumio:/etc$ mpc clear
volume:100%   repeat: off   random: off   single: off   consume: on 
volumio@volumio:/etc$ mpc add http://nas:8888/index.m3u8
volumio@volumio:/etc$ mpc play 
http://nas:8888/index.m3u8
[playing] #1/1   0:00/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: on 
volumio@volumio:/etc$ mpc status
http://nas:8888/index.m3u8
[playing] #1/1   0:10/0:00 (0%)
volume:100%   repeat: off   random: off   single: off   consume: on 

Checking the logs again, and MPD (when invoked directly) does correctly guess the media type as being mpegts, with ffmpeg handling that media:

Oct 22 09:03 : ffmpeg/mpegts: Estimating duration from bitrate, this may be inaccurate
Oct 22 09:03 : ffmpeg/hls,applehttp: Estimating duration from bitrate, this may be inaccurate
Oct 22 09:03 : player: Decoder is too slow; playing silence to avoid xrun

I’m afraid i don’t clearly understand how the Volumio binaries <-> MPD interact, so I’m looking for advice and guidance in helping to debug the issue. I can provide sample .ts files, along with a sample playlist m3u8 file if that helps.

Thanks for reporting !
We can work on a fix for this

Any update on this?

I’ve been trying to add the BBC Radio 320kbps M3U8 streams to my Volumio webradio with no success and discovered this thread whilst searching for a fix. Happy to assist with testing if it helps.

1 Like

+1 asking about any updates.

The URLs available on the net work fine in, for example, the browser on my phone.

But Volumio refuses to play them.

Example URL: http://a.files.bbci.co.uk/media/live/manifesto/audio/simulcast/hls/uk/sbr_high/ak/bbc_radio_three.m3u8