Support coding on the fly.
Many of us have been waiting for this moment and now we are happy to see that version 3 has full support for the Live application mode via 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 in the system, and add them as sources. For more information, you can explore the Microsoft.Expression.Encoder.Live namespace and see the installed examples.
Advanced profile with full support for H.264 settings
In the 3rd version we divided profiles by types. Thus, if you are dealing with a main H.264 video profile, then you will see properties belonging only to this object. (Note that you must have the full version of the Encoder to support H.264) Along with this, you now define profiles within the OutputFormat property of the MediaItem object.
Bit rate is determined using the new class bit rate, ConstantBitrate, VariableConstrainedBitrate, VariableUnconstrainedBitrate and VariableQualityBitrate. Once again, only those properties that made sense to separate were moved out of 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 applies 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 full version). The video profile class now has a streaming property that is used to set the details of each stream you want to encode. Smooth streaming can be used to encode to a constant bit rate of VC-1 and H.264 or a limited variable bit rate using VC-1. Also, using VC-1 and a limited variable bit rate, you can establish that the size of the stream 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 stream.
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 .
Coding different sources together
In the 2nd version, we could combine 3 sources using the leader, the main video and the trailer. In the 3rd version, we can leave this restriction in the past and combine multiple 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
There are new classes for analyzing existing media files to determine information about video and audio streams (in case 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 Source class AudioStreamIndex property.
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 pre-declared static instances that simplify the work, if you do not want to set all the properties of the profiles individually.
mediaItem.ApplyPreset(Presets.VC1HighSpeedBroadbandVBR);
* This source code was highlighted with Source Code Highlighter .
And so, we saw a quick introduction to some of the new changes and improvements in the object model of the Expression Encoder 3. Additional questions can be asked on the forum
social.expression.microsoft.com/Forums/en-US/encoder/threads