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 was written to cover how to install TVHeadend Server, the tvhProxy tuner applicance and to then intergrate 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.
|1. From a pre-provisioned USB with Ubuntu Server 16.04 installed boot to the USB.|
|2. Ubuntu Server will load up, select **EnglishIMG_20180313_180327-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180327.jpg)|
|7. Configure keyboard countrIMG_20180313_180433-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180433.jpg)|
|8. Configure the keybIMG_20180313_180442-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180442.jpg)|
|9. 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 adaptIMG_20180313_180521-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180521.jpg)|
|10. Enter your Hostname. Can be anything you lIMG_20180313_180718-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180718.jpg)|
|11. Enter Full first and last name of the user. In my case I IMG_20180313_180747-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180747.jpg)|
|13. Enter a passIMG_20180313_180825-1024x576.jpg)](/content/images/2IMG_20180313_180843-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180843.jpg)|
|15. Timezone check. **IMG_20180313_180911-1024x576.jpg)](/content/images/2021/02/IMG_20180313_180911.jpg)|
|16. Partitioning of the disk. This step you will need to pick the disk you want to install Ubuntu Server on. In myIMG_20180313_181013-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181013.jpg)|
|17. Partitioning method.IMG_20180313_181002-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181002.jpg)|
|18. The 'Are you sure' part of the installation. IMG_20180313_181055-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181055.jpg)|
|19. Proxy information. Leave blank iIMG_20180313_181417-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181417.jpg)|
|20. 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 willIMG_20180313_181608-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181608.jpg)|
|21. 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 IMG_20180313_181640-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181640.jpg)|
|22. Install the GRUB boot loader master boot record to boIMG_20180313_181822-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181822.jpg)|
|23. 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 cIMG_20180313_181831-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181831.jpg)|
|24. We now have installed Ubuntu Server, **remove the USB drIMG_20180313_181918-1024x576.jpg)](/content/images/2021/02/IMG_20180313_181918.jpg)|
|25. The computer will now reboot and load into Ubuntu Server. You should now be able to login IMG_20180313_182617-1024x576.jpg)](/content/images/2021/02/IMG_20180313_182617.jpg)|
|26. Once logged in run the following command to determine the IP address.||
|27. As you can see 192.168.1.119 is](https://itstuff.non-stop-tech.com/content/images/2021/02/Untitled.png) 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.|
|28. Open up a new Putty session and login to your server. The host is the IP address. **Selec](https://itstuff.non-stop-tech.com/content/images/2021/02/Untitled-1.png)|
|29. You should now see a terminal ](https://itstuff.non-stop-tech.com/content/images/2021/02/putty.png)|
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.
|1. Add the bintray's GPG key|
`sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61` [!(https://itstuff.non-stop-tech.com/content/images/2021/02/gpg-1024x337.png)](https://itstuff.non-stop-tech.com/content/images/2021/02/gpg.png)|
| 2. 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` ### [!(https://itstuff.non-stop-tech.com/content/images/2021/02/2-1024x308.png)](https://itstuff.non-stop-tech.com/content/images/2021/02/2.png)Supported Distributions and Architectures **Distribution** **Architecture** **Notes** ``` 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 **Build Type** **Description** **Version** **Repo Component** release The latest version marked for release 4.2.5 release-4.2 stable The latest stable code with changes/fixes between releases 4.2.5-x~githash stable-4.2 unstable This is the current development "bleeding-edge" 4.3.x unstable ``` |
| 3. Refresh the available packages and install. Keep an eye out for anything that mentions TVHeadend.|
``` sudo apt update sudo apt-get install tvheadend ``` [!(https://itstuff.non-stop-tech.com/content/images/2021/02/3.png)](https://itstuff.non-stop-tech.com/content/images/2021/02/3.png)|
| 4. Set a username of the TVHeadenmages/2021/02/admin-1024x693.png)](/content/images/2021/02/admimages/2021/02/pass-1024x696.png)](/content/images/2021/02/pass.png)|
| 6. Once the installation is complete, you can accages/2021/02/access-1024x692.png)](/content/images/2021/02/access.png)|
| 7. TVHes/2021/02/complete-1024x693.png)](/content/images/2021/02/complete.png)|
| 8. Access TVHeadend URL with yomages/2021/02/login-1024x715.png)](/content/images/2021/02/login.png)|
| 9. The following Welcome setup wizard wilages/2021/02/wizard-1024x715.png)](/content/images/2021/02/wizard.png)|
| 10. 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/ Lead/2021/02/tv-tuner-1-1024x715.png)](/content/images/2021/02/tv-tuner-1.png)|
| 11. 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 **es/2021/02/networks-1024x715.png)](/content/images/2021/02/networks.png)|
| 12. Select Add, Click on the drop down arrow2021/02/add-network-1024x715.png)](/content/images/2021/02/add-network.png)|
| 13. In the Add DVB-T Network, enter th](https://itstuff.non-stop-tech.com/content/images/2021/02/dvbt-network.png)|
| 14. 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 thent/images/2021/02/5-1024x718.png)](/content/images/2021/02/5.png)|
| 15. 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 netwo/2021/02/force-scan-1024x716.png)](/content/images/2021/02/force-scan.png)|
| 16. Coffee break.. This is a good time to grab yourself your favorite beverage. Depending on hardware this could take](https://itstuff.non-stop-tech.com/content/images/2021/02/screen_shot_2016-01-12_at_07.31.53.png)|
| 17. 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/02/services-detect-1024x716.png)](/content/images/2021/02/services-detect.png)As you can see there have been channels added but none of the channel ID information has been detected yet.|
| 18. Once everything is finished up you should see something similar like the following, you es/2021/02/channels-1024x666.png)](/content/images/2021/02/channels.png)|
| 19. We now need to add them finally to TVHeadend. Click on **Map Servic02/map-all-services-1024x716.png)](/content/images/2021/02/map-all-services.png)|
| ](https://itstuff.non-stop-tech.com/content/images/2021/02/all-services.png) This will now start to map each channel and get it imported into the TVHeadend database.
21. 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 y/images/2021/02/m3u-1024x147.png)](/content/images/2021/02/m3u.png)|
| 22. 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.
|1. Log into your Plex and go to **Setmages/2021/02/Plex1-1024x672.png)](/content/images/2021/02/Plex1.png)|
|2. Click on Set up Plex DVR.|
|3. The](https://itstuff.non-stop-tech.com/content/images/2021/02/plex-add-tv-tuner.png) Enter the IP address of your TVHeadend Server with port 5004 on the end. Click on connect, and continue.|
|4. The next section will show you how ma](https://itstuff.non-stop-tech.com/content/images/2021/02/channel-plex.png) Click continue.|
|5. This section is device mapping. If everything lo](https://itstuff.non-stop-tech.com/content/images/2021/02/channel-mapping.png)|
|6. Setup complete, cl](https://itstuff.non-stop-tech.com/content/images/2021/02/setup-complete.png)|
|7. Done, you now have TV in Plex. Congrats!|
[caption id="attachment_1257" /2021/02/tv-works-1-1024x557.png)](/content/images/2021/02/tv-works-1.png) Discover[/caption]
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.
[caption id="attachment_1259" s/2021/02/watch-now-1024x603.png)](/content/images/2021/02/watch-now.png) Watch Now - Live TV. Representation of each live channel.[/caption]
[caption id="attachment_1261" t/images/2021/02/TV-1024x604.png)](/content/images/2021/02/TV.png) TV Shows[/caption]
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.
[caption id="attachment_1260" ages/2021/02/movies-1024x605.png)](/content/images/2021/02/movies.png) Movies[/caption]
[caption id="attachment_1258" es/2021/02/rec-guid-1024x599.png)](/content/images/2021/02/rec-guid.png) Recording Schedule[/caption]
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.