Click or drag to resize

VideoThumbnailer Class

Generates meaningful thumbnails for a video.
Inheritance Hierarchy
SystemObject
  GleamTech.VideoUltimateVideoThumbnailer

Namespace:  GleamTech.VideoUltimate
Assembly:  GleamTech.VideoUltimate (in GleamTech.VideoUltimate.dll) Version: 1.8.0.0
Syntax
public class VideoThumbnailer : IDisposable

The VideoThumbnailer type exposes the following members.

Constructors
  NameDescription
Public methodVideoThumbnailer(Stream, VideoUltimateConfiguration)
Initializes a new instance of the VideoThumbnailer class from the specified video stream.
Public methodVideoThumbnailer(String, VideoUltimateConfiguration)
Initializes a new instance of the VideoThumbnailer class from the specified video file.
Top
Methods
  NameDescription
Public methodDispose
Releases all resources used by this instance.
Public methodGenerateThumbnail
Generates a meaningful thumbnail for the video by seeking to a sensible time position and avoiding blank frames. Every call returns a new Bitmap instance which should be disposed by the caller. Once the smart time position is determined after the first call, the consecutive calls will be faster and can be used to retrieve Bitmap instances in different sizes.
Top
Examples

Get the thumnail of a video file and save it as an image file:

using (var videoThumbnailer = new VideoThumbnailer(@"C:\Video.mp4"))
//Generate a meaningful thumbnail of the video and
//get a System.Drawing.Bitmap with 100x100 maximum size.
//You are responsible for disposing the bitmap when you are finished with it.
//So it's good practice to have a "using" statement for the retrieved bitmap.
using (var thumbnail = videoThumbnailer.GenerateThumbnail(100))
    //Reference System.Drawing and use System.Drawing.Imaging namespace for the following line.
    thumbnail.Save(@"C:\Thumbnail1.jpg", ImageFormat.Jpeg);

Get the thumnail of a video file from a stream:

using (Stream videoStream = OpenYourVideoStream())
using (var videoThumbnailer = new VideoThumbnailer(videoStream))
{
    //Process..
}

Get the thumnail of a video file from a URL:

using (var videoThumbnailer = new VideoThumbnailer("http://vjs.zencdn.net/v/oceans.mp4"))
{
    //Process..
}

Get the thumnail of a video file from a URL:

using (var videoThumbnailer = new VideoThumbnailer(@"C:\Video.mp4"))
{
    //Get the thumbnail with 100x100 maximum size and overlay video duration 
    //on the bottom-right of the thumbnail (like youtube does).
    using (var thumbnail = videoThumbnailer.GenerateThumbnail(100, true))
        thumbnail.Save(@"C:\Thumbnail100WithDuration.jpg", ImageFormat.Jpeg);

    //Get the same thumbnail this time with 300x300 maximum size.
    //Thumbnail frame is already generated on the first call above so you can
    //get different sizes of the thumbnail many times very fast
    using (var thumbnail = videoThumbnailer.GenerateThumbnail(300))
        thumbnail.Save(@"C:\Thumbnail300WithoutDuration.jpg", ImageFormat.Jpeg);
}
See Also