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
    // 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

void OnPublishProgress(object sender, PublishProgressEventArgs e)
Comments (4)

  1. Nick says:

    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!

  2. Once you’ve created a MediaItem , you’re probably going to want to specify which video and/or audio profile

  3. Once you&#39;ve created a MediaItem , you&#39;re probably going to want to specify which video and/or