tvheadend Config

tvheadend is a backgrounded process run by the username entered during the XBMC+PVR installation and it is usually started when your Revo boots into the Ubuntu 12.04 desktop. It handles a lot of functionality in that single process, though this is a weakness if it ever crashes - all of its functionality is lost in that case and it doesn't auto-restart after a crash by default either.

Before you investigate the TV functionality of tvheadend, you must attach your Freeview HD USB TV stick to your Revo. I did this with my Revo powered off and via the small USB extension lead supplied, so you get a bit of extra distance to use. It also prevents straining the Revo's USB port, since the stick is quite large and will also have a coaxial adaptor (supplied with the tuner stick), the coaxial lead plug and the coaxial aerial lead all attached.

So the sequence is:
  • Shut down and power off the Revo if it's powered on.
  • Attach the small USB extension cable that was supplied with the USB tuner stick to a spare USB port on the Revo.
  • Attach the USB tuner stick to the free end of the USB extension cable.
  • Attach the gold-coloured coaxial adaptor (supplied with the USB stick) to the coaxial lead plug that's on the end of your terrestial coaxial lead.
  • Plug the small gold "prong" on the end of the coaxial adaptor into the hole on the end of the USB tuner stick (it just pushes in - no screwing/turning needed).
  • Lay down the whole connection setup so that you won't trip over it and hopefully so it doesn't look too messy (i.e. out of sight).
  • Power on the Revo and you should see a bright blue solid light on the side of the USB tuner stick to indicate it has power. If you don't see the light, disconnect everything and try again.
To view the tvheadend interface, start Firefox and surf to http://localhost:9981/ - obviously if you want to be lazy, you can not only bookmark it (or even set it as your Firefox home page) but also save the username/password that it prompts you for (the one that you provided during the installation of tvheadend).

If you've already forgotten the tvheadend username and/or password, there is no easy way to reset it other than re-running the tvheadend configurator. To do this, bring up a terminal and type:

sudo dpkg-reconfigure tvheadend
[Type your login password when prompted]

This will ask for a fresh username/password combo which you can then use with the Web interface. Now you're in the Web interface, the first thing you're going to want to do is to tune in Freeview multiplexes on the single TV tuner you've plugged in via USB. Sadly, tvheadend's list of multiplex frequencies is woefully out of date - they're all pre-DSO (Digital SwitchOver) - so you have to enter those multiplex frequencies manually.

First of all, you're going to need to know which terrestrial transmitter you will be using for Freeview. You should probably already know which TV region it is (e.g. London, Yorkshire, etc.), so you just need to narrow it down to the actual transmitter name and its frequencies. The best place to get the transmitter name is on the Engineering Information page on the Digital UK site. Type in your postcode and house number in the form on the right hand side and click on the Go button.

For example, if I put "W1A 1AA" as the postcode and "Broadcasting House" as the house name, I get BBC TV Centre listed and predictably the Crystal Palace transmitter as the most likely one. However, although most of the multiplex info is there on a tooltip if you hover over the channel number, the actual frequency of the multiplex isn't shown! All is not lost though, because you can type the transmitter name into Wikipedia - "Crystal Palace Transmitting Station" (or "Crystal Palace Transmitter") in our case  - substitute your transmitter name as appropriate - and you can get the transmitter frequencies from the resultant page's digital television section.

Multiply the Mhz frequency figure by 1,000 in the first table column to get the kHz figure (that's what tvheadend uses) and for Crystal Palace, we get:

482000 kHz
490000 kHz
506000 kHz
514000 kHz
514000 kHz
530000 kHz
545800 kHz

This is for Crystal Palace multiplex frequencies only - other transmitters will have different frequencies to Crystal Palace's. Put the frequencies in a text file and keep them safe in case you ever need to re-use them. If you're lucky enough to be able to pick up extra transmitters, simply repeat the process, but select one of the "alternative transmitters" listed on the Digital UK site.

Right, now it's time to put those frequencies to good use! Log into the tvheadend Web interface and click on the Configuration -> TV Adapters tab. Click on the Select TV adapter... pop-up and choose the USB stick (it showed "Sony CXD2820R (DVB T/T2)" for me). Don't panic that it doesn't match the brand name of the device - the Sony model is the manufacturer of the tuner chip.

A fair amount of info and selectable options will appear on the default General tab, but the only one you need to at least temporarily tick on is "Monitor signal quality". This will give you a set of strength bars for each multiplex on a later screen and if you give a bad frequency or setting, the strength quickly drops from 100% to 0%! Click on the Save button to remember the change.

Do not click on the "Add DVB network by location..." button - this uses a hard-coded database of incorrect multiplex frequencies. Instead, click on the Multiplexes tab and then on the "Add mux(es) manually" button. A pop-up dialogue will appear and the first field is the frequency in kHz, so type in the first frequency in here (e.g. 482000 in the Crystal Palace case). The Bandwidth field is always "8 Mhz", so choose that. All the other 6 fields have to be annoyingly manually set to Auto (quite why they don't default to Auto is beyond me).

Click on the Add button in the dialogue box, but don't close that box. You should see a multiplex line appear with a green "100%" signal strength (don't believe that - it's just really saying "I've found it!") and, most importantly, a MuxID number will appear. If the MuxID remains blank, you have not found a multiplex and you must work out why. Either the multiplex info you typed in was wrong, your tuner stick isn't correctly connected or the terrerstrial aerial isn't working. Check it all and fix any issues. Also note that the Network column may also show your TV region name, which is a useful confirmation that you have picked the right transmitter.

To add the remaining multiplex frequencies, simply edit the next frequency in the dialogue box (that's all that changes between multiplexes) and click on Add again. Rinse and repeat until all your multiplexes have a number in the MuxID column. Close the dialogue box and then select the Services tab. You will see a massive number of channels listed which can be quite overwhelming (and exciting at the same time!) and your first task is to decide which ones should be disabled because every single one is enabled by default.

The ones you should disable by unticking them in the first column are:
  • Channels you will never listen to/watch live or record.
  • Channels in the "wrong" region (if you have their equivalent in the "right" region).
  • SD equivalents of HD channels (this is risky though - there's no regional news on HD channels and you may find some HD channels have reception issues that the SD equivalents don't).
It's simple enough to go to Configuration -> TV adapter -> Sony -> Services in the future and re-enable any channels if you change your mind. Now click on the General tab, untick the "Autodetect muxes", "Idle scanning" and "Monitor signal quality" options and click on the Save button. Now click on the "Map DVB services to channels..." button.

Click on the Channel tab under Configuration and you will see a list of all the enabled channels you can pick up. Before we delve into the EPG and recording facilities, you've probably keen to see some live TV. To allow even the same machine to connect to tvheadend's services, you must go to Configuration -> Access control in the tvheadend Web interface and click on the "Add entry" button. Enter a username/password (I used the same ones that I entered during the tvheadend configuration for convenience), a Prefix of (i.e. every machine on your network), tick all the options on and perhaps put a little text string in the Comment field to explain what the entry is. Made sure it that it is Enabled (i.e. that option is ticked) and click on the "Save changes" button. You can now jump to the XBMC Config page and come back here when you've configured at least the live TV part of the setup.

Right, you're now ready to see if you can record a programme, so to do this, you'll need to go to Configuration -> Digital Video Recorder and configure the settings appropriately. Here's the stuff I changed (leave anything not mentioned unticked/blank):

Recording system path: /data
Note that the tvheadend user won't have write access to the /data directory because it is initially created with root ownership. To fix this, start a Terminal and type:

 sudo chown username /data
(where "username" is the tvheadend username, not yours)
(However, type in your own Ubuntu login password when prompted for it)

Extra time before/after recordings (minutes):
Never, ever trust any TV programme to start or end on time (a few start early, but many, many run late). Hence, I set 2 minutes before and, yes, a full 10 minutes after the time to "auto-pad" all recordings. Yes, it's a bit wasteful but even if Accurate Recording was available, I still do it (mainly because you can't always rely on AR either!).

Make subdirectories per day:
Initially, you might think this is a waste of time, but during the Olympics, it's extremely useful. Instead of /data containing a flat list hundreds of hard-to-sift through recordings by the time the Olympics has finished, this neatly splits them into separate daily directories. If you aren't going to create a directory per channel (the next option below), you really must enable this daily directory option before you start recording the Olympics.

Make subdirectories per channel:
If you are just recording a few channels per day, then you don't need to enable this option, but if you are recording many like I will be during the Olympics, then set this option too.

Remove all unsafe characters from filename:
Quite why this isn't enabled by default is beyond me - make sure you enable it. Why on earth would you ever want this option disabled?

Replace whitespace in title with '-':
Spaces in filenames always cause grief at the Linux command line, so enable this option.

Post-processor command:
It's almost certain you won't bother running anything as each recording finishes so you can leave this blank, but for me, I want to move each finished recording from SSD to HDD, so I'll be putting a custom command to do so here (yes, I'll be writing my own C program to do it - it's not quite as easy as calling rsync!).

Leave the "Tag files with metadata" option on (always useful if you play the .mkv recording in a media player) and then click on the "Save configuration" button. Now click on the "Electronic Programme Guide" and click on the programme you want to record. Use the  "Search title..." or the channel selector if necessary. A dialogue box should appear with the programme info - click on the "Record program" button and will either start recording now if the programme has already started or it will set a recording event in the future (the log window at the bottom will confirm this).

If you go the "Digital Video Recorder" tab, you will see any programmes you've set for recording. If they are recording right now, there will be a red recording icon in the first column, otherwise it will have an alarm clock icon for future recording events. You can now fire up XBMC and the top right of the home screen will indicate what's recording now and what the next recording after that will be.

There's nothing to stop you watching the programme in XBMC that's being recorded right now of course - just go to Live TV, choose the channel being recording (it'll have a red blob next to it) and then click on the picture-in-picture on the right to go fullscreen.

Please note that a single tuner USB stick can of course record or view multiple channels simultaneously, but only if they're on the same multiplex. All HD channels are on the same multiplex, as are all non-HD channels owned by the same TV company (e.g. BBC, ITV, Channel 4). However, this means that you can't watch/record a BBC non-HD channel at the same time as a ITV non-HD channel - you'd need a second USB tuner stick to able do that (if there's HD versions of both, you can record/view those simultaneously of course). It's why I have a twin tuner PCIe card for recording Freeview HD - it's the cheapest route to get two such tuners, but if you only have a Revo, you'd have to buy a second USB tuner stick.

No comments:

Post a Comment