Wednesday, October 31, 2007

Generating Video Thumbnail Using VB.NET

I have finally get a snapshot/thumbnail of a given video using FFMPEG.

If you wish to do accomplish the same thing follow instruction below:


Download the zip file containg ffmpeg and corresponding files.

Copy the dll and the exe to your bin folder.

Give your .NET user (probably Network Service) full permission to ffmpeg.exe. This step may not be neccesary or may vary depending on your Windows security settings.

Paste this code in your codebehind

' Generate thumbnail
Dim p As Process
Dim pInfo As New ProcessStartInfo()
pInfo.FileName = "\bin\ffmpeg.exe"
pInfo.WindowStyle = ProcessWindowStyle.Hidden
pInfo.Arguments = String.Format("-y -i ""{0}"" -f mjpeg -ss 5 -vframes 1 ""{1}""", , )

p = Process.Start(pInfo)
While (Not p.HasExited)
System.Threading.Thread.Sleep(10)
End While

Hope this helps.