IMediaSeeking::GetDuration method (strmif.h)

The GetDuration method gets the duration of the stream.


HRESULT GetDuration(
  LONGLONG *pDuration



Receives the duration, in units of the current time format.

Return value

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.


This method gets the duration of the stream at normal playback speed. Changing the playback rate does not affect the duration.

The duration is expressed in the current time format. The default time format is REFERENCE_TIME units (100 nanoseconds). To change time formats, use the IMediaSeeking::SetTimeFormat method.

Depending on the source format, the duration might not be exact. For example, if the source contains a variable bit-rate (VBR) stream, the method might return an estimated duration.


Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header strmif.h (include Dshow.h)
Library Strmiids.lib

See also

Error and Success Codes

IMediaSeeking Interface