ASP.NET WebM Encoding

ASP.NET Media Handler Pro allow you to publish any format videos to webm video format on the fly in real time using asp.net, c# and vb.net applications.

Libvpx WebM Preset Files

Preset files (.ffpreset) can be used to set quality and compatibility of output video or audio to meet requirements of targetted devices. Normally preset files available within /preset/ folder.

List of available libvpx .webm preset files.

  • libvpx-360p.ffpreset for generating normal (480x360) size .webm video
  • libvpx-720p.ffpreset for generating 720p (1280x720) size HD .webm video
  • libvpx-720p50_60.ffpreset for generating 720p (1280x720) size HD .webm video
  • libvpx-1080p for generating HD 1080p .webm video
  • libvpx-1080p50_60 for generating HD 1080p .webm video

360p WebM Encoding

The following sample codes can be used to encode 360p (480x360) size .webm video using ASP.NET Media Handler Pro

Direct Encoding

// Sample code for encoding any format video to 360p .webm
// video format using asp.net.
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.OutputPath = RootPath + "\\contents\\webm";
_mhandler.FileName = "sample.mp4";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".webm";
_mhandler.Video_Bitrate = 800;
_mhandler.Audio_Bitrate = 64;
_mhandler.VCodec = "libvpx";
_mhandler.ACodec = "libvorbis";
_mhandler.Audio_SamplingRate = 44100;
_mhandler.Parameters = "-f webm -aspect 4:3 -fpre " + presetpath + "\libvpx-360p.ffpreset";
_mhandler.Width = 480;
_mhandler.Height = 360;
VideoInfo info = _mhandler.Process();

1 Pass Encoding

// Sample code for encoding any format video to 360p .webm
//video format using asp.net (1 pass encoding).
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.OutputPath = RootPath + "\\contents\\webm";
_mhandler.FileName = "sample.mp4";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".webm";
_mhandler.Video_Bitrate = 800;
_mhandler.Pass =1;
_mhandler.Parameters = "-f webm -an -fpre " + presetpath + "\libvpx-360p.ffpreset";
_mhandler.Width = 480;
_mhandler.Height = 360;
VideoInfo info = _mhandler.Process();

2 Pass Encoding

// Sample code for encoding any format video to 360p .webm
//video format using asp.net. (Pass 2)
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.OutputPath = RootPath + "\\contents\\webm";
_mhandler.FileName = "sample.mp4";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".webm";
_mhandler.Video_Bitrate = 800;
_mhandler.Audio_Bitrate = 64;
_mhandler.VCodec = "libvpx";
_mhandler.ACodec = "libvorbis";
_mhandler.Pass =2;
_mhandler.Audio_SamplingRate = 44100;
_mhandler.Parameters = "-f webm -aspect 4:3 -fpre " + presetpath + "\libvpx-360p.ffpreset";
_mhandler.Width = 480;
_mhandler.Height = 360;
VideoInfo info = _mhandler.Process();

720p HD WebM Encoding

The following sample codes can be used to generate 720p (1280x720) size .webm video using ASP.NET Media Handler Pro

// Sample code for encoding any format video to 720p .webm
// video format using asp.net.
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.OutputPath = RootPath + "\\contents\\webm";
_mhandler.FileName = "sample.mp4";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".webm";
_mhandler.Video_Bitrate = 3900;
_mhandler.Audio_Bitrate = 64;
_mhandler.VCodec = "libvpx";
_mhandler.ACodec = "libvorbis";
_mhandler.Audio_SamplingRate = 44100;
_mhandler.Parameters = "-f webm -aspect 4:3 -fpre " + presetpath + "\libvpx-720p.ffpreset";
_mhandler.Width = 1280;
_mhandler.Height = 720;
VideoInfo info = _mhandler.Process();

1080p HD WebM Encoding

The following sample codes can be used to generate 1080p (1920x1080) size .webm video using ASP.NET Media Handler Pro

// Sample code for encoding any format video to 1080p .webm
video format using asp.net.
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.InputPath = RootPath + "\\contents\\original";
_mhandler.OutputPath = RootPath + "\\contents\\webm";
_mhandler.FileName = "sample.mp4";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".webm";
_mhandler.Video_Bitrate = 3900;
_mhandler.Audio_Bitrate = 64;
_mhandler.VCodec = "libvpx";
_mhandler.ACodec = "libvorbis";
_mhandler.Audio_SamplingRate = 44100;
_mhandler.Parameters = "-s hd1080 -f webm -aspect 4:3 -fpre " + presetpath + "\libvpx-1080p.ffpreset";
VideoInfo info = _mhandler.Process();

Click here for detail about retrieving information from video