m2psd: fast MPEG 2 Program Stream demultiplexer


7-Feb-2004: Release 0.11 adds the ability to demultiplex to PES streams.


m2psd will demultiplex an MPEG 2 Program Stream into Elementary Streams (ES) or Packetized Elementary Streams (PES), provided that the packs are exactly 2048 bytes long. It was written for use with MPEG 2 Program Streams recorded by a Hauppauge WinTV PVR 250 or 350, and trimmed with Womble (Windows) or GOPChop (Linux).

mp2psd was written because all of the free software MPEG 2 demultiplexers I could find were very slow, and did not output the offset between the first video and audio timestamps.


The input MPEG Program Stream file name must be supplied as an argument.

A base name for the output files may optionally be specified; if none is provided, the base name will be the input file name with all characters from the last dot to the end removed. The output filenames will be of the form basename-n.mpa and basename-n.mpv, for audio and video, respectively, where n is the stream number (0-31 for audio, 0-15 for video).

The "-t" option prints the difference between the first presentation time stamps of the video #0 and audio #0 streams (0xe0 and 0xc0) in milliseconds. This is useful as input to a multiplexer.

The "-a" option discards any partial MPEG audio frame at the start of audio streams, because some software gets upset at partial audio frames.

The "-p" option produces PES streams as output rather than elementary streams. This preserves the time stamps, but many programs cannot deal with PES streams. This option is mutually exclusive with the "-t" and "-a" options.


m2psd is made available under the terms of the Free Software Foundation's General Public License, Version 2.

Source code as well as an executable for Fedora Core 1 (x86) are available for download.

m2psd development uses the Subversion revision control system. Instructions for access to the Subversion repository for Altogether are found at http://svn.brouhaha.com/, and there is a web interface to browse the repository at http://svn.brouhaha.com/viewcvs/m2psd.

Related web pages

Last updated February 14, 2004

Copyright 2003, 2004 Eric Smith


hacker emblem
Best Viewed With Any Browser Valid HTML 4.01! Valid CSS!

check now

check now