Clock Times

[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

DirectShow defines two related clock times: reference time and stream time.

  • Reference time is the absolute time returned by the reference clock. (See Reference Clocks.)
  • Stream time is defined relative to when the graph last started running.
    • While the graph is running, stream time equals reference time minus start time.
    • While the graph is paused, stream time remains at the stream time when it was paused.
    • After a seek operation, stream time resets to zero.
    • While the graph is stopped, stream time is undefined.

When a media sample has a time stamp t, it means the sample should be rendered at stream time t. For this reason, stream time is also called presentation time.

When an application calls IMediaControl::Run to run the filter graph, the Filter Graph Manager calls IMediaFilter::Run on each filter. To compensate for the slight amount of time it takes for the filters to start running, the Filter Graph Manager specifies a start time slightly in the future.

Time and Clocks in DirectShow

Time Stamps