Media Handler Pro 5.0 introduce generalized function that can be used to perform any level of media processing task. You can use this function to process any level of ffmpeg commands covering almost all needs: video conversion, sound extraction, encoding file for iPod or PSP, and more.
View below list of some practicle examples for using "Process()" function in your .net applications (c#, vb.net, asp.net) to achieve any level of video processing tasks.
Note: It requires Media Handler Pro 5.0 or later
MediaHandler _mhandler = new MediaHandler();
string RootPath = Server.MapPath(Request.ApplicationPath);
_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");
_mhandler.InputPath = RootPath + "\\contents\\source";
_mhandler.OutputPath = RootPath + "\\contents\\output";
//****************************
// Example 1: FLV Encoding
//****************************
//_mhandler.FileName = "sample.wmv";
//_mhandler.OutputFileName = "sample";
//_mhandler.OutputExtension = ".flv";
//_mhandler.Video_Bitrate = 500;
//_mhandler.Audio_Bitrate = 64;
//_mhandler.Audio_SamplingRate = 44100;
//_mhandler.Width = 320;
//_mhandler.Height = 240;
//VideoInfo info = _mhandler.Process();
//****************************
// Example 2: Extracting sound from a video, and save it as Mp3
//****************************
//_mhandler.FileName = "sample.mp4";
//_mhandler.OutputFileName = "sample";
//_mhandler.OutputExtension = ".mp3";
//_mhandler.DisableVideo = true;
//_mhandler.Audio_SamplingRate = 44100;
//_mhandler.Channel = 2;
//_mhandler.Audio_Bitrate = 192;
//_mhandler.Force = "mp3";
// VideoInfo info = _mhandler.Process();
//****************************
// Example 3: Convert .avi to dv
//****************************
// _mhandler.FileName = "sample.avi";
//_mhandler.OutputFileName = "sample";
//_mhandler.OutputExtension = ".dv";
//_mhandler.AspectRatio = "4:3";
//_mhandler.Parameters = "-s pal -r pal";
//_mhandler.Audio_SamplingRate = 48000;
//_mhandler.Channel = 2;
//VideoInfo info = _mhandler.Process();
//****************************
// Example 4: Convert .avi to wmv
//****************************
_mhandler.FileName = "sample.avi";
_mhandler.OutputFileName = "sample";
_mhandler.OutputExtension = ".wmv";
_mhandler.VCodec = "wmv2";
_mhandler.ACodec = "wmav2";
_mhandler.Audio_Bitrate = 128;
_mhandler.Video_Bitrate = 700;
//*******************************************************************
// Example 4: Translating sample ffmpeg command in Media Handler Pro component
//*******************************************************************
Encode a video sequence for the iPpod/iPhone
ffmpeg -i source_video.avi -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4
********************************************************************
_mhandler.FileName = "source_video.avi";
_mhandler.OutputFileName = "final_video";
_mhandler.OutputExtension=".mp4";
_mhandler.ACodec = "aac";
_mhandler.Audio_Bitrate = 128;
_mhandler.VCodec = "mpeg4";
_mhandler.Video_Bitrate = 1200;
_mhandler.Parameters = "-mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -title X";
_mhandler.Width = 320;
_mhandler.Height= 180;
********************************************************************
VideoInfo info = _mhandler.Process();
if (info.ErrorCode > 0)
{
Response.Write("Error occured: Error Code: " + info.ErrorCode + "<br />Error Message: " + info.ErrorMessage);
return;
}