[Matroska-devel] RFC 80085 - Required TimecodeScale for sample accurate seeking
Steve Lhomme
steve.lhomme at free.fr
Tue Jan 20 23:24:49 CET 2004
Now let's see another example. A file using only audio (MKA file).
You only have one audio track at 44100 Hz.
My point is that the Global TimecodeScale can remain at 1,000,000. But
the Track TimecodeScale should be 1000/44100 = 0,022676...
So imagine you have Audio Blocks of 1152 samples. Here is a list Of
values in the first Cluster :
Block # Timecode 1st Smpl Final Timecode Block Timecode
1 0 0 0
2 1152/44100 s 26,122,449ns 1152
3 2*1152/44100 s 52,244,898ns 2304
4 3*1152/44100 s 78,367,347ns 3456
......
(using formula AudioTimecode = int16 * float * uint64)
So for each Block you know exactly the sample count on which starts the
Block.
This way, if you want to seek to sample 2353 you compute the timecode :
AudioTimecode = 2353/44100 = 53,356,009ns
So you know that the Block to use is the Block # 3 in Cluster # 1. And
with the sample count, you know what is the exact sample you're looking
for (the 50th).
I don't know if the computing of the Block Timecode might lead to
rounding errors...
More information about the Matroska-devel
mailing list