When Encoder 3 is installed we now install the API help file, intellisense files and the sample projects, so you’re ready to go with the SDK as soon as Encoder is installed. You will find a SDK link on the start menu that will take you to the folder from where you can find the samples (in C# and Visual Basic) and the help CHM file.
I know a bunch of you have been waiting for this for a while now and you’ll be glad to see that V3 has full support for the Live mode of the application through the object model.
// Create a new LiveJob to begin broadcasting this file.
using (LiveJob job = new LiveJob())
// Create a new file source from the file name we were passed in
LiveFileSource fileSource = job.AddFileSource(@"C:\myvideo.wmv");
// Set this source to Loop when finished
fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;
// Make this source the active one
From the LiveJob object you can get a list of video and audio capture devices installed on the system and add them as sources as well. See the Microsoft.Expression.Encoder.Live namespace for further details and the new Live SDK sample that is installed.
In V3 we now have separate profile classes for each profile type. This way if you’re dealing with the Main H.264 video profile for instance you’ll just see the properties that pertain to that profile on the object. (Note that you need the full version of Encoder for H.264 support). Along with this you now specify the profiles within the OutputFormat property on the MediaItem.
Bitrate is specified by using one of the new bitrate classes, ConstantBitrate, VariableConstrainedBitrate, VariableUnconstrainedBitrate and VariableQualityBitrate. Again this is so that only the properties that make sense are exposed on the class. For example when using VariableConstrainedBitrate there is a PeakBitrate property but that property isn’t exposed on any of the other bitrate classes as it only applies to the variable constrained bitrate type.
MainVC1VideoProfile videoProfile = new MainVC1VideoProfile();
videoProfile.Bitrate = new ConstantBitrate(350);
videoProfile.Complexity = VideoComplexity.Fastest;
videoProfile.Size = new System.Drawing.Size(640, 480);
MediaItem item = new MediaItem(@"C:\myvideo.wmv");
item.OutputFormat = new WindowsMediaOutputFormat()
VideoProfile = videoProfile
The Encoder SDK supports encoding to the smooth streaming output format (when using the full version of Expression Encoder). The video profile class now has a streams property which is used to specify the details of each stream that you wish to encode. Smooth Streaming can be used when encoding to constant bitrate for VC-1 and H.264 and to variable constrained bitrate when using VC-1. Additionally when using VC-1 and variable constrained bitrate you can specify that the sizes of the streams should be automatically determined by the encoder based upon the content and the bitrate. In this case you specify the maximum width and height to use for each stream.
AdvancedVC1VideoProfile videoProfile = new AdvancedVC1VideoProfile();
// When you create a VideoProfile you'll get one stream by default.
// In this example remove that one as we’re going to explicity
// add the three streams below.
new VariableConstrainedBitrate(1450, 1600),
new System.Drawing.Size(800, 600));
new VariableConstrainedBitrate(1050, 1600),
new System.Drawing.Size(640, 480));
new VariableConstrainedBitrate(600, 1600),
new System.Drawing.Size(400, 300));
// Use smooth streaming with automatically sized streams.
videoProfile.SmoothStreaming = true;
videoProfile.Streams.AutoSize = true;
In V2 you could essentially combine up to three sources by using the leader, main video and trailer. In V3 you can move past this limit and combine multiple sources into one by using the new Source class.
MediaItem item = new MediaItem("mymovie1.wmv");
There are new classes to help analyze an existing media file to determine information about its video streams and audio streams (in case the file has more than one).
AudioVideoFile source = new AudioVideoFile("myvideo.wmv");
If the source file does have more than one audio stream you can now specify which stream is used when encoding by setting the AudioStreamIndex property on the Source object.
item.Sources.AudioStreamIndex = 2;
For all the standard presets that are installed with the application we have specified pre-defined static instances for each one to make it easier to use in case you don’t want to set all the properties of the profiles individually.
If you look at the Presets Members in the SDK help file you’ll see all the options along with descriptions.
So there you have a quick introduction to some of the new changes and improvements to the Expression Encoder object model in version 3. You can check out the What’s New section in the SDK help file for further details and feel free to give us your feedback and ask questions either by adding a comment here or over in the Expression Encoder Forum