
Process Media (Videos, Audio, Photos) using ASP.NET
This post will help you process almost every type of custom FFmpeg commands using media handler pro in your asp.net, c#, and vb.net applications.
Sample Codes
Example: Translating and processing sample FFmpeg command using asp.net media handler pro component.
e.g sample FFmpeg command for encoding a video sequence for the iPod/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;
}
You can pass almost all FFmpeg commands via media handler pro parameters object e.g
_mhandler.Parameters = "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";
VideoInfo info = _mhandler.Process();
if (info.ErrorCode > 0)
{
Response.Write("Error occured: Error Code: " + info.ErrorCode + "<br />Error Message: " + info.ErrorMessage);
return;
}
You must make sure your FFmpeg command is supported by your FFmpeg build you are using in your application. Also must provide a complete path for an input media file, source media file, and any presets used.