IWMEncVideoSource2.Width

Windows Media Encoder SDK banner art

The Width property specifies and retrieves the width of a live video image.

Syntax

int = IWMEncVideoSource2.Width;
IWMEncVideoSource2.Width = int;

Parameters

This property takes no parameters.

Property Value

An Int32 type that indicates the width, in pixels.

If this property fails, it returns an error number.

Return code Number Description
NS_E_INVALID_REQUEST 0xC00D002BL The request is invalid for sources other than devices or screen captures.

Remarks

Using the Height and Width properties, the encoding session determines the ratio of the source size to the output size specified in the profile. The live source can then be captured at the same size as the output, rather than resizing the image after it has already been captured. The capture size compensates for any margins you specify to clip.

Example Code

using WMEncoderLib;

try
{
// Create a WMEncoder object.
  WMEncoder Encoder;
  Encoder = new WMEncoder();

// Create a source group and add the sources.
  IWMEncSourceGroupCollection SrcGrpColl;
  IWMEncSourceGroup SrcGrp;
  IWMEncSource SrcAud;
  IWMEncVideoSource2 SrcVid;
  SrcGrpColl = Encoder.SourceGroupCollection;
  SrcGrp = SrcGrpColl.Add("SG_1");
  SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
  SrcVid = (IWMEncVideoSource2)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);
  SrcAud.SetInput("Default_Audio_Device", "Device", "");
  SrcVid.SetInput("Default_Video_Device", "Device", "");

// Retrieve the height and width of the live video image.
  int lHeight;
  int lWidth;
  lHeight = SrcVid.Height;
  lWidth = SrcVid.Width;
}

catch (Exception e)
{
     // TODO: Handle exceptions.
}

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also