This procedure explains how to turn a Raspberry Pi into a DVR, or “digital video recorder”. A DVR is a box that sits under your television, allowing you to watch digital television and record it to a hard disk. TV and recordings can also be “streamed” to other devices on your network, such as phones, tablets and PCs.
Commercial examples of DVRs are available from manufacturers like Humax and Panasonic, providing access to free digital TV services, which in the UK are called Freeview and Freesat. Other brand names are used in other countries, but the underlying technology is the same. By following the article, you will be able to view, record and stream free digital TV. (You won’t be able to watch encrypted services, like those broadcast by Sky and BT).
Why turn a Pi into a DVR? You might be just curious about the possibilities. You might be looking to move from a paid-for service (eg. BT or Sky) to a free one. You might want to replace older equipment or just get access to more modern services, such as HDTV (high definition TV). I was looking to replace my old Topfield DVR, and the procedure below worked for me.
Follow the first part of this article to get a basic working setup, giving the ability to watch and record Live TV. You can leave it at that, or build on the solution as explained in later sections. They describe how to add storage, add a proper remote control, tweak the GUI to your liking, add TV Logos, and stream TV and and recordings to any device on your network, such as a phone, tablet, PC or other TVs.
Three pieces of software will be used. OSMC provides the GUI that works on your television, allowing you to switch TV channels, watch recordings, check the programme guide and so on. Meanwhile, TVHeadend works in the background, receiving TV signals from the tuner, decoding and recording them where necessary.
The third item is called TVHeadend HTSP Client Add-on. It allows OSMC and TVHeadend to work together. More accurately, it enables OSMC to control TVHeadend. All three packages run on the Raspberry Pi.
Note: OSMC is really a “shrink wrapped” version of Kodi, the well known media software, pre-configured and available as a Pi image. Conveniently, we can download and burn it straight to an SD card. I have found OSMC to be very stable and well supported. It also has a very active community support, as do Kodi and TVHeadend.
The procedure below assumes you have the following hardware.
- a Pi, model 2 or 3, connected to a TV (or display). Preferably these are located where you watch TV: in your lounge, living room, den (in the USA), or wherever. The Pi should also be connected to your home network via an Ethernet cable. A wireless connection will work too, and will probably suffice for testing. If you decide to afterwards keep the Pi acting as your TV solution, I would strongly recommend a wired connection. The Pi 1 and Pi 4 are not currently recommended, for reasons explained at the end of this article.
- A spare micro SD card. To go into the Raspberry Pi. 8 GB or larger is recommended, class 10.
- A keyboard attached to the Pi, wired or wireless.
- A TV tuner. If you don’t happen to have one lying around, some money will have to be spent, I’m afraid. I successfully used a Hauppauge WinTV dualHD. It is a little expensive in the UK (£69). Being a dual model, it will allow you to watch one TV channel while recording another. The single model would probably work too, but I haven’t tested it.
- A separate PC, to perform configuration tasks.
For the record, I used a Pi 2 connected to my TV in the lounge via an HDMI cable, and a wireless keyboard. The PC I used was a laptop running Linux but Windows is also fine.
This part of the procedure is carried out on your PC. Go to the OSMC download page. Click on the “Disk images” button. A list of image files will appear. Scroll down to the section entitled “Raspberry Pi 2 / 3 / 3+” and click on the most recent image you see there. Download and save the file, which is about 230 MB in size. At the time of writing (19th Nov 2019), the latest file was called “2019.10-1”, so I downloaded that one, but yours will likely be more recent.
Burn OSMC to an SD Card
Put an unused micro SD cared into your PC. Unzip the downloaded image file and “burn” it to the SD card using your favourite burning software. Note: all data currently on the SD card will be destroyed.
If you are using Linux, it can be done on the command line as below. My downloaded file is called “OSMC_TGT_rbp2_20191107.img.gz”. Yours will have a slightly different name. /dev/sdb is the device corresponding to my SD card. Again, your SD card might have a different name, eg. /dev/sdc or /dev/sdd. Note: it is very important that you get the device name correct here, otherwise you could accidentally overwrite your PCs operating system. Be absolutely clear before proceeding that you have typed the correct device name.
$ gunzip OSMC_TGT_rbp2_20191107.img.gz $ sudo dd if=OSMC_TGT_rbp2_20191107.img of=/dev/sdb bs=1M
Burning the card should take a minute or so. When it completes, pop the SD card out of the PC.
For this part of the procedure, you should be sitting in front of your Pi and TV. Start with your Pi connected to a screen and keyboard and powered off. Insert the SD card into the Pi and power it on. The Pi should boot and you will then see a blue screen announcing “OSMC” and below that a message saying “Formatting device”, then “Installing files”. Wait about 5 minutes. A screen saying “videos”, “music” and some other stuff will appear for a few moments. Then that will change and you should be left with a screen saying “Welcome” and some language choices.
- Choose your language here. Use the Pi keyboard to scroll to your preferred language and press [Return] to select it. On the “Confirm” screen that appears, select “Yes“.
- In a similar way, choose your timezone. I am in the UK, so I select “Europe” followed by “London”.
- You will now be asked to “Give your device a name”. Scroll down to “Accept” and press [Return] to accept the default system name of “osmc“.
- The following screen asks about SSH. Accept the default, which is to have SSH enabled, by scrolling down to “Accept” and pressing [Return].
- Press [Return] (“Continue”) to accept the boring license agreement.
- The next screen asks you to choose between “OSMC” and “Classic”. This is a choice between two “skins”, and the skin is displayed in a large graphic in the right of the screen. Select “Classic” and press [Return].
- Finally, you will be asked “Would you like to receive the news letter?”. For now, select “No thanks” and press [Return].
An announcement screen appears. Read the announcement then select “Exit”. After a moment, the OSMC home screen appears and a moment later, the skin changes and we are left with the classic version of the OSMC home screen, shown by the word “KODI” at the top left.
Check for Latest OSMC Updates
You might expect now to be running the latest version of OSMC but this isn’t necessarily the case. Proceed as follows to download the latest updates.
On the OSMC home screen, use your keyboard to move down the menu on the left. Scroll right down to the bottom item, which is “My OSMC” and select that. The “My OSMC” screen appears, which looks like a circle of 8 icons. Your currently running version of OSMC is shows at the bottom of the screen. (In my case it was “October 2019, 2019.10-1”).
Select the cloud icon at the top and press [Return] to move into the Update section.
Highlight the “Manual Controls” button on the left. Then, on the right, “Scan for updates now“. The “My OSMC” screen will reappear and messages at the top right of the screen will confirm progress as updates are downloaded and applied.
If, instead, a message appears saying “No updates were available”, well, then no updates were available, and you can move straight to the next section, entitled “Install TVHeadend”.
Apply Latest OSMC Updates
If updates are available, they will be applied. A dialogue might be shown, saying “OSMC Update Available”, and asking if you would like to exit and install the updates now. Choose “Yes“. The system will exit to Linux to install updates, giving further messages about installing packages. Finally, you will see the OSMC home screen again, signified by the word “Kodi” at the top left.
If you want to check the update, scroll down to and select “My OSMC” again. The new version number is shown at the bottom left of the screen. In my case, the version number was updated to “November 2019 2019.11-1”.
Press the [Escape] key on your keyboard to move back to the Home screen.
Change the OSMC skin. Annoyingly, the update might have caused OSMC to change back to its default, or “OSMC” skin. We want to use the “classic” skin instead. Scroll down the left hand menu and choose “Settings”. Then, again on the left, “Interface”. Now on the right, select “Skin”. A list of 3 skins is shown, one of them being called “Estuary“. Select the Estuary skin and press [Return], and then choose “Yes” (within a few seconds) to confirm the change. OSMC reverts to its “Classic” appearance.
Congratulations! That Completes the installation of OSMC. Move back to the home screen by pressing [Backspace] 2 or 3 times.
Using the left hand menu, scroll down to “My OSMC” again and select it. In the My OSMC screen, choose the shopping trolley symbol at the lower right to enter the OSMC App Store. Highlight “TVHeadend Server” (it should be the first item in the list and already highlighed) and press [Return].
An information page will appear, telling you about TVHeadend server and the version number. Select “Install“, at the bottom left of the screen. Then “Apply” at the bottom right of the next page. TVHeadend is installed, progress being confirmed by messages at the top right of your screen. Click “OK” in the “Operations successfully completed” dialogue, when it appears.
In this step, TVHeadend will be configured. This part of the procedure should be carried out from your PC, in a browser.
Open your favourite browser and surf to the address http://<ip address of pi>:9981. For example, my Pi’s IP address is 192.168.1.75, so I go to http://192.168.1.75:9981.
Login with the user osmc, password osmc.
TVHeadend Configuration Wizard
You should see the TVHeadend web interface. The configuration wizard is already running, appearing as a window entitled “Welcome – Tvheadend – Your TV streaming server and video recorder”. Execute the wizard as follows.
- Enter your preferred language twice on the first page. Once under “Web Interface” and again under “EPG Language (priority order)”, “Language 1”. I am in the UK, so I chose “English (GB)” for both.
- Click “Save & Next“. The first page will actually re-appear. Click “Save & Next” again to move to the second page.
- On the second page, about access, accept the defaults and just click “Save & Next“.
- The third page is called “Network Settings“. It shows a series of “Networks”. The first, called “Network 1”, refers to IPTV and can be ignored. The others each refer to one of your connected tuners. If you are using a single tuner, you might see one or two networks, one for each of the tuner’s capabilities. For a dual tuner, you might see 2 networks or 4.
- Note, the word “network” here is just an abstraction, used by TVHeadend to refer to a tuner or collection of tuners that do the same thing, and pick up TV in the same way. You will see your tuner’s name, greyed out, and a drop down. By selecting an item from the drop-down, you add that tuner to the named “network“, or group of tuners.
- I am using a dual DVB-T tuner (ie. two tuners). So I see two networks. I select the drop-down beside each and add both to the network “DVB-T Network”. I am really just telling TVHeadend to use both tuners to do the same thing, ie.pick up broadcast (DVB-T) television. Do likewise for each of your tuners. If you are using a single tuner, you only have one to do. Choose “DVB-T Network”. (If, on the other hand, you are using cable TV and a cable tuner, choose “DVB-C Network”). Then click Save & Next.
- The next page is called “Assign predefined networks to muxes“. Here we allocate the network group (or tuner group) just defined to a local TV transmitter. From the drop down, select your nearest TV transmitter. (The UK ones are all near the bottom of the list). See this page for more. I selected my nearest transmitter, which was “uk-sandyheath”. Click Save & Next“.
- A frequency scan will be performed. The system will pick up TV and radio channels being transmitted. Wait for the scan to complete (scan status 100%). Then click Save & next.
- The next page is called “Service Mapping“. A “Service” here just means a TV or radio channel. In digital TV parlance they are called “services”. Select all three check boxes and make sure they are ticked: “Map all services”, “Create provider tags” and “Create network tags”. Then choose “Save and Next“.
- The next page says “You are now finished”. Click the “Finish” button to complete the Wizard. You might have to click it twice.
Watch Some TV !
After completing the configuration of TVHeadend, you should now be looking at a list of channels. The list includes TV shows that are on now, and those scheduled in the future. At the top left is a drop-down that says “All”. Change it to “Now”. The list changes to just show TV programs now being broadcast.
Choose a channel to watch and click the “info” icon at the extreme left. An information page appears showing details of the current TV show. Click the “Play Programme” button. A player window appears and after a few seconds, you should be watching that channel.
When you have seen enough, close the viewer window.
Record Some TV
Repeat the procedure for watching TV. But instead of clicking the “Play Programme” button”, click “Record Programme” instead. A “record” icon will appear under the “Details” column in the GUI. Wait a minute or so. Click the “information” icon again (extreme left) and click “Stop recording“. To see your minute of recorded TV, select the “Digital Video Recorder” tab and under that, the “Finished Recordings tab”. There you can see the recording. Play it by clicking the “Play” button on the left.
Excellent. TVHeadend is working. We will just alter a couple of settings before moving on.
Miscellaneous TVHeadend Settings
Make the following configuration changes using the TVHeadend web interface.
Show all settings. Select the Configuration tab -> General tab -> Base tab. Change the “User Interface level” to “Expert“. Click the “Save” key (just under the Base tab). All settings in the interface are now available.
Enable time shifting. Select the Configuration tab -> Recording tab -> Timeshift tab. Under “Basic Settings”, click the “Enabled” box. Click the “Save” key (at the top left). This enables the pausing and rewinding of live TV. NB. the system will buffer live TV to a temporary area on the internal SD.
Remove Unwanted Channels. Prevent unwanted channels from appearing the in programme guide (EPG) later on. Select the Configuration tab -> Channel / EPG tab -> Channels tab. At the very bottom right, change the “Per page” setting to “All”, so that all channels are displayed. Now, in the second column, called “Enabled“, uncheck the box for every unwanted channel – eg. direct sales channels, Adult, all of the “+1″s . When you are finished, click the Save button at the top left.
Configure EPG Grabbers. An “EPG Grabber” is a part of TVHeadend that obtains programme schedule information, which you will see later displayed in OSMC. To make sure that complete data is collected, enable the correct grabbers. Select Configuration tab -> Channel/EPG tab -> EPG Grabber Modules tab. A list of about 13 “grabber modules” appears on the left. Probably there are two already enabled by default, called “EIT: DVB Grabber” and “PSIP: ATSC Grabber”. Leave those. If you are in the UK, highlight the one called “Over-the-air: UK: Freeview“. Enable it by clicking the “Enabled” check box on the right, followed by the Save button at the top left.
If you are not in the UK, you should enable a different grabber as appropriate. I haven’t tested this procedure outside the UK so I am not sure which one will work for you. Also if you are using a satellite receiver rather then terestrial, enable the appropriate satellite grabber instead.
Congratulations! That concludes the installation of TVHeadend.
Configure TVHeadend HTSP Client Add-on
For this part, go back to the Pi keyboard and TV. There is one more thing to do to complete the setup. That is to configure and enable an OSMC “add-on” called TVHeadend HTSP Client. It acts like a piece of glue between TVHeadend and OSMC, allowing us to carry out all TV functions from OSMC.
In OSMC, make sure you are looking at the Home screen, shown by the word “KODI” at the top left. You can get there by pressing the [Backspace] key on your keyboard a number of times.
On the left-hand menu, choose “Add-ons” then on the right, “My add-ons“. A list of add-on categories appears. One of them is “PVR clients“. Choose it. Scroll down the long list that appears, select “Tvheadend HTSP Client” and press [Return]. The client page appears. Configure it as follows.
First, select the “Configure” button. Under “Connection Settings”, leave the defaults unchanged, except for “Username” and “Password”. Set these both to “osmc“, which is the name and password we chose when setting up TVHeadend. The add-on will interact with TVHeadend using these credentials. Select the OK button on the right to return to the main page for the add-on.
Enable TVHeadend HTSP Client Add-on
At the bottom is an “enable” button. Select it and press [Return] to enable the add-on. Note: when the add-on is enabled, the button legend changes to say “Disable”. Confusing enough to fool me first time around, but there it is.
Press [Backspace] on your keyboard a number of times until you reach the OSMC home screen, indicated by the word “KODI” at the top right.
In OSMC, press the “e” key on your keyboard. An EPG should appear (electronic programme guide) showing current and scheduled TV shows for the first 8 channels you are receiving. Use the down arrow to scroll down the list of all channels. Press [Return] to start watching a channel. An information screen will appear. Choose the “Switch” button at the bottom to start watching.
When you have seen enough of that channel, bring up the EPG by pressing “e” again and choose another channel. Or just press “x” to stop watching altogether and return to the OSMC home page. Or press “k” to bring up the recordings page – you should see the short recording(s) made above, while testing TVHeadend. Press [Return] to view a recording. To delete it instead, press “c” to bring up the context menu and choose “Delete“
The context menu also works in the EPG, allowing you to schedule programme recordings and more. For a full list of key functions in OSMC, see the Kodi keys page. Happy viewing!
End of basic procedure.
End of Basic Procedure
The main procedure ends here. If you have followed it, you should now be able to watch and record live TV. The following sections describe a series of improvements which, though optional, will enhance your viewing experience.
Enhancement 1. Obtain SSH Access
After completing this section, you will be able to log into your Pi from another PC. Command line access is needed for some of the improvements below. It is also useful for checking logs and troubleshooting, especially as you learn more about the system.
From Windows, use an SSH client such as Putty. From Linux, use ssh. The IP address of my Pi is 192.168.1.75, so I use this command from my PC to log into the Pi:
$ ssh -l osmc 192.168.1.75 Generating locales (this might take a while)… en_GB.UTF-8… done Generation complete. osmc@osmc:~$
Enhancement 2. Enlarge OSMC Fonts
Unless you like to watch TV through binoculars, you might find the default font sizes to be too small. A simple improvement will take care of that. The OSMC user interface is highly customizable, and there are many Internet pages explaining how it all works. But for now, we will just make a small change.
From your PC, login into the Pi via SSH. Then, using your favourite editor, edit the file /usr/share/kodi/addons/skin.estuary/xml/Font.xml. For example, here I am using vi to edit the file. First, take a backup, using the cp command as shown.
osmc@osmc:~$ cd /usr/share/kodi/addons/skin.estuary/xml osmc@osmc:/usr/share/kodi/addons/skin.estuary/xml$ sudo cp -p Font.xml Font.xml.org osmc@osmc:/usr/share/kodi/addons/skin.estuary/xml$ vi Font.xml
Inside the file, near the top, are two definitions for “font12” and “font13“. Font13 is used to draw “label” type controls throughout the OSMC user interface, including the text in the EPG grid and in many other places. Font12 controls the size of text in the EPG time line (near the top, showing the time of day horizontally), and smaller text in other places, eg Home page widgets.
Recommendation: increase the size of font13 from 30 to a maximum of perhaps 38, depending on your personal preference. Change the size of font12 from 25 by anything up to 35. Bigger increases can displace other screen elements and make a mess.
Recommendation: also change the style of font 13 from “lighten” to “bold”. This makes EPG text really stand out.
Below, I have increased font12 from size 25 to 30, and font13 from 30 to 35. Font13 has also been emboldened, by changing its style from “lighten” to “bold“.
To see the effect of your changes, restart OSMC or reboot the Pi. Highlight the of/on button at the top left of the OSMC Home screen and select “Exit” (to restart OSMC) or “reboot” to reboot the Pi.
Enhancement 3. Add Storage
You should now have the Pi set up as a basic working DVR. You can watch and record TV. Any recordings you make are written to the directory /home/osmc. This is the default. It isn’t the best place to store your data, however, because it is on the Pi’s internal SD card. The card doesn’t have much capacity and is likely to fill up after a few hours of TV have been recorded. Proceed as follows to add another disk.
A 2 TB external USB disk can be bought for £50 or so. That would give enough capacity to store 2000 hours of television (a bit less for HD TV recordings). You might even have a spare disk lying around. To use it to store TV recordings, attach it to the Pi via a powered USB hub. (It might work without the hub. On the other hand, it might not – it might not even spin, and it might starve the other components of power).
An alternative it to use a thumb drive/memory stick. It will not need a powered hub, but the capacity will be smaller. For this procedure, I am using a 128 GB memory stick. Really, I would recommend something bigger, but this will demonstrate the process.
Format the Drive
Attach your chosen drive to the Pi, or to a Linux PC if you are using one (I will use the Pi, here). Then, go back your PC and log into the Pi over SSH. Your disk will be identified by a device name, such as sda1, sdb1 or sdc1. My USB stick appeared as /dev/sda1.
If the drive mounts automatically (probable), unmount it:
osmc@osmc:~$ sudo umount /dev/sda1
Be aware that the formatting will destroy all data currently on the drive. Note: If you would prefer not to format, perhaps because you want to preserve some other data already on the drive, then don’t format it. Just skip to the next section, “Configure Recording Path”. Things should still work, but it depends on the existing setup of your drive, and troubleshooting that is beyond the scope of this article.
Create a new XFS file system with the following commands, replacing “/dev/sda1” with the correct device name for your drive. The second line creates a new file system and the third labels it “disk1”.
osmc@osmc:~$ sudo apt-get install -y xfsprogs osmc@osmc:~$ sudo mkfs -t xfs -f /dev/sda1 osmc@osmc:~$ sudo xfs_admin -L disk1 /dev/sda1
Remove the drive from the Pi, wait a few seconds, then insert it again. It should automatically mount and appear as “/media/disk1”. Check it with df:
Filesystem 1K-blocks Used Available Use% Mounted on
...other output removed...
/dev/sda1 30655860 63568 30592292 1% /media/disk1
Configure Recording Path
It is necessary to configure the system to use the new drive for TV recordings. First, create a directory on the drive:
osmc@osmc:~$ mkdir /media/disk1/Recordings
In a browser, surf to the TVHeadend interface page again (http://<ip address of your pi>/9981). Select the “Configuration” tab -> Recording tab -> Digital Video Recorder Profiles tab. On the right you should see a field called “Recording system path:” (under “Recording file options”). Change it from the default, which is /home/osmc, to “/media/disk1/Recordings“. Then click the “Save” button, at the top left just under the tabs.
Test the Disk
As a test, start a TV recording, either from the TVHeadend web interface or from OSMC. You should see the file being written to the new disk, under /media/disk1/Recordings. You might also see the access light on the disk flashing. Here is the new file, seen on SSH, showing a recording of BBC News:
osmc@osmc:~$ ls -l /media/disk1/Recordings -rw-rw-r-- 1 osmc video 403066924 Nov 22 18:20 BBC News.ts
TVHeadend will now write recorded programs to the new disk, instead if its internal SD card. Any recordings remaining on the SD card (such as the tests made earlier in this procedure) will continue to exist there and be managed by the system until you choose to view and/or delete them.
It might be considered a good idea to move existing recordings from the SD card to the external disk. I would not recommend this. The software keeps a database of recordings, which would be put out of sync if the files were moved. Just delete them instead.
Enhancement 4. Add a Swap Area
In testing, I have found that the Pi will, very occasionally, run out of memory. The problem appears to be caused by a bug in TVHeadend (a “memory leak“). If it happens, you might find that programmed recordings were never made. Future releases of TVHeadend are likely to fix the issue. But for now, we will avoid it by creating a swap area.
The effect of the new swap area will be to increase the virtual memory capacity of the Pi. In normal circumstances it won’t be used and it won’t affect performance. But it will prevent the above bug from showing up and ruining things. Proceed as follows.
Log into the Pi over SSH. Create a swap file. Note this command will take about 3 minutes to complete (on a Pi 2). Stop watching TV on the Pi first, and stop any running recordings, otherwise it will take much longer:
osmc@osmc:~$ sudo dd if=/dev/zero of=/swapfile1 bs=1M count=1024
Configure the swap file:
osmc@osmc:~$ sudo chmod 0600 /swapfile1 osmc@osmc:~$ sudo mkswap /swapfile1 Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes) no label, UUID=db8dd543-1781-4647-b4b2-32016d565171 osmc@osmc:~$ sudo chmod 0600 /swapfile1
Activate the swap:
osmc@osmc:~$ echo "/swapfile1 none swap sw 0 0" | sudo tee -a /etc/fstab > /dev/null osmc@osmc:~$ sudo swapon -a
Finally, the swapon -s command will confirm the presence of the new swap area:
osmc@osmc:~$ swapon -s Filename Type Size Used Priority /swapfile1 file 1048572 0 -2
That completes the swap configuration.
Enhancement 5. Add a Remote Control
OSMC can be operated fine with a keyboard. All functions are accessible. You can watch TV and TV recordings and control everything with different key presses, detailed in the guide referenced above. Many people find it more relaxing to use conventional remote control handset (as they are called in the USA, a “zapper” or “clicker”).
There are many ways to add a remote control to OSMC. The method below is perhaps the easiest, simplest and most effective. It requires the purchase of a “Flirc USB“, a small device available on Amazon for about £20 at the time of writing (Nov 2019). A spare remote control handset is also needed. Most of us have old remotes sitting in a drawer. Well, find your favourite one, check the batteries and give it a dust, because it is going into battle.
Alternatively, you might already be using a universal remote, such as those made by Harmony/Logitech or “One for All“. If it has a spare function, you can use it with the Flirc. Just program the keys in the same way as is described below.
The Flirc attaches to the Pi over USB. It picks up infra-red (IR) signals from your remote control and converts them into key presses, which are passed into the Pi. The Pi reacts in the same way it would if you pressed the equivalent key on an attached keyboard.
Personally, I decided to use the remote control from disused Western Digital media player. The handset is well made and has large keys, which are well spaced. I recommend avoiding controls that have wobbly keys, or keys that are too close together (like with some old DVD players).
Install the Flirc
Unbox the Flirc and put it into a spare USB port on your PC (don’t attach it to the Pi yet). Download the Flirc software, which is available for Windows, Mac and Linux. install it following the instructions for your platform.
Configure the Flirc
Run the Flirc application. If you are running it for the first time, it might offer to upgrade the firmware. Let it do that.
Select the “Controllers” menu and choose “kodi“. A diagram appears showing Kodi applicable keys. Configure, in turn, all the keys you are interested in using on the remote. For example, the key to bring up the EPG: click your mouse on the “EPG” key. A message appears asking you to press the button you want to use to display the EPG. Press the desired button on the remote (while poining it at the Flirc device). A message confirms that button has been programmed.
Go through every key you want to use. To undo a mistake, click “erase” in the Flirc window, then click the button that the wrong meaning was accidentally assigned to. It will be de-programmed (erased). I would recommend setting all the number buttons, volume, mute, play, stop, C (context menu). Under the “Controllers” menu again, select “full keyboard”. Configure more buttons, eg. one for the “k” key, which in OSMC displays the list of recordings.
When you have finished, before removing the Flirc device, choose File -> Save configuration. Save into a file with the suffix “fcfg”. For example, I was using a remote made by Western Digital. I saved the configuration into a file called “wd_remote.fcfg”.
Remove the Flirc from your PC and plug it into the Pi. Press some buttons on the remote to check it out. They should all work as programmed.
Modifying the Flirc Configuration
After checking the control, you will likely want to change or add some buttons. Proceed as follows.
- Put the Flirc back into your PC
- Run the Flirc software
- Select File -> Clear configuration, to wipe all button definitions from the Flirc.
- Select File -> Load configuration. Choose to load the file saved in the previous section.
- Make your changes.
- Select File -> Save configuration. Save to the same file again, overwriting it.
I found that following the above procedure every time avoids confusing situations with seemingly mixed up configurations.
Using different file names, different configurations can be maintained for different remotes. Useful if you are experimenting with several models of remote to see which one is the best, for example. I was testing remotes from LG and Western Digital, saving the configurations into files called “lg_remote.fcfg” and “wd_remote.fcfg”.
Enhancement 6. Use a Proper Power Supply
To make your Pi TV setup function well and reliably, it is necessary to use a power supply of sufficient capacity. With several USB devices attached (TV tuner, USB disk, Flirc, wireless keyboard transmitter), the Pi will consume more current and power than if it were operating standalone. Power adapters sold with some Pi models cannot supply enough enough energy to run all of these peripherals.
If your power adapter isn’t up to the job, the Pi and its USB devices will receive a voltage somewhat lower than the required 5.0 Volts. If this is happening:
- the Pi’s red LED will flash intermittently instead of being constantly on.
- A small “lightning bolt” icon might appear at the top right of the OSMC screen.
- “under volt” messages might be seen in the system logs, the output of journalctl, and dmesg.
Any of the above would indicate that a better power supply is needed. In testing, I encountered under-voltage when using the standard Pi 2 power adapter (rated 10 W), and I wasn’t even using a spinning disk. If you want the Pi to function reliably, there are two choices:
- Obtain a powered USB Hub. The Hub comes with its own power lead. Plug your TV tuner and disk into the powered hub instead of directly into the Pi. The power draw on the Pi (and its adapter) is thereby reduced, and voltages are maintained to all components. In testing, I found that a powered hub enabled all components to work properly, without any under-voltage, including an external spinning disk. In fact without a hub, the disk did not spin at all.
- Obtain a better power supply. If you are not using a spinning disk, and keeping your TV recordings on a memory stick instead, then a powerful adapter will suffice. Leave your peripherals plugged straight into the Pi, and power the Pi with an adapter capable of delivering 15 W or more.
I opted for a version of (2), avoiding under-voltage by employing a 15 W power adapter (actually the adapter that comes as standard with the Pi 4). One small addition: To make the USB-C adapter lead connect to the micro-USB power input on the Pi 2, I used a suitable adapter, this one in fact. It worked fine with a memory stick, but still wouldn’t spin-up a proper disk.
Power Supply Summary: If you want to use a spinning disk for storage, get a USB hub. If you are using a memory stick instead, a powerful adapter will suffice.
Some Power Consumption Tests
In the course of using the Pi as a TV system, it will be necessary to leave the Pi switched on all the time. It has to be left on so that TV recordings can be made at any time of day. That being the case, it is interesting to note the power consumption, from the point of view of both the environment and your electricity bills.
Using a Wattmeter, I obtained the following readings.
Power consumed by the Pi 2 and all components (no spinning disk, no USB hub, memory stick for storage): 6 W. It doesn’t matter what the Pi is doing. It takes around 6W whether you are watching TV, recording 2 channels, whatever. Except that, if completely dormant (no viewing or recording), consumption drops to about 5.5 W. Note that there is no “standby” mode with the Pi. It is on all the time.
Power consumed by the Pi 2 and all components (with external spinning 1TB disk & USB Hub): Around 12 W when fully active, viewing TV and recording 2 channels. 11 W when idle (disk spun down, not watching TV. Note there is only 1 W of difference between a spinning and still disk. The USB hub I used for testing was about 15 years old I suspect not as efficient as a new one would be. For example the hub takes 2.3 W even with no devices attached to it, rising to 5.1 W when you add the disk (which is spinning). The disk itself therefore consumes 2.8 W.
Power Consumption Summary: The Pi TV solution is highly economical & environmentally friendly when compared to other solutions. For example, my Topfield DVR takes 7.5 W on standby (it must be on standby to make timed recordings), 17 W if I am watching TV and 25 W when it is recording. Other hard disk DVRs such as the Humax models, are likely to be similar. The Pi TV solution is rather less economical if used with a spinning disk, at least with my old USB Hub.
Why does the above procedure not use a Pi Zero, a Pi 1 or even the latest model of Pi, the Pi 4?
- Well, the Pi Zero (W) and the Pi 1 will likely be much to slow. They just don’t have the CPU grunt or memory to cope. Although they are still great units and suitable for many less demanding roles, they just aren’t powerful enough to run TVHeadend and OSMC at the same time, and can’t properly function as a media centre.
- Regarding the Pi 4, it isn’t yet supported by the OSMC project, although it soon will be according to the OSMC blog. After extensive testing with a Pi 4 and manually installed Kodi/TVHeadend, I found it not to be stable enough and has issues with picture quality. The Pi 4 is a powerful beast. It makes the Kodi GUI run almost too fast and, as I’ve written here, you should be able to shift recordings off it at at gigabit saturating speeds. The Pi 4/OSMC is the future. But like that old beer advert says, “it isn’t ready yet”. When the Pi 4 is supported by OSMC this article will be updated.
- The Pi 3 is fine. However, if you are trying the procedure on a Pi 3A, this will likely not be suitable. The 3A has only half a GB of memory, unlike other models that have a full GB. It will probably work, but be a little slow (I haven’t tested it). If you go ahead, please be sure to add the swap area as described in the section entitled “Enhancement 4”. Also, please come back and leave a comment explaining how successful the Pi 3A was.