Sunday 24 August 2014

Media Centre in Galway, Ireland

Introduction

I've been progressing my media centre setup at home.  This is something I've been wanting to get to since we moved into our new home.  As we built it, the house was cabled with a certain media centre architecture in mind.


  • No silly co-ax based distribution;
  • Just one or two Cat5e cables from a central point to every room where the bits and bytes that make up our digital media might be consumed;
  • Co-axial cables going from the same central point up to TV/satellite antennae the roof.
  • And something in the middle to make it work together.


See, this is to be a client-server setup, distributed using TCP/UDP.


I was under time pressure to make decisions about this stuff as we built the house, so the "something in the middle" was a bit undefined.  I had built MythTV systems in the past (for my dad and myself), and I really liked the idea of being client-server.  Once you start costing everything out a MythTV based setup, it quickly gets pretty expensive.


So I've been holding off.


In the meantime, the cost of computing has been tumbling.  New powerful yet low power consumption devices are being released, and satellite distribution over IP is burgeoning.  In the last month, all the pieces finally look like they've finally fallen into place.

MythTV

Media centres have interested me for a long time.  I first started thinking about these things back in the mid to late '90s when companies like Tiny in the UK were selling PCs with TV tuners in them.  As I recall it was a bit of a hack at the time because I think the tuner card just carved out a part of the VGA signal and overlaid the picture.  

Fast forward a few years and the idea of pausing "live TV" started coming to market through devices like those from Tivo.  In '04 or '05 a friend back home in Australia put me on to the MythTV project.  So I built one and it was a lot of fun.  I started from a Debian 'net install' and got something running on an old Pentium III that a friend had donated to the cause.  It had a nice Hauppauge PVR-350 for tuning the analogue cable TV and encoding/decoding MPEG-2, a 400GB HDD.  It was really cool.

But it was also noisy, so I moved to a quieter SFF machine, quieter PSU, etc.  After some time, it fell into disrepair for want of maintenance, upgrades etc.  There was also an annoying bit of interference on the PVR-350's encoder/decoder; I thought maybe a power fluctuation caused by the HDD affecting the ADC/DAC?

I also built a MythTV box for my Dad in Australia.  There we had 720p/1080i over DVB-T to play with, so I had to size it for HD decoding.  This meant either a really fast and expensive CPU or trying to do GPU decoding - I went for the latter because nVidia GeForce 5200 cards were supposedly up to it and relatively cheap.  For a tuner I had the access to the DViCo Fusion HDTV range of DVB-T tuners, and someone at UofQ had done the patches needed to get it working under V4L.

The project for Dad actually started on an old AMD K6 based PC that he had lying around.  I thought it might have worked but the Linux kernel drivers I was trying to use wouldn't work on that thing.  So we went for a whole new machine built from parts.  By this stage Mythbuntu was available, so we had an easier time installing the software.

Not living in Australia anymore, I wasn't able to keep it running for Dad but I think he has fun keeping it going as much as he could.  It fried a couple of PSUs (failing fans) etc which he replaced.  It did get an upgraded graphics card at one stage, a passively cooled nVidia 7x00 thing and that improved things a bit.  Dad periodically goes back to it and messes around, installs latest Mythbuntu etc.  I think he sometimes uses it to record TV programs for the family which he then burns to disc.

The MythTV project moved to using the new VDPAU drivers some time ago and away from the xvmc drivers.  Unfortunately getting a VDPAU capable graphics was going to mean a whole new machine so his MythTV setup is no longer in active service.

Farewell MythTV

When it came to the new house, I just wasn't liking the price of putting together a MythTV setup.  The cost of the PCI card satellite tuners alone was adding up.  I then discovered Sat>IP where a bunch of companies were already selling hardware with four tuners, and would stream over gigabit ethernet.  But there didn't seem to be any support in MythTV...

I'm also fairly time-poor these days, so the idea of giving time to installing and maintaining it has been putting me off.  We got a DVR from our cable TV provider quite some time ago so the immediate need to setup MythTV at home has gone away.  Having had the DVR from our provider for some time now I've realised how immature MythTV actually is.  This DVR upgrades itself, automatically, without anybody having to come to the house.  That's really useful.



The front end hardware for a MythTV setup wasn't looking so cheap either, although I've had my eye on Zotac's ZBox range for a while.  It's a shame there hasn't been a Raspberry Pi port because that is super cheap.  XBMC is very attractive from a cost point of view because it seems quite well supported on Raspberry Pi.

Having done so much with MythTV I was mostly ignoring XBMC - just checking in on it now and again.  Also, for a long time it didn't support live TV which is a critical requirement.  It was purely a media centre application designed to play/stream content over IP.  That's still the case mostly, but now it *does* include live TV through a series of "PVR Add-ons".  It's actually very well integrated.


I recently found that the tvheadend project (one of XBMC's PVR backends) has added support for the Sat>IP protocol as of April 2014.  So another piece of the puzzle now fits.  The tvheadend server also can do the job of fetching the EPG, controlling the tuners, putting recordings on disk, and streaming the video to XBMC over TCP/IP.


With tvheadend supporting Sat>IP and XBMC supporting Live TV in place, I now feel I can actually move forward with this project.

Getting Started

I bought a Raspberry Pi (RPi) and have installed XBMC on it.  Actually what I installed was OpenELEC which is a stripped down version of Linux OS with XBMC pre-installed.  It runs off a 32GB Mircro SD card using 4W of power.

At the moment it's all running in the RPi - I have a borrowed USB DVB-T tuner - and I've been able to watch Irish digital TV in HD.  When I consider all the work I did to get the original MythTV setup running in '05, it was amazingly easy.  Something else - OpenELEC can update itself in situ.  Fantastic stuff.

RF Stage

The next phase is to install a proper TV antenna and a satellite dish.  A lot of the TV we pay for on cable plus a bunch of channels besides is actually available for free on satellite.  Some are in HD too (something we'd have to pay extra for on our cable TV subscription).  I haven't picked a TV antenna just yet.  We're less than 3Km from a 250W repeater and I have direct line of sight, so I don't think there's anything too fancy required there.  The satellite dish will have a quad LNB which means it can tune to four different satellite frequencies at once.

The LNB also acts as the IF stage, downconverting the 10~12 GHz from the satellite to something that can run over cheap co-ax.  Usually the LNB is connected to a set-top-box but in my case will go into a Sat>IP server which streams the DVB-S/DVB-S2 over IP.


Tuning the terrestrial transmissions is likely to be done using DVB-T USB sticks.  More on this later.

Clients and Servers

The end-goal will be to split the installation into separate frontend (XBMC) and backend (tvheadend).  The backend server is going to be an HP N54L micro server that I bought a little while back and should be good for housing hard drives and running tvheadend.  It will have the DVB-T tuners connected (probably two) and an ethernet connection to the Sat>IP server.

Then I can run OpenELEC/XBMC on one or more RPi(s) as clients.  XBMC is also available for the Mac and Windows.  iOS apps as clients are the next thing of course, although I don't see it as something that would be heavily used.

Pi

The RPi and what's behind it is a really interesting part of the story.  You've probably heard of them?  As I recall, what was behind the project was that an engineer at Broadcom (Eben Upton) identified a surplus of a particular ARM system-on-chip (SoC) they had, and proposed that they design and build a small, very cheap system that was easy for kids to get started with.

The goal of the project was to trigger the next generation of British computer engineers; he wasn't happy with the state of computer education in schools which seems to revolve around teaching kids MS Office applications and I think this is a theme repeated in Ireland (and Australia I believe?).

The price he originally committed to was something like 25 pounds.  To achieve that they put in fairly cheap power management components, removed ethernet, etc to produce a Model A.  But it had USB, a 700MHz processor and 256MB of RAM.  There was also Model B which included the ethernet and double the RAM.

The power management design meant that many have found that if too much current was drawn by a USB device, the system would shut down all the time.  But it boots from an SD card, has HDMI and composite video and stereo audio outputs, a bunch of general purpose input/output (GPIO) ports, an optional camera.  It's a great concept and has inspired a lot of little projects as well as other similar devices.


Now there's a Model B+ which has switched from SD to micro SD, fixed the power supply issues, added more USB ports, improved the audio output; the B+ is what I've bought.

GPU Acceleration

The Broadcom SoC actually has a GPU built in; in that sense I guess it's basically like the SoC you'd find in a smartphone.  The GPU can encode/decode H.264 video when you get the RPi out of the box, something I find amazing considering what little the graphics cards we bought for your MythTV could do.

They've now released programming interfaces for the RPi's GPU so there are actually lots of things than can be done with it as seen in sample code they've released.

The generation of graphics card(s) I got for Dad's setup could only support MPEG-2 through xvmc acceleration that MythTV could use at the time.  Since then the graphics card manufacturers have made the video decoding libraries available for Linux.  But in order to support H.264 we were looking at a complete hardware replacement because this was only available for later model graphics cards which only fit PCI-E slots - not the AGP we started with.

MythTV has long since dropped support for xvmc.  Dad is getting on OK without GPU support for H.264, but it could be better with VDPAU.

Broadcast Standards

In Australia DVB-T in HD is using MPEG-2.  This is actually quite wasteful, and it means that to actually be able to do an HD stream and an SD stream (or two) in a single multiplex they have to compress the video quite hard.  I find sports on the SD channels quite unwatchable because so much detail is lost.

In Ireland, we're using the Nordig standard, and SD/HD H.264 is being broadcast over DVB-T rather than DVB-T2.  So it's a much more efficient codec and better use of the spectrum.  DVB-T2 might have been more efficient again from a symbol coding efficiency perspective, but it being DVB-T is great for me because the DVB-T tuners are a lot cheaper than the DVB-T2 tuners.


I can also very cheaply get licenses for the RPi to decode MPEG-2 (and VC-1) which is good because a lot of the standard definition channels off the satellite are encoded using MPEG-2.  An alternative to that might be to get an Elgato EyeTV Netstream 4Sat as the Sat>IP server because it includes hardware transcoding to H.264.  But it's a good bit more expensive too.

XBMC

Currently the RPi is connected to our 42" LCD and the picture from it is great.  I get full 1080p from the little thing.  The UI of XMBC is also pretty nice, and there are even smartphone apps available to control it.  XBMC supports Airplay too.

To be honest, in terms of quality it's not as good as something like an AppleTV; not by a long chalk.  I guess the little 700MHz CPU gets over taxed at times.


XMBC is awesome in the number of add-ons it has (I have one for ABC Radio National installed), but I find the add-ons slow to fetch/process their data.  That said, once the streams get going it seems rock-solid.  One downside is that the TV is being broadcast interlaced.  We had this issue on MythTV as well I think.  I can turn on deinterlacing but I'm not sure how well the RPi is going to handle it.


I will have to wait and see once I get an antenna up.  I may yet be getting more powerful hardware to use as a frontend!

Anyway I will keep you posted!

No comments: