You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add TimestampNumerator/TimestampDenominator to override the value of TimestampScale
This allows sample precision of each timestamp is some cases, mostly single track files.
Wherever TimestampScale was used, if this fraction is found, it should be used
instead.
Copy file name to clipboardExpand all lines: ebml_matroska.xml
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -88,8 +88,16 @@ The format depends on the ChapProcessCodecID used; see (#chapprocesscodecid-elem
88
88
<documentationlang="en"purpose="definition">Timestamp scale in nanoseconds (1.000.000 means all timestamps in the Segment are expressed in milliseconds).</documentation>
<documentationlang="en"purpose="definition">Timestamp numerator to apply instead of the TimestampScale, when the TimestampDenominator is present as well.</documentation>
<documentationlang="en"purpose="definition">Timestamp denominator to apply instead of the TimestampScale, when the TimestampNumerator is present as well.</documentation>
<documentationlang="en"purpose="definition">Duration of the Segment in nanoseconds based on TimestampScale.</documentation>
100
+
<documentationlang="en"purpose="definition">Duration of the Segment in nanoseconds based on TimestampScale and TimestampNumerator/TimestampDenominator in v5.</documentation>
<documentationlang="en"purpose="definition">Absolute timestamp of the cluster (based on TimestampScale).</documentation>
121
+
<documentationlang="en"purpose="definition">Absolute timestamp of the cluster (based on TimestampScale and TimestampNumerator/TimestampDenominator in v5).</documentation>
<documentationlang="en"purpose="definition">The duration of the Block (based on TimestampScale).
183
+
<documentationlang="en"purpose="definition">The duration of the Block (based on TimestampScale and TimestampNumerator/TimestampDenominator in v5).
176
184
The BlockDuration Element can be useful at the end of a Track to define the duration of the last frame (as there is no subsequent Block available),
177
185
or when there is a break in a track like for subtitle tracks.</documentation>
178
186
<implementation_notenote_attribute="minOccurs">BlockDuration **MUST** be set (minOccurs=1) if the associated TrackEntry stores a DefaultDuration value.</implementation_note>
Copy file name to clipboardExpand all lines: notes.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -577,6 +577,32 @@ Some general notes for a program:
577
577
that it started with. Using a slightly lower timestamp scale factor can help here in
578
578
that it removes the need for proper rounding in the conversion from sample number to `Raw Timestamp`.
579
579
580
+
## Rational Number and Nanoseconds
581
+
582
+
Historically timestamps in Matroska were stored in nanoseconds precision.
583
+
The `TimestampScale` would reduce the size of each value stored in the file by dividing each real timestamps by a certain value.
584
+
For many sampling frequencies, that means rounding the values and losing precision.
585
+
There are `TimestampNumerator` and `TimestampDenominator` to fix this precision loss.
586
+
They override the value of `TimestampScale` in all places it is used.
587
+
588
+
This formula remains but there is no rounding involved anymore:
589
+
590
+
(a + b) * c
591
+
592
+
a = `Block`'s Timestamp
593
+
b = `Cluster`'s Timestamp
594
+
c = `TimestampScale`
595
+
596
+
For compatibility with older readers that don't understand these elements, the `TimestampScale` value *MUST*
597
+
be the rounded values of `TimestampNumerator` divided by `TimestampDenominator` in nanoseconds.
598
+
599
+
This fraction may not be usable in most cases. It works well with files having a single Track.
600
+
It only works when Tracks have a sampling frequency which is highly divisible.
601
+
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.
602
+
A `TimestampNumerator` of 1 and `TimestampDenominator` of 25\*48000 would give ticks that hit on each clock.
603
+
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.
604
+
It would only work if audio samples were packed with a multiple of 25 samples, which is usually not the case.
605
+
580
606
## TrackTimestampScale
581
607
582
608
The `TrackTimestampScale Element` is used align tracks that would otherwise be played at
0 commit comments