The latest TTML spec is at http://www.w3.org/TR/ttml1/
Many of the timing semantics come from SMIL 2.1.
There are two parts to your answer: first, how do you compute the times for any particular content element; second, how do you relate those times to some other timeline for playback.
Computing time values
The computation of times depends on several things. First, can we assume that you are working in a timeBase and markerMode that allow for time calculations? This applies in all but one scenario, so if you have timeBase="media"
or timeBase="clock"
then you can. Also if you have timeBase="smpte"
and markerMode="continuous"
. The exception is if you are in smpte discontinuous
.
Second, you need to know the value of the timeContainer
attribute on the parent element. By default it is par
which means that times are computed relative to the parent element's time. If it is seq
then times are computed relative to their siblings, or to the parent for the first child.
In your example, let's assume the default of a par timeContainer with a continuous markerMode. Then the computed time of each p is its time added to the begin time of the parent div and clipped by the parent div's end time, giving:
<div begin="00:00:22.0 end ="00:00:30.0">
<p begin="0s" end="1s">Hi,</p> <-- 00:00:22 -> 00:00:23
<p begin="3s" end="5s">Hello</p> <-- 00:00:25 -> 00:00:27
<p begin="5s" end="10s">there?</p> <-- 00:00:27 -> 00:00:30 (cut off by parent)
</div>
Relating times to playback
The best part of the spec to look at here is probably Appendix N. The interpretation of your computed time values depends on the value of ttp:timeBase
:
clock
means they relate to some real clock somewhere, e.g. a UTC or GPS clock.
media
means they relate to the time in some other media like a video file. Time 0 relates to the beginning of the media generally, and if you need to map to frame values then you need to know the frame rate etc.
smpte
means they relate to time code in some other media. If you have a discontinuous
ttp:markerMode
then all times are just event markers: in that case when you see the time code value in the media, you begin or end the content element as needed.
Other stuff
I haven't mentioned evaluating the time expressions themselves - there are several syntaxes available including ticks at a tickrate, frames at a framerate, hours minutes and fractions of minutes etc.
Local times are also allowed.
In seq timeContainers siblings cannot overlap in time; in seq timeContainers they can.
It's not required to put times on both the div and the p in the example given. Also you can put times on body and span if you like.