Share via


IWMEncVideoSource2.Duration

Windows Media Encoder SDK banner art

The Duration property retrieves the duration of the video input file.

Syntax

int = IWMEncVideoSource2.Duration;

Parameters

This property takes no parameters.

Property Value

An Int32 type that indicates the duration of the video source, in milliseconds.

Remarks

This property is read-only. Retrieve the value of the Duration property after you have initialized the encoding process using the WMEncoder.PrepareToEncode method.

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("C:\\Sourcefile.avi", "", ""); // REPLACE WITH A VALID FILE NAME
  SrcVid.SetInput("C:\\Sourcefile.avi", "", ""); // REPLACE WITH A VALID FILE NAME

// Configure the output and profile for the encoding session.

// Initialize the encoding process.
  Encoder.PrepareToEncode(true);

// Retrieve the duration of the source file, in seconds.
  int lVidDuration;
  lVidDuration = SrcVid.Duration / 1000;
}

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

Requirements

Reference: Windows Media Encoder

Namespace: WMEncoderLib

Assembly: Interop.WMEncoderLib.dll

Library: WMEncoderLib.dll

See Also