Click here to Skip to main content
6,631,404 members and growing! (15,511 online)
Email Password   helpLost your password?
Web Development » ASP.NET » Howto License: The Code Project Open License (CPOL)

Media Handler

By Claudio Pizzillo

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.
.NET (.NET 2.0), ASP.NET
Posted:28 Jan 2008
Updated:29 Jan 2008
Views:8,961
Bookmarked:17 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
3 votes for this article.
Popularity: 0.80 Rating: 1.67 out of 5
1 vote, 33.3%
1
2 votes, 66.7%
2

3

4

5

Introduction

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:

   <appSettings>
    <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>
  </appSettings> 

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.

Set_buffering(Encoded_Video_Name)

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_duration(Encoded_Video_Name)

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"

License

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

About the Author

Claudio Pizzillo


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

Other popular ASP.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmemberMember 146749322:27 10 Jul '09  
GeneralUnable to play video on server PinmemberSujit Gupta1:30 2 Aug '08  
GeneralTo get better quality film Pinmemberdavidberlin8:35 13 Apr '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 29 Jan 2008
Editor:
Copyright 2008 by Claudio Pizzillo
Everything else Copyright © CodeProject, 1999-2009
Web22 | Advertise on the Code Project