container/mts: Function to extract PTS times from MTS

Issue #86 resolved
Alan Noble created an issue

In addition to the timestamp, it is desirable to extract MTS presentation time stamps (PTS) for the start and finish of each clip. The following is proposed:

getPtsRange(clip []byte) (pts [2]int, error err)

It is suggested that return values are raw 90kHz numbers to avoid rounding errors, i.e., units of 1/90000.

NB: While pts[0] should correspond to the first PTS in the clip, pts[1] should be (lastPTS + 1) (which should correspond to the PTS that immediately follows). pts[1] - pts[0] is therefore the duration of the clip in units of 1/90000.

Comments (5)

  1. Alan Noble reporter

    Further more, the mts package should export the PTS resolution (1/90000) so callers can convert PTS units into times.

  2. Saxon Milton

    To calculate the PTS of the frame that would immediately follow the final frame in the clip, I will either have to assume a particular frame rate, or find the change in PTS between frames and add this onto the PTS of the final frame in the clip. Which method do you think I should follow?

  3. Alan Noble reporter

    The first approach sounds brittle and the second approach sounds messy. Let’s just report the final PTS found in the clip, even if it is not the very end of the clip.

  4. Log in to comment