The never final, always subject to revision article on how to build a Satellite TV PVR distribution system using Tvheadend

THE “WHY” BEHIND THIS ARTICLE

I’ve wanted to write an article to help new users set up a working PVR backend system for our peculiar type of North American free-to-air satellite for quite some time, but have never felt as though I had the all the pieces to do it right. I finally decided that the only way it would ever get written is if I start it, and then add to it as I remember things I had to do, or find out new things I should have done. Therefore, this article should probably never be considered finished – there is always the chance that I will edit it or add to it. And if you leave a comment on the article, I just might incorporate your comments into one of the edits.

First of all, I should probably explain why you would want to build a Satellite TV PVR distribution system using Tvheadend. And actually, it’s probably easier to explain why you wouldn’t want to do this. You probably would not want to do this if:

  • You have a very limited budget for satellite TV and don’t want to invest in any new equipment.
  • You have, or plan to purchase, a standalone satellite TV receiver that will receive all the satellite channels you’d like to receive.
  • You don’t care about recording shows, or your satellite TV receiver gives you a reliable way to record shows.
  • You never want to watch live TV or recordings on any TV’s or devices except for the TV directly connected to your satellite receiver.
  • You never have scheduling conflicts where you cannot watch or record a show you’d like to see because your receiver’s tuner is already in use.
  • You don’t have multiple dishes, or you do have more than one dish but a simple DiSEqC and/or tone switch meets your needs for connecting your dishes.
  • You either don’t care about the types of signals that some find difficult to receive, such as 4:2:2 or 16APSK, or your satellite receiver allows you to receive such signals.
  • Your receiver gives you a reliable way to schedule shows you want to record, and doesn’t make you wish you had a better guide (or any guide at all) to use when scheduling recordings.
  • If you use a regular TV antenna for local channels, your receiver also allows you to watch or record shows from those channels, or you have another way to record shows from those channels.
  • You are under the impression that this type of system will let you pirate signals from subscription satellite TV services. It won’t, particularly in North America. This is only for unencrypted free and legal satellite TV.

If the first item on the above list is true, then you probably should stop reading now. Building a backend system for satellite TV doesn’t need to be super expensive, particularly if you have a local source for gently used desktop computers that are new enough to have PCIe card slots (note the “e”, the older PCI slots won’t work), and there are compromises you can make to bring the cost even lower, but if you are living paycheck to paycheck then this might be a major expenditure for you. The one advantage of standalone free-to-air (FTA) satellite receivers is that they are dirt cheap nowadays, although that usually also means the quality is not that high. But at those prices (sometimes less than $50) you could try a few and still come out ahead.

Otherwise, if any of the other items on the above list is NOT true for you, then you probably will want to read on.

While writing this article I have made the assumption that the reader already has some experience with C-band and/or Ku-band satellite TV, and already has one or more satellite dishes and a satellite TV receiver. Therefore, I will not be explaining some of the essentials of setting up a satellite dish, peaking the dish and LNB for best reception, etc. It would be my recommendation that even if you know you want to do what is described in this article, you at least start out with a cheap standalone free-to-air (FTA) satellite receiver and get your feet wet with that. It is much more difficult to set up and tune a new dish for peak reception if you don’t have a FTA receiver available, so you can see if you’re getting a good signal from your dish(es).

WHAT IS THE DIFFERENCE BETWEEN A BACKEND AND A FRONTEND SYSTEM?

I need to cover this early because there is still a lot of confusion about this. For those of you used to computers and networking, you can think of the backend as roughly analogous to a server, and the frontend as roughly analogous to a client. A better way to describe this is as follows, but please keep in mind that these are generalizations and that certain specific setups may not fit into the mold I am about to describe.

As I wrote in the article, What is the best backend software to use for a Free-To-Air satellite TV system?,

If you use a program like Kodi to watch live or recorded television, you’re probably already familiar with the backend/fronted model. To put is simply, the backend is a server that communicates with the tuners, such as a tuner card or USB-connected tuner, or even a network tuner such as a HDHomeRun. The backend system can sit anywhere on the local network and communicates with one or many frontends. The backend handles streaming live programming, or recording it for viewing at a later time. In contrast, the frontend is run on a computer that often connects to a television set via a HDMI cable. It displays live or recorded programming, and usually gives the user a way to schedule programs for recording and perform some other administrative tasks. Some tasks can be performed from either the backend or frontend, some from the backend only, and some from the frontend only. But generally speaking, the frontend is what the user most commonly interacts with after the initial configuration is finished.

But remember, it is the backend that performs the crucial task of communicating with the tuners, which includes sending any control commands that might be necessary. So, for example, if you have any switches (DiSEqC or 22kHz tone) between the tuner and your LNB’s, the backend will control them. If you have a USALS or DiSEqC controlled motor, the backend will need to deal with that as well.

…..

Note that it is usually possible to run a backend and a frontend on the same computer – you don’t need two computers for the purpose, and if the backend computer has a HDMI output and is in a location close enough to your TV that you can connect a HDMI cable between the two, there’s generally no reason not to run a frontend program on the same system as the backend. Some software installers set up a backend and frontend by default.

In other words, the backend is the “brains” of your setup. The client software, which for most users is Kodi, interacts with the backend. This article is NOT about the client software, however. The only thing I will say here about Kodi is that you should NEVER buy a small box that comes pre-loaded with Kodi at a county fair or from someone on Craigslist, or in some equally questionable situation where the seller can take your money and disappear. These boxes are typically sold with a number of piracy addons included, most of which are unsupported and some of which can be a security risk for that system and for others on your local network. The mere use of those addons can also make you guilty of copyright infringement, which could cause you to incur legal fees or financial penalties, or could get your Internet service shut off. Just because you might know someone who uses such a box and hasn’t yet had any of those issues doesn’t mean it won’t happen to you. The Kodi developers hate these boxes because they say it gives the Kodi project a bad name; of course it must also be said that a few of the Kodi developers are perfectly capable of giving the Kodi project a bad name without any outside help, but that’s a whole other discussion. It’s okay to use a small, inexpensive box for Kodi, but it should be one on which YOU install the operating system (Windows or Ubuntu Linux, for example) and where YOU install Kodi, and and you do NOT install addons from any dicey repositories, or for that matter addons from any source other than the official Kodi repositories.

Most users have only one backend system (in this case it will be the system running Tvheadend), but will have one or more frontend systems, only one of which may be on the same computer as the backend. A frontend system can be a dedicated computer connected to a television receiver, in which case it’s sometimes referred to as a HTPC (Home Theater PC), or simply the Kodi software running on a general purpose computer, a tablet computer, or possibly even a phone. Kodi runs on many different platforms, so it’s possible to have many different types of frontend systems. And that’s all I will say about frontends for the moment.

WHAT HARDWARE DO I NEED?

There are many possible choices here, but I recommend a standard desktop style computer that contains a motherboard with at least three or four PCIe card slots (again, note the “e”, the older PCI slots aren’t compatible with the newer PCIe cards). You only need one PCIe card slot for each PCIe card you will install, but once you get your first tuner card working successfully there’s at least a chance you will want more sooner or later. Speaking of which, you will need one or more DVB-S2 tuner cards. In North America, if you don’t want to import cards directly from overseas, your choices are for tuner cards are somewhat limited, and you will probably wind up using the ones made by TBS Technologies, only because they are the most readily available.

Let me once again quote from my earlier article (the same one I quoted from above):

Also, you need to be aware of the limitations of various tuners. Some older DVB-S tuners cannot receive DVB-S2 signals, and some DVB-S2 cards cannot receive 16APSK signals (if you really want to receive one of the handful of 16APSK signals on North American satellites, and you are considering the purchase of a TBS tuner card, it is strongly recommended that you purchase one of the “professional” grade models). Some tuner brands do not support their tuners with updated drivers, meaning that people may recommend you use some unofficial driver from a questionable source. Or, if you want to use more than one tuner card from the same manufacturer or of the same model in the same backend system, you may find that’s impossible because the driver programmers apparently never anticipated that someone might like their tuners enough to want to buy a second one (I guess that lets you know what they think of their product). The may be certain tuner models that will not work at all under Linux (you can find lists of DVB-S2 tuners known to work in Linux by following the links on this page, but just because a particular tuner isn’t mentioned does not necessarily mean it won’t work – it may just be that no one ever bothered to add it to the page). Problems caused by tuners or by tuner drivers will likely affect any backend software you might choose to use.

With TBS tuner cards in particular, you need to be careful that they are not sharing interrupts (IRQs) with other hardware devices in your system. Also, if you have a newer model TBS card and find that it will not scan muxes to find channels, try this. If you find that many of your recordings have bad timing information, and it’s not due to a weak signal, it is sometimes possible to fix that by changing a setting in Tvheadend.

If you start asking around about which tuner you should purchase, please keep in mind that the “Linux snobs” (the type that will only point you to man pages and Google when you need help) may prefer a particular piece of hardware, but only because they’ve had enough Linux experience to work around any issues they encounter. Just because they could get a particular tuner to sing and dance doesn’t mean that you can, unless you have a similar level of Linux experience. If you ask in a Linux forum which tuner is best, and make a purchasing decision based on the responses you receive, and you are relatively inexperienced with Linux (or you are simply not a Linux devotee), there is a real good chance that you that you will not be happy with your purchase. One tip, no matter how much they may be recommended by a particular user or group of users, avoid older PCI cards – any tuner cards you purchase now should be PCIe (note the “e”) cards.

Unfortunately, not all PCIe tuner cards are compatible with all motherboards. I’ve had good luck with a MSI motherboard (specifically the model B85M-G43, although I’m sure many other models will work equally well), but when I had tried using the same tuner card in a particular Gigabyte motherboard it would not work. A real Linux expert perhaps could have figured out the reason why, but since I’m not a Linux expert it was a lot easier to just try a different motherboard. Had I known about this thread in the TBS forum, I might have tried the suggestion there to see if I could get it to work.

There are also USB-connected external tuners, and while some users have had no problems using these, several others have reported problems with overheating leading to premature failure. Also, with certain USB-connected tuners there is an extra step of installing firmware, in addition to the drivers, at least when using Linux as the operating system. I’ve never used a USB-connected tuner, but if you decide to try one, I’d at least keep it in a well-ventilated place.

If you want to build a reliable system, I definitely recommend a desktop computer that will accept the PCIe cards. If you choose to “cheap out” and use something smaller, at least please be sure it does not have an ARM-based processor. You can get Tvheadend to run on such systems, but certain things will be more difficult than they should be, and you may also find you have more bad recordings and other weird issues. Note that you don’t need a high-powered gaming computer to run Tvheadend, in fact most of what Tvheadend does will not put much stress on the CPU(s). An older standard desktop model will probably work just fine, as long as it has the PCIe card slots. The computer must be capable of running Linux, so generally speaking, that leaves out boxes that run Android only.

Although there may have been some custom builds of Tvheadend for specific smaller devices, I recommend that new users avoid them. Once you have built your first Tvheadend system and see how it works, then you’re ready for the challenge of installing it on something smaller and with fewer resources, if that’s what floats your boat. But when starting out, you don’t need any additional challenges. Remember, a system that works fine for terrestrial television may not be at all suitable for free-to-air satellite TV reception, due to the difficulty of installing drivers required by the tuner cards, or the difficulty of installing and running additional software required to get program guide data.

At the time I am writing this I suggest using TBS tuner cards. The “consumer grade” ones are fine for most transponders but if you are going to try to receive anything in 16APSK or 32APSK format, I strongly recommend going with a “professional grade” card (this will also be true if you are going to try receiving C-band signals on a 6-foot or smaller dish). Each card will have between one and four tuners, and unless you are restricted in some way as to the number of dishes you can have on your property, you might want to think about getting a quad (four) tuner model. You may find that even four tuners aren’t enough, but if you can afford it I’d at least start out with a quad tuner card. If money is no object, I’d start with the TBS6908 Professional DVB-S2 Quad Tuner PCIe Card. When paired with a 10 foot (or larger) dish and a good LNB you should be able to receive just about any unencrypted service up there. However, many users will opt for a less expensive “consumer grade” model, and that’s fine, just don’t expect great results on “difficult” signals such as 16APSK or 32APSK signals.

Beware of satellite dealers that have old stock they are trying to sell. In some cases the older cards work perfectly fine, but may not receive newer formats (a card that only receives DVB-S, and not DVB-S2 is nearly worthless nowadays). In other cases the cards may be dogs that no one would buy because they never worked that well, or ONLY worked well for extreme Linux geeks that dream in code and talk in a language that you or I would only understand about 10% of, at best. The sort of people who can write their own drivers for tuner cards, in other words. Such people can make some of the more obscure tuner cards sing and dance, figuratively speaking, but their preferred choice for tuner cards may not be the best choice for you if, like most of us, you intend to use the stock drivers provided with the device. I hate saying anything bad about these guys, because I’m sure they are extremely intelligent, but they should probably never give advice to us mere mortals on which tuner cards to buy, because we just want something that works without a lot of fuss, and we don’t want to have to rewrite the tuner driver or poke around in the bowels of Linux to make a tuner card work!

Speaking of tuner card drivers, if you are somewhat more of a Linux expert than I (which isn’t exactly a high standard, since I struggle with Linux), you should be aware that TBS DVB-S2 tuner users may now be able to use open source drivers.

I HAVE A COMPUTER AND HAVE INSTALLED A TUNER CARD, NOW WHAT?

In order to install Tvheadend you will first need to install the Linux operating system. If you don’t plan on using the same computer for both your backend and frontend, I suggest using Ubuntu Server. You do not need a desktop on your backend server. However, if you also want to install Kodi on the same computer, then install regular Ubuntu. In either case you should install a Long-Term Support (LTS) release, so you’re not forced to upgrade the software prematurely.

If you are using TBS tuner cards, I have found it necessary to do this after installing Ubuntu, in order to avoid serious errors while building the drivers (at least this was true under Ubuntu 14.04):

sudo apt-get update
sudo apt-get install linux-headers-`uname -r`
sudo apt-get install make gcc

I’m not sure whether it’s still necessary to do this under Ubuntu 16.04, though it probably couldn’t hurt. Even after that, you may see warnings and other notices while the TBS drivers are compiling, but usually they will still work.

One thing I would like to warn you about is that there are distributions out there called “OpenElec” or “LibreElec.” I most emphatically DO NOT recommend these, unless you simply must have the absolute easiest installation, and you don’t care about the fact that you won’t be able to get to a Linux command prompt easily. And before you say you don’t care about that, please understand there will be consequences, such as not being easily able to get program guide data (and that is doubly true if you also ignored my advice not to use an ARM-based processor). Quoting Robert Cameron in the Tvheadend forum:

… And if you do decide to go with a PVR, for everyone’s sake please ditch LibreELEC: it is a poor excuse for a proper OS and will cause you nothing but problems trying to work around its limitations (such as inability to easily upgrade core components, like a current and proper build of Tvheadend).

If you are installing something for a senior citizen that knows absolutely nothing about computers, doesn’t want to know anything about them, will just accept any limitations they encounter because they don’t know any better, AND you won’t be around to help them at all, then maybe you can make a case for using one of the “-Elec” distributions, but please don’t come crying when you are frustrated as hell because you can’t do anything in Linux. Please use a LTS build of Ubuntu Server or Ubuntu Desktop if you don’t like dealing with problems.

Assuming you have followed the manufacturer’s instructions while installing your tuner card, you will probably find that you need to install drivers for your tuner, and they should have given you the driver software or shown you where to get it online. Once again I will quote from my earlier article:

One downside of using any Linux-based backend is that you may need to install drivers, either to get your tuner to work at all, or to get it to work at peak efficiency. And if you are used to installing drivers in Windows, where it’s more or less a point-and-click type of operation, you may find that the procedure for doing it under Linux is a bit off-putting. For certain tuner brands, it is not very difficult if you can follow instructions (for example, this page explains how to do a TBS driver install under Ubuntu 11.10, 12.04, 12.10 and 13.04 (TBS6921 and other)). But not everyone finds it easy; sometimes there are entire forum threads about driver installation. If you’ve never touched Linux before in your life, then you may want to seek help from an experienced Linux user. Make sure you watch how it’s done and take notes, because you will likely need to do it again if you ever upgrade the Linux kernel on your system (and Ubuntu loves to push kernel updates every so often, so don’t just blindly accept a software update 10 minutes before you have something scheduled to record!). This bash script can help simplify the task of rebuilding the TBS drivers after a kernel update.

Note that the bash script mentioned in the previous paragraph is for building the standard closed-source TBS tuner drivers. If you choose to use the open source drivers, you’re probably enough of a Linux expert to know how to rebuild them without needing a script (but if you happen to find one, please let me know in the comments!).

After you have installed the drivers and rebooted the system, you can discover whether your tuner cards are being recognized by the operating system by using either or both of these two commands:

dmesg | grep -i dvb
ls -l /dev/dvb

If you have installed TBS Tuner cards, before you go any further please read these articles, which will help you avoid some pitfalls down the road:

At the very least, TBS card owners should read the first article in the above list now, and keep the others in mind for future reference.

Also, if you are using a version of Ubuntu newer than 14.04, it may have come with the package unattended-upgrades installed by default.  With the default settings, this package will install certain types of updates automatically, including Linux kernel updates.  The problem with that is that if you have received a kernel update and then reboot the system for any reason, and you have not reinstalled the TBS drivers since the update was installed, it will use the new kernel and you will not have any tuners available (so you will not be able to view channels, and scheduled recordings might be missed).  And if you ssh into the system it will print *** System restart required *** in your terminal window, which might cause you to reboot the system without thinking about the fact that you then need to reinstall the drivers.  To avoid this problem, you may wish to disable unattended upgrades.  The easiest way to do this is to edit the file /etc/apt/apt.conf.d/50unattended-upgrades and comment out the lines that are allowing the upgrades, such as these:

// “${distro_id}:${distro_codename}”;
// “${distro_id}:${distro_codename}-security”;
// “${distro_id}ESM:${distro_codename}”;

If any of these lines do not have the // characters at the start, place them there and save the file. Note you will probably need to use sudo to edit this file, for example sudo nano /etc/apt/apt.conf.d/50unattended-upgrades. See this page for more information on disabling unattended upgrades, though I do not recommend the “Method Three” shown there.

Once you have installed the tuner drivers and verified that the operating system can detect them, it is time to install Tvheadend. Before we go any further, I should point out that Tvheadend is an evolving program, and as with many programs, when newer versions are released, configuration options may change, and often new options are added. In most cases, if you see a new option and you don’t know what it’s for, you can safely leave it at the default setting. While writing this article I am using Tvheadend 4.0.9, which is the current stable version. There have long been rumors of an upcoming 4.2 release, but it hasn’t happened yet and when it is released, it will probably be some time before I get around to installing it. When it does appear, I’m sure the interface will be changed up in some ways. I have heard, for example, that there will be a configuration wizard that will make configuration easier. While I hope that’s true, I have my doubts about it including a setup for North American free-to-air satellite channels. My guess is that we in North America will need to skip the wizard, and use the manual configuration as I will explain here. I hope I’m wrong about that; it would be great if this process were easier.

The installation instructions for installing Tvheadend under Ubuntu are here. You will need to choose a repository, and I suggest either the “stable” or “unstable” repositories. In the case of Tvheadend, “unstable” isn’t all that unstable, compared to what that means in some other software projects. Many people run the unstable version to get the latest software improvements, but that is entirely up to you. If you have very little familiarity with Linux, then it’s probably best to stick to the stable version. I am currently running the stable version (4.0.9) as I write this.

CONFIGURING TVHEADEND

There are many videos and web pages on configuring Tvheadend, and many of them will confuse you more than help you, especially if it’s your first exposure to Tvheadend. That is because they were either based on old versions of Tvheadend, which had a somewhat different interface, or because they assume that Tvheadend is running on an OpenElec or LibreElec system, which as mentioned above is not recommended. Or, they may have been intended for terrestrial TV viewers, which has a slightly different configuration, or for the European version of free-to-air satellite, which is different in many ways from what we have in North America (for a decent explanation of the differences, there is a Wikipedia article on Free-To-Air – just skip to the section on North America and read that entire section).

Setting up Tvheadend for the North American style of Free-To-Air satellite is in some ways similar to configuring it for over-the-air reception using an ATSC tuner, but there are some important differences. In most cases setup will be a lot more manual because you will need to enter in the details for each satellite and each transponder manually.

There are a couple of terms that Tvheadend uses that may confuse you during configuration. One is “Networks”, and the other is “Muxes”. These easiest way to think about these is as follows:

A “Network” in most cases will be associated with a single satellite, whether you have one or more LNB’s (or LNB outputs, in the case of dual or quad output LNB’s) receiving from that satellite. So for example, if you have two dishes and one is pointed at Galaxy 19 and the other at AMC 21, you would make two networks and call them “Galaxy 19” or “G19”, and “AMC 21” or just “A21”. The name is not important, so use something meaningful to you, and in most cases that will be the satellite name. You could also use positions, such as “97W” and “125W”. The point is, the word “Network” has nothing to do with what we think of as a television network, instead it is all the sources that have the same transponders available. So, if for some reason you have two dishes aimed at the same satellite and they could receive the same channels, those would be under the same “Network”. On the other hand, if you have a moveable dish, you could have several “Networks” associated with that dish. This will become more clear as we look at the configuration.

A “Mux”, when associated with free-to-air satellite, is the same thing as a transponder, which (if you’re not too nit-picky) is the same thing as a specific frequency allocation on a satellite. When a Mux is created and scanned, it should show all the active services (TV, radio, and data channels) available on the transponder, which will be on a specific frequency on the satellite. To use a specific example, as I write this, on AMC 21, Ku band, there is a transponder, or “Mux” in Tvheadend terminology, at 12180 V that contains several PBS channels. In that case, you can think of all the channels on the 12180 frequency as the “Mux”. When used in relation to terrestrial TV, a “Mux” is a single physical channel on a specific frequency, which may have several virtual channels. So whether on satellite or terrestrial TV, a “Mux” is a single frequency that may contain one or more TV and/or radio channels. In Europe things can get a bit more confusing, because they can duplicate transponders across multiple satellites, but we don’t see that here in North America.

I should also mention tuners. Generally speaking it is best to have one tuner input on your backend for each LNB output you have out on a dish. But if some satellites are infrequently viewed, it would be wasteful to dedicate a single tuner to the LNB associated with that satellite. Tvheadend does support the use of 4-input DiSEqC switches, at least with TBS tuner cards. As far as I can tell, even though Tvheadend supposedly supports them, either Tvheadend or the TBS cards, I’m not sure which, have some problem controlling 22kHz tone switches. I didn’t spend much time trying to make them work, since DiSEqC switches are relatively inexpensive.

If you have a card or cards with multiple tuners (for example, if you obtained a quad tuner card), then I would suggest using fixed rather than moveable dishes if your situation allows. While Tvheadend can in theory control a dish positioner motor, I’ve not yet seen it work in practice, and I’ve never personally attempted to do it. But feel free to try; if you can get it to work, please leave a comment and let us know what you had to do. The same goes for using any type of switch other than a standard 4-input DiSEqC switch. Remember that even if Tvheadend is capable of sending the correct signals to a switch, it is also up to the tuner card and its drivers to make sure the switching signal gets sent, so what works in one installation might not work in another if different tuner cards or drivers are used.

Note that you can buy LNB’s with dual (or, more rarely, quad) outputs. By hooking each output of a LNB to a separate tuner input (either directly or through a DiSEqC switch), you can watch or record shows from different transponders (or muxes, as Tvheadend calls them) on the same satellite at the same time. Note that you can watch or record as many simultaneous channels as you like from the same transponder (mux), because the LNB and tuner card can receive a full transponder stream, and Tvheadend breaks out the channels as necessary. It’s only when you want to watch or record from two different transponders (a.k.a. muxes, a.k.a. frequencies) on the same satellite that you’d need multiple LNB outputs connected to different tuner inputs.

The more dishes, LNB outputs, and tuner inputs you have available, the more likely it is that you’ll be able to avoid scheduling conflicts, where you want to watch or record a show, but no free tuner is available because all the tuners associated with that dish are already in use.

TVHEADEND’S WEB-BASED INTERFACE

Once Tvheadend is installed, you access its configuration pages via a web browser. The address will be port 9981 at the backend’s IP address, so if for example the backend is at 192.168.1.50 you’d use http://192.168.1.50:9981 in your browser’s address bar to access Tvheadend’s web interface. If Tvheadend is running on the same machine you’re using, then you can use http://127.0.0.1:9981 to access it.

You will see tabs across the top of the page, and the first place you will want to go is the Configuration tab. Click on that and it will expose a new row of tabs. You need to understand this about Tvheadend, it does not expose options until a previous selection indicates you need them. So if, right after installation, you were to try to discover where you configure a DiSEqC switch, you’ll never find it because you haven’t indicated to Tvheadend that you have a DiSEqC switch, therefore it will not show you that option.

In the second row of tabs, choose DVB Inputs. This will expose a third row, which is where most of the initial configuration will be done. First, choose the TV adapters tab. You should see a list of your available tuners. If you don’t, something is probably wrong – either your tuner card is not being detected by Linux, or you don’t have the correct drivers properly installed. You will need to resolve that before continuing on. Note that if you ever come here and the tuners have disappeared, it probably means you applied a Linux kernel update and forgot to rebuild the tuner card drivers. Just rebuild and reinstall the drivers, and all should be fine again (we hope).

Now go to the Networks tab. Create one network for each UNIQUE tuner input. In other words, if you have four satellite dishes and each has a single-output LNB and your are feeding all four LNB’s into discrete tuner inputs, then you will want to have four networks. If you have two satellite dishes and each has a dual-output LNB and you are feeding all four LNB outputs into discrete tuner inputs, you will only need two networks, because two of your tuners can receive duplicate programming. To possibly simplify this, if none of your satellite dishes are moveable (or if you always leave your moveable dishes parked on the same satellite) then you need to create one network for each satellite you can receive, and that’s probably a good rule to follow even if one or more of your dishes are moveable. Also, C and Ku band LNB’s should be on separate networks, and if you receive both the C and Ku bands from the same satellite, use different network names to reflect that (you could add “-C” or “-Ku” to the name).

To create a network, click the Add button, then in the window that appears select DVB-S Network in the dropdown (don’t worry if it’s DVB-S2, in this window DVB-S covers it).
Adding a DVB-S networkIn the next window that appears, give the network a name (again, I recommend you give it the name of the satellite, or the orbital position, whichever works for you, with the “-C or “-Ku” suffix if you receive both) and UNCHECK “Network Discovery”. Leave everything else at the default for now. Then click “Create”. Repeat as necessary for each unique tuner input/satellite you can receive.

Add a DVB-S networkYou may have noticed during the Network creation process that you could have selected a pre-defined mux. You could do that, but I don’t recommend it because pre-defined mux lists are often inaccurate, and sometimes don’t distinguish between C-band and Ku-band. So if you try to use those in North America, you will likely wind up with a list of outdated or inaccurate muxes and will wind up having to delete them manually. It’s your system; you can try the pre-defined mux setting if you like, but don’t say I didn’t warn you. You may also have noticed that you can select an orbital position, but you would only need to do that if you were going to try to control a moveable dish. For a fixed-position dish, it matters not whether you select anything there.

When you have configured your networks, go back to the TV adapters tab. This is where things get a little tricky. The first thing I will say is that you need to enable each tuner by checking the “Enabled” checkbox associated with each tuner as shown in the following screenshot, and also you need to click “Save” each time you make a configuration change (I can’t tell you how many times I have forgotten to click “Save”, and then wondered why something wasn’t working). Also, most configuration pages will have settings that don’t need to be changed, in which case leaving them at the defaults is fine.

At this point I’m going to quote from a previous article that covers this topic, but please note that the images are from a slightly older version of Tvheadend, so may not correspond exactly to what you’ll see. In some cases you’ll see additional options or settings, but this covers the ones you need to change:

There are a few things that North American users should be aware of. For one thing, Tvheadend assumes you’ll be using a Universal LNB, which is not something used all that often in this part of the world. Here, you are much more likely to be using a standard (Ku band) LNB, or even a C band LNB. But when you are setting up the TV adapters, you won’t find an option for those. The trick is that you need to select “Advanced” in the SatConfig dropdown, then save it, and then you will notice that in the left hand menu tree, additional options are exposed. This is how Tvheadend seems to work; it doesn’t show you options that are not applicable to your existing configuration, so as you make the configuration more complex, more options are exposed.

TV Adapters settingsSo once you have selected the Advanced setting and clicked Save, you can expand the tree view an additional level and click on Advanced, where you will select the number of orbital positions that each tuner has access to, which is 1 if you are connecting a tuner directly to an LNB. If you are connecting to a 4 port DiSEqC then it’s 4, as shown here:Orbital Postions settingAfter you save that, then you can configure settings for each of your orbital positions, including LNB type. In North America you will probably want to select either “C-band” or “Circular 10750”. You would use the latter for any standard Ku band LNB that has a LO Frequency of 10750 MHz, even if it’s not circularly polarized. Keep in mind that this type of software (or at least the satellite tuning portion) is much more widely used in Europe and other places outside North America, and they are much more likely to be using a circularly polarized LNB than we are here.

I’m going to interrupt my quoting here to note a few things. First, just to show how much some screens can change between versions, the above screenshot was from a 3.9 version of Tvheadend. By the time we got to version 4.0.9. that “Parameters” section on the right hand side had expanded to include many more options (mostly to support moveable dishes, or so it appears) but at this point you would likely still only need to set the number of orbital positions. After you get things working on a single satellite, then if you have a moveable dish you can come back and try to configure those settings: Baby steps, as the saying goes:

New Advanced ParametersAlso, when looking at the screenshot below, the setting for Ku in North America is now “Ku 10750” rather than “Circular 10750”. And, please note the “Name” and “Networks” dropdowns in the screenshot below. I find it easiest to use the satellite name in the Name field, and then select the network corresponding with the satellite that will be received by this tuner and switch combination. So in my configuration, which does not include any moveable dishes, the “Name” and “Networks” are always the same. However, if I were trying to control a moveable dish, I would likely select a “Name” associated with the dish (such as “C-Band moveable”) and then under “Networks” select all the networks (satellites) that dish is capable of receiving. Also for a moveable dish, I’d need to select a “Rotor Type”, which for most users would probably be “USALS”. Again, please bear in mind I have never tried to use a moveable dish with Tvheadend, so the parts about the moveable dish are just conjecture on my part. Continuing on with the quote…

Tvheadend Orbital Position Settings showing C-Band LNB and Generic switch type selectedIf you are using a standard DiSEqC and/or 22 kHz tone switch, then select “Generic” for the switch type. For a four port DiSEqC switch, you would use the “Committed” dropdown and select the port there. Tvheadend uses AA, AB, BA, BB port descriptors, which correspond to DiSEqC switch ports 1, 2, 3, and 4 respectively. I had no problem using a standard 4 port DiSEqC switch (well, except that it turned out that the brand new DiSEqC switch had a bad port 4, but that’s obviously not the fault of Tvheadend or the tuner). In the screenshot below, DiSEqC port 2 (AB) is selected. Settings for any types of switches you don’t have should just be left at the default settings.

Tvheadend Generic Switch Settings showing showing DiSEqC port 2 (AB) selectedOne other consideration for North America is that it is extremely rare for the free-to-air signals to include Electronic Program Guide data. Therefore, it would be a good idea to go to Configuration | Channel / EPG | EPG Grabber and in the Over-The-Air Grabbers section, uncheck all the grabber selections. None of those will work in North America anyway, so there’s no sense burning up CPU cycles checking for EPG data that will never appear. I will have a bit more to say about getting EPG data later in this article.

Disable the Over-The-Air GrabbersI have updated the above screenshot because in addition to disabling all the grabbers, you also want to make sure that the “Force initial EPG scan at startup” box is unchecked and that all the “Over-the-air Cron multi-line” entries are removed or commented out. It’s probably worth emphasizing that Tvheadend was designed primarily for use in other parts of the world, where commercial free-to-air services are available. We don’t have anything at all like that in North America, so there are many parts of the Tvheadend interface that simply aren’t applicable to us. An example is the “CAs” tab in the above screenshot; there is no reason to ever go into that tab here in North America.

After you get your tuner(s) configured and enabled, you will want to try creating a mux and scanning it. To do this, find a reference that shows available satellite channels, such as Sathint, or check in your favorite satellite forum. Let’s say you wanted to add the PBS channels on AMC-21. You could first go to Sathint’s North & South America page and select AMC-21. On that page you would find that the main PBS feeds are on 12180 V, that the symbol rate is 30000, that the FEC is 3/4 and if you mouse over the little arrow just to the right of “3/4” you will see that it is a DVB-S2, 8PSK signal.

Sathint exampleThis is the information you will need to create a mux. Note that both the frequency and the symbol rate in such listings are expressed in short form, in other words they should rightly read 12180000 and 30000000. Many receivers and software programs will accept the shorthand version, but Tvheadend does not.

So to create a mux, click the Muxes tab, then click the Add button. A window will pop up asking you to pick a network, in this case you’d pick AMC-21 or 125W, assuming you followed my advice to name the network after the satellite. After picking the network, you will then see the following window which should be filled in as shown here:
Sample MUX settingsYou want to check the “Enabled” box. Set the EPG Scan to “Disable” because North American channels do not contain EPG data, so why make all your hardware search continuously for something that will never be found? Set the Scan Status to PEND because you want it to scan the mux to find channels. Set the Delivery System to DVBS2 because it is a DVB-S2 mux. Set the Frequency to 12180000 and the Symbol Rate to 30000000; don’t forget the extra three zeroes at the end or it won’t work. The “Polarisation” (U.K./Canadian spelling there!) is Vertical, so pick V. The modulation is 8PSK, which Tvheadend presents as PSK/8 for some reason. The FEC is 3/4. The Rolloff can almost always be left set to AUTO. The other settings can be left at the defaults.

Try not to use AUTO for any setting other than Rolloff; Tvheadend is not very good at auto-detecting settings, particularly with 8PSK and higher signals. With QPSK signals it will often detect the FEC if you leave that set to AUTO, but if you know the FEC it’s always better to put it in. But, please be aware that data you find online isn’t always accurate; on a few occasions I’ve found channel listings containing incorrect FEC information.

Note: This guide was written using Tvheadend 4.0.9, but if you are setting up Tvheadend 4.2 or later there are some new checkboxes you need to know about, that you can only see if you are using the “Expert” view level.  The screenshot below shows an unconfigured mux, but does show the locations of the new checkboxes.  In North America you are probably going to need to check both of these.  If you don’t, some or all services on a mux may not scan in, or later on when you attempt to watch a channel on that mux, you may get “No input source available for subscription” errors or other errors.

UNCONFIGURED Add Mux screen showing new checkboxes in Tvheadend 4.2

When you click “Create” it should create the Mux and then if all goes well, a few seconds later it will start scanning the Mux to find channels. Watch the two columns labelled “Scan Status” and “Scan Result”, when the “Scan Status” returns to “IDLE” and the “Scan Result” is OK, that means it has successfully scanned the transponder. If it actually found any services (potential channels), the number found will be listed in the “# Services” column.

If, instead of OK, you see the word FAIL for the scan result, that means either the mux or the tuner were not configured properly, or the tuner didn’t detect any signal (or the signal strength was too low). Or it could be a timeout issue – if you are using a TBS card, see Tvheadend users, if your TBS card will not scan muxes to find channels, try this. Remember that satellite signals can come and go without any advance warning, and in particular remember that transponders that are active on weekdays sometimes are taken down on the weekends. If your first attempt to scan a mux is a failure, just try another. If you also have a satellite receiver, temporarily connect it to the dish and make sure the transponder you’re trying to receive is actually there.

Assuming the mux scanned correctly, go to the Services page and you should see the newly-scanned services. You might want to sort the list by Mux to find them easily, if other muxes have been previously scanned.
Example Services pageThere is one thing that is set by default that really should be changed in North America, but before I go into that I want to point out something in the above screenshot. Note at the lower right-hand corner of the screenshot there is a small button with two caret symbols (^) on it. If you click that, it will open a debugging window at the bottom of the screen that shows you what Tvheadend is doing in the background. For example, if you open that window before you scan a mux for channels, it will show you which tuner it’s using and other information that could possibly be useful in determining why a scan fails. If you open it while importing program guide data, it will show you statistics on what it’s imported and whether it encountered any problems. This can be quite useful when you are trying to diagnose a problem.

But getting back to the problem, in the Automatic Checking column in the above screenshot, note that it says “Auto Check Enabled”. What this means is that every so often, Tvheadend will check for the service presence, in other words, it will look to see if that service is still there. If it’s not found, this field will change to “Missing In PAT/SDT” and then you won’t be able to tune it in or watch it, because Tvheadend believes it no longer exists. The problem in North America is that services can disappear for a time, for any of several reasons. One is that some feed channels (channels that send feeds of smaller network or syndicated programs) often stop uplinking to their transponders on weekends, to save energy when nothing’s being transmitted. Another very common one, especially in Canada and the northern United States, is a huge snowstorm that dumps so much snow on the dish that reception is severely impeded. And, if you use a moveable dish, you will of course have no service from the satellites the dish isn’t pointed at. This type of check may make sense in sunny Spain, but not in North America. Fortunately this check can be disabled for any or all services, but unfortunately it’s a pain in the ass to do it because you have to do it for each individual service.

There are two ways to disable this check, and I will tell you about both of them because this is common to other parts of the Tvheadend interface. The first is to highlight a service and click Edit. A window will pop up and you can pick “Auto Check Disabled” from the dropdown. This is also how you can undo the “Missing in PAT/SDT” designation if it somehow gets set. Make the change and click Save, then repeat for each service that has Auto Check Enabled.
Setting Auto Check to DisabledThe second method is on the services page itself, you can click or double-click on the words “Auto Check Enabled” and a dropdown should appear right there, with the same options shown in the dropdown above. Select “Auto Check Disabled” and then (this is important) click SOMEWHERE ELSE in the window to make the dropdown disappear (this could be a double click on the next item you want to change). A small red triangle will appear next to the changed item; this means it is a pending change that has not yet been saved! You can work your way down the list of “Auto Check Enabled” services and change each to “Auto Check Disabled” but after the last item make sure you click somewhere else to make the dropdown go away and the small red triangle appear., Then, BEFORE YOU LEAVE THE PAGE, click the “Save” button (which is just above the “Play” column heading on the left hand side of the screen). The page should reload and all the red triangles should have disappeared. Only now are your changes saved! If you forget and leave the page before clicking Save, you get to make all the changes over again. I wish there were a way to make “Auto Check Disabled” the default, because I do not want Tvheadend making the decision that a service is no longer available and locking it out. In North America, that’s generally a really bad idea!

The two methods of making configuration changes that I have mentioned above work on several of the pages in Tvheadend, but you always have to remember to click Save before leaving or refreshing a window or page, otherwise your changes will be lost!

Once you have disabled all the Auto Checks, what you want to do next is map the valid services to Channels. You can always delete a channel you don’t want later, so if in doubt it doesn’t hurt to map it. Sometimes the Service ID numbers and/or the Service Names will give you some clue as to which are viewable channels, but if you like you can just try mapping all the services. Highlight the ones you want, in the same way you’d highlight files for copying in your computer’s file browser. When you have highlighted one or more services, the “Map All” button shown in the screenshot above will change to “Map Selected”. So when you have highlighted the ones you want, click on “Map Selected”, and you’ll then see a popup window that looks like this:

Map services optionsIn most cases you’ll simply click the Map button. Most of the other options would make more sense in other parts of the world, but will only cause problems if you use them in North America. The one exception to that is the “Include encrypted services” option. Once in a great while a satellite channel will be marked as encrypted when it really isn’t. If you see something that indicates you should be able to receive a channel, but it’s indicated as being Encrypted in the services list, you can try checking the “Include encrypted services” box to map the channel anyway.

To see the channels that have been successfully mapped, go to the Channel/EPG tab (in the second row of tabs) and select the Channels tab in the bottom row. You should see a list of all the channels that have been successfully mapped. You can highlight any channel and use the Delete button to delete any channel you don’t want (this does not delete the service in the services list, only the mapped channel) and you can use the Edit button to edit the data for channels. In most cases you will want to edit channels you plan to watch regularly. As was the case with changing the Auto Check settings in Services, there are two ways to do this, but probably the best way when you are first starting out is to highlight a channel and then press the Edit button. You will see a dialog box that looks something like this:

Edit channel windowBefore editing the channel, though, you may want to try actually viewing it using your frontend software. If you are using Kodi, you will need to enable and configure the Tvheadend PVR addon first. Go to this page and skip down to section 5, “Connecting Kodi to Tvheadend” and follow the instructions there. After you do that, go to the TV settings (System-Settings-TV) and in the General section make sure “Synchronise channel groups with backend(s)” and “Use channel order from backends” are selected (you will have to set the “Settings Level” to “Advanced” or “Expert” to check and, if necessary, change those options). If you have an older version of Kodi, you may have to go to the “Live TV” section and make sure it is enabled; but that no longer seems to be necessary in the latest versions of Kodi.

Once you have configured the PVR addon you can go to TV in Kodi’s main menu, and under Channels you should see your newly added channels. They may have strange names at this point, but you should try watching each, first to see if there is really a channel there, and second to try to determine which channel it is. Sometimes you will know from online listings which channels are which, but in other cases the only way to know is by watching for a while and looking for a channel identifier.

In the above image, we have shown the Edit channel dialog for PBS “HD01”, which you might determine is an eastern time zone feed for PBS. So for now, we can make the following edits to the channel. The most important at this point are the channel name and number.

The channel name should ideally be one that identifies the channel, in this case “PBS East” would be a good choice. The channel number should be any non-zero number; it will be used to order the channels in Kodi. The numbers do not have to be contiguous; it’s perfectly okay to group channels into blocks of numbers and leave some unused channel numbers in between, but you should try not to leave any enabled channel un-numbered or duplicate any channel numbers. Neither Tvheadend nor Kodi will complain if you do, but channels may not be in the order you expect if you do that.

The “EPG Source” field will be very important when you are setting up your program guide, but you probably aren’t ready to deal with that quite yet. You’ll most likely want to first get all your muxes and channels entered.

There is a field for a “User Icon”. There are two places you can store channel icons, one is in Tvheadend and the other is on the frontend systems where Kodi is being run. In my opinion it is better to store them on the frontend systems. I tried doing it in Tvheadend and had some weird issues as a result, such as Kodi freezing up when I attempted to exit the program. Such issues may or may not have been fixed in newer versions of Tvheadend and/or Kodi. In any case, you don’t need to add channel icons right now. When you are ready to do so, my suggestion is that you store them on the frontends running Kodi and then go to Kodi’s TV settings (System-Settings-TV) and in the Menu/OSD section, set the “Folder with channel icons” to the path where your channel icons are stored. But feel free to try doing it in Tvheadend if you like; if it works for you and doesn’t cause any problems then use that if you prefer.

In some places in Tvheadend you may see a reference to “picons” – these are small, generally low resolution channel icons that often appear blurry in Kodi. In Europe and other parts of the world people often download archives of picons that correspond to the channels available from their satellite provider. Kodi doesn’t care what size icon you use; if it is too small it will upscale it and it will look bad, whereas if it is too large Kodi will reduce it to fit and it will be very clear. Therefore, if you have a choice between a large icon or a small one, larger is often better (within reason – you don’t need one that fills half the screen on your computer’s display). Since we don’t have packages of “picons” corresponding to the channels available on North American C- and Ku-band satellite, and since I wouldn’t touch them if we did, I suggest you use your favorite search engine’s image search feature to find channel logos. You can also try LyngSat Logo, but be careful because some of their logos are too small to display clearly in parts of Kodi. Another thing to beware of is logos that don’t contrast well with Kodi’s dark background. If you have any experience with programs like Photoshop or The Gimp, you will probably find yourself wanting to modify a few logos slightly to make them look better in Kodi.

One additional point about storing the icons in Kodi is that they should be in PNG format, and should be named exactly the same as the channel name you gave the channel in the “Edit Channel” window. So for example, if you you have an icon for PBS East, it should be named PBS East.png. Yes, that means you will need to duplicate icons if you use the same icon for more than one channel (for example, even if you use the same icon for PBS East and PBS West, you’ll need two files, PBS East.png and PBS West.png). I would guess that icons in JPEG format (with a .jpg extension) might also work, but I have never tried it because I don’t care for JPEG artifacts.

Enough about icons. One other thing you may wish to do, which might help your frontend systems work a little easier, in in Tvheadend’s configuration select the Configuration tab on the top row of tabs, then the Stream tab on the second row, and the Stream Profiles tab on the third row. Then select the “pass” (MPEG-TS Pass-through) stream profile. Make sure all the checkboxes are checked next to these items:

  • Rewrite PMT:
  • Rewrite PAT:
  • Rewrite SDT:
  • Rewrite EIT:

The result should look something like this:

Pass-through stream profileThe reason for doing this is when you are streaming a channel to your frontend, with these boxes checked it will only send information about that specific channel, and not about all the channels in the MUX (if there is more than one). When information about multiple channels is sent, it might confuse your frontend, resulting in no video or audio. The only reason for not checking all these boxes would be if Tvheadend is running on a very underpowered system, which it probably isn’t if you followed my advice to use a desktop computer system when installing Tvheadend. It does take a little bit of CPU power to do these rewrites, but generally speaking, not enough that you’d ever notice.

SETTING UP THE ELECTRONIC PROGRAM GUIDE (EPG)

Once you have configured Tvheadend, and have added all your muxes and channels, you will probably want to have the EPG populated so you can schedule programs to record. In North America, there is a company that offers paid schedule listings, and occasionally some of their proponents stoop to implying that it is somehow illegal or immoral to get program listings for free. It is neither, as long as you are using them for your own personal use (disclaimer: I am not an attorney, and I am not giving you legal advice). No one has ever gotten in trouble for using free listings in Tvheadend, and I would be shocked beyond belief if anyone ever does. Honestly, it pisses me off when a company or their supporters attempt to imply that you are a bad person for not purchasing their product, when you know their only reason for saying that is because they want to make money.

At this writing the easiest way to get free EPG listings for the USA and Canada is to use a program called zap2xml. That link takes you to a page of instructions for setup and use under Windows or Linux, and download links. You will probably want to run the Linux version on your backend system. Some time back I created an article containing additional hints and instructions, titled Some hints for getting free-to-air satellite channels into the Electronic Program Guide in Kodi (or another frontend). That article was not my best work; it’s been edited a few times and I may completely rewrite it some day, but if you are having problems figuring out how to use zap2xml or how to get Tvheadend to use the generated listings, that article may give you the clues you need to make it work.

Some other guides out there may mention a program called mc2xml. This program used Microsoft’s listing service, and several months ago Microsoft made some changes that rendered mc2xml inoperable. At that time, many users switched to zap2xml. The only problem some users have with zap2xml is that it is a Perl script, and therefore your system must have Perl installed. Ubuntu includes Perl in its operating system. However, if you ignored my advice above and decided to use a machine with an ARM-based processor, or if you are running one of the distributions ending in -Elec rather than Ubuntu, you may find that Perl isn’t installed and there’s no way to install it, or that there is no way to run a Perl script. Or, you may find that the tv-grab-file script used by Tvheadend won’t run because you don’t have the Bash shell installed, which is another thing that’s installed with Ubuntu. Or, you might discover you have no way to set up a cron job to get your schedule data automatically in the middle of the night. It’s usually possible to work around these issues one way or another, with considerable effort, but if you are not running Ubuntu you will likely find that setting up the EPG is a much more difficult process.

SPECIFIC CHANNEL ISSUES

Occasionally you may want to tune in a channel that requires “special handling”. For example, one major U.S. provider uses six discrete audio channels to send 5.1 audio, and no standalone satellite receivers can decode it properly. But Tvheadend can, with a little coaxing. See the article, Fixing the audio on live TV from a certain network (which shall remain nameless) in Tvheadend for information.

Also, if you are using low-powered computers for your frontend systems, they may not be capable of playing back certain high-bitrate channels in real time. However, you can record shows from such channels, and play them back on equipment with more CPU power (such as your desktop computer), or you can convert the recording to a format that has lower CPU/GPU requirements for playback. Here’s an example of the latter approach: How to play video recorded from high-bitrate 4:2:2 sources on low-power systems

ADDING OVER-THE-AIR CHANNELS

If you have a TV Antenna, I will just mention two ways you can add over the air channels to your backend. One is to use a tuner card that picks up ATSC Channels (be sure it receives ATSC, and not DVB-T or some other format that’s not used in most of North America) such as a TBS6704 ATSC/Clear QAM Quad Tuner PCIe Card. That card’s tuners should appear in your tuner list, just like any other tuner.

Another option is to use a HDHomeRun device, such as a HDHomeRun Dual (model HDHR3-US or possibly the newer model HDHR4-2US, also known as the HDHomeRun CONNECT). These have two independent ATSC tuners, which can be fed from the same antenna using a splitter, or from two different antennas, which may be useful as explained in the next paragraph. However, buying a HDHomeRun can be confusing because there are several models, and not all of them will work for this application. Also, Silicon Dust (the makers of the HDHomeRun) are now trying to push users toward their DVR product, so I don’t know if newer models will work as well with Tvheadend. The HDHomeRun Dual connects to your antenna(s) and also to your local network via an Ethernet jack. It can therefore be placed near where the antenna’s cable enters the house, as long as there’s an Internet connection and a power source there, and after a reboot Tvheadend will probably just find it on the network and show it in its tuner list, assuming you are using a recent version of Tvheadend.

Note that if you search on the Internet you will find several older guides that will tell you that you need to install extra software, such as drivers, to use a HDHomeRun device with Tvheadend. That may have been true at one time, but it no longer appears to be necessary to install any additional software if you are using Ubuntu 14.04 and Tvheadend 4.0.9 or newer.

You only need to set up one ATSC network for over-the-air channels, unless you have multiple antennas pointing in different directions, feeding different tuner inputs. For example, if you are in between two major cities and receive strong signals from both, you could put up two TV antennas, each pointed at a different city’s transmitters, and feed each antenna into a different tuner input. You would then create two ATSC networks in Tvheadend, so that Tvheadend could select which antenna to use for the best reception on any channel.

ADDITIONAL TVHEADEND INFORMATION

If you keep in mind that much of the information out there regarding Tvheadend is geared toward users in the Eastern hemisphere, and that settings that are useful in other parts of the world don’t apply to us in North America, then you may find reading the official documentation for Tvheadend helpful. It will tell you about some features of the program that I haven’t covered here. Probably the best place to start is the Tvheadend Wiki and the Tvheadend User Guide.

AND THAT’S ALL, FOLKS… FOR NOW, ANYWAY.

Please leave a comment if you spot any errors or omissions, or have anything useful to add!

Advertisements

How to use two TVHeadEnd backends with Kodi

Most people consider themselves lucky if they can get one PVR backend to work, but sometimes it makes things easier if you can run two different TVHeadEnd backends and let Kodi access both of them.  Unfortunately, Kodi works best with a single PVR backend, although that seems to be less true in Kodi Isengard than in previous versions.

Why would you want to run two different backends?  There are many reasons, but a primary one is proximity to an antenna or satellite dish.  As just one example, say you want to receive terrestrial television signals using a TV tuner card or device, and also satellite signals from your satellite dish, but the two are nowhere near each other.  Maybe your antenna is located right next to your house, but in order to clear a hill or other obstruction, your dish has to be placed several hundred feet away.  You don’t want to run several hundred feet of RG-6 cable if you can help it, because the signal loss would be quite significant.  A better solution would be to place a backend server in some kind of climate controlled (or at least waterproof) enclosure near the dish, and then connect that server to your local network using a fiber optic cable.  But you’d also need a second backend server at your house, to receive signals from your antenna (well, unless you are using networked tuners such as HDHomeRun devices from SiliconDust, but this is just an example).

Note that some people actually have a second TVHeadEnd backend at a completely separate geographical location, maybe in another city, or even another state or country, and connect to it over the Internet.  But, I don’t recommend that unless you’re not subject to ISP usage caps at either end, or you use compression (but that’s beyond the scope of this article).  And anyway, that’s the beauty of receiving signals from the satellites – they can be viewed from a very wide geographic area, as long as there aren’t any obstructions between your dish and the satellite.

Whatever the reason you need two backends, Kodi doesn’t give you a readily apparent way to use both easily.  However, there is a method that works in some Kodi and XBMC installations.  I don’t know why it works great on some systems and not so well others, all I can suggest is that if you find yourself with this need, try this and see what happens.

Note that I am only giving instructions here for Linux and OS X systems.  It should also be possible to do this on other platforms, but since I don’t use those, I don’t know the correct paths.

In Linux, copy /usr/share/kodi/addons/pvr.hts to pvr.hts2 in the same (/usr/share/kodi/addons/) directory.  You will have to be a system administrator to do this (use sudo).  The .hts2 ending is somewhat arbitrary; you could also call it something descriptive like pvr.htsantenna if you like, but if you change it make sure you follow that same naming convention everywhere.  I’ll assume you’ve used pvr.hts2 for the balance of these instructions.  In OS X you do the same thing, except the original file is at /Applications/Kodi.app/Contents/Resources/Kodi/addons/pvr.hts and again you make a copy in the same directory.  Note that you are copying an entire directory, not an individual file.  I tend to do things like this in Midnight Commander because I find it easier than trying to remember the correct Linux command line syntax, but if you are a command line devotee you’re welcome to do it from there.

Next, change to the copied directory (pvr.hts2 in this example) and find a file inside named addon.xml.  You want to edit this file, so do something like sudo nano addon.xml (or use your favorite text editor, or highlight the file and press F4 inside Midnight Commander), and change two values, specifically the “id” and “name” strings.  Change the id to match the name of the newly-copied directory (pvr.hts2 in this example), and change the “name” to somehow differentiate the copied addon from the original.  For example, you could add the word (antenna) or (satellite) to the end of the string.

You should do the following steps as a user: In Linux, copy the ~/.kodi/userdata/addon_data/pvr.hts directory to pvr.hts2, or in OS X copy the ~/Library/Application Support/Kodi/userdata/addon_data/pvr.hts to pvr.hts2.  In both cases, the copied directory should be in the same directory as the original, similar to the way you did it in the first step but don’t do it as an administrator, in other words, don’t use sudo.

Now go into the directory you just copied and edit the settings.xml file (same as the way you edited addon.xml but again don’t do it as an administrator).  You will likely need to edit the “host” value to point to your second backend, and you may also need to edit the “pass” and “user” values if the backend requires a username or password for access.  Note you can also change these items from inside Kodi using the second addon’s configuration page, if you prefer, but it’s probably better to at least change the host address before you start it up so you don’t have two addons trying to access the same server.

In many cases, this is all you need to do, other than go into Kodi’s PVR addons and make sure that both are enabled and have the correct configuration settings.  You will see your channel list populated with channel numbers from both backends, and you will see recordings from both backends, etc.  But on some Linux-based systems, there is one additional directory that must be copied, as an administrator.  This directory is at /usr/lib/kodi/addons/pvr.hts and you’d again copy the entire pvr.hts directory to pvr.hts2 in the same (/usr/lib/kodi/addons) directory.  I have no idea why this additional step is necessary with some systems but not others.  And this doesn’t seem to apply to OS X – if there’s an equivalent directory there, I haven’t been able to find it.

As I noted, this same technique should work with Kodi on other platforms if you can find the correct equivalent directories.  Note that you will need to repeat these steps any time you upgrade Kodi to a newer version, unless you are using Linux.  Under Linux, you will need to repeat these steps only when the TVHeadEnd PVR addon is updated.  And in either case you will likely only need to repeat the steps that require administrator access; the settings in the userdata directory shouldn’t be affected by a software update.

It goes without saying that I do not guarantee this will work.  I’m not a programmer, so if it doesn’t work for you, all I can suggest is you go into the Kodi PVR forum and add your support to this thread, which actually provided some of the information in this article.

Getting bad satellite recordings in TVHeadEnd? Here’s a possible fix

I was perusing the TBS forum recently and discovered that there’s a problem that can occur, notably with certain TBS cards but possibly with others as well, that can result in semi-corrupted recordings. The .ts file that contains the recording actually contains the entire program, and can usually be repaired by chopping off a few megabytes at the start of the file, but as it sits on the TVHeadEnd server it’s not easily playable for one or both of two reasons:

  • It reports the wrong length (time) for the recoding – for example a one hour program may appear to be of a much greater length (several hours long), and/or
  • The video and audio are out of sync by a second or two, where this is not usually the case.

In Kodi, you can generally play such a recording from the start, but skipping around within the program may be problematic or impossible.

The possible fix for this is to set a “Skip Initial Bytes” setting for each tuner, as described in this post on the TBS forum.  The conversation there appears to be about a specific TBS card (the TBS6905) but I have heard of this problem happening with other cards as well.  As best I can understand the problem, the card starts sending a virtual firehose stream of data before the buffers are ready to receive it, and some data gets lost at the start, corrupting the file.  By skipping some initial bytes, you get only the “good” data once everything has had time to initialize.  That’s probably a gross oversimplification, but that’s what I got out of that thread.

The place to change the setting is here:

Configuration | DVB Inputs | TV adapters, in the "Advanced Settings" section

Configuration | DVB Inputs | TV adapters, in the “Advanced Settings” section

You might think the number of bytes skipped is quite high, but since even a 30 minute recording can contain several gigabytes of data, that number is actually insignificant.  The original poster in the thread states that “The 18800000 setting is a bit arbitrary; I chose it because it is more than 1 Meg and is the ‘Input Buffer (Bytes)’ value x 1000. If the issue persists I may try an even higher value.”  Feel free to experiment with lower or higher values; I personally think I’d start with something lower such as 188000 (10 times the Input Buffer) and then if that doesn’t resolve the issue, go up to 1880000. And if that still doesn’t always fix the problem, then go to the 18800000 value.  But, it’s entirely up to you.  And remember that if you have more than one tuner, you have to add this setting for each affected tuner.

The thread also notes, “If the new value doesn’t appear after you change it and click save, refresh the page in your browser, then navigate back to the TV adapters tab.”

If TVHeadEnd is creating these types of bad recordings on your backend server, I’d suggest this fix is at least worth a try, since you can easily reverse it if it turns out to not have any effect.

A few Linux utilities that are useful for manipulating XMLTV schedule files

In my previous article, Some hints for getting free-to-air satellite channels into the Electronic Program Guide in Kodi or XBMC (or another frontend), I mentioned that schedule “grabber” programs save their files in XMLTV File format. So let’s say you have one or more XMLTV type files, but you want to do some additional manipulation on them before feeding them to your backend software.  Here are a few tools that run under Linux that I have found that may be useful, under certain circumstances.  These are in addition to zap2xml, which I mentioned in my previous article.

NOTE:  To find out if you have a particular program installed on your system, try entering the word which followed by a space and the program name at a Linux command prompt.  If the program is installed on your system, it should show you the path to the file.  Note that you will probably need to use the full path and filename if you are attempting to run the program from a shell script or a cron job!

  • tv_cat – Concatenate XMLTV listings files. The man page description says, “Read one or more XMLTV files and write a file to standard ouput whose programmes are the concatenation of the programmes in the input files, and whose channels are the union of the channels in the input files.”  Or in simple terms, it merges XMLTV format files together.  This program may already be on your backend system but if it’s not, you can typically install it on a Ubuntu/Debian-based system (and possibly in some other Linux distros) by installing the xmltv package.  tv_cat is a bit picky about the format of the files it will combine, so check the output carefully to make sure it is including all the channels.  I had some issues using tv_cat with TVHeadEnd, and wound up using a small quick-and-dirty Perl script to combine XMLTV listings files instead.
  • sed – Stream EDitor. This is a utility built into just about EVERY Unix/Linux system out there, and it’s probably available for Windows in some form also. sed is more or less a one-trick pony – it searches for text and replaces it with something else.  You can use it to resolve duplicate channel ID’s in two different XMLTV files by changing them in one of the files, using a command of the form sed -i ‘s/original text/replacement text/’ filename but note that there are some potential “gotchas”, so read the documentation first.  For example, if either the search or replace string contains a / character, it mush be “escaped” with a backward slash, so as not to be confused with the / delimiter character.  So if, for example, your search or replace string included the closing tag </display-name> you’d use <\/display-name> instead. (EDIT: You can also change the delimiter character to avoid this issue – see the first comment below).

    I will note that there are some “purists” out there that will say that you should never use sed to manipulate an XML file, even though it’s easy and (if you are careful to use unique strings that don’t appear anyplace that you don’t want to change) fairly foolproof, so I suppose I had better mention a tool that is specifically intended for manipulating XML files…

  • xmlstarlet – command line XML toolkit. According to the description, “XMLStarlet is a set of command line utilities (tools) which can be used to transform, query, validate, and edit XML documents and files using simple set of shell commands in similar way it is done for plain text files using UNIX grep, sed, awk, diff, patch, join, etc commands.” This is another one that you will likely find in your Linux distribution’s repository, at least if you are running a version of Ubuntu or Debian.  This one offers you a lot more flexibility in manipulating XML files, but at the expense of being somewhat more complicated to use.

Since xmlstarlet is a bit difficult for some users to wrap their heads around, I will give here some actual examples of how it could be used on an XMLTV format file, but please note that I am no expert with this so if you have a different proposed usage, please try to figure it out for yourself using the handy documentation, available as a web page or in PDF format.  No offense, but better you should spend a couple hours trying to figure out the correct syntax to achieve whatever results you want than me! 🙂

1. Remove all “Local Programming” entries from an XMLTV file named xmltv.xml and save to newfile.xml:
xmlstarlet ed --delete "//programme[title='Local Programming']" xmltv.xml >newfile.xml
2. Same as above but only for one specific channel:
xmlstarlet ed --delete "//programme[title='Local Programming'][@channel='someid.someaddress.com']" xmltv.xml >newfile.xml
3. To change the value of @channel wherever it appears in the file:
xmlstarlet ed -u "//programme[@channel='someid.someaddress.com']/@channel" -v 'newid.newaddress.com' xmltv.xml
4. To extract all entries for a specific channel to a separate file (non-destructive – does not change the original file):
xmlstarlet sel -t -m "//programme[@channel='someid.someaddress.com']" -c . -n oldfile.xml >newfile.xml

Note that I am not saying that any of the above are the best example of how to do something.  As you can see, especially from the last example given, this program has some rather non-intuitive syntax for its command line arguments (to put it mildly).  If you have any additional – or better – examples of using xmlstarlet to manipulate XMLTV files, please leave them in a comment and I will consider adding them here.

That said, if you need to do an operation on an XMLTV file and don’t want to write a program or script to do it yourself, xmlstarlet could be your salvation – IF you can figure out how to use it!

Some hints for getting free-to-air satellite channels into the Electronic Program Guide in Kodi (or another frontend)

If you are running a satellite backend system such as TVHeadend or MediaPortal (or MythTV, if you are one of the lucky few that can actually get it to work), and you use Kodi or the MythTV frontend, then it is possible to populate the schedule grid with listings from many sources. Note I did not say that it is easy, just that it is possible. The key is to use an external program such as zap2xml (Zap2it TV listings to XMLTV or XTVD .xml). These are commonly referred to as “schedule grabbers”, or just “grabber” programs.

The real trick is figuring out how to use one of those programs. Typically they are used to grab listings for a single over-the-air market, not a hodgepodge of stations and services from various locations. Such programs will create a xml file that contains schedule listings (in TVHeadend it will typically be at /home/hts/.xmltv/tv_grab_file.xmltv, assuming that “hts” is the TVHeadend username on your system), and that file will have all the over-the-air channels in your area, or all the cable or satellite channels from your provider. If you want to use zap2xml and you’ve never set it up before, I’ll give you some setup hints later in this article. But for now, lets assume that you have it all set up and you know how to create an xml file (named /home/hts/.xmltv/tv_grab_file.xmltv) containing your local listings.

Once you have created the xml file, it can be imported into the TVHeadend, MediaPortal, or MythTV database. To import it into TVHeadend, you need to use a file called tv-grab-file, which must be downloaded and moved into the /usr/bin directory on the system running TVHeadend (be sure to make it executable, since it is a bash script). Also, you may need to edit the line in the script that starts with “cat” and contains the path to the tv_grab_file.xmltv file, to specify the correct path and file name of the file produced by your selected grabber program, if it isn’t being saved as /home/hts/.xmltv/tv_grab_file.xmltv. Note that if the tv_grab_file.xmltv file is not owned by the TVHeadend user, it must at least be made readable by TVHeadend – incorrect permissions and/or ownership on this file will make it inaccessible to TVHeadend.

Once you have done that, you tell TVHeadend to use the tv_grab_file script by going to Configuration | Channel / EPG | EPG Grabber page.  First, if any grabbers are enabled in the “Over-the-air Grabbers” section, disable them by unchecking the boxes next to them.  Then, in the “Internal Grabber” section, select “XMLTV: tv_grab_file …”  in the dropdown (you may need to restart TVHeadend or reboot the system before it will appear – if it still doesn’t appear, check the ownership and permissions of the file, it should be the same as the other tv_grab_* files in the /usr/bin directory – owned by root, and executable by all users). This is how it looked in previous versions of TVHeadend:
TVHeadend Internal Grabber SettingsIn the newest versions of TVHeadend you can actually schedule the Internal Grabber to import the listings at a specific time each day. Here I have set it to run at 2:33 AM every day (after commenting out the default):

NEW TVHeadend Internal Grabber settingsAfter you get the schedule grabber working, all you need to do set up a cron job or scheduled task to run your listings grabber (the zap2xml program, or whatever you use) once a day. Then if you have the newer version of TVHeadend as shown above, set it up to import the listings ten minutes after you have run the listings grabber (you could probably get by with a shorter interval, but why rush it – you want to make sure the listings grabber has completed its task before TVHeadend grabs the resulting file).

NOTE: There are some people that find that for whatever reason, they cannot run the tv_grab_file script. This most often happens on systems or devices where bash is not installed (to determine whether that is the case, enter which bash at a Linux command prompt and if bash is installed it will display the path, typically /bin/bash). In such a case it may be possible to use a modified tv_grab_file script. For example, in my Review of the TBS MOI+, I showed a variation of that script that runs under ash (as provided in BusyBox), since the original bash script won’t work in that environment. But if you can’t do it that way, there’s another method that involves using xmltv.sock, which is discussed in this thread on the Kodi forum. The advantage of doing it that way is that your new listings can be imported into TVHeadend immediately after you’ve obtained them, but the disadvantage is that most people find it harder to get that method to work, and the use of tv_grab_file is definitely easier to explain. If you do use xmltv.sock then you must go to the External Interfaces section of the page shown above, and check the box for the XMLTV module (not shown in the screenshots).

Note that after TVHeadend imports NEW channels, you MUST refresh the browser window before the new channels will appear in the EPG Source dropdowns under the Configuration | Channel / EPG | Channels tab. You may even need to close and re-open your browser. Failure to do this is probably the #1 reason people think TVHeadend has not imported the newly-added channels.  You must select an EPG source for each channel before schedule data for that channel will be read into TVHeadend, which will happen on the next scheduled import of the TV schedule data.

NOTE: You can force an unscheduled read of TV schedule data by temporarily setting the Internal Grabber Module to “No grabber”, clicking the “Save Configuration” link, then changing the Internal Grabber Module back to “XMLTV: tv_grab_file …” and clicking the “Save Configuration” link again.

When you are setting up your listings sources (channels) on whatever TV listings service you plan to use, if you don’t know which providers or stations carry a specific channel, you can look it up on Wikipedia, which will often tell you which providers and/or local stations carry that channel.

There are some national services that I will not name here, but that aren’t listed in the channel listings because they aren’t intended for viewing by home viewers. You need to get creative with those. For example, if you just happen to find a feed of the QXZ network, and you are smart enough to not blab about it all over creation so that the signal gets scrambled, you may be able to get listing data for at least prime time by grabbing the listings for the network owned “flagship” station in your time zone, which might be WQXZ on the east coast or KQXZ on the west coast. Of course the QXZ network is totally fictitious, but hopefully you get the idea.

If you spend a little time studying the XMLTV File format, you can even write your own scripts or programs to create “fake” XMLTV data for certain stations – I suppose you could even do it manually if you are a very patient and precise person.

There is one pitfall to all this, which was actually more of a problem with a grabber program that’s no longer useful due to changes in the underlying service, but I’ll mention it anyway just in case you ever run across it. The various schedule sources sometimes change channel ID numbers without any advance warning, particularly when you are grabbing terrestrial (over-the-air) channels. If you find that the schedule data for a particular channel “runs out” after a certain day, it’s probably because the ID numbers have changed. In TVHeadend, go to the Configuration | Channel / EPG | Channels tab, find the affected channel(s), and change the EPG Source using the dropdown – you will probably see both the old and new ID’s, usually one underneath the other. Uncheck the old one and check the new one, and the next time TVHeadend updates its EPG information, it should be okay (don’t forget to click the “Save” button before you leave the page!). By the way, in case you hadn’t figured it out from the previous paragraphs, that’s the place where you select the channel data to associate with a channel in the first place, but I will again note that if the EPG sources aren’t appearing in the dropdowns after TVHeadend has imported your xml file, then you may need to refresh the page, or close and re-open your browser.

EDIT: For those that have never set up zap2xml before, here is the general procedure. These are basically their instructions, but with some added comments to help clarify what needs to be done.

1. Register your free Zap2it.com TV Listings account (input zip/postal code and select lineup) – COMMENT: I suggest you only select an over-the-air lineup, not a cable provider and particularly not a satellite provider, and here is why. When you are finished adding all your “favorite channels”, change your location to a zip or postal code in your time zone, but in a place where it’s impossible to receive any of the favorites you have selected. What you will then notice is that in the Zap2it grid, no channel numbers are displayed for each channel. That is a good thing, because as I mentioned above, channel numbers can change without warning (particularly on cable or commercial satellite lineups) and this will stop the channel numbers from being imported into TVHeadend. When channel numbers aren’t shown, zap2xml cannot include them in the channel ID strings it creates, therefore you no longer need to be concerned that an unexpected channel number change will leave you without EPG data for one or more stations.

(I will just note here that recent releases of zap2xml allow you to select TV Guide as your listings source instead of Zap2it. While TV Guide arguably provides better program descriptions, it will not allow you to display listings or favorites from more than one TV market area at a time, and they do use channel numbers in their identifiers and there is no way to disable that. Since satellite users often watch channels from several different TV market areas, I suggest sticking with Zap2it unless you have such mad programming skills that you can figure out how to combine separate listings from the different areas where your channels originate, and you don’t mind creating a separate TV Guide account for each such market area).

2. First click “Display Descriptions” (do not click if it says “Hide Descriptions”), then click “Set Preferences“:

Click "Display Descriptions" first, then "Set Preferences"

When you click “Set Preferences” the Manage Favorite Channels page should appear. If it doesn’t, select Manage Favorite Channels from the left-hand menu on the page that appears.

COMMENT: It has come to my attention that some people don’t seem to understand why you should set favorite channels. The reason for using favorites, and then setting Zap2it to display only those favorites, is to reduce bandwidth usage. This has three benefits, two for you and one for Zap2it. First, if your ISP enforces usage caps, you’ll be using less data if you’re not downloading schedules for stations that you cannot receive or that you never watch. Second, it takes time to download schedule information, so when you are testing (as you might after adding a new channel) you won’t have to sit and twiddle your thumbs while unnecessary schedule data is being downloaded. And finally, if everyone downloaded a monster amount of schedule data from Zap2it every night, it could increase their costs, and then they might change things to make this data completely unavailable to us. This is also the reason I tell you to use a six hour grid below; it reduces the amount of data that you receive (and that Zap2it has to send) while obtaining schedule data, without omitting necessary information. Please follow the instructions in this section exactly as shown, even if some other well-intentioned person tells you (incorrectly) that these settings don’t do anything.

  1. Select your favorite channels from the “Available Channels” and put them in the “My Favorite Channels” list – COMMENT: Once you select a location and select your favorite channels, you can then change your location (using a different zip or postal code) and add more favorites from the new location, without losing the ones you have already added. So, you are not limited to adding only channels that are available to a particular zip or postal code to your favorite channels list.

Additional Settings – COMMENT:  These are VERY IMPORTANT, don’t skip any of these steps! And, please don’t listen to anyone who says these are not important – see the explanation above.

  1. Checkmark [✔] “Show six hour grid”
  2. Checkmark [✔] “Show only my favorite channels in the grid”
  3. Click “Save”

3. You may need to install the required supporting perl libraries (not needed with the Par-Packed Windows file) – COMMENT: I’d try step 4 first before you go adding any perl libraries, as they may already be present.

4. Run zap2xml with the userEmail and password parameters of your account – COMMENT: Watch the output and see it complains about missing Perl libraries. If so, see step 3. Here is how you might invoke it, assuming that you are running TVHeadend and that your TVHeadend user is “hts”:

./zap2xml.pl -u user@email.com -p yourpassword -o /home/hts/.xmltv/tv_grab_file.xmltv -c cache -F -O -T -q

(Leave off the -q while testing, because it may suppress error messages that you’ll want to see). This assumes that you have created a directory named “cache” (as a subdirectory off the directory where the zap2xml.pl script is saved) and that you have either already created a file /home/hts/.xmltv/tv_grab_file.xmltv (can be a zero byte dummy file to start) and made it world writeable, or else that you are always going to run the zap2xml.pl script as the TVHeadend user, in order to avoid file permissions issues. Of course, you must create the /home/hts/.xmltv directory if it doesn’t already exist. The point is that when you run the script and it tries to create the /home/hts/.xmltv/tv_grab_file.xmltv file, you don’t want it to fail due to file permissions or ownership issues.  You can read about the options shown above, and others you may wish to use, on the zap2xml home page (in particular, you may want to use something like -d 12 to get 12 days of listings instead of the default 7).  NOTE: Should you happen to be running OpenElec or LibreElec, which I most emphatically DO NOT RECOMMEND, zap2xml.pl will not work for you, in part because you may find it difficult or impossible to get to a command line, but also because Perl is not available.  There is an alternative for OpenElec/LibreElec that is written in Python, but I have absolutely no experience with it.

5. Optionally set up a cron job/task scheduler task to run it every day – COMMENT: Keep in mind that when setting up a cron job, you must use full paths, and not any shortcuts such as “.” or “~” in the path. The cron job or task should be scheduled to run a few minutes BEFORE TVHeadend’s Internal Grabber is scheduled to run. So if TVHeadend’s grabber is set to run at 2:33 A.M., you may want to run your cron job that invokes zap2xml at 2:23 A.M., giving it ten minutes to finish (which is, generally speaking, more than ample time for it to run to completion).  Please set it to run at some odd random time (in other words, not right on an hour, half hour, or quarter hour mark) so that everyone isn’t clogging up the servers at once.

(End of edit.)

I am painfully aware that there is nothing at all that is easy about this process, and it probably makes you wish that we had European-style free-to-air services, where EIT guide data is embedded right in the program stream (lucky Europeans!1). But since we don’t, I just wanted you to be aware that you don’t need to have a blank EPG in your Kodi Live TV section. There is definitely a learning curve to getting it all working, but the more you work with it the more you will understand how all the pieces fit together. You may never be able to get schedule data for every channel you can receive, and you’ll obviously never find it for “wild feeds” that come and go, but I’ve been able to populate the EPG grid for quite a few of the stations I’m able to receive on my dishes.

(By the way, if you want icons for the channels, at least in Kodi you have to load those to the frontend system – as far as I can tell, there’s no good way to put them in the TVHeadend backend server and have Kodi get them from there. So just create a directory, dump your channel icons there, rename them to EXACTLY match the channel names except for the extension – for example, if you have a channel named “Big Fart Channel”2 then the icon file name should be “Big Fart Channel.png”, or whatever the correct extension is – then in Kodi go to System | Live TV | Menu/OSD and modify the “Folder with channel icons” setting to point to the directory containing the icons.  And yes, I’m aware that you can supposedly enter a path to a “User Icon” for each channel in TVheadend’s Configuration | Channel / EPG | Channels tab, but those are really intended to be the paths to “picons” supplied by TV channels in some other parts of the world.  I’ve found that if you attempt to use those, more than likely you are going to slow down Kodi or cause some other undesirable effect, such as Kodi hanging when you attempt to quit Kodi.  You are better off to store your channel icons on each of your devices that run Kodi.)

If you know of any software tools that would make this easier, or pick up any hints or tips that I have not mentioned, please feel free to post a comment (but be aware that I will not approve spam comments that promote commercial services. Also, I don’t need any praise – if you like this article, don’t tell me, tell your friends that have satellite dishes and that could possibly benefit from this information!).

Here are some possibly useful links:

zap2xml software and documentation.
tv-grab-file, a file used with TVHeadend to import xmltv format data
Zap2xml for ATSC in OpenELEC (Kodi forum thread)
Installing zap2it grabber in OpenELEC (YouTube Video)
Setup instructions and files for Synology NAS users (TVHeadend forum thread)
NextPVR – EPG Setup – XML/XMLTV EPG – Zap2it & Zap2xml (NextPVR forum thread)
Home DVR Tvheadend OTA EPG Setup (Part 2) (YouTube Video)

Note regarding the video in the previous link: It shows the basic setup, but using an older version of TVHeadend, and using the free version of the mc2xml listings grabber which stopped working in July, 2015. So, don’t use mc2xml, use zap2xml instead. Carefully read and follow the instructions at the top of that page on how to set up your Zap2it account, and also consider utilizing the tricks I mentioned earlier in this article.

If you found this article useful, you may like my followup article, A few Linux utilities that are useful for manipulating XMLTV schedule files.

NOTES:
1 Sure, the lucky Europeans get EIT guide data with their free-to-air channels, but at least we don’t have to pay a “telly tax” on each TV set we own, so there’s that!
2 Someone REALLY should start the “Big Fart Channel” – that would be a real gas! And with that, this article has really bottomed out. What do you mean, my puns stink?

I hear there’s a problem with playing satellite audio…

You may not realize it but when you run a backend such as TVHeadEnd with a satellite tuner card or device for the purpose of recording or viewing Free-To-Air signals in North America, and then use Kodi as your frontend, there’s a good chance you are not hearing the audio correctly on some channels, particularly if you have a multi-channel audio system (5.1 or better). The reason is that many of the uplinkers encode their audio in a specific manner that Kodi doesn’t understand.

This is not the same issue I wrote about in Fixing the audio on recorded programs from a certain network (which shall remain nameless), although that does show that different uplinkers encode their audio in a different ways. In fact, on “feeds” channels the audio can vary from program to program.

When you play a stream or recording in Kodi, if you display the on-screen controls or press INFO on your remote (depending on the skin you are using), you will often see an indicator of what type of audio Kodi thinks it is receiving. If you see indicators for both “Dolby Digital” and “5.1” then it is probably decoding the audio correctly. If you see anything else, such as “MP3” or “2.0”, then it may or may not be decoding the audio correctly, depending on how the source was encoded.

The strange thing is that if you have a suspect recording and you happen to have a machine that has the MythTV frontend software installed and you play the recording there, you may in fact hear the full 5.1 audio! Play the same recording using Kodi and you’ll hear audio on all channels, but your ears might tell you there’s something wrong.

Here’s the issue: 5.1 audio has 6 channels – Left Front, Right Front, Center Front, LFE (low frequency audio generally played through a subwoofer), Left Surround, and Right Surround. Kodi will play the first four of those through the proper channel in almost all cases, but it’s the Left and Right Surround channels that are mishandled. If you play the recording in the MythTV frontend, you will hear the Left Surround audio come from both the left front and left rear speakers, but with equal energy from both OR more audio from the rear. Same with the Right Surround, except that it will only come from the right front and rear speakers. However, when that same audio is played in Kodi, what sometimes happens is that any audio that should come from the Left or Right surrounds will be played at equal volume from all four Left and Right speakers, or if there is a difference in audio energy it will be biased more toward the front speakers! In other words, the Left and Right channel separation is totally lost for surround sounds.

So as you are sitting watching a recording or a live TV screen, you may notice that you are getting more than just 2-channel stereo, but it doesn’t sound quite right. Kodi will tell you it’s only 2.0 audio, and if you have a display on your receiver it may tell you the same thing. In fact it actually is 2-channel audio, viewed one way, but with the 5.1 channel information encoded within those two channels.

I’ve been reading various threads on this subject over the last few days, and it appears that in at least some cases what is happening is that the uplinkers are using Dolby Pro Logic II audio or some variation. To confuse matters further, in the audio communities this is sometimes referred to as just PLII audio.

It appears that the MythTV frontend has code that will decode this audio correctly, while Kodi does not. And you can’t even use ffmpeg to post-process a recording and convert the audio to a format that Kodi understands, because although ffmpeg has a PLII encoder, it does not have a PLII decoder.

This was a topic of recent discussion in a thread on the Kodi forum, although it appears that the developers didn’t show much interest in fixing the problem. There is a reference to a Dolby Pro Logic II test video on YouTube, which if you can figure out how to download and save, it will show you the problem in Kodi.

The thread above references a “ffmpeg user thread” – in my searching I found this archive of ffmpeg mailing list messages, and if you look at the ones with “5.1” in the subject, I suspect that is the thread being referenced, though I’m not entirely sure since the person who mentioned that thread in the Kodi forum did not include a link. In any case, reading those messages proved rather informative, even if ultimately nothing was ever resolved.

Normally when I present a problem, I like to also present a solution, but it this case it appears that for the time being there isn’t one. Programs that have this type of audio encoding will not play correctly in Kodi – it’s not that any audio will be missing, it just won’t be coming from the correct speakers, and some people may not even care about that (and if you only have two stereo speakers you definitely won’t care). If you happen to also have the MythTV frontend installed, you could play recordings in that, but in my experience some satellite recordings do not play all that well in the MythTV frontend – you may get all the audio channels coming from the correct speakers, but the audio itself may have microgaps and breakups. I suppose this in part depends on how good your HTPC hardware is; if you have a better HTPC than I do, then recordings may play fine in the MythTV frontend for you.

Most people will not want to install MythTV just to hear better audio, so that’s not really a viable solution for most readers. And MythTV has problems of its own, as I mentioned in What is the best backend software to use for a Free-To-Air satellite TV system?. So I guess the point of this article is to simply bring awareness of the problem. Maybe if enough people are aware that there is an issue, someone more knowledgeable than I will contribute code to the Kodi or ffmpeg projects that can play or convert this audio format correctly, or perhaps someone will develop a (hopefully free) standalone converter that can reformat the audio in the .ts files to something that Kodi understands.

I will note that some AV receivers may play this audio correctly IF you tell the receiver to use the correct decoder, and IF you have all the capabilities of your receiver enabled in Kodi’s System – Settings – Audio section (particularly “Dolby Digital (AC3) Capable Receiver” and “Dolby Digital Plus (E-AC3) Capable Receiver”, also be sure to “Enable Passthrough” so those settings will be used). For example, with Yamaha 5.1 receivers, you may find that using one of the Dolby or Neo:6 settings plays the audio of certain channels or recordings through the correct speakers, but selecting a “normal” mode does not. I imagine this is true of some other brand receivers as well, and may require that the receiver has HDMI connectors (this may not work if you are sending the audio to the receiver over a S/PDIF conection). I have found that the “Neo:6 Cinema” setting will play many types of encoding correctly, but feel free to try others. On such receivers, the “SUR. DECODE” button on the remote is your friend!

There is a followup article:
Why you’re not hearing full surround sound on some satellite channels – or maybe just think you aren’t

What is the best backend software to use for a Free-To-Air satellite TV system?

If you use a program like Kodi to watch live or recorded television, you’re probably already familiar with the backend/fronted model. To put is simply, the backend is a server that communicates with the tuners, such as a tuner card or USB-connected tuner, or even a network tuner such as a HDHomeRun. The backend system can sit anywhere on the local network and communicates with one or many frontends. The backend handles streaming live programming, or recording it for viewing at a later time. In contrast, the frontend is run on a computer that often connects to a television set via a HDMI cable. It displays live or recorded programming, and usually gives the user a way to schedule programs for recording and perform some other administrative tasks. Some tasks can be performed from either the backend or frontend, some from the backend only, and some from the frontend only. But generally speaking, the frontend is what the user most commonly interacts with after the initial configuration is finished.

But remember, it is the backend that performs the crucial task of communicating with the tuners, which includes sending any control commands that might be necessary. So, for example, if you have any switches (DiSEqC or 22kHz tone) between the tuner and your LNB’s, the backend will control them. If you have a USALS or DiSEqC controlled motor, the backend will need to deal with that as well.

Unfortunately not all backends are equal when it comes to dealing with Free-To-Air satellite. For one thing, Free-To-Air in North America differs from the variety used in Europe and some other parts of the world. For a decent explanation of the differences, there is a Wikipedia article on Free-To-Air – just skip to the section on North America and read that entire section.

Most of the configuration information that you find online for backend software is intended for European users and other users outside of North America. So setting up a backend system on this side of the Atlantic can be a bit tricky, even if you do pick good software for the purpose.

Note that it is usually possible to run a backend and a frontend on the same computer – you don’t need two computers for the purpose, and if the backend computer has a HDMI output and is in a location close enough to your TV that you can connect a HDMI cable between the two, there’s generally no reason not to run a frontend program on the same system as the backend. Some software installers set up a backend and frontend by default.

In my time attempting to set up a working backend, I have gone through three pieces of software – MythTV (Mythbuntu), MediaPortal, and TVHeadEnd. MediaPortal runs under Windows and the other two under Linux. If you really want to avoid Linux for some reason, then MediaPortal is an okay choice, but it has several limitations that particularly affect North American users.

The biggest problem with MediaPortal is that it has a very different way of controlling DiSEqC and 22kHz tone switches, and in my experience, it doesn’t do either very well (especially DiSEqC switches). As long as I connected an LNB directly to a tuner, MediaPortal for the most part worked great. But if you have more LNBs than tuners and you want to use them all, and you have to try to use a DiSEqC or tone switch, then you might find that everything falls apart.

Under MediaPortal, with TBS tuner cards you need to install some non-official drivers if you want DiSEqC switching to work at all. And the way they enable control of 22kHz tone switches assumes that anything connected to the “tone off” side is a C-band LNB, and anything connected to the “tone on” side is a Ku-band LNB. There are weird and wonderful ways to work around this but the point is that you can’t just say that when you want to select a particular LNB, the tone needs to be on or off, as the case may be.

I also found that even if I avoided using 22kHz switches, I could not tune Ku-band frequencies except by lying to the program and assigning them equivalent C-band frequencies. I suspect this was partly caused by the non-official drivers, so the end result was that I could have either used DiSEqC switching or tone switching, but not both.

And getting it to scan in channels in the first place had been a real problem. I quote from the Wikipedia article I mentioned above:

Because many of these broadcasts are essentially point-to-point transmissions, the originators often do not follow any international standards when setting various identification fields in the data stream. This causes issues with receivers and software designed for use in other parts of the world, as they may assume that if a channel contains the same ID information as another channel, those are duplicate channels. This may be a valid assumption in other parts of the world, but is almost never valid for North American FTA signals. When such an assumption is made, during a “blind scan” the receiver or software will often fail to correctly insert one or more channels into its database, or it may overwrite previously scanned valid channels (including other channels on the same satellite) with invalid information picked up from another, more recently scanned channel. If the end user does not understand what is happening, they may assume that the receiver cannot receive certain channels or that it is defective, yet if the correct data for those channels can be manually entered, those channels may become receivable. This problem can be mitigated if receivers can be set to ignore channels that appear to be duplicates during a “blind scan”, except when such channels are on exactly the same satellite and same transponder frequency (as might occur if the user rescans a previously-scanned satellite).

MediaPortal is a VERY Euro-centric program, and it has the exact issue mentioned above. So it might scan one transponder correctly, but then overwrite the channels it scanned with other channels from a completely different satellite and/or frequency. So, you wind up having to enter a LOT of channels manually. I’m not saying that no other software has this issue, because there are a few other programs that behave the same way, but it was definitely a huge issue in MediaPortal.

So, every program has its weird quirks, but MediaPortal seemed to have more than its share of them. In the end, there were two things that really put me off about it. One was that it ran under Windows – for several reasons I need not go into here, I much prefer running Linux on a server, even though I am not a Linux expert by any stretch of the imagination. And, that I could never count on it to record reliably – for reasons I was never able to determine, it would sometimes fail to record a scheduled recording, or only record a short bit of a program and then just quit. Of course when that happens, the first thought everyone has is that it’s a hardware problem, but that same hardware worked just fine with TVHeadEnd.

On the plus side, I will say that the MediaPortal forums were among the most helpful I have ever seen. If you don’t plan on using DiSEqC or tone switching, or mind using workarounds, and you don’t have the issue of it stopping recordings in mid-program (which no one had a good answer for), then it appears that you can get an answer to almost any question you might have. It might not be an answer you particularly like, but at least it may provide some sort of a workaround to get you going again. I don’t want to oversell them, but there is a night and day difference in the attitude toward less experienced users in the MediaPortal forum vs. just about any forum for a piece of Linux-based software I’ve ever encountered. If you hate dealing with “Linux snobs” and people whose idea of “help” is telling you to read man pages and/or use Google, then stick with MediaPortal, because perhaps in time they will work out some of these issues and come up with some software that doesn’t cause so many problems for us North Americans.

Prior to trying MediaPortal I had tried Mythbuntu, which is a Linux distribution that includes MythTV, and saves you the trouble of installing the MythTV packages and supporting software. You just install Mythbuntu on your backend and you are supposedly good to go, with both the backend and frontend available. I actually have some experience with Mythbuntu, having used it with a HDHomeRun in the past to receive over-the-air television. So I thought setting up a new Mythbuntu installation would be a piece of cake. Boy, was I wrong.

One of the HUGE design flaws of Mythbuntu is that it appears that the backend and frontend versions must always match. That is, you can’t run version 0.25 on the backend and 0.27 on the frontend and expect it to work. Either the two will outright refuse to talk to each other, or only parts of the program will work. This is a problem because people rarely upgrade all their computers and devices at once. And if your distribution’s repository only offers a particular version of the frontend that doesn’t match what you are running on the backend, you might be kind of screwed, at least until you can figure out how to match up the versions again.

So I had to drop back a couple versions of Mythbuntu to match what my frontends were running, and I’m not sure if that caused me problems or not, but the end result was that I could never get Mythbuntu to actually work. When it did a scan it would appear to find some (but not all) the satellite signals that were up there, but there was no way it would play any of them. You could click all day and just nothing. That, coupled with some information I read in various forum threads as I was trying to figure out the crux of the problem, led me to think I was pursuing a fool’s errand. The impression I got was that MythTV USED to work for receiving satellite programming at some time in the past, but something is broken now so that in recent versions it doesn’t work anymore. Another issue was that even when people had been able to get it to work, it would not receive certain high-bitrate signals such as 4:2:2 format signals.

I am only willing to beat my head against a brick wall for just so long, so that’s why I moved on to MediaPortal. I’m not saying that no one could ever get MythTV to work in this application, but it appeared that other people who seemed much more familiar with Linux than I had tried and failed. I got the distinct impression that no one in North America has been able to use a recent version of Mythbuntu for this purpose with satisfactory results, or at least not anyone who was willing to speak up in the various forums.

The real winner of the three is TVHeadEnd. Now, TVHeadEnd is a bit different than the other two in that as the name implies, it is backend software only – there is no specific TVHeadEnd frontend. I believe that most TVHeadEnd users use Kodi as their frontend software, although there are undoubtedly other choices.

I covered some aspects of TVHeadEnd configuration in my Review of the TBS MOI+ DVB S/S2 Satellite TV Linux Server (see the section on Configuring TVHeadEnd) but I just want to emphasize one point – many of the options in TVHeadEnd are not exposed until they are needed. So if you just install the software and start looking for things such as “Where do I tell it what type of LNB I have?” or “How do I specify that I am using a DiSEqC switch and/or 22kHz tone switch?”, you won’t see those options until you have set other options that expose those settings. The aforementioned review shows examples of this.

Because of that, some users think that TVHeadEnd doesn’t support DVB-S/S2 satellite tuners very well, when the truth is that it does a much better job of it than either Mythbuntu or MediaPortal. I’ve never seen TVHeadEnd fail to record a scheduled program unless there was some obvious reason, such as no available tuner due to a scheduling conflict, or a problem with an LNB or DiSEqC switch. or the program starting in the afternoon right in the middle of a solar outage period.

Where TVHeadEnd does fall down a bit is in scanning satellites and transponders. What you are probably going to find is that you will need to add a few of your desired transponders manually, and maybe even the occasional channel or two. Once you have used TVHeadEnd a few times, this all becomes fairly intuitive, but it can really confuse new users. On the plus side, it appears that TVHeadEnd is still under active development, so some of the things that were confusing in earlier versions are less so in more recent ones, and sometimes new functionality is added. For example, in my review mentioned above, I wrote:

I should mention that TVHeadEnd does have one glaring deficiency – if you don’t have schedule data available for a particular channel, then to the best of my knowledge you cannot set up a recurring recording on that channel. You can tell it to record once at a specific time on a specific channel, but without schedule data there is no way to specify that you want to record that same channel at the same time every day or every week.

And while that was true for the version of TVHeadEnd included with the TBS MOI+ that I received for review, it’s something that has been addressed in newer versions of TVHeadEnd.

Now you can specify the duration of recordings and day(s) of the week to record.

Now you can specify the duration of recordings and day(s) of the week to record.

(Note that for most channels you should be able to obtain free schedule data. Don’t subscribe to a pay service for schedule data, just follow these hints to set up your program guide in TVHeadEnd).

I am not saying that any of these programs are perfect, but once you get past the initial hurdle of getting your mind wrapped around how TVHeadEnd operates, it all clicks into place. And of the three, TVHeadEnd has so far proven to be the most trouble free and the most reliable of the bunch.

One downside of using any Linux-based backend is that you may need to install drivers, either to get your tuner to work at all, or to get it to work at peak efficiency. And if you are used to installing drivers in Windows, where it’s more or less a point-and-click type of operation, you may find that the procedure for doing it under Linux is a bit off-putting. For certain tuner brands, it is not very difficult if you can follow instructions (for example, this page explains how to do a TBS driver install under Ubuntu 11.10, 12.04, 12.10 and 13.04 (TBS6921 and other)). But not everyone finds it easy; sometimes there are entire forum threads about driver installation. If you’ve never touched Linux before in your life, then you may want to seek help from an experienced Linux user. Make sure you watch how it’s done and take notes, because you will likely need to do it again if you ever upgrade the Linux kernel on your system (and Ubuntu loves to push kernel updates every so often, so don’t just blindly accept a software update 10 minutes before you have something scheduled to record!). This bash script can help simplify the task of rebuilding the TBS drivers after a kernel update.

Also, you need to be aware of the limitations of various tuners. Some older DVB-S tuners cannot receive DVB-S2 signals, and some DVB-S2 cards cannot receive 16APSK signals (if you really want to receive one of the handful of 16APSK signals on North American satellites, and you are considering the purchase of a TBS tuner card, it is strongly recommended that you purchase one of the “professional” grade models). Some tuner brands do not support their tuners with updated drivers, meaning that people may recommend you use some unofficial driver from a questionable source. Or, if you want to use more than one tuner card from the same manufacturer or of the same model in the same backend system, you may find that’s impossible because the driver programmers apparently never anticipated that someone might like their tuners enough to want to buy a second one (I guess that lets you know what they think of their product). The may be certain tuner models that will not work at all under Linux (you can find lists of DVB-S2 tuners known to work in Linux by following the links on this page, but just because a particular tuner isn’t mentioned does not necessarily mean it won’t work – it may just be that no one ever bothered to add it to the page). Problems caused by tuners or by tuner drivers will likely affect any backend software you might choose to use.

With TBS tuner cards in particular, you need to be careful that they are not sharing interrupts (IRQs) with other hardware devices in your system. Also, if you have a newer model TBS card and find that it will not scan muxes to find channels, try this. If you find that many of your recordings have bad timing information, and it’s not due to a weak signal, it is sometimes possible to fix that by changing a setting in TVHeadEnd.

If you start asking around about which tuner you should purchase, please keep in mind that the “Linux snobs” (the type that will only point you to man pages and Google when you need help) may prefer a particular piece of hardware, but only because they’ve had enough Linux experience to work around any issues they encounter. Just because they could get a particular tuner to sing and dance doesn’t mean that you can, unless you have a similar level of Linux experience. If you ask in a Linux forum which tuner is best, and make a purchasing decision based on the responses you receive, and you are relatively inexperienced with Linux (or you are simply not a Linux devotee), there is a real good chance that you that you will not be happy with your purchase. One tip, no matter how much they may be recommended by a particular user or group of users, avoid older PCI cards – any tuner cards you purchase now should be PCIe (note the “e”) cards.

Unfortunately, not all PCIe tuner cards are compatible with all motherboards. I’ve had good luck with a MSI motherboard (specifically the model B85M-G43, although I’m sure many other models will work equally well), but when I had tried using the same tuner card in a particular Gigabyte motherboard it would not work. A real Linux expert perhaps could have figured out the reason why, but since I’m not a Linux expert it was a lot easier to just try a different motherboard. Had I known about this thread in the TBS forum, I might have tried the suggestion there to see if I could get it to work.

There are also USB-connected external tuners, and while some users have had no problems using these, several others have reported problems with overheating leading to premature failure. Also, with certain USB-connected tuners there is an extra step of installing firmware, in addition to the drivers, at least when using Linux as the operating system. I’ve never used a USB-connected tuner, but if you decide to try one, I’d at least keep it in a well-ventilated place.

Now, I don’t mean to say that the backend choices I have mentioned above are your only three options. There are, in fact, other programs that that can act as a backend program, but I just haven’t tried them. The TBS MOI+ that I reviewed offered a choice of TVHeadEnd or VDR. I did look at VDR once, for all of about half an hour, but could not figure out how to do anything in it and just generally didn’t care for it much. Perhaps if I’d had clear instructions on how to proceed, I might have liked it more, but I got the feeling that it’s a program that very few people in North America use. Which doesn’t necessarily make it good or bad, it just means that when you have problems, there are going to be a lot fewer people around that might be able to help you. If you prefer running Windows rather than Linux, but don’t care for MediaPortal, NextPVR is another somewhat popular choice, but I have no personal experience with it so I cannot offer any opinion on it.