Windows Media Video (WMV) is the most recognized codec within the WMV family. While all versions of WMV support variable bit rate, average bit rate and constand bit rate.
Media Handler Pro can be used to create WMV and WMA video and audio files. View c# examples below for encoding wmv and wma files using Media Handler Pro version 3.0 or later.
// 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 3.0
string output = _mhandler.Encode_WMV();
// Encode WMV Video using Media Handler Pro version 4.0 or later
VideoInfo info = _mhandler.Encode_WMV();
// Check for errors
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}
// Retrieve output information from VideoInfo Object. View Detail
// 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 3.0
string output = _mhandler.Encode_WMA();
// Encode WMA Audio using Media Handler Pro version 4.0 or later
VideoInfo info = _mhandler.Encode_WMA();
// Check for errors
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}
// Retrieve output information from VideoInfo Object. View Detail