Friday, January 1, 2010

Getting the max out of UPnP

I just did some counting, we have about 10'000 photos and rarely view them. Why? Very simple, because you can't find anything. Obviously we have a directory structure based on date and incident like 2002/Kids-are-born/ but you never want to see the 200 images taken at that day. The worst photos have been deleted, but out of those 200 just 5 are good enough to show to others. So we could copy those into a special folder but then once you want to view all pictures taken at the day, another time only portrait photos of the kids should be returned, or you want to see the very best photos only.
This calls for a database of same kind with keywords to each picture. Keyword hierarchies regrading Who? Where? When? What kind of? Reason? Rating?....

An easy question to answer is where to enter that data as the Exif standard is all about that, a method to store this kind of information in the jpeg file itself. But to search for specific tags, a database is needed. We experimented with different image databases, starting from Windows programs like Picasa, FastStone Image Viewer, Adobe LightRoom and Adobe Bridge, or WebBased solutions like Flickr and the PS3 internal Photo Gallery. Every solution had its unique pros and cons. The Windows programs are very flexible and easy to use, yet their internal databases do not cope with these amounts of files. Not to mention how to view the photos on other equipment like the PS3 or the TV in the sleeping room.

Because we use UPnP already for distributing mp3s and Videos across the house, that was the first thing to investigate. How fast is the MediaServer, can it cope with the number of pictures and how would you setup the system to accomplish the task of viewing just the high rated photos, or just the Windsurfing Photos?

Our UPnP server is Mediatomb, I have upgraded it to the latest 0.12 version and implemented a new import.js script. This scripts creates a hierarchy like shown here (sorry, it's in German). Basically it lets me search for images by various categories, the Camera Model used, the Date the picture was taken, the storage location, the hierarchical keywords stored in the Exif data and the rating of the picture (If you use Vista or Win7, you can rate the picture from 0 to 5 stars). Especially the rating is important as with that I can view the best 100 pictures out of the 10'000 by viewing just the 5* rated ones, or just the 4* ones or all that are rated 1* or better ("* oder besser" in German).

The cool thing now is that there are various ways to few the same pictures.
* The neighbors visited us, in the background a slideshow was running with all images tagged with their name. So they have seen their kids in various activities at our place.
* I was in the mood of going though all Windsurfing images of all years.
* Look, these are the images I have taken yesterday.
* Or simply a slideshow of the best 500 photos, meaning viewing all photos in the folder 3* rated or higher.

And this functionality is available on all UPnP clients, the PS3, the TV built-in one, the one in the Gym, whatever.

One UPnP Client however is not supported, that is Win7 Media Player. The ingenious idea Microsoft had was to use UPnP as a pure transport layer. So the Media Player WMP12 browses through the entire tree, sucks in all 10'000 photos, all mp3s, all Videos everything and wants that to be organized in their own library. They want to read the entire database of mediafiles to store it in their database. Copying a database? Sounds stupid? Probably is. The first problem with that is it takes forever. The second, as I have multiple ways to navigate to the same picture, all pictures show up multiple times. I have checked the low level UPnP protocol, it is really a simple browse through the root directory, not even constraining the mediatype. Each file found is sucked in, each directory found will be browsed recursively. And on top there are other limitations in the Win7 UPnP client, like no distinction between thumbnails and the real file etc.

Okay, so I am using XBMC as a Windows Client instead. Too bad.

Overall I am very happy with the implementation. The Mediatomb database is blazing fast, I got what I was looking for, still places for improvements, but these mostly depend on the UPnP client capabilities. I would just love to open a globe on the UPnP Client, the client would issue a search on all geocoded images with a 5* rating belonging to the current map area and choose one after the other. Have you seen on the PS3 -> Network -> Live with Playstation? I can just envision how this could look like, right now all the globe does is showing the weather conditions of 5 cities in Europe. I just hope the globe will support UPnP as well in future, I bet Sony will not.

Next to come: The technical setup to make above happen.