Sample code to transcode a .wmv into a Smooth Streaming set of files using the smooth streaming default profile settings – Expression Encoder v4

The following sample code demonstrates transcoding a .wmv file to a default set of Smooth streaming files.  Thanks again to my colleague Random on Windows Media  for colloboration on this sample.

 Note the following references are also needed:

This programming sample is provided as - is  for illustration only, without warranty either expressed or implied. The sample assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures.

Simply Copy and Paste the following code into your Microsoft Visual Studio 2008/2010 C# project, build the project, add the necessary Expression Encoder references and make avaliable the pinball.wmv or appropriate video file to transcode.

  • Microsoft.Expression.Encoder
  • Microsoft.Expression.Encoder.Types
  • Microsoft.Expression.Encoder.Utilities

Also note that the sample below is for a console application and may vary from a WPF based application.



using System;
using Microsoft.Expression.Encoder;
using Microsoft.Expression.Encoder.Profiles; 

namespace EE4smooth
    class Program
        static void Main(string[] args)
            using (Job job = new Job())
                string MediaFile = "d:\\Sample Media\\pinball.wmv";
                MediaItem mItem;
                    mItem = new MediaItem(MediaFile);

                catch (InvalidMediaFileException)

                    Console.WriteLine("Error: Invalid Media File or Path");

                 mItem.OutputFormat.VideoProfile = SetVideoProfile();             

                // Output mode must be set for Smooth Streaming.  Otherwise it

                // will default to a WMV file

                OutputMode outputmode = new OutputMode();

                outputmode = OutputMode.SmoothStreamingMultipleFile;                          

                Console.Out.WriteLine("Output mode is: " + outputmode.ToString());               


                // Sets one of the template profiles to make things easier


                job.OutputDirectory = @"c:\output";




         static AdvancedVC1VideoProfile SetVideoProfile()


            // Sets the video profile properties

            AdvancedVC1VideoProfile profile = new AdvancedVC1VideoProfile();

            // The SmoothStreaming property must be set to true on the video profile

            // if you are using Smooth Streaming.  This is not necessary for the audio profile.

            profile.SmoothStreaming = true;

            profile.AdaptiveGop = false;

            return profile;




Comments (0)

Skip to main content