MPEG-2 Demux Run-Time Modes

[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.]

The MPEG-2 Demultiplexer ("demux") can operate in push mode or pull mode. In push mode, the data comes from a live source, such as a network broadcast. In pull mode, the data comes from a local file.

  • Pull mode is available in Windows XP and later, for program streams only. On down-level platforms, use the MPEG-2 Splitter filter.
  • Push mode is available on all platforms, for both program streams and transport streams.

The demux therefore supports three possible modes: Program streams in pull mode, program streams in push mode, and transport streams in push mode. The demux determines which mode to use at run time. The mode is determined when the input pin connects, or when the first output pin is configured, whichever happens first:

  • When the input pin connects: On Windows XP and later, the demux queries the upstream filter for the IAsyncReader interface; if the upstream filter exposes that interface, the demux configures itself for program streams in pull mode. Otherwise, the demux uses push mode, and the media type determines the stream type (program stream or transport stream). See MPEG-2 Demultiplexer Media Types for a list of input types.
  • When the first output pin is configured: If you create an output pin and query it for IMPEG2PIDMap, the demux configures itself for transport streams in push mode. If you query the pin for IMPEG2StreamIdMap, the demux configures itself for program streams, also in push mode. Any subsequent queries for the other interface fail, because the demux cannot operate in two modes at once.

Once the demux has configured itself for a particular mode, it remains in that mode. To use a different mode, you must create a new instance of the demux.

Using the MPEG-2 Demultiplexer