ASP.NET WMV Encoding

This page have detail examples and code which will help you publishing wmv videos and audio files using media handler pro component on the fly in your asp.net, c# and vb.net applications

For more detail please visit media handler pro discussion forum section

C# Sample Code

Sample code for encoding wmv video using asp.net media handler pro component.

// Sample code for encoding any format video to wmv format.
MediaHandler _mhandler = new MediaHandler();
required properties string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");
_mhandler.InputPath = RootPath + "\\contents\\video"; 
_mhandler.OutputPath= RootPath + "\\contents\\wmv"; 
_mhandler.FileName = "sample.mpg";
// optional output filename
_mhandler.OutputFileName = "sample.wmv";
// setting video related properties
_mhandler.Video_Bitrate = 786;
_mhandler.Audio_Bitrate = 64;
_mhandler.Audio_SamplingRate = 44100;
// generate highest quality mp4 video, note by making this option true, video bitrate will no longer work.
_mhandler.MaxQuality = true;
// optional video width and height settings
_mhandler.Width = 320;
_mhandler.Height = 240;
// optional video and audio codec settings, make sure it is compatible with wmv video otherwise result in failure of video encoding.
_mhandler.ACodec = "wmav1";
_mhandler.VCodec = "wmv1";
// posting watermark on wmv video, view detail in watermark section
_mhandler.WaterMarkPath = RootPath + "\\contents\\watermark";
_mhandler.WaterMarkImage = "watermark.gif";
// view more options in component documentation.
// Encode WMV Video using Media Handler Pro version 4.0 or later
VideoInfo info = _mhandler.Process();
// Check for errors
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}

WMA Audio Encoding

Below code can be used to publish wma audio encoding in your asp.net, c# and vb.net application

// Sample code for encoding any format video to wma format.
MediaHandler _mhandler = new MediaHandler();
// required properties
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");
_mhandler.InputPath = RootPath + "\\contents\\video";
_mhandler.OutputPath = RootPath + "\\contents\\wmv";
_mhandler.FileName = "sample.mpg";
// optional output filename
_mhandler.OutputFileName = "sample.wma";
// setting video related properties
_mhandler.Video_Bitrate = 786;
_mhandler.Audio_Bitrate = 64;
_mhandler.Audio_SamplingRate = 44100;
// optional video and audio codec settings, make sure it is compatible with mp4 video otherwise result in failure of video encoding.
_mhandler.ACodec = "wmav1";
// view more options in component documentation.
// Encode  WMA Audio using Media Handler Pro version 4.0 or later
VideoInfo info = _mhandler.Process();
// Check for errors
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}

Click here for detail about retrieving information from video