Play radio stream in TVHeadend

Right, I’m losing the will to live trying to sort this… I think it’s very simple and I’m just making a pigs ear of it all!

All I want to do is as an MP3 radio stream to TVHeadend within a Coreelec setup!

Take these URLs


what code do I have to put into the Mux section to transcode/pipe it through to appear in the radio section of TVheadend?

Any advice much appreciated

What works for me is:

pipe:///usr/bin/ffmpeg -loglevel fatal -I INSERT_URL_HERE -vn -acodec libmp3lame -metadata service_provider=MAKE_UP_A_NAME -metadata service_name=NAME_OF_CHANNEL -f mpegts -mpegts_service_type digital_radio pipe:1

I just tested on my TVH 4.3 server and both streams work no problem. Make sure however, that you’ve set the “type override” of the services to “Radio”, otherwise Kodi assumes they’re video streams. Map them to channels and then you’re golden.

1 Like

Thank you!!

now to spend the next hour adding stations!


Thanks I didn’t think such thing was possible to do …

I have created a playlist with the correct syntax to make a number of radio streams work with TVHeadened. Note sure it will be to everyone’s taste but it’s going to keep my house happy!

It can be added in the same way a IPTV playlist can be added…only problem is I can’t upload file as I’m a new user, will pop back in a few days and see if I can upload it then.

Thanks again for your help

No problem. I’ve spent a lot of time making my CoreELEC box into an all-in-one media device, so I game on it, watch live tv, movies, and of course, listen to radio.

If anyone’s interested, has a machine they can run python on and are able to navigate python enough to import modules, I have a simple script that grabs radio stations off of and creates a TVHeadend-compatible M3U8 file. The script will grab local stations by default, and should work with any tunein radio list page—including location lists like

It doesn’t account for geo-location fencing, nor does it scrape streams when tunein directs to external players. YMMV.

File "/home/john/TEST/", line 44
    m3ufile = open(tuneinradiom3u, 'w+')
IndentationError: unindent does not match any outer indentation level

I know nothing of python, just ran the script with the above result.
Suggestions? Thanks.


sed -i "s|  |\t|g"

But it will not work on CE box itself because it needs some extra modules like requests and selenium.

I use the great “radio” app which gives access to thousands of stations from around the world in a simple interface.


Which doesn’t have anything to do with getting a radio stream in TVHeadend, does it?

1 Like

I tried it on my desktop machine running Linux.

python-requests is installed but have no info about selenium … is that also python?

Selenium is a python module. In this case, it connects with the phantomjs driver in order to download a rendered page dump.

You’ll need to install both selenium and phantomjs.

pip install -U selenium

You can also manually download the tar file ( and manually install from the file contained within:

python install

apt install phantomjs

Phantomjs gives a depreciation warning, but ignore it, it’ll work fine regardless.

1 Like

Oh well, I tried.
Apparently phantomjs is not available in this distro’s repository. (PCLinuxOS)

No need to give up so quickly. I’m not that familiar with PCLinuxOS. What distro is it most similar to? Another distro’s PhantomJS may work on PCLINUXOS.

Regardless, it’s only one way of getting a JavaScript rendered pagedump. Headless Chromium or Firefox or even other options are also capable. Do you have either of those two browsers on your system?

1 Like

Here is another version which works without selenium module:

Let me know if works as I expected :slight_smile:

I am apparently doing something wrong or missing something …

$ python ./                 
Traceback (most recent call last):
 File "./", line 137, in <module>
 File "./", line 57, in main
   imageList[children['title']] = children['image']
KeyError: 'image'

Firefox and Chrome are both installed as well as several other browsers.
PCLinuxOS is an individual distro … a fork of Mandrake from way back … and is a rolling release.

New version uploaded.

That produced an .m3u8 file with contents of


# ======================
# TuneIn Radio Playlist
# ======================

The terminal gave
Failed URLs/streams:

I guess I was meant to edit the script?

I edited the ‘local’ url to my actual location and it did indeed produce a populated m3u8 list. :slight_smile:

I have not tested it on the server yet, but will do soon I hope.

For your information, in case it might be important to you, the terminal, as well as listing the found stations also produced the following output

 Traceback (most recent call last):
  File "./", line 145, in <module>
  File "./", line 128, in main
    m3ulink = "#EXTINF:-1 tvg-logo=\"" + thisimage +  "\" tvg-id=\"" + title + "\" group-title=\"MyRadio\" radio=\"true\"," + title + "\npipe:///usr/bin/ffmpeg -loglevel fatal -i " + finalurl + " -vn -acodec libmp3lame -metadata service_provider=" + provider + " -metadata service_name=" + provider + " -f mpegts -mpegts_service_type digital_radio pipe:1\n\n"
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 93: ordinal not in range(128)

Thanks again for doing this … appreciated :smiley:


I think the reason for the errors is that some of the stations are not functioning (at least not in a browser), and the script errors out when it meets such a radio station.
So the list produced is incomplete as all stations following the ‘bad’ one never get listed.