Share via


IWMEncSource.SetInput

Windows Media Encoder SDK banner art

The SetInput method specifies the stream capture source.

Syntax

void IWMEncSource.SetInput(
  string  bstrInput,
  string  bstrScheme,
  string  bstrStreamName
);

Parameters

bstrInput

[in]  String containing the full name of a plug-in or file from which the source stream is captured. Specify a plug-in name in the "scheme://resource name" format. Specify the full path name of a file. If you put only the resource name in pstrInput, the encoding process uses strScheme to find the scheme type.

bstrScheme

[in]  String containing the scheme type. If you supply a value for this parameter, the encoding process uses strInput to form a "scheme://resource name" plug-in identifier without parsing the stream. This is useful if the resource part of the string contains special characters or symbols that cannot be interpreted as part of a standard URL.

bstrStreamName

[in]  String containing the name of a stream. Use this parameter to identify specific information for a plug-in object. Currently, this parameter is not used.

Return Values

If this method fails, it returns an error number.

Number Description
0xC00D0011 This method cannot be called if the encoder engine is running.

Remarks

Images with odd-sized dimensions are not supported. For example, an image that is 300 by 321 pixels generates an error, but an image that is 300 by 320 pixels does not.

When using HTML as a source, only the scheme is used; for example, use "FileTransfer://placeholdertext" as strInput.

Example Code

using WMEncoderLib;

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

// Declare objects and variables.
IWMEncSourceGroupCollection SrcGrpColl;
IWMEncSourceGroup SrcGrp;
IWMEncSource SrcAud;
IWMEncVideoSource SrcVid;
IWMEncProfileCollection ProColl;
IWMEncProfile Pro;
int i;

// Create an IWMEncSourceGroupCollection object.
SrcGrpColl = Encoder.SourceGroupCollection;

// Create an IWMEncSourceGroup object.
SrcGrp = SrcGrpColl.Add("SG_1");

// Create an audio and a video source object.
SrcAud = SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);
SrcVid = (IWMEncVideoSource)SrcGrp.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);

// Loop through the collection of system profiles to set
// a specific profile into the source group object.

ProColl = Encoder.ProfileCollection;
for (i = 0; i < ProColl.Count; i++)
{
    Pro = ProColl.Item(i);
    if (Pro.Name == "Windows Media Video 8 for Local Area Network (384 Kbps)")
    {
        SrcGrp.set_Profile(Pro);
        break;
    }
}

// Specify audio and video sources.

SrcVid.SetInput("C:\\InputFile.mpg", "", "");
SrcAud.SetInput("C:\\InputFile.mpg", "", "");

// Verify that the repeat property is turned off. This is
// the default.

SrcVid.Repeat = false;
SrcAud.Repeat = false;

// Start the encoding process 10 seconds after the source
// has started, and stop the encoding process 25 seconds
// after the source has started.

SrcVid.MarkIn = 10000;
SrcAud.MarkIn = 10000;
SrcVid.MarkOut = 25000;
SrcAud.MarkOut = 25000;

// Start the encoding process.
SrcGrp.PrepareToEncode(true);
}

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

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also