container/mts: Function to extract PTS times from MTS
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)
-
reporter -
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?
-
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.
-
Alright no worries.
-
- changed status to resolved
resolved in PR #197
- Log in to comment
Further more, the mts package should export the PTS resolution (1/90000) so callers can convert PTS units into times.