[Matroska-devel] Opus in Matroksa Cont.

Moritz Bunkus moritz at bunkus.org
Sat Jun 15 12:17:50 CEST 2013


Hey,

do it.

Now the question how to timestamp & mux it properly.

Let's assume a fictional OggOpus stream with a pre-skip of 40ms
containing exactly five packets. Let's further assume the Opus packets
are all 20ms long (meaning each covers 2400 granulepos values in Ogg)
except for the last one, that one's only 15ms long (1800 granulepos).
So the first Ogg packets would have the following granulepos values:

A0 @ Ogg(2400)
A1 @ Ogg(4800)
A2 @ Ogg(7200)
A3 @ Ogg(9600)
A4 @ Ogg(12400)

The first decoded we would actually hear would be the ones from P2
(4800 granulepos values in P0+P1 = 40ms of decoded data which a player
must discard accdoring to pre-skip).

This will translate into Matroska the following way if I'm not mistaken:

- We set CodecDelay to 40_000_000 = 40ms
- The Matroska blocks will look like this at TimecodeScale 1_000_000
(standard ms resolution):
A0 @ Matroska(0)
A1 @ Matroska(20)
A2 @ Matroska(40)
A3 @ Matroska(60)
A4 @ Matroska(80) with SilentPadding set to 5_000_000 (= 5ms of
silence at the end)

So the "logical" timestamps after decoding would be:

A0 @ decoded(-40ms)
A1 @ decoded(-20ms)
A2 @ decoded(0ms)
A3 @ decoded(20ms)
A4 @ decoded(40ms)
and playback would stop after 55ms have been output. Right?

Now. How do we interleave these with other packets? My example assumes
a progressive video track @ 25fps = 40ms per frame/Matroska block. We
have two options: interleave according to their block's timestamps
values or interleave according to their "logical"/decoded timestamp
values.

1. Interleaving according to the block's timestamps without
considering CodecDelay:

V0 @ Matroska(0)
A0 @ Matroska(0)
A1 @ Matroska(20)
V1 @ Matroska(40)
A2 @ Matroska(40)
A3 @ Matroska(60)
V2 @ Matroska(80)
A4 @ Matroska(80)...

2. Interleaving according to their "logical"/decoded timestamps taking
CodecDelay into account:

A0 @ Matroska(0)
A1 @ Matroska(20)
V0 @ Matroska(0)
A2 @ Matroska(40)
A3 @ Matroska(60)
V1 @ Matroska(40)
A4 @ Matroska(80)
V2 @ Matroska (80)

Judging from what Steve said a couple of days earlier ("As discussed,
PreSkip is now CodecDelay. (...) And I added a warning about large
values that may break proper muxing.") he seems to lean towards 1.
which I also do as it keeps the necessary changes to muxers and other
assorted tools (like mkvvalidator) to a minimum.

Kind regards,
mosu


More information about the Matroska-devel mailing list