FFMPEG Commands

Execute FFMPEG Commands using ASP.NET

Example: Translating and processing sample FFmpeg command using asp.net media handler pro component.

Sample ffmpeg command you want to execute

>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

Via ASP.NET Video Converter, you can execute same code via code shown below


_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 + " 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 + "
    Error Message: " + info.ErrorMessage); 
    return;
}

You must make sure your FFmpeg command is supported by your FFmpeg build you are using in your application.

 

You must provide a complete path for the input media file, source media file, and any presets used.