Update (25/09/2020) : This guide is now out-of-date and is only provided for archive purposes. This guide has now been adopted to the Raspberry Pi and updated based on this. The Raspberry Pi has more than enough power to perform TV duties in this mannor.
Update (23/10/2019) : As many of you now know, Plex replaced FreeEPG with IceTV which now no longer lets us use open source solutions like TVHeadend Server. Unfortunately due to this change, the below guide now no longer works within Australia and a couple of other countries which use the IceTV EPG service . I have been trying some alternatives, but to date none have functioned at all through Plex.
This guide will cover how to install TVHeadend, tvhProxy and integrate this all into Plex through the Live TV & DVR options.
This guide will use the following applications to achieve this:
TVHeadend: an application that reads video streams and allows the sources to be recorded or streamed via network.
tvhProxy: an application to proxy between TVHeadend and Plex. This will mimic a HDHomerun Tuner.
Plex: Media Center Server. This should already be setup prior to going through this guide. Setup of Plex will not be covered in this guide.
Installing Ubuntu Server 16.04.2
In the screenshots below I installed Ubuntu Server on a old desktop and I have had to capture the screenshot with my phone.
I have found it is easier to setup on a physical device rather than virtually. It is possible to do this virtually on either VMware ESXi or UnRaid. You do need to have PCI passthrough working correctly before attempting however. To simplify the setup I opted to run it on an old desktop.
- From a pre-provisioned USB with Ubuntu Server 16.04 installed boot to the USB.
- Ubuntu Server will load up, select English to begin the installation.
- Select Install Ubuntu Server.
- Select your Language. English
- Select your Region. Australia
- Configure your keyboard. No
- Configure keyboard country of origin. English (US)
- Configure the keyboard layout. English (US)
- Select your network adapter. In my case I also had a wireless card installed. Hence the options for 2 adapters, in your case it will default to the NIC adapter and may not prompt either.
- Enter your Hostname. Can be anything you like, I went with “TVHeadend”.
- Enter Full first and last name of the user. In my case I just entered “tvheadenduser”.
- Enter the user account. tvheaduser
- Enter a password and verify the password.
- Encrypt your home directory? No
- Timezone check. Australia/ Queensland - Yes
- Partitioning of the disk. This step you will need to pick the disk you want to install Ubuntu Server on. In my case it was the 128GB drive.
- Partitioning method. Guided - use entire disk.
- The ‘Are you sure’ part of the installation. Write changes to disk. Yes
- Proxy information. Leave blank if you don’t have a HTTP proxy.
- Automatic updates? I usually set this to No automatic updates, and manually install them. This server has a purpose of only running TVHeadend and if I automatically do an update will it break it or be compatible? These are the checks I will do prior to updating the box.
- Install features we want on the server. Because this box will be headless we want a way to remote into the server. The easiest way is to SSH in. Select OpenSSH Server and hit continue.
- Install the GRUB boot loader master boot record to boot into Ubuntu Server. Yes
- Location of the boot record. Because we are installing from a USB, the USB storage is also an option to set the boot loader on. Select your local drive. In my case its the 128GB drive again.
- We now have installed Ubuntu Server, remove the USB drive and select continue.
- The computer will now reboot and load into Ubuntu Server. You should now be able to login using the credentials you set.
Once logged in run the following command to determine the IP address.
- As you can see 192.168.1.119 is the current IP of the server. Depending on the router/ DHCP configuration you may need to check to ensure that this remains static. The IP of the TVHeadend Server must be a static address for it to work.
- Open up a new Putty session and login to your server. The host is the IP address. Select Yes to accept the new key.
- You should now see a terminal into your server. Again login.
The following steps have been sourced from
TVHeadend.org and may be subject to change in the future. It is best to double check their source first and verify if it matches what is below here. As of the 13/03/2018 the following steps are up-to-date.
Add the bintray’s GPG key
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv-keys 379CE192D401AB61
Select which build type you want and add the repository accordingly. In my case the below is what I used.
echo “deb https://dl.bintray.com/tvheadend/deb xenial stable-4.2” sudo tee /etc/apt/sources.list.d/tvheadend.list
Debian Jessie “jessie” (8.x)
- i386 - amd64
Debian Stretch “stretch” (9.x)
- i386 - amd64
Ubuntu Xenial “xenial” (16.04)
- i386 - amd64 - armhf - arm64
armhf/arm64 do not have transcoding support (yet)
Trusty “trusty” (14.04)
- i386 - amd64
### Build Types and Versions
The latest version marked for release
The latest stable code with changes/fixes between releases
This is the current development “bleeding-edge”
Refresh the available packages and install. Keep an eye out for anything that mentions TVHeadend.
sudo apt update sudo apt-get install tvheadend
- Set a username of the TVHeadend administrator. I used Admin.
- Set a password.
- Once the installation is complete, you can access via http://localhost:9981.
- TVHeadend installation completed.
- Access TVHeadend URL with your favorite browser and login.
- The following Welcome setup wizard will prompt, click on Cancel.
- Go to Configuration, DVB Inputs and TV Adapters. Verify that your TV Tuner cards are being detected. I have had a lot of luck with the tuner cards I have thrown at TVHeadend. If you stick with the Avermedia/ Leadtek brands you should be okay.
- Now that we have verified that the tuner is working we need to setup the scanning range to tell the tuner what frequency to scan in. The next couple of steps are very similar to setting up a new tv. Click on Networks beside TV Adapters.
- Select Add, Click on the drop down arrow and select DVB-T Network.
- In the Add DVB-T Network, enter the following and select Create.
- Go back to the TV Adapters tab and select the tv adapter. On the right hand side select the drop down on Networks and select Australia and Enable the adapter. Click on save.
- Now that we have added a way for the TV tuner to scan channels, lets scan some channels. Go back into the Networks tab and select the Australia network, and select Force Scan.
- Coffee break.. This is a good time to grab yourself your favorite beverage. Depending on hardware this could take about 30 minutes to complete.
- Click on the Services tab now and you should start to see after a while TV channels being picked up. At this stage I would also go to an actual TV and check the EPG guide and see how many channels it picks up. Once the scan on TVHeadend completes you want to see the same amount of channels. In my area locally I can pick up about 30 - 40 free to air channels.As you can see there have been channels added but none of the channel ID information has been detected yet.
- Once everything is finished up you should see something similar like the following, you now have TV channels with IDs.
- We now need to add them finally to TVHeadend. Click on Map Services and Map all services.
- Click on Map services. This will now start to map each channel and get it imported into the TVHeadend database.
- We now need to test a couple of channels to ensure that everything is working as it should. Click on the Play button on one of the channels and you should download a .m3u file.
- Open it up with VLC and you should see live TV start to play. Ensure that the quality and sound is okay. At a later stage I will add a channel troubleshooting guide to outline some things you could do if you run into channel problems.
Setting up tvhProxy
Now that we have TVHeadend installed and working correctly we need to setup the proxy between Plex and TVHeadend. Originally when I first found the tvhProxy I had some trouble getting it to run and didn’t understand what was going on. It turned out that there were also other users in the same boat. Steps 1 to 4 were not actually in the readme!
Back in the Ubuntu Server putty terminal run the following commands:
sudo apt install python-pip
Create another user for tvhProxy
sudo useradd -m tvh -s /bin/bash
Become the user ‘tvh’
sudo su - tvh
Get the files and setup the environment
git clone https://github.com/jkaberg/tvhProxy.git cd tvhProxy virtualenv venv . venv/bin/activate pip install setuptools –upgrade pip install wheel pip install -r requirements.txt
Exit out of the tvh user account and go into the home directory of tvh.
exit cd /home cd tvh cd tvhProxy
We now need to setup the tvhProxy.py script with details from the TVHeadend server.
sudo nano tvhProxy.py
Edit the following lines:
‘tvhURL’: os.environ.get(‘TVH_URL’) or ‘http://test:test@localhost:9981’, ‘tvhProxyURL’: os.environ.get(‘TVH_PROXY_URL’) or ‘http://localhost’,
http://test:test@localhost:9981 > http://[user account to log into tvheadend with]:[Password of this account]@[IP address of the TVHeadend server]:9981
http://localhost > http://[IP of TVHeadend Server]
Create a service that automatically starts when Ubuntu Server boots.
sudo cp tvhProxy.service /etc/systemd/system/tvhProxy.service sudo systemctl daemon-reload sudo systemctl enable tvhProxy.service sudo systemctl start tvhProxy.service
Setting up Plex
Nearly done! We are in the home stretch now.
- Log into your Plex and go to Settings and Live TV & DVR.
- Click on Set up Plex DVR.
- The following window will appear. Enter the IP address of your TVHeadend Server with port 5004 on the end. Click on connect, and continue.
- The next section will show you how many channels have been scanned. Click continue.
- This section is device mapping. If everything looks right, click continue.
- Setup complete, click on View Program Guide.
- Done, you now have TV in Plex. Congrats!
If you have done everything right, you should now see your Program Guide displaying content and a new section called Live with Recording Schedule and Program Guide.
As you can see the TV Shows is missing some covers. From time to time I have noticed that this occurs. Most of the time its because the internal scanners can’t pick up the correct cover art to display.
I have now been trialing this for some time now and can say that it works very well and has been a great alternative to some of the other options out there. I am a huge fan of this as now ALL my media is together in the one place.
- (15/05/2018) Added install PIP step in tvhProxy.