Affiliate Disclosure: By buying the products we recommend, you help keep the lights on at MakeUseOf. Read more.
Watching live TV seems old school in the Netflix era, but you can’t always find every show or movie you want on a streaming service. The alternative is paying out for cable or satellite TV, and who wants to do that?
Thankfully, if you’re in a country with terrestrial TV broadcasting, you can cut the cord and record live TV to a network DVR with Tvheadend instead, running on a Raspberry Pi. Here’s how you do it.
What Is Tvheadend?
Tvheadend is a streaming server for live TV broadcasts. It can handle streaming and recording over-the-air terrestrial DVB-T/T2 broadcast TV, like Freeview in the UK. It can also handle other forms of TV streaming, including cable (DVB-C), satellite (DVB-S and DVB-S2), ATSC, and IPTV.
This guide will focus on using Tvheadend with a DVB-T/T2 tuner for over-the-air terrestrial TV, but many of the instructions for setting up Tvheadend will remain the same if you prefer to use Tvheadend to record TV from other input sources.
What You’ll Need
To set up a Tvheadend DVR, you’ll need the following:
- Raspberry Pi 2, 3, or 3B+ with Case
- MicroSD card with Raspbian installed
- A high-quality power supply (5V @ 2.5A)
- A USB DVB-T/T2 tuner for OTA TV reception or a Raspberry Pi TV HAT
- A DVB-T/T2 antenna
- Another PC, for SSH connections, with an SSH client installed
Step 1: Preparing Your Raspberry Pi
You’ll need to install an operating system onto your Raspberry Pi first; this guide will assume you’ve flashed the latest version of Raspbian Lite onto a microSD card and your Pi has internet connectivity. It’s also a good idea to run the usual commands on first boot to update your Pi and change the default password:
sudo apt update sudo apt upgrade passwd
If you haven’t already, after you’ve flashed your microSD card, add a file named ssh without a file extension to your boot partition. This will enable you to connect via SSH. You’ll have to check your Pi’s IP address, which you can do using a network monitoring app on your smartphone.
Once your Pi boots, plug your DVB-T/T2 tuner into your Pi (or attach to the GPIO pins, if you’re using the HAT) and connect via SSH. Confirm that your USB tuner is working:
Assuming that it is, check that the firmware for your tuner exists and loads:
dmesg | tail | grep dvb
If the command returns nothing (or there are no errors), your DVB-T/T2 tuner should be ready. If the command returns log snippets that suggest your firmware can’t load, or the firmware files you need are missing, you’ll need to download them.
A Git repository from the developers of OpenELEC, a Linux media center distro, contains a large number of firmware files for various tuner chipsets. To install these onto your Pi, run the following commands on your terminal and reboot:
sudo apt install git git clone https://github.com/OpenELEC/dvb-firmware.git cd dvb-firmware ./install sudo reboot
Step 2: Installing Tvheadend
To install Tvheadend and any additional packages, type:
sudo apt install tvheadend
Type Y and hit enter to agree to installation. As it begins, you’ll need to provide a username for Tvheadend for administrative access once it’s installed. Type a suitable username in, then hit enter.
You’ll need to provide a password, so type one in and hit enter. A final menu provides information on what to do once Tvheadend has installed to access the web interface on port 9981; just hit enter to continue installation.
Step 3: Configuring Tvheadend
With installation complete, open a web browser and go to
http://YourIPAddress:9981 replacing “YourIPAddress” for the IP Address of your Pi. Use the username and password you created during installation to gain access.
Select languages for both the web interface and the EPG (electronic program guide, for TV listings) and click Save & Next.
At the next menu, unless you plan on allowing access to Tvheadend outside of your internal network, and assuming your IP address is in the 192.168.1.0/24 range, type 192.168.1.0/24 under Allowed Network. You can also provide additional usernames and passwords for a standard administration and standard user account; fill in the username and password sections, as required, and then click Save & Next.
The next stage configures your tuner. Tvheadend should already detect your DVB-T/T2 tuner; for my configuration, this was listed under Network 2. Select the network type as DVB-T Network. Again, click Save & Next to proceed.
To get your tuner to scan for the right channels, the next menu has you choose”pre-defined muxes” which are lists of appropriate frequencies to scan. Search the list for one that corresponds with your country and area. As I live in the UK, I used this search tool from the BBC to locate the transmitter closest to my location.
Once you’ve selected one, hit Save & Next to continue.
This will start a scan for channels operating on the frequencies from your chosen transmitter. Let it run through until the progress reaches 100%, then click Save & Next.
The next menu will have options to map these services to channel names that can be understood by media players. Check the checkboxes for Map all services, Create provider tags and Create network tags before hitting Save & Next.
Once you’ve done that, your Tvheadend installation should be complete, with channels matched to services being broadcast in your area. Just click Finish to close the configuration pop up.
Step 4: Stream or Record TV
With Tvheadend installed and configured, you can now get to the fun part—watching or recording TV. You can use Tvheadend to stream to media players like Kodi, to your phone or tablet using apps like Tvhclient, to your PC using VLC, or through Tvheadend’s web portal itself.
If you want to quickly load your channels into VLC to test, type the following into your web browser to download a playlist for streaming, replacing the username, password and IP address with your own:
To record TV through the web portal, search for content under the Electronic Program Guide and click the first icon (with an “i” symbol) to show information about it.
To record a show, select Record program. Select Record series if you want to record episodes of a TV series automatically.
Record and Stream Live TV to Your Entire Home
Thanks to Tvheadend, you can do away with costly TV and streaming packages. Using a Raspberry Pi, you can stream media content, whether it’s live or pre-recorded, to all of the devices in your home, cutting the cord for good.
With your network DVR ready, it’s time to take your media ambitions further, so consider building yourself a media center PC to stream your favorite TV shows and movies in style (and without the buffering). You can even build an Android TV box with your Raspberry Pi to enjoy the benefits of popular Android-based streaming apps.