Editing files with Encoder

In Encoder V2 we added the ability to edit multiple sections out of a video/audio file and this can also be accomplished with the Expression Encoder SDK. MediaItem has a property called SourceClips which contains the list of clips for that media item. When you create a MediaItem it starts with one clip that encompasses the entire duration of the source. Each clip is represented by the SourceClip class and that contains two properties StartTime and EndTime. These properties indicate the times within the source file that the clip represents. For example, if I wanted to change it so that I only encoded the first 15 seconds of the file I could do something like the following.

 MediaItem item = new MediaItem(@"C:\myvideo.wmv");
item.SourceClips[0].EndTime = new TimeSpan(0, 0, 15);

If I wanted to include the time from 0-15 seconds and from 30-45 seconds of the file I could add the following lines.

 TimeSpan timeStart = new TimeSpan(0, 0, 30);
TimeSpan timeEnd = new TimeSpan(0, 0, 45);
item.SourceClips.Add(new SourceClip(timeStart, timeEnd));

You can keep added SourceClip’s for as many sections of the source that you wish to add before calling the Encode method.