VB.NET Tips / Tricks / Examples and Help

VB.NET - Creating Thumbnail Images from Video Files

There can be any number of reasons why one might want to take a video file and create thumbnail images from the video. I had a need to do this, and after developing a solution, I thought I would share it here for others looking to do the same.

When I first started looking into this, I was not able to find any clear way to do this directly. I looked into using the Windows Media Player component to open the file and take screen shots, but that lead to a dead end.

Eventually, what I stumbled upon was the MediaElement component of WPF. This doesn't mean your application has to be a WPF one. I was able to wrap everything up into a class library that could be referenced from WinForms, WPF, or ASP.NET. All that is required is that the .NET framework that includes support for WPF is installed (3.0 or higher).

I ended up creating a Windows Forms test harness application, that illustrates all the various settings I built into the class library, so you can specify how many thumbnails you want, start and end offsets (for example, if a video starts with a few seconds of black, you can use this to make sure you don't get a solid black image as your first thumbnail). You can specify a size, or just use the original source video size for the output thumbnails.

I also added the ability to create the thumbnails to disk, or to create them directly into memory, for use in an application without needing to write files to disk.

Here is what the test harness app looks like with all the available options:

 Video Thumbnailer Harness

And here is what the output looks like when I create 20 thumbnails from an episode of Futurama.

 Video Thumbnailer Output

 The source code for this project can be found here. Enjoy and drop me a line if you found it helpful.

Posted Mar 04 2014, 01:49 AM by Matthew Kleinwaks
Filed under: , ,

© 2014 - ZerosAndTheOne.com - Hosting by Orcsweb (http://www.orcsweb.com/)
Powered by Community Server (Non-Commercial Edition), by Telligent Systems