Search This Blog

Sunday, December 4, 2011

Bringing Live TV into XBMC (using a Sony Play TV and TVHeadEnd in a virtual machine!)

Ok, so this was a little tricky.

But totally worth it - the results are really very good indeed,and  even with all sorts of beta/development version involved, it's all looking good and fairly stable.

For a long time, I have wanted to get rid of our cable TV package (Foxtel).  We barely ever use it and it costs us $60+ a month I think - it's kind of like a gym membership, this vampire like thign that sucks you dry while you're not really watching.

I finally convinced my wife that the only thing we really watch on Cable these days is kids stuff - notably, ABC4Kids which is a free to air digital channel featuring excellent pre-school programming.  Cable also delivers to us the over-the-air free channels, so I've never actually just used the tuner side of my TV until now.

(As an aside - the ABC here in Australia is a totally awesome, progressive, and tech friendly organisation with some fantastic stuff, like iView, and their iApps etc. - this is how a TV statuon should be, if you ask me.  They actually treat their viewers with some respect, offer interesting programming, and don't make it hard to consume or have 17+ minutes of add per hour like the commercial networks!  There are XBMC plugins for the ABC streams, so it's really easy to use inside of XBMC too).

So here was the goal - an digital TV server running on our main home server machine (which runs Windows 7 Ultimate and is regularly used for other work as well, so it needs to be Windows).  Feeding the TV signal over Ethernet to gorgeous XBMC clients - so one media centre to rule them all!

*** Hardware Required

We still do want at least some access to Live TV, so the first thing I did was buy a TV tuner for the PC as my plan was to have this on the PC - and there was no aerial port in the TV room as it happens, so I though I'd start there and then get an aerial port put in the TV room.

My research led me to the Sony PlayTV - this is inexpensive, USB based, and a neat little box that requires only one aerial input for two tuners, so it's tidier.  You can get there cheaper if you only want one tuner, but I'd stick to USB based tuners and check carefully about Windows and Linux support for your chosen device before you embark on all this, as good drivers are essential.  PCI devices don't work well with virtual machines, or at least as well as USB ones, so USB is the way to go even though it means an external box.

The Sony Play TV was $85 from JB Hi-Fi, you can get them even cheaper off eBay.  Not bad for a two tuner unit, really.  It's USB powered, so it just needs one USB connection to the PC, and a single standard aerial jack plugged in works for both tuners.  Very simple, and uses bugger all power.  It doesn't get hot, and this unit is very well shielded against RF interference unlike some of the little stick ones.

So, I bought this, and though I'd try it at work.  No real luck here, couldn't get a signal really.  I wasn't too bothered, as I have never really used TV at my workplace so I don't know about the state of the aerial.  I brought it home and tried our aerial jacks - no go their either.  Oh dear.  I decided it might be the device, so I tried with a  rabbit ears and was able to get at least some response.  So I realised both work and home have crappy aerials.

I had an aerial guy come in and put in a new fancy pants digital aerial (turns out the old one was  a bizarre home made frankenaerial - all sorts of weird plastic and just a heap of crap basically - no wonder there was no signal, and God knows what the previous owners were watching?!).  The cost was $350 all up for a new top of the line aerial and install of two aerial points, which in our old house was not simple, so I think these guys (New Image Antennas) did a great job (thanks Eric!).  And on the very same day I rang them, no less.

At this point, I finally had a working aerial port both at my server and next to my TV, and the TV itself was getting excellent digital reception - very occasional minor glitches but far better than most digital installs I have seen.

*** Software
Moving beyond just Digital TV to the TV - Hello XBMC based PVR

Next test was to try Windows MCE to confirm the PlayTV was fully working at least under Windows. 

Ok - about drivers - this was a bit hard.

Under Windows7 - to get the PlayTV working reliably - you need to install these drivers and this technique -  - do not use the hacked pinnacle drivers, these don't change channels properly on Win7!  Note be careful when extracting this .exe (use 7 zip) - I think there are two .inf files in there and one doesn't work (not I am not talking about the HID inf, ignore that, but two .inf files for the actual elgato device itself).  If you get an error saying 'these drivers are not for your device' then re-extract the archive manually and try the other .inf) - it was a bit wierd, I could not get this to work on my laptop but iot went straight on the server, and the onyl differnce was how I extracted the archive, so be warned!).

Once the Elgato drivers were in place, Windows MCE instantly tuned all 20+ channels and all tests were perfect in terms of rapid channel changing etc.  Maybe 2-3 seconds to change channels, could record one and watch another etc.  All good.

However, MCE doesn't help me much - I want to be able to serve the TV up to my XBMC clients.  My reading suggest the easiest approach, and the one the current XBMC PVR main developer is using, is to use the linux only TvHeadEnd package to serve up the TV feed over ethernet to my XBMC clients.  So now I wanted to get this working under linux - either running direct on one of my rather feeble XBMC clients (all Atom/ION type machines), or ideally on my main server - which is Windows and needs to be for many reasons - I don't have any Linux server.

Alternatives are other Windows based TV servers, like MediaPortal but everything suggested TvHeadEnd was very much the way to go.  And I have never like MediaPortal for some reason....the one time I tried it I found it very clunky and fiddly, but that was years ago.

Enter Linux - Ubuntu Oncelot Virtual Machine in WMWare Workstation

So it seemed my best option was a Linux virtual machine running on my Windows server.  Not only would this potentially give me a proper TV feed, but I could potentially start using linux for other servive tasks, like Calibre book serving, etc - a lot of these things run easier and better on Linux than Windows.  But first things first, let's try TV....

My first tests were done under VirtualBox which I have used before and is very easy.  Slightly slicker to use than VMWare Player in my experience.  However, I installed the device and TvHeadEnd on this ang got it running and the USB device was recognised and working - but no matter what, I could not get TvHeadEnd to tune.  I saw other eports of TvHeadEnd failing under VirtualBox.

(TvHeadEnd install instructions are here - - but I found that script doesn't do TvHeadEnd, just the depends really, so I manually installed it, see below).

I almost gave up at this point (the one paragraph above sounds like not much hassle but in reality it was a LOT of mucking about and trying for zero result, so it was a bit dis-motivating - after several days of mucking about with the aerial ports and then VBox, I'd got basically nowhere).

I decided to throw jsut a bit more time at it and couldn't find any reference to VMWare Player and TVHeadEnd but decided to try that as well - thankfully, this was a lot easier really!

In the end, I am actually using VMWare Workstation as it has more options, but you can test you install under the basic, free Player first, and if it works for you, consider the $195 cost of Workstation if you want the extra features...

So, I set up a pretty standard Ubuntu install under VMWare Player.  30GM hard drive, 1GB Ram, USB passthrough of the SonyPlayTV etc.  Running in Bridge networking mode so that the VM gets its own IP, I couldn't get the server visible externally using the basic NAT mode for some reason.  I actually like it having it's own IP as it means I can set up testing servers of things I already have and easily switch between them by changing one IP digit, rather than port numbers.

I installed TvHeadEnd using the pulse eight .deb Packages available here - note I used the lucid packages as there's no specific Oncelot version (so tvheadend_2.12.99~pulse-2_i386.deb in the lucid folder)....

....just downloaded that and double clicked it I think, and ubuntu went ahead and installed it.  (I tried other ways and versions of tvheadend but this seems to be an easy and reliable way as opdenkamp the XBMC dev (aka dushmaniac on the forums) is clearly working with these guys and so it appears this is a relatively stable source of the latest PVR code both at the server and client ends). 

Initially this seemed to work ok, but damn it still no actual service results in TvHeadEnd.  Both my tuners came up as available, and I could at last see Muxes (I used the 'Add Mux by location' button or whatever it is called to add the Melbourne muxes).  This got me Muxes with good signal quality, but grrr still no services.  Grrr.

I checked dmesg and saw there was some errors associated with the PlayTV device...much googling let me to this problem and solution:

Working PlayTV Under Ubuntu Oncelot (11.10) - the latest linux kernel has broken some usb-dvb support.  So I had to rebuild the drivers per these bug notes -
( it appears it will be properly patched in later kernels but an easy fix is to follow this method to manually re-build the drivers

Compiled and installed per those instructions, rebooted the VM...and wa la - instant awesomeness in TvHeadEnd.  Both tuners found, and all the expected services.  I then used the auto 'map services to channels' button and I had 20+ channels ready to go.  Note, make sure you do both tuners the same, in terms of mapping channels etc. or you might get wierdness at the client end if two clients are tuned to different channels.

(Incidentally, if have lots of clients, there's no reason you couldn't add another PlayTV for another two tuners, or indeed multiples for many many tuners - TVHeadEnd is happy to use many tuners).

One other thing I did was give all my channels a logo URL for the TV station logos (I used the Harmony One icons from here).  Looks much prettier at the client end.

I also added a user (xbmc/xbmc) in TvHeadEnd as without it you can't access the admin panel (at :9981) or the TCP TV feed itself (:9982)

The Client Ends, & How It Works

All this is part of preparing to move to Eden for me so I have been trying Eden builds with the clients.  This is where they can be found:
Linux Client -
Windows Client -

Install one of those, go into add ons and enable and configure the TvHeadEnd Client Add on.  And then go into XBMC main settings and set up the Live TV settings.  Now back to the main menu and click on Live TV and with any luck you'll see a nice channel map screen...

First test was using the Windows.  And WOW!  it works.  And it works so well!

Instant connection to the TvHeadEnd server.  Live TV @1080 streaming (over wireless 11g!! no less) - to my laptop.  And the PVR stuff in XBMC is *slick*.  Way, way better (and more stable) than I expected.  Very nice.  The build is not super current so there are some noticeable Eden bugs but overall it's remarkably good...and I am sure more builds will follow as Eden heads towards stable release.  It's easily good enough for testing though.

Next I installed the Openelec version on to my ASRock Ion 330 box (from one usb key to another, not yet willing to over-write my very stable Openelec 1.0.2 Dharma install on that machine).

Here's what you get.....

Basic viewing & Channel changes - takes maybe 2-3 seconds - about the same speed as my 50" pana plasma really, maybe marginally slower, but way quicker than most TV tuner PC things I have seen.  All channels work well, in a window or fullscreen, and changing is very easy using up/down channel, or popping up the mini window (I will need to do some dedicated remote mapping for this section!).  There's seems to be no speed or quality trade off streaming the TV over Ethernet at all.  It works so well it really shocked me.

Pause TV works?! - which I was not expecting as I kept reading TvHeadEnd does not support time shifting.  So I guess this is some clever XBMC/instant record implementation....I have not tested thus for long periods yet but pausing for a few seconds certainly works just fine...

Recording & Scheduling works, and is all done back at the server end - you can trigger the record from the client end or the server end, but I mean the actual recording is done on the server machine so visible to all the clients and you don't need to have big hard drives in your clients.

EPG works well - It picked up my EPG from the digital TV feed (no need for xml grabbers thankfully) and this info is all in place at both the client and server ends - although once I have seen it get lost on one of the clients, I just went into the settings and dumped the EPG and it got it all probably happened because I tweaked the channels on the server end.

Summary & Results

It's all amazingly good.

I really had no idea how well this would all work.  Honestly, apart from the alpha nature of xbmc-pvr and Eden itself, I had real concerns about the virtual machine offering enough performance.  But in reality, the virtual machine approach is very neat and doesn't seem to place undue load on our home server (a fairly beefy Core i7 with 16GB machine offering about 20TB of total storage).  It very happily streams at least two channels to two client at 1080 simultaneously with no issues at all.  XBMC-PVR startup initially takes maybe 5 seconds after XBMC itself starts, as it re-loads channels and EPG at the beginning, and after that it's really just like a super super slick PVR fully inegrated into XBMC.

Recordings I have re-directed from the Virtual Machine virtual HD to a shared folder on my main server, so these are accessible both directly through the PVR interface and more manually via the 'video files' view in XBMC.  This means the tiny virtual HD won't fill up.

I have snapshotted the virtual machine in this working state and can now experiment with moving some of my other server stuff acorss, like SABnzbd, sickbeard etc, to isolate this virtual machine into a very easily re-installable thing if I upgrade the home server, or a friend wants a pre-made copy of all this stuff etc.  And basically, the snapshots form a very easy backup - I will probably even copy the entire VM over the net to my work server so it's completely backed up even if the computer dies/gets stolen or whatever.

Nothing techy has impressed me so much since XBMC itself.  Most of the difficulties were from my own unfamiliarity with Linux and virtual machines, although obviously this isn't for the faint of heart in all.  It does take a fair bit of work to get going like this.  If you has a Linux server in place already, it would doubtless be much quicker....

I will say working with the UI in Oncelot is truly truly hideous (Unity, they call it - under the VM I seem to only have Unity 2D working) - I think I would just whack Lucid on if I could be bothered doing it again as the old Ubuntu interface is a lot nicer.  I presume Unity will be much improved over time although its such a bad base one can hardly see where it can go from here that would help.  But to be honest, I mainly use the terminal when I am working in the VM, and Firefox for downloading things etc, so I won't spend much time in there.

XBMC is very slick, we all know that - and XBMC + PVR really is the ultimate media centre.  All the goodness of regular XBMC (gorgeous skins, great meta info, easy navigation and high WAF factor, extensive customisation, add ons etc etc) - with a very slick and easy PVR interface bolted on.  Just beautiful.  You can use cheap, quiet, simple client machines, with all the load on the server, way off in the inaudible distance.


  1. Very impressive, i will try to replicate this.

  2. You should get down to JB Hifi and pickup a HDHomeRun (Aus version)

    These are now known as Kaiser Baas

    then head over to this thread on OpenElec forum:

    I just got my Aus HDHomeRun working with TVHeadEnd running all out of the Openelec distro.

    This will do away with the Virtual/USB passthrough setup.

    Great writeup, big fan of your site


  3. For me the virtual machine is super handy to have in any case, so I am not that fussed, and I would much rather have the load on my server than on my ION clients that are wimpy enough as it is without more running on them!

    But definitely sounds good if you want to have the TV server running right on the OE box.

  4. does the TVHeadEnd Support season pass... i.e. record a whole season of a show without having to select each episode individually - and track what shows you've already seen?

  5. Not quite season pass but you can define a name matching rule and it will happily pull & record anything with that name. My providers don't provide episode numbers or anything, so you do have to do a bit of your own filtering of repeats etc.

    Honestly though, why not just download? It's usually better and easier....

  6. A quick follow up to this one - turns out that the Sony PlayTV are in the current Pulse8/Openelec PVR builds so the advice above is right really - I plugged it directly into my shuttle and had TVHeadEnd running and full live TV again in less than 5 minutes - absurdly now I feel kinda stupid for not trying this first - all that VM mucking about was unnecessary! I thought the Shuttle would struggle with it but it really doesn't, it plays perfectly and even happily streams HD out to my other client while playing TV itself. So since my Shuttle is on 24/7 anyway, it might as well be the TV server... I have yet to test recording etc., but I am pretty confident this will work well.

    THe VM was still a really interesting thing to do and interesting to learn about, I like having a linux install handy to try things, but since I want to pass this LiveTV ability on to my parents-in-law and friends etc, it's nice to know that there's a super simple way to do it - just buy a PlayTV, plug it in via USB and to the aerial, install openelec PVR version, and in less than 5 minutes there you go....

  7. (so in other words Kortina above gave me the right advice! Thanks!!)

  8. which version of openelec PVR did you install?

  9. At the time is was from the Pulse packages here:

    As I found the actual OE version to be less stable.

    But have changed evberything now and am using the PVR install from here:

    ..and running TVHeadEnd directly on the Shuttle (using the add on) and sharing the TV to other clients from here. Works a treat and in fact better than my VM approach!

    Took about 5 mins to install too, had drivers in place already for the Sony Play TV, so no fiddling at all....

  10. Hi! CAn you help me configure the drivers? It seems that TVHeadend found them by default, but it doesn't find any channels. I haven't modified the drivers in any way and am new to Ubuntu.

  11. Apologies, I have long since moved to ArgusTV running on a windows server as it is both vastly more functional, and considerably more stable.

  12. Hi, we have satellite installation so the cable is an lnb end. Any similar box and method to do the same with that? Our aerial option isn't as grand with only 4 channels and is being fazed out..

  13. See comment above, I am not using any of this anymore (though it worked well for a few years).

    Gievn this is now so old, I'm going to close comments....