What's new in Expression Encoder 3 SDK?

Original author: deanro
  • Transfer

Support coding on the fly.


Many of us were waiting for this moment and now we are happy to see that the 3rd version has full support for the Live mode of the application through the object model.
// Создаем новый объект LiveJob для начала вещания файла
using (LiveJob job = new LiveJob())
{
  // Создаем новый источник по переданному адресу
  LiveFileSource fileSource = job.AddFileSource(@"C:\myvideo.wmv");

  // Устанавливаем источнику режим зацикливания, после окончания проигрывания
  fileSource.PlaybackMode = FileSourcePlaybackMode.Loop;

  // Делаем источник активным
  job.ActivateSource(fileSource);


* This source code was highlighted with Source Code Highlighter.


Through the LiveJob object, we can get the entire list of video or audio devices that are installed on the system and add them as sources. For a more detailed look, you can examine the Microsoft.Expression.Encoder.Live namespace and see the installed examples.

Advanced profile with full support for H.264 configuration


In version 3, we divided profiles by type. Thus, if you are dealing with the main H.264 video profile, then you will see properties that belong only to this object. (Note that you must have the full version of Encoder to support H.264) Along with this, you now define the profiles inside the OutputFormat property of the MediaItem object.

Bitrate is determined using the new bitrate classes, ConstantBitrate, VariableConstrainedBitrate, VariableUnconstrainedBitrate, and VariableQualityBitrate. Once again, only those properties that made sense to be separated were taken out of the class. For example, when we use the VariableConstrainedBitrate class, we have the PeakBitrate property, but this property has not been moved to other bitrate classes because it is applicable to a limited variable 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
};

* This source code was highlighted with Source Code Highlighter.

Smooth streaming


Encoder SDK supports encoding in smooth streaming format (again, only in the full version). The profile video class now has a streaming property that is used to set the details of each stream that you want to encode. Smooth streaming can be used to encode to the constant bitrate of VC-1 and H.264 or to a limited variable bitrate using VC-1. Also, using VC-1 and a limited variable bit rate, you can set that the stream size should be automatically determined by the encoder based on the content and bit rate. In this case, you set the maximum width and height for each thread.
AdvancedVC1VideoProfile videoProfile = new AdvancedVC1VideoProfile();

// Когда вы создаете VideoProfile, вы получите один поток по умолчанию
// В этом примере мы добавим три потока
videoProfile.Streams.RemoveAt(0);
videoProfile.Streams.Add(
  new VariableConstrainedBitrate(1450, 1600),
  new System.Drawing.Size(800, 600));
videoProfile.Streams.Add(
  new VariableConstrainedBitrate(1050, 1600),
  new System.Drawing.Size(640, 480));
videoProfile.Streams.Add(
  new VariableConstrainedBitrate(600, 1600),
  new System.Drawing.Size(400, 300));

// Используем smooth streaming с автоматическим размером потоков videoProfile.SmoothStreaming = true;
videoProfile.Streams.AutoSize = true;

* This source code was highlighted with Source Code Highlighter.

Encoding different sources together


In the 2nd version, we could combine 3 sources using the leader, the main video and trailer. In version 3, we can leave this limitation in the past and combine many sources into one using the new Source class.
MediaItem item = new MediaItem("mymovie1.wmv");
item.Sources.Add(new Source("mymovie2.wmv"));
item.Sources.Add(new Source("mymovie3.avi"));
item.Sources.Add(new Source("mymovie4.wmv"));

* This source code was highlighted with Source Code Highlighter.

File info


New classes have appeared for analyzing existing media files to determine information about video and audio streams (if there are more than one file)
AudioVideoFile source = new AudioVideoFile("myvideo.wmv");
Console.WriteLine(source.VideoStreams[0].VideoSize);
Console.WriteLine(source.VideoStreams[0].AspectRatio);
Console.WriteLine(source.VideoStreams[0].Duration);
Console.WriteLine(source.AudioStreams[0].Channels);
Console.WriteLine(source.AudioStreams[0].SampleSize);

* This source code was highlighted with Source Code Highlighter.

If the source file has more than one audio track, we can determine which track will be used for encoding using the AudioStreamIndex property of the Source class.
item.Sources[0].AudioStreamIndex = 2;

* This source code was highlighted with Source Code Highlighter.

Presets


For all standard presets that are installed with the application, we have defined previously declared static instances that simplify the work if you do not want to set all the profile properties individually.
mediaItem.ApplyPreset(Presets.VC1HighSpeedBroadbandVBR);

* This source code was highlighted with Source Code Highlighter.

And so, we saw a quick introduction to some new changes and improvements to the Expression Encoder 3 object model. Additional questions can be asked on the social.expression.microsoft.com/Forums/en-US/encoder/threads forum .

Also popular now: