Grab Thumbnails

Grab Thumbnails

This page will provide detailed example codes that will help you grabs or capture single or multiple thumbs from any format video using media handler pro component in your asp.net, c#, and vb.net application.

You can use media handler pro to capture single or multiple thumbs from any format video from any specified position and in any image format. Recommend output is .jpg, .png

C# Sample Code

Sample code for capturing single or multiple thumbs from video using media handler pro component in your asp.net, c#, vb.net application.


//***************************************************
// Multiple Thumbs: Thumb Mod: Normal // Recommended for multiple thumbs as it supports long length videos too
//***************************************************
// set thumb start index, e.g sample_ generate sample_001.jpg, sample_002.jpg etc
string thumb_start_index = "sample_";
// set source video filename
_mhandlerFileName = "sample.mp4";
// set output image format
_mhandler.Image_Format = "jpg";
// set image codec (optional)
_mhandler.VCodec = "image2";
// set image name, in multiple mode image index required
_mhandler.ImageName = thumb_start_index;
// set to enable multiple thumb mode
_mhandler.Multiple_Thumbs = true;
_mhandler.ThumbMode = 0;
// set total no of thumb to be generating from video.
_mhandler.No_Of_Thumbs = 15;
// set start positing / length of video from where thumb grabbing start
_mhandler.Thumb_Start_Position = 10;
// set width and height of thumb, not it must be multiple of two.
_mhandler.Width = 160;
_mhandler.Height = 120;
// start grabbing thumbs
VideoInfo info = _mhandler.Grab_Thumb();
//******************************************************
// Single Thumb
//******************************************************
_mhandler.FileName = "sample.mp4";
// set output image name
_mhandler.ImageName = "sample.jpg";
// set length in seconds from where you want to grab thumb
_mhandler.Frame_Time = "10";
//OR
//_mhandlerThumb_Start_Position = 10;
_mhandler.Image_Format = "jpg";
_mhandlerVCodec = "image2";
_mhandler.Width = 160;
_mhandler.Height = 120;
// start grabbing single thumb from video
VideoInfo info = _mhandler.Grab_Thumb();