Setting up IPTV viewing in Plex Media Server

TV in 2022 is a completely different entity when compared and viewed from the side even of the 2010s. Now, few people use a TV in its usual sense – Smart TV applications, all kinds of services, subscriptions or home media centers with network storage. TV is now just a screen for displaying pictures. And television has generally faded into the background or is not at all interesting to the user.

But what if you still keep up with the times and have a home media center based on Plex Media Server, but at the same time do not mind scrolling through TV channels, like in the good old days?

The task is easily solved if you have a DVR tuner or provider in your everyday life, supported by Plex. And the second option is more modern, without wires and dust-collecting receivers – IPTV with an inexpensive playlist and a good TV guide. It is on this option that we will stop. Let’s get started!

Content

  1. Basic data and some theory

  2. Installing Plex Media Server

  3. Preparing an IPTV playlist

  4. Installing and configuring HLS Proxy

  5. Installing and configuring xTeVe

  6. Connecting xTeVe to Plex Media Server

1. Initial data and some theory

My case is based on the Kubuntu 20.04 operating system and Plex Media Server version 1.25.3.5385, an m3u playlist with IPTV channels from the service zedom.net for $1/month and EPG/Picons from epg.it999.ru. Therefore, all installation and configuration manipulations will be focused specifically on Linux, as well as a specific IPTV provider. But this solution is cross-platform and can be easily implemented on other platforms (FreeBSD, OS X, Windows).

Since there is no way to directly connect an m3u playlist in Plex Media Server, because it is waiting for a physical tuner or antenna to be connected, we will have to do a little tricky – we will broadcast for Plex through a software receiver xTeVe. It is important to note that Plex cannot accept an HLS stream.

HLS (m3u8) – stands for HTTP Live Streaming. In this structure, the broadcast server divides the stream into separate mp4 segments of 10 seconds each. This is very handy when an ISP needs to stream in multiple quality options so that the viewer can use the appropriate video bitrate based on network bandwidth. HLS was invented and used by Apple on their devices. The only downside is that HLS has a delay of 10 to 30 seconds.

MPEG-TS (ts) – consists of two parts: MPEG and TS. MPEG – streaming video, TS – transport stream. This format can provide audio, video, and metadata such as subtitles and EPG. MPEG has an error correction feature to keep the video integrity when the signal level is low.

It is in the HLS format that almost all modern IPTV providers broadcast, without the possibility of changing this format. My provider is no exception. Therefore, it will be necessary to convert the HLS broadcast at the input and send it to Plex in the required MPEG-TS format. For this step, we will use HLS Proxy.

It is perceived as complicated and cumbersome, but in practice everything is extremely simple and not difficult to implement. We figured out the theory – let’s get to work.

2. Install Plex Media Server

If you already have a Plex server deployed, skip this step. For a new installation, you need to add the key from the downloads.plex.tv repository and the repository itself:

echo deb https://downloads.plex.tv/repo/deb public main | sudo tee /etc/apt/sources.list.d/plexmediaserver.list
wget -O - https://downloads.plex.tv/plex-keys/PlexSign.key | sudo apt-key add -
sudo apt-get update && sudo apt -y install plexmediaserver

Upon completion of the installation, make sure that the server is correctly installed and running.

systemctl status plexmediaserver
plexmediaserver service started

3. Preparing an IPTV playlist

With registration and payment on the service ZeDomI don’t think there should be any problems. I will not describe it in detail. The first day, by the way, you can try for free.

In your personal account in the “Playlist” section, I recommend choosing only the groups of channels you need (many foreign, not “Russian-speaking”). In addition to choosing groups, I also recommend going through the channels themselves, turning off the ones you don’t need. You can do this in the “Designer” section. So, for example, initially my playlist was 1800+ channels. After turning off the excess, 480 channels remained.

480 channels is not a random number. This is exactly the limit on the number of channels in xTeVe. This must be taken into account, otherwise you will not be able to add a single channel.

The playlist can be used as a local m3u file or as a link – it doesn’t matter. I will use a file with a playlist, due to periodic blocking by the provider.

4. Installing and configuring HLS Proxy

Loading from site archive with the latest stable version for the linux x64 platform. At the time of writing, the current version is 8.0.7.

wget -P /tmp https://www.hls-proxy.com/downloads/8.0.7/hls-proxy-8.0.7.linux-x64.zip

Let’s place HLS Proxy in the /opt/hls-proxy directory, after creating this directory and assigning rights.

sudo mkdir /opt/hls-proxy
sudo chmod -R 0777 /opt/hls-proxy
unzip /tmp/hls-proxy-8.0.7.linux-x64.zip -d /opt/hls-proxy

We make two files executable – hls-proxy and install.sh

chmod +x /opt/hls-proxy/hls-proxy install.sh

Set HTTP port 8080 (or any other if 8080 is already busy) for HLS Proxy. Or you can not configure the port at all, the default is 80.

/opt/hls-proxy/hls-proxy -port 8080 -save -quit

And install the HLS Proxy itself using the script. It will do everything automatically, including adding a unit to the systemd subsystem for autorun

/opt/hls-proxy/install.sh

Upon completion of the installation, check if the hls-proxy service is running

sudo systemctl status hls-proxy
Service started successfully

Now you can go to the HLS Proxy web interface

http://ip_адрес_сервера:порт

If the port is left by default, then just go to the IP address or localhost in the browser. If everything is successful, then you should see such a simple interface

HLS Proxy start page

Go to the server settings (“Open config”) and in the “Playlists” section specify the path to the playlist from zedom.net. Since I will use a local file, I specify the type – “file” and the location of the file /opt/hls-proxy/zedom.m3u.

Adding a playlist to HLS Proxy

In the “TV Guide” section, specify the path to the EPG. I personally use the program with high-quality channel logos from it999.ru.

http://epg.it999.ru/epg2.xml.gz

Adding EPG to HLS Proxy

The rest of the settings can be left as default. Save and go to the main page. Click “Reload playlist” and “Update TV guide”.

EPG Processing

If you did everything correctly, then a list of your channels should be displayed, with the corresponding logos and TV program.

Downloaded and available channels in HLS Proxy

This completes the preparation of the HLS Proxy, for further work with it we need two links to it:

  • http://server_address:port/?output=ts – this is our IPTV playlist already in the required format

  • http://server_address:port/epg – TV guide

5. Installing and configuring xTeVe

The next step is to install xTeVe and get our entire playlist from HLS Proxy in it. To do this, download from the project page to GitHub archive, unpack and place it in the /opt/ directory and make the xteve binary executable.

wget -P /tmp https://github.com/xteve-project/xTeVe-Downloads/blob/master/xteve_linux_amd64.zip
unzip /tmp/xteve_linux_amd64.zip -d /opt/
sudo chmod +x /opt/xteve

You can start xTeVe manually by executing /opt/xteve, and to start xTeVe at system startup, create a unit in the systemd subsystem

sudo mcedit /etc/systemd/system/xteve.service

Insert content

[Unit]
Description=xTeVe Service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStart=/opt/xteve
ExecReload=/usr/bin/killall xteve
ExecStop=/usr/bin/killall xteve
KillMode=process
Restart=always
RestartSec=15

[Install]
WantedBy=multi-user.target

We reread the changes, add a symbolic link to autostart and start the service

sudo systemctl daemon-reload
sudo systemctl enable xteve
sudo systemctl start xteve

Make sure the unit is created correctly and the service is running

sudo systemctl status xteve
xteve service up and running

The xTeVe web interface will be available at

http://ip_server_address:34400/web/

Let’s start setting up. We leave the tuner number by default – 1.

EPG source type – XEPG.

Specify the address to the playlist in MPEG-TS format on our HLS Proxy server, be sure to use the parameter ?output=ts.

Specify the path to the EPG on the HLS Proxy server.

If you did everything right before, then xTeVe should process the playlist and EPG. The summary at the top of the page will list the available channels and paths for clients to connect.

Also in the “Mapping” section you can see all connected channels with their logos.

All preparatory work has been completed, and as a result, we received an IPTV playlist in MPEG-TS format, available along the path:

  • http://ip_server_address:34400 – IP address of our software DVR receiver

  • http://ip_server_address:34400/xmltv/xteve.xml – TV guide

6. Connect xTeVe to Plex Media Server

Go to your account settings and the “Live and Recordings” section and add our receiver.

Plex detects our tuner and all available channels without any problems. We do not select the country, but click on the hyperlink “Use TV guide for XMLTV” and indicate the address to the EPG on xTeVe (http://ip_server_address:34400/xmltv/xteve.xml).

We are waiting for Plex to process the entire list of channels and download the EPG. The first run will take a long time.

In HLS Proxy, you can see summary information about the current stream while browsing, as well as detailed process logging.

The Plex mobile client on iOS also does a great job of watching IPTV, with no stutters or freezes, with a detailed TV guide and “smooth” channel logos.

Conclusion

Everything is ready, now you can enjoy watching TV with a Plex home server, without bulky and dusty receivers, wires and practically for nothing! Yes, the implementation is a little more complicated, due to certain features of both Plex itself and the IPTV service broadcast format.

In addition to difficulties in implementation, such a broadcasting scheme also entails the need for large server resources. The most “gluttonous” in terms of RAM in this chain is xTeVe – it uses about 850 MB, which can be critical for a home media center. HLS Proxy is less demanding and even while watching a channel uses about 180 MB.

If we compare Plex with its closest competitor, then in Kodi with PVR IPTV Simple Client, viewing IPTV is much easier and less resource-intensive. But the choice is always yours.

Similar Posts

One Comment

  1. Hi – thanks for the guide. I have run into a couple of problems and wondered if you have any ideas:
    1) I am running Ubuntu Server 18.04.6 because I only have a 32 bit PC that I am using as a server – is that likely to be a problem?
    2) when I tried to run the command ‘/opt/hls-proxy/hls-proxy -port 8080 -save -quit’ to set the port for hls-proxy, I received an error: cannot execute binary file: Exec format error
    3) I ignored the above, since you suggested that there is a default port 80. However when I installed, and then chekced if the service was running: ‘sudo systemctl status hls-proxy’ …. I got a status: failed response

    I hope you can help as your solution looks interesting
    Rgds
    Steve

Leave a Reply Cancel reply