[MPlayer-G2-dev] mpeg container's timing (PTS values)

Billy Biggs vektor at dumbterm.net
Thu May 8 01:20:43 CEST 2003


Arpi (arpi at thot.banki.hu):

> The video part is relative easy, but a bit tricky: when a PS packet
> has a PTS timestamp, that timestamp belongs to the next complete
> frame.  (not to the one which ends in that packet!)

  Doesn't it belong to the video frame which starts in that packet?

> The audio is however very tricky.

  I remember it being a total bitch.

> It is very inaccurate for mpeg. Now i've found why: in mpeg
> containers, the audio timestamps behave like the video: they belong to
> the _next_ complete frame/block.

  I don't think this is exactly correct.

> After experimencng with several streams, i've found that ct: value is
> the time length of an audio frame. Strange, isn't it?

  I think there is a more logical explination.

> Do anyone have accurate info about the meaning/calculation of audio
> PTS for mpeg container?

  It's been a while, but here is a comment I wrote in movietime:

    /**
     * Interesting tidbit.  The PTS value in an A/52 audio frame
     * is for the audio frame which starts after the pointer
     * value (bytes p[2] and p[3] of the 4-byte header, byte
     * p[1] is the number of frames in the pack).  So, I need to
     * pass this into the A/52 parse code so it can tag the new
     * PTS at the correct position.
     */

  Basically, each pack can contain multiple audio frames, and the header
tells you which one the PTS belongs to.  It's not necessarily the first
one.

  I can go through my code some more, but when I wrote all this code in
movietime walken and I had a ton of conversations on IRC, and I was just
shocked at how hard it was to get all the sync to line up perfectly such
that I wasn't like dropping audio or resyncing my video all the time.

  Once I had it done though, everything lined up _perfect_.

  I'm anxious to get into the G2 code, and when I'll do I'll probably go
through it alongside my movietime code and post any discrepancies I
find.

  If it would help, I can go through my code some more and refresh my
memory.

  -Billy



More information about the MPlayer-G2-dev mailing list