Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle PTS rollovers #130

Closed
slifty opened this issue Jun 21, 2021 · 2 comments · Fixed by #131
Closed

Handle PTS rollovers #130

slifty opened this issue Jun 21, 2021 · 2 comments · Fixed by #131

Comments

@slifty
Copy link
Member

slifty commented Jun 21, 2021

Task

Description

MPEG PTS and DTS have a limit, and when that limit is reached they roll over.

I'm not certain if the rollover is part of the MPEGTS standard (e.g. it will always roll over at 2^33) or if it is up to the encoding agent to determine when to initiate a rollover. Handling rollovers is non-trivial for that reason, so this issue will require a bit of R&D before implementation.

The solution needs to work for stream and file based videos (e.g. a file with 2 weeks of video would have a rollover as well). This means that the rollover should be in terms of the origin that is passed to the video ingestion appliance (as opposed to some kind of logic like if PTS went down, use the current time as origin).

@slifty
Copy link
Member Author

slifty commented Jun 21, 2021

Some relevant threads related to timestamp rollover as I find them:

First, transport streams were originally intended for very long broadcasts (days or weeks. Think television stations). TS uses 33 bits to store 90kHz ticks. This makes timesamp rollovers very common (about once a day). Because the timestamp rolls over so frequently, It is generally not a good idea to rely on the time stamps as anything other than an arbitrary tick on a ever moving clock with a start time at an unknown point in the past. Think of an analog clock, and remove all markings. Without the orientation, you can not use it to tell time. But you can still use it to measure time. In other words the timestamps only have meaning relative to other timestamps in the stream. They do not exist for human convenience. They exist so the decoder can do its job.

@slifty
Copy link
Member Author

slifty commented Jun 21, 2021

It looks like the answer is to detect discontinuity and add 2^33 / 90000 ms to the "origin time" whenever a rollover occurs.

slifty added a commit that referenced this issue Jun 30, 2021
MPEG-TS stores packet positions using 33 bits, which means that for long
running streams the position will rollover approximately every 26.5 hours.

TV Kitchen appliances need to be able to ingest videos and streams of
any length, which means when rollovers occur the appliance needs to
properly update the origin times to account for the rollover.

Issue #130
slifty added a commit that referenced this issue Jun 30, 2021
MPEG-TS stores packet positions using 33 bits, which means that for long
running streams the position will rollover approximately every 26.5 hours.

TV Kitchen appliances need to be able to ingest videos and streams of
any length, which means when rollovers occur the appliance needs to
properly update the origin times to account for the rollover.

Issue #130
slifty added a commit that referenced this issue Jul 2, 2021
The new appliance-core fixes a bug where video ingestion would fail
to update timestamps after 26.5 hours.

Issue #130
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant