-
Notifications
You must be signed in to change notification settings - Fork 44
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
Draft: Proposal to add some rational number in timestamps #425
Open
robUx4
wants to merge
1
commit into
master
Choose a base branch
from
timestamp-fraction
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -577,6 +577,32 @@ Some general notes for a program: | |
that it started with. Using a slightly lower timestamp scale factor can help here in | ||
that it removes the need for proper rounding in the conversion from sample number to `Raw Timestamp`. | ||
|
||
## Rational Number and Nanoseconds | ||
|
||
Historically timestamps in Matroska were stored in nanoseconds precision. | ||
The `TimestampScale` would reduce the size of each value stored in the file by dividing each real timestamps by a certain value. | ||
For many sampling frequencies, that means rounding the values and losing precision. | ||
There are `TimestampNumerator` and `TimestampDenominator` to fix this precision loss. | ||
They override the value of `TimestampScale` in all places it is used. | ||
|
||
This formula remains but there is no rounding involved anymore: | ||
|
||
(a + b) * c | ||
|
||
a = `Block`'s Timestamp | ||
b = `Cluster`'s Timestamp | ||
c = `TimestampScale` | ||
|
||
For compatibility with older readers that don't understand these elements, the `TimestampScale` value *MUST* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. More info about the |
||
be the rounded values of `TimestampNumerator` divided by `TimestampDenominator` in nanoseconds. | ||
|
||
This fraction may not be usable in most cases. It works well with files having a single Track. | ||
It only works when Tracks have a sampling frequency which is highly divisible. | ||
For example even a video track of 1/25000 (PAL) with audio of 1/48000 (DAT) doesn't work well. The reduced fraction gives 25/48. | ||
A `TimestampNumerator` of 1 and `TimestampDenominator` of 25\*48000 would give ticks that hit on each clock. | ||
But the amount of samples possible in a Block/SimpleBlock is stored on 16 bits or 65536 values. So the duration possible in a Cluster would be 65536 / (25\*48000) or 54.6 ms. Which is not enough to be efficient storage. | ||
It would only work if audio samples were packed with a multiple of 25 samples, which is usually not the case. | ||
|
||
## TrackTimestampScale | ||
|
||
The `TrackTimestampScale Element` is used align tracks that would otherwise be played at | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
TrackTimestampScale
is revived it should be mentioned its value MUST be the rounded value in nanoseconds of this fraction.