Thumbnailing Movies in the Right Way

2006-02-03 16:24:47 GMT

About Thumbnailing in General

Thumbnailing is a very nice feature, although I think it's not essentially usable in case of most formats. Speaking of audio files, it's clearly impossible, of course and textual files generally don't differ that much that one could efficiently differentiate them based on their thumbnails. Image files however, have an obvious relevance here and it's pretty straightforward to thumbnail all of them. The last type, which really hits home for me are movies.

Why Movie Thumbnails Suck?

Movies are special kinds of animals in the context of thumbnailing, because picking up a random image out of a movie stream generally results in an irrelevant image. We cannot really associate a randomly selected image with the movie in our mind, because statistically it's a kind of image that loosely relates to the content of the actual movie. Imagine what it's like to see an ocean with a boat, an average american house, a city from 10 000 feet, or a cast list as a thumbnail? Could you tell me which movie it's taken from? I can hardly think so.

Unfortunately every desktops that exist today operate by this policy. Windows XP captures the first frame of every movie file as its thumbnail. Nautilus essentially does the same, but it captures an image that is at the 1/3th of the movie, which is a smarter policy I guess considering that most movies start with black screen.

Best Case Scenario

So what would be the best scenario for thumbnailing movie files? The whole point of movie thumbnails is that the user can associate the thumbnail with the movie it belongs to, so the user must be provided with an interface which makes him able to associate a thumbnail that is actually relevant to him. I see two possibilities for achiving this goal:

  1. Implement a mini movie player that provides a way to capture a frame into a thumbnail. Unfortunately GStreamer isn't wrapped in Mono yet, so I cannot implement this solution in UC.
  2. Randomly capture more images of the movie so that the user can choose of them the one which he likes the best. If he doesn't like either of them, he can recapture the same number of images any time. This solution has the undisputable advantage that it can be easily implemented as a command line application as you'll see below. I also think it's a more convenient approach.

Thumbnailing in GNOME

Several months ago using Nautilus I was impressed by its movie thumbnailing feature considering how well it handled different movie formats. Later when I played with gconf-editor, I could easily understand the thumbnailing infrastructure of GNOME. Under the /desktop/gnome/thumbnailers gconf key, one can find all the thumbnailing applications GNOME applications fork to get the related thumbnail file of the associated MIME type.

The New Way of Movie Thumbnailing

I noticed that every MIME movie file is referenced to gnome-video-thumbnailer on my system which is symlinked to totem-video-thumbnailer. In the next moment I was fetching the source of Totem. Totem can be compiled with two backends: GStreamer and xine, but for some wicked reasons, only xine worked well for me. As soon as I saw how well it worked I started to implement the above "Best Case Scenario #2" features. So here's what I've done a la ChangeLog:

I've just committed this babe to the UC repo. You can find it in the depot-video-thumbnailer directory. If you wanna try it, install the xine-dev and totem (and probably other) packages on your Debian distribution or look for similarly-named packages on other distributions. After that use make and it should compile.

It's pretty easy to use it actually:

lee@whisper:~/projects/uc/depot-video-thumbnailer$ ./depot-video-thumbnailer
Usage: ./depot-video-thumbnailer [-s <size>] <number-of-thumbnails>
       <input> <output-prefix> [xine backend options]

Let's give it a try on one of my favorite movies, The Rock:

$ ./depot-video-thumbnailer -s 384x348 4 the-rock-cd2.avi rock
Capturing image 1 of 4 as rock1.png...
Capturing image 2 of 4 as rock2.png...
Capturing image 3 of 4 as rock3.png...
Capturing image 4 of 4 as rock4.png...

Wanna see how the thumbnails look like?

rock-capture-1

rock-capture-2

rock-capture-3

rock-capture-4

They seem pretty neat. Which one would you choose?

As a last note, maybe you should use depot-video-thumbnailer instead of totem-video-thumbnailer, because it uses bilinear filtering so your thumbnails won't look that messy.