Grab thumb image via ASP NET

44 views
Skip to first unread message

tony nabarro

unread,
Jun 21, 2011, 11:34:43 PM6/21/11
to mediasoftpro
Hello MediaSoft team,

Re: Grab thumb image via ASP NET

I have always valued Media Handler Pro in the past and I decide to try
the method to grab the thumb image from well-known files (avi, mpeg,
wmv, flv and so forth).

I am using your sample code as below and I am not sure where the file
containing thumb image will be stored in. Should it be in RootPath &
"\contents\output"?

Please kindly confirm me that as I am unable to find it.

Regards
Tony



' required properties.

Dim _mhandler As New MediaHandler()

Dim RootPath As String =
Server.MapPath(Request.ApplicationPath)

_mhandler.FFMPEGPath =
HttpContext.Current.Server.MapPath("~\ffmpeg\ffmpeg.exe")
_mhandler.InputPath = RootPath & "\contents\source"
_mhandler.OutputPath = RootPath & "\contents\output"

' grab single thumbnail.

_mhandler.FileName = "Sample.avi"
_mhandler.Frame_Time = "10"
'OR
_mhandler.Thumb_Start_Position = 10

_mhandler.Image_Format = "jpg"
_mhandler.VCodec = "image2"
' optional
_mhandler.ImageName = "testimage.jpg"
_mhandler.Width = 160
_mhandler.Height = 120
Dim infoxx As VideoInfo = _mhandler.Grab_Thumb()
If infoxx.ErrorCode > 0 Then
Response.Write("<b style=""background-
color:yellow"">*** Error occured while grabbing thumbs from video ***</
b>")
Else
Response.Write("<b style=""background-
color:green"">*** image successful? ***</b>")
End If

shane

unread,
Jun 22, 2011, 6:50:49 AM6/22/11
to mediasoftpro
Hi,

In order to grab thumbnails properly, all u need the following steps.

i: Download / use latest stable ffmpeg build.

ii: Set the following parameters

_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\ffmpeg
\ffmpeg.exe")
_mhandler.InputPath = RootPath & "\contents\source" // input folder
must exist and source video must be there.
_mhandler.OutputPath = RootPath & "\contents\output" // output folder
must exist

_mhandler.FileName = "sample.mp4"; // sample.mp4 or any other file
must exist in source folder before starting
_mhandler.ImageName = "sample.jpg"; // output image name in case of
grabbing single image
_mhandler.Frame_Time = "10";
//OR
//_mhandler.Thumb_Start_Position = 10; // position in seconds from
where you want to grab thumbs. it must be lesser than final length of
video.
_mhandler.Image_Format = "jpg";
_mhandler.VCodec = "image2";
_mhandler.Width = 160;
_mhandler.Height = 120;
VideoInfo info = _mhandler.Grab_Thumb();
if (info.ErrorCode > 0)
{
Response.Write("Error occured while grabbing thumbs from
video");
Reply all
Reply to author
Forward
0 new messages