Welcome to MSDN Blogs Sign in | Join | Help

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.

Published Monday, March 16, 2009 12:03 AM by deanro
Filed under:

Comments

# Click & Solve » Editing files with Encoder

Sunday, April 12, 2009 11:50 PM by Afiqah Azlee

# Help.

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:\Users\maS\Music\Miley 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.

Sunday, April 19, 2009 3:02 PM by Dean Rowe

# re: Editing files with Encoder

Do you get that with every file? Are you running Windows XP or Vista?

Tuesday, May 05, 2009 2:31 AM by CapCrunch

# re: Editing files with Encoder

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!

Tuesday, May 05, 2009 4:16 AM by Dean Rowe

# re: Editing files with Encoder

Thanks for the feedback, always nice to hear from someone using the SDK.

Tuesday, May 05, 2009 3:32 PM by CapCrunch

# re: Editing files with Encoder

Hi Dean,

Can the console encoding sample be incorporated into a simple Windows Form application, without having to setup for threading, etc.?

My attempt to add the console encoding logic to a Windows Form makes the system hang after the job.encode(); line and the progress event never gets called (or maybe once), but the encoding process seems to be going on in the background. What gives?

Is there a simple way to make this work without threading?

Thanks,

CC

Tuesday, May 05, 2009 3:32 PM by CapCrunch

# re: Editing files with Encoder

Hi Dean,

Can the console encoding sample be incorporated into a simple Windows Form application, without having to setup for threading, etc.?

My attempt to add the console encoding logic to a Windows Form makes the system hang after the job.encode(); line and the progress event never gets called (or maybe once), but the encoding process seems to be going on in the background. What gives?

Is there a simple way to make this work without threading?

Thanks,

CC

Monday, May 11, 2009 1:17 PM by Dean Rowe

# re: Editing files with Encoder

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.

New Comments to this post are disabled
 
Page view tracker