Share via


IWMEncSourceGroup.RemoveSource

Windows Media Encoder SDK banner art

The RemoveSource method removes a media stream from the source group.

Syntax

void IWMEncSourceGroup.RemoveSource(
  WMENC_SOURCE_TYPE  enumType,
  object  var
);

Parameters

enumType

[in]  Member of a WMENC_SOURCE_TYPE enumeration type identifying the type of the media stream being added.

var

[in]  Object containing the index of the media source. Each type of media stream has a separate index. Currently, all index values must be zero (0).

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.
0xC00D1B5F The media content defined in the profile does not match the media content defined in the source group.

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;
int iAudCount;
int iVidCount;


// 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);

// Specify the .avi source file.
SrcAud.SetInput("C:\\filename.avi", "", "");
SrcVid.SetInput("C:\\filename.avi", "", "");

// You can also use the AutoSetFileSource property to
// automatically parse a file and add the source streams
// to the source group.

//    SrcGrp.AutoSetFileSource ("C:\\filename.avi");

// 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;
    }
}

// Change the name of the source group.
SrcGrp.Name = "Music Only";

// Retrieve the number of audio and video streams
// in the source group.
iAudCount = SrcGrp.get_SourceCount(WMENC_SOURCE_TYPE.WMENC_AUDIO);
iVidCount = SrcGrp.get_SourceCount(WMENC_SOURCE_TYPE.WMENC_VIDEO);

// Remove the video stream. In the current release of the
// Windows Media Encoder SDK, a source group can contain
// at most only one audio, one video, and one script stream.
// You must verify that the count is not 0 before deleting
// the source stream.
if (iVidCount <> 0)
{
    SrcGrp.RemoveSource(WMENC_SOURCE_TYPE.WMENC_VIDEO, 0);
}

// Specify automatic archiving when the source group
// is active.
SrcGrp.set_AutoArchive(WMENC_ARCHIVE_TYPE.WMENC_ARCHIVE_LOCAL, WMENC_ARCHIVE_OPERATION.WMENC_ARCHIVE_START);

// 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