SplitStream 0.3 and other utils

charlie@a... charlie at a...
Mon, 22 Oct 2001 01:24:18 -0000


--- In ExtractStream@y..., joe666boxer@y... wrote:
> It's not easy, so I wanted something to help. I looked closely at 
> the PES headers in tyStream, and found what looks like a timestamp.
> The clock seems to tick 0x1950 for every 36 ms. 


There's info on this in the MPEG-2 Systems Specification. Both the 
audio and video PES headers contain the timestamp you're speaking 
of. This is the way the audio-video synchronization is maintained. 
You say it's incrementing 0x1950 every 36ms, but actually it's 
incrementing 0x0CA8 (half 0x1950) every 36ms. Bit zero is a dummy 
(marker bit) that is always 1. The least significant bit of the 
timecode starts at the next bit to the left (bit #1). You can thank 
the wonderful MPEG standard for this! Since the code (hex)00 00 01 
has special meaning, it can never be allowed to accidentally pop up 
in any value. Because of this, the stream is littered with 
annoying "marker bits". This means you end up having to do lots of 
bit shifting in order to figure out the actual value.

The whole timecode is 33 bits long (yes, wonderful isn't it) and it's 
stored in 5 bytes. It looks like this (starting with the MSB):

what's there: How many bits it is:
'0010' 4
PTS [32..30] 3
marker bit 1
PTS [29..15] 15
marker bit 1
PTS [14..0] 15
marker bit 1

"PTS" stands for Presentation Time Stamp it indicates the exact time 
that the audio or video should be presented to the viewer. The PTS 
increments at a rate of 90KHz (fast enough for ya?).