IWMEncProfile.MinPacketSize

Windows Media Encoder SDK banner art

The MinPacketSize property specifies and retrieves the minimum size, in bytes, of the Windows Media data units generated during encoding.

Syntax

int = IWMEncProfile.MinPacketSize;
IWMEncProfile.MinPacketSize = int;

Parameters

This property takes no parameters.

Property Value

An Int32 containing the minimum packet size, in bytes.

If this property fails, it returns an error number.

Number Description
0xC00D0011 This property cannot be set while the encoder engine is running.
0xC00D1B75L The packet size must be either 0, or a number between 100 and 65,535.

Remarks

The MinPacketSize property controls the minimum size of the Advanced Systems Format (ASF) packets in the resulting Windows Media-based content. The value can be between 100 and 65,535 (in bytes), or 0. The actual packet size is calculated during the encoding process to optimize the content for streaming.

If the profile does not support uncompressed streams, the default value is 0. If the profile supports uncompressed streams, the default value is 65,535. The minimum packet size does not include the networking packet header or the Advanced Systems Format packet header.

Using a larger minimum packet size may reduce the file size of a Windows Media file by reducing the number of packets, and thus the overhead in the file. However, using a larger packet size may cause problems when streaming the content.

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

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

// Loop through the collection of system profiles to set
// a specific profile into the source group object.
string sProDesc;
int lMaxPacketSz;
int lMinPacketSz;
int iMediaCount;
bool bMultiBitRate;

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));
        sProDesc = Pro.Description;
        lMaxPacketSz = Pro.MaxPacketSize;
        lMinPacketSz = Pro.MinPacketSize;
        iMediaCount = Pro.get_MediaCount(WMENC_SOURCE_TYPE.WMENC_VIDEO);
        bMultiBitRate = Pro.MultipleBitrate;

        break;
    }
}
}

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

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also