Click here to Skip to main content
13,451,389 members (49,542 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


23 bookmarked
Posted 28 Jan 2008

Media Handler

, 29 Jan 2008
Rate this:
Please Sign up or sign in to vote.
You can use Media Handler in your VB.NET applications to encode videos to FLV and perform other processings including posting wartermark on videos, grab single thumbnails from video.


A free Media Handler class for ASP.NET applications to encode videos to FLV format and perform other processings including posting wartermark on videos, encode / convert videos to flv format, grab single thumbnails from video.

Thanks to "nothingelz" for the example.

Using the code

First download the latest "SHARED" ffmpeg build from here or from here. You need the shared version for watermark function.

Unzip it under your "test" directory: ex c:\inetpub\wwwroot\test\ffmepg

Download the FLVTOOLS form here and unzip in the same way: ex c:\inetpub\wwwroot\test\flvtool.

Now convert your "test" dir in application.

Set the "test" web.config like this:

  <add key="PathTHUMBS" value="C:\InetPub\wwwroot\test\Images\Thumbs\"></add>
  <add key="PathFILE" value="C:\InetPub\wwwroot\test\Images\Default\"></add>
  <add key="PathFLV" value="C:\InetPub\wwwroot\test\Images\FLV\"></add>
  <add key="PathFFMPEG" value="C:\InetPub\wwwroot\test\ffmpeg\ffmpeg.exe"></add>
  <add key="PathFFMPEGdir" value="C:\InetPub\wwwroot\test\ffmpeg\"></add>
  <add key="PathFLVTOOL" value="C:\InetPub\wwwroot\test\flvtool\flvtool2.exe"></add>

Note: create 1 sub dir under test called "Images" and under this 3 sub dirs called "Thumbs" (where the class save the generated thumbails), "Default" (where are saved the uploaded files), "FLV" (where are located the generated flv files).

The usage is very simple:

FLV.Encode(filename, width, height, audio bitrate, audio samling rate)

Encode a file to flv, with specified width and height and audio. The file path is defined by the key "PathFILE". The encoded flv file path is defined by th key PathFLV.


Call Set_Buffering function to set meta-information to flv video.

Set_watermark(Encoded_Video_Name, imagename)

Is used to post watermark image on video. The imagename must resides in the ffmpeg path.


Get the duration of the flv files.

Grab_image(Encoded_Video_Name, framenumber, imageformat, width, height)

Is used to capture frame in image format from flv video from a given frame number. Recommended image format for grabbing thumbnails are jpg and png. The thumbs are saved in the path "PathTHUMBS"


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Claudio Pizzillo
Software Developer (Senior) KefaOnLine di Techworld S.r.l.
Italy Italy
VB.NET, C# Developer.
Skills: VB.Net, ASP.Net, SQL 2000/2005.

You may also be interested in...

Comments and Discussions

Questionwatermarking in Pin
Member 1000379529-Jan-14 4:09
memberMember 1000379529-Jan-14 4:09 
QuestionResolved Error Pin
sridharnetha17-Mar-13 23:56
membersridharnetha17-Mar-13 23:56 
QuestionSample Coding Pin
sathya.spidy3-May-11 1:36
membersathya.spidy3-May-11 1:36 
GeneralMy vote of 1 Pin
Member 146749310-Jul-09 21:27
memberMember 146749310-Jul-09 21:27 
GeneralUnable to play video on server Pin
Sujit Gupta2-Aug-08 0:30
memberSujit Gupta2-Aug-08 0:30 
GeneralTo get better quality film Pin
davidberlin13-Apr-08 7:35
memberdavidberlin13-Apr-08 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.180318.3 | Last Updated 29 Jan 2008
Article Copyright 2008 by Claudio Pizzillo
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid