Split Video in small clips

ASP.NET Media Handler Pro version 4.0 or later have features to split video in multiple clips and encode these clips to other video formats in single step.

You can split video in small clips using two approaches.

  • Split video in no of clips, e.g split video in six parts with equal time.
  • Split video in no of clips and set time for each clip. e.g split video in six parts and each part should be 30 seconds long.

This function is only available in Media Handler Pro version 4.0 or later.

Sample code: C#

Sample code for splitting video in small clips using c#.

MediaHandler _mhandler = new MediaHandler();

string RootPath = Server.MapPath(Request.ApplicationPath);

// set required parameters

_mhandler.FFMPEGPath = HttpContext.Current.Server.MapPath("~\\ffmpeg\\ffmpeg.exe");
_mhandler.InputPath = RootPath + "\\contents\\videos";
_mhandler.OutputPath = RootPath + "\\contents\\splitvideos";

// video name to be split in small clips
_mhandler.FileName = "sample.mp4";

// start spliting video in six equal parts.

VideoInfo info = _mhandler.Split_Video(6, 30, true);
// true represent auto_time, which means clip duration automatically setup with duration of total video / no of clips.
if (info.ErrorCode > 0)
{
Response.Write("Video processing failed, Error code " + info.ErrorCode + " generated");
return;
}

// retrive video information from VideoInfo object info. more detail.

 

©2007 - 2008, MediaSoft Pro Inc  | Site Map