<p>How do I programmatically find out the width and height of the video in an mpeg-2 <strike>transport</strike> program stream file?  </p>

<p>Edit: I am using C++, but am happy for examples in any language.
Edit: Corrected question - it was probably program streams I was asking about</p>

Check out the source code to
libmpeg2
, a F/OSS MPEG2 decoder.  It appears that the width and height are set in the
```
mpeg2_header_sequence()
```
function in
```
header.c
```
.  I'm not sure how control flows to that particular function, though.  I'd suggest opening up an MPEG2 file in something using libmpeg2 (such as
MPlayer
) and attaching a debugger to see more closely exactly what it's doing.