Live Chat with Operator

HTML5 WebM Encoding Using ASP.NET

WebM is a new container format and is designed with the VP8 video codec and vorbis audio codec and is announced at May, 2010. It is supported natively without platform-specific plugins, in the latest versions of Chromium, Google Chrome, Mozilla Firefox, and Opera. Adobe has also announced that a future version of Flash will support WebM video.

ASP.NET Media Handler Pro can be used to publish or encode any video format to .webm format on the fly in real time in order to play it on HTML5 compatible browsers and devices (ipad, iphone etc).

Libvpx WebM Preset Files

Preset files (.ffpreset) can be used for generating different level of videos in order to play on variety of devices, formats & with quality. 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 generate 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

 

Direct Encoding

// 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();

1 Pass Encoding

// Sample code for encoding any format video to 720p .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 = 3900;
_mhandler.Pass =1;
_mhandler.Parameters = "-f webm -an -fpre " + presetpath + "\libvpx-720p.ffpreset";
_mhandler.Width = 1280;
_mhandler.Height = 720;
VideoInfo info = _mhandler.Process();

2 Pass Encoding

// Sample code for encoding any format video to 720p .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 = 3900;
_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-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

 

Direct Encoding

// 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();

1 Pass Encoding

// Sample code for encoding any format video to 1080p .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 = 3900;
_mhandler.Pass =1;
_mhandler.Parameters = "-s hd1080 -f webm -an -fpre " + presetpath + "\libvpx-1080p.ffpreset";
VideoInfo info = _mhandler.Process();

2 Pass Encoding

// Sample code for encoding any format video to 1080p .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 = 3900;
_mhandler.Audio_Bitrate = 64;
_mhandler.VCodec = "libvpx";
_mhandler.ACodec = "libvorbis";
_mhandler.Pass =2;
_mhandler.Audio_SamplingRate = 44100;
_mhandler.Parameters = "-s hd1080 -f webm -aspect 4:3 -fpre " + presetpath + "\libvpx-1080p.ffpreset";
VideoInfo info = _mhandler.Process();

If you like this article, please recommend this to google.
© 2007 - 2012, mediasoftpro.com  | Site Map | Privacy Policy | Terms of Use