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.

Comments

  • Anonymous
    March 15, 2009
    PingBack from http://www.clickandsolve.com/?p=23531

  • Anonymous
    April 12, 2009
    Hello there, I have problems regarding putting an audio/video in Windows Movie Maker. Everytime I try put an audio/video in it, this message will come out; "C:UsersmaSMusicMiley Cyrus - Fly  On The Wall.mp3 could not be imported. The specified module could not be found." What does it mean? Please help :) Thank you.

  • Anonymous
    April 19, 2009
    Do you get that with every file? Are you running Windows XP or Vista?

  • Anonymous
    May 04, 2009
    hi, just wanted to say you guys have done a great job with the sdk. i wish there was more c# samples included. thanks and keep up the good work!

  • Anonymous
    May 04, 2009
    Thanks for the feedback, always nice to hear from someone using the SDK.

  • Anonymous
    May 05, 2009
    The comment has been removed

  • Anonymous
    May 05, 2009
    The comment has been removed

  • Anonymous
    May 11, 2009
    If you look at the WPFEncode example in the samples you'll see an example of how to update the UI during an encode. You do have to create another thread, but it's fairly straightforward.