Basic code to encode a file
Here's a very small snippet of code that uses the Expression Encoder object model to create a job, add a media file to the job and then encode it. There's a lot more to the object model, but I thought this would give a little taste of the basics. In the object model we wanted to expose most features of the full Encoder application, but we also wanted to make sure the user could do the simple operations without having to write a lot of code.
public void EncodeAFile()
{
// Create a job and a media item for the video we wish to encode
Job job = new Job();
MediaItem mediaItem = new MediaItem(@"C:\input\MyVideo.avi");
// Add the media item to the job
job.MediaItems.Add(mediaItem);
// Set the output directory where any encoded files will go.
job.OutputDirectory = @"c:\output";
// Set up the progress callback function
job.PublishProgress += new EventHandler<PublishProgressEventArgs>(OnPublishProgress);
// Encode the file
job.Encode();
}
void OnPublishProgress(object sender, PublishProgressEventArgs e)
{
Console.WriteLine(e.Progress);
}
Comments
Anonymous
March 06, 2008
PingBack from http://msdnrss.thecoderblogs.com/2008/03/07/basic-code-to-encode-a-file/Anonymous
March 12, 2008
Thanks Dean. I've used this to get something working and have used the VideoProfile.TryFindProfile to do some basic configuration. This is going to be very cool!Anonymous
March 12, 2008
Once you've created a MediaItem , you're probably going to want to specify which video and/or audio profileAnonymous
March 12, 2008
Once you've created a MediaItem , you're probably going to want to specify which video and/or