
X264 Encoding
ASP.NET Video Converter support using preset files for encoding videos with x264 codec. You can use lots of predefined preset files for mp4 / x264 encoding to achieve the best results.
Preset File:
A preset file contains a sequence of option=value pairs, one for each line, specifying a sequence of options that would be awkward to specify on the command line.
Check the `presets' directory in the FFmpeg source tree or download preset files directly from here.
Preset files are categorized with
- Default quality preset files.
- Normal quality preset files.
- High-quality preset files.
- Maximum quality preset files.
- Also, make sure that you must use the latest FFmpeg build that supports ff preset or preset files.
Some of preset files supported byffmpeg build rev 22598 are as follows
- libx264-baseline.ffpreset
- libx264-default.ffpreset
- libx264-fast.ffpreset
- libx264-fast_firstpass.ffpreset
- libx264-faster.ffpreset
- libx264-faster_firstpass.ffpreset
- libx264-fastfirstpass.ffpreset
- libx264-hq.ffpreset
- libx264-ipod320.ffpreset
- libx264-ipod640.ffpreset
- libx264-lossless_fast.ffpreset
- libx264-lossless_max.ffpreset
- libx264-lossless_medium.ffpreset
- libx264-lossless_slow.ffpreset
- libx264-lossless_slower.ffpreset
- libx264-lossless_ultrafast.ffpreset
- libx264-main.ffpreset
- libx264-max.ffpreset
- libx264-medium.ffpreset
- libx264-medium_firstpass.ffpreset
- libx264-normal.ffpreset
- libx264-placebo.ffpreset
- libx264-placebo_firstpass.ffpreset
- libx264-slow.ffpreset
- libx264-slow_firstpass.ffpreset
- libx264-slower.ffpreset
- libx264-slower_firstpass.ffpreset
- libx264-slowfirstpass.ffpreset
- libx264-ultrafast.ffpreset
- libx264-ultrafast_firstpass.ffpreset
- libx264-veryfast.ffpreset
- libx264-veryfast_firstpass.ffpreset
- libx264-veryslow.ffpreset
- libx264-veryslow_firstpass.ffpreset
Sample Code for using ffpreset file while encoding mp4 video with x264 codec.
Sample c# code that uses Media Handler Pro component for encoding mp4 video with x264 codec using preset file mentioned above.
_mhandler.PresetPath = RootPath + "\\ffmpeg\\ffpresets\\libx264-veryfast_firstpass.ffpreset";
Complete Example:
var _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";
// set ffpreset file mentioned above using media handler pro property PresetPath.
_mhandler.PresetPath = RootPath + "\\ffmpeg\\ffpresets\\libx264-veryfast_firstpass.ffpreset";
// set mp4 related required properties.
_mhandler.FileName = "Sample.VOB";
_mhandler.OutputFileName = "Sample.mp4";
// Set width and height of final output.
_mhandler.Width = 320;
_mhandler.Height = 240;
// Call method to process parameters
VideoInfo info = _mhandler.Encode_MP4();
if (info.ErrorCode > 0)
{
Response.Write("Error occured: Error Code: " + info.ErrorCode + "<br />Error Message: " + info.ErrorMessage);
return;
}