C# – How to get a Video Thumbnail in .Net


I'm looking to implement a function that retrieves a single frame from an input video, so I can use it as a thumbnail.

Something along these lines should work:

// filename examples: "test.avi", "test.dvr-ms"
// position is from 0 to 100 percent (0.0 to 1.0)
// returns a bitmap
byte[] GetVideoThumbnail(string filename, float position)

Does anyone know how to do this in .Net 3.0?

The correct solution will be the "best" implementation of this function.
Bonus points for avoiding selection of blank frames.

Best Solution

I ended up rolling my own stand alone class (with the single method I described), the source can be viewed here. Media browser is GPL but I am happy for the code I wrote for that file to be Public Domain. Keep in mind it uses interop from the directshow.net project so you will have to clear that portion of the code with them.

This class will not work for DVR-MS files, you need to inject a direct show filter for those.