Quantcast
Channel: Dean Rowe's WebLog
Viewing all articles
Browse latest Browse all 35

Basic code to encode a file

$
0
0

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 encodeJob job = new Job();
    MediaItem mediaItem = new MediaItem(@"C:\input\MyVideo.avi");// Add the media item to the jobjob.MediaItems.Add(mediaItem);// Set the output directory where any encoded files will go.job.OutputDirectory = @"c:\output";// Set up the progress callback functionjob.PublishProgress += new EventHandler<PublishProgressEventArgs>(OnPublishProgress);// Encode the filejob.Encode();
}void OnPublishProgress(object sender, PublishProgressEventArgs e)
{Console.WriteLine(e.Progress);
}

Viewing all articles
Browse latest Browse all 35

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>