Monday, 25 June 2007

TV Guide upgrade

Prompted by my purchase of the Pinnacle Dual tuner, over the last week or so I've been rewriting my TV guide application to work with an arbitrary number of tuners. I've added a plugin type architecture, which allows me to add tuner "adaptors" as and when required. For example, I now have a Nebula DigiTV adaptor, a Pinnacle adaptor and a testing adaptor. Which ones are in use is controlled by a configuration file, and the TV guide just expands its processing to accommodate as many as are available.

One of the things this would allow me to do would be to create an adaptor for Windows Mediacenter for example. That way, any one who had MCE working would then be able to use my TV guide to control it. Of course, with my purchase of DVB Web scheduler (detailed in my last post) I'm not currently needing that facility, but it's good that I can now add it painlessly to the guide should I need to.

Another feature I've added is that the order of the tuners is respected. I.e. although the main aim now is to use the two Pinnacle tuners for recording and the DigiTV tuner for watching, all three are available for recording if necessary. The TV guide will however only use the DigiTV tuner if both the other tuners are already recording something else. Given that both types of tuner can record multiple programmes from a single multiplex, this actually means that I need to be recording three separate multiplexes for all three tuners to be required. Generally, that just doesn't happen, but it's nice that it will handle it if necessary.

Transport Streams

One thing I've had to deal with since I moved the majority of recording to the Pinnacle is that it records as a .TS transport stream file. Back in the days, DigiTV used to do the same but fortunately it was changed to do TS-to-DVD MPG on the fly. With the Pinnacle I'm back with a transport stream.

TS files don't matter too much as both Media Player Classic (my preferred player) and VLC both play them back natively. I do however have an automatic conversion application which converts the native video to XVid as soon as the recording has finished. This, prior to this weekend, did not work with TS files.

When I originally had a problem with DigiTV, I used a program called ProjectX to convert the TS stream to an MPG. This worked very well and still seems to stand above the rest in the marketplace. It works from the command line too, which makes it easily integratable into my automatic conversion system.

I've now made some changes to the automatic conversion to detect a TS stream and insert a conversion step before the XVid work is done. This seems to be working fine, and gets me back to where I wanted - automatic conversion to XVid with no interaction. That's more like it!

Monday, 11 June 2007

New Tuner(s)

I bought a new Pinnacle PCTV Dual DVB-T USB tuner recently, to extend the capability of my media centre PC. I chose this device because it follows the now relatively standard BDA interface which will let it work with Windows Media Centre for example. Given it uses this interface, it should also not be too hard to get it to work under Linux if necessary.

Being compatible with lots of software, I felt confident that I would be able to adapt my TV guide application to set recordings on it and, albeit a lower priority, I hoped that the Nebula DigiTV software would also recognise it.

The latest version of the DigiTV software states that it will work with BDA compatible devices. Unfortunately it appears that it won't (at least with this tuner anyway), but I don't see that as too much of a problem because there's every likelihood that the next Nebula version will recognise it better.

In the meantime, I have a choice of methods to set recordings:
  • Windows Media Centre. I like the interface a lot, but it is a bit fiddly to get to where you want quickly which does not make it my player of choice. It has however proven to be a useful application for testing the new tuners. Another downside is its choice of recording being only MS-DVR format which is not directly playable by many applications. There is a recording API in .NET which I can call direct from my TV Guide which is handy, but because of the reasons above, I probably won't use it.
  • Pinnacle Media Centre. This is a pretty horrible looking application from Pinnacle and only stayed installed for the day whilst I was testing it. There's no comparison (IMHO) with either MCE or Nebula's software.
  • DVB Web Scheduler Pro. I discovered this recently and I like it because it does pretty much exactly what I want it to do. It's an application which sets up a small website on your computer which you can then use to schedule recordings. It works with any BDA compatible tuner, and records in a number of formats. It will support multiple tuners, and multiple simultaneous recordings from the same multiplex. It costs AUD 29.95 and seems to work fine. From my TV guide perspective, because it uses a web UI, it's easy for me to adapt it to work with my guide using just a new timer plugin.
The plan for now is to add a plugin to the TV guide so that it can talk to DVB Web Scheduler, and use the two new tuners primarily for recordings. It's unlikely that the third tuner (Nebula) will be required then for day-to-day Tivo like operation so the Nebula can be used for viewing live TV instead.

Once I have it set up like that, I'll extend the TV guide so that it can use the Nebula if it needs to, but will use the other tuners in preference. That should give me the best of all worlds.

One interesting point about DVD Web Scheduler is that an early version (which I was testing) allowed streaming of live TV over the network, something which I've not managed to do until now. I followed the instructions on the VideoHelp forum, and to my surprise it worked seamlessly! It also has the advantage of controlling the streaming via the web front end - meaning I could change channels remotely too!

Oddly however, that functionality has disappeared from the latest version. I'm not sure why yet, but already there appear to be workarounds.

I'll give it a go and report my findings..

Wednesday, 6 June 2007

Mono

Having had quite a lot of success with Linux and open source replacements for my most common applications, I'm left with one big problem. How do I get the TV guide application to work under Linux?

One idea would be to rewrite or extend it to present a web interface rather than a Windows one. That would easily make it cross-platform. The problem with that is with the level of interactivity that it provides, the web site would be quite a challenge to write. I know it's been done before, I've seen many other web based guides which do the job - the question is do I have the time to rewrite my app?

The other option would be to look at Mono on Linux. The mono project is a set of open source libraries which (in theory) allow you to run .NET applications natively on Linux. Now call me a sceptic, but that sounds too good to be true. I wouldn't have to rewrite the application at all..

Recently I actually got around to trying to run my application using Mono. Fortunately you can test mono under Windows first to speed up the process. What I found was amazing - it basically works!

I needed to make some trivial changes to my application, such as converting path separators from "\" to "/" and, given that the application is heavily graphical, remove the double-buffering I'd put on to smooth the scrolling in the Windows version. Other than that, I can quite happily run the guide under Mono. It reads the XML data and displays it in its full graphical glory(!)

Seeing as the graphical side is probably the most complicated part of the application, it's unlikely that there are going to be any other issues. Ok so maybe there will be a few, but I'm sure a little alteration will be able to fix that.

Best of all, one application code base and binary runs on both Windows and Linux. Mono will even run on MacOS should I ever go that route..

Sunday, 3 June 2007

Ubuntu vs Kubuntu

Having had so much success with the Kubuntu live CD, I thought it was time to try it on a real PC. My laptop was going to be the guinea pig as it had the least to loose if everything went horribly wrong.

The dual boot installation was a piece of cake, and is a credit to the K/ubuntu team. Once I had Kubuntu (7.04 feisty) installed, I wanted to try the TV streaming again in case it was just a virtual machine issue. Unfortunately it wasn't and still I couldn't get it to work. I'll need to keep working at that.

Instead, I installed Thunderbird 2.0 and tested my central mail/calendar locations under Linux. Sadly TB would not run under Kubuntu for me. It wouldn't on the laptop and it wouldn't on the virtual machine either.

To be honest I didn't spend much time trying to find a solution and a google search did not seem to lead to an immediate fix.

Moving on with Kubuntu, I kept having applications crash on me for little reason. I also didn't like the way that Konquerer (the file manager) kept taking over everything including web browsing. I wanted to make Kubuntu look as much like MacOS as possible, including transparency and centering of the icon bar. That's easy to do, but even then I couldn't get it quite how I wanted.

My overall feeling with using KDE is that it's probably great if you already like it, but for me as a Windows user, it was a bit much to get used to in one go.

The crashes continued and although I'm sure that they had something to do with my laptop's graphics card, they were such a pain I decided to move from Kubuntu to Ubuntu as the "perceived reliability" had been higher with that version of the OS.

Sure enough, I've not had any problems with Ubuntu since, and TB installs and runs without issue too. I bet there's a quick fix for Kubuntu, but I only have a certain amount of time to play with it. Thankfully the virtual machine will let me continue with that even if the laptop is now set up with Ubuntu.

Other applications

Generally though, with most applications the experience has been great. I gave OpenOffice a go, successfully opening my Word documents and saving a new document in Office format. For the kind of word processing and spreadsheet work I do at home, OpenOffice is going to be absolutely fine.

With regards TB2 (with my profile stored on the network remember) the mail worked perfectly and only the calendar presented a problem. For some reason Lightning under K/Ubuntu won't let me create a calendar or subscribe to one. This is a bit strange because Sunbird on the same installation works just fine. I'm assuming it must be related to TB 2.0 not being fully available for Ubuntu yet - it does not appear in the official package list at the moment. I'm not too concerned about this because I'm sure it will be fixed and in the meantime I just use Sunbird instead.

I attached to my network shares using Samba, including connecting to my shared printer. No problems there at all.

Playing back Xvid avi's, and recorded MPEG2 PS files from the network was not a problem at all using Totem movie player, and neither were local DVDs.

My music was read and played with the default Rhythmbox player without any issues either. It's nice to have an application there which just does what you tell it and does not have all the extra "flash" of Windows media player. In the end, I want to create a playlist and play it. Searching is easy and not cluttered. Just about perfect.

In conclusion, Ubuntu seems to be a great step forward and at present would be my choice for a new, low cost HTPC.

Friday, 1 June 2007

Linux weekend

One of the biggest issues with moving my HTPC to Linux is my TV card. Although the machine is used for lots of different things, without the TV recording and guide functionality, there's really no need for it.

I did quite a bit of research at the DigiTV forum which was very helpful. In particular there is a great how-to which explains what you need to do under Kubuntu to get it to view TV on the Nebula DigiTV card which I own.

Not wanting to pull my existing PC apart just to test this, I booted into the Kubuntu Live CD and installed the necessary drivers to the ram drive. Sure enough, without any problems at all, the Kaffeine player scanned for channels and found them just like on Windows. I even managed to record some TV direct from the live CD onto my network, just to prove I could watch it elsewhere.

Aside from the fact that I can boot Kubuntu, install drivers, tune channels and watch TV directly off a live CD without affecting my existing system, I was very impressed that it worked so painlessly. Thumbs up Linux, thumbs up Kubuntu.

Streaming TV

In reading around this area, I noticed that Kaffeine could stream TV on the network. This interested me because it would allow the tuners in one PC (near the aerial input) provide tv to other boxes around the house. Think shared music or video playback, but with live TV.

This is not just serving up the TV either, it's also providing the client application with the ability to change channels too.

I used my virtual machine installation of Kubuntu as a client and left the main DigiTV PC running Kubuntu off the live CD.

Turning on the streaming feature in Kaffeine forced me to pick a "broadcast address". By default this was 192.168.0.255. Apparently this is the broadcast address for the 192.168.0 subnet, but I would have thought a multicast address would have been better (230.x.x.x for example).

On the client, with the server broadcasting on 192.168.0.255, I could succesfully read which channels were available, but double-clicking on one brought garbled pictures in the screen area. Despite playing for a while, I couldn't get this to work properly which was a shame.

I noticed that whilst it was broadcasting, it took out my other network connections, preventing me for example from accessing the web. I changed the broadcast address to a legitimate multicast address (230.1.1.1) and that brought back my internet. Unfortunately, now the client couldn't even display a list of channels, implying it couldn't pick up the server's transmission.

Just to prove that the principle was not impossible, I set up VLC on the server and client and asked it to stream a recorded video on the 230.1.1.1 address. I was able to have multiple clients watching the stream simultaneously without any problems. Of course, I don't really need recorded video to be streamed, it's the live stuff I'm interested in. VLC can take live TV but then you can't change channel.

Close, but no cigar. At least it is definitely possible to watch and record TV under Linux from my DigiTV card. That's a start.