Timed Text Markup Language

OpenSaveXMLStyled

The W3C's XML for subtitles and captions, and what broadcasters and streaming services ask for. DFXP was the name of its first profile, and many files still carry it. IMSC, EBU-TT-D and Apple's iTT are TTML too, each with its own habits.

At a glance

Extension.ttml
Media typeapplication/ttml+xml
SpecificationW3C, Timed Text Markup Language 1 (TTML1), a Recommendation. TTML2 extends it; IMSC and EBU-TT-D are subsets for distribution.
Time precisionAny: fractions of a second, frames or ticks
Text encodingDeclared in the XML. UTF-8 almost always.
StylingNamed styles and tts: attributes: font, size, colour, background, italic, bold, underline, line-through, outline
PositioningRegions: boxes placed and sized anywhere on the picture
SpeakersAgents (ttm:agent), named in the head
In containersMP4 as stpp (ISO/IEC 14496-30), in DASH, CMAF and HLS streams

Anatomy of a file

An XML document: a head that names styles and regions, and a body of paragraphs, one for each subtitle.

<tt xml:lang="en" …>
<head>styles, regions</head>
<body><div>
<p begin="00:00:23.000"
   end="00:00:24.500">
You're a jerk,<br/>Thom.</p>
</div></body>
</tt>
  1. 1 · Root

    <tt>, with TTML's namespaces, the language, and the clock the times count by: ttp:frameRate, ttp:tickRate.

  2. 2 · Head

    Named styles, the regions of the screen, and who speaks.

  3. 3 · Timing

    Each paragraph's begin, and its end or dur.

  4. 4 · Text

    The subtitle. Spans style parts of it, and <br/> breaks the line.

Times

TTML writes a time in more ways than any other subtitle format:

Written What it is
00:00:23.500 Hours, minutes, seconds and a fraction
00:00:23:12 Frames after the seconds: twelve at the file's ttp:frameRate
23.5s, 23500ms, 1h An offset in hours, minutes, seconds or milliseconds
564f Frames
235000000t Ticks, ttp:tickRate of them to the second

Times count from what holds them. A paragraph's begin counts from the start of its <div> and its <body>, and a paragraph with no end of its own ends with them.

Styles

A style is a set of tts: attributes. Text takes them in order: from its region, then from the body, div, paragraph and span around it. Each element takes the styles it names (style="s1 s2", and the ones those name), then its own attributes.

Attribute Effect In Subtitld
tts:fontStyle="italic" Italic Kept
tts:fontWeight="bold" Bold Kept
tts:textDecoration="underline", "lineThrough" Underline, strikeout Kept
tts:color Text colour: a name, #rrggbb, #rrggbbaa or rgb() Kept, without its transparency
tts:displayAlign, tts:textAlign Where the text sits in its region Kept, as one of nine places
tts:fontFamily, tts:fontSize Font and size Not kept
tts:backgroundColor, tts:textOutline A box behind the text, an outline Not kept
<set> A style that changes over time Not kept

Regions

A region is a box on the picture, placed by tts:origin and sized by tts:extent. Inside it, tts:displayAlign puts the text at the top, middle or bottom (before, center, after), and tts:textAlign to one side or in the centre.

<region xml:id="top"
        tts:origin="10% 10%"
        tts:extent="80% 80%"
        tts:displayAlign="before"/>

Subtitld works out where the text lands, whether the region is measured in percentages, pixels or cells, and takes the nearest of the nine places that SubRip's {\an1} to {\an9} name. When it writes a file, each place it uses is a region of that name: bottom, top, top-left…

When a file does not say. TTML's own defaults put text at the top left of its region, but players show it at the bottom and centred, and so does Subtitld. It also reads textAlign="start" in a region with no size or place as centred: files written with pycaption, older Subtitld's among them, put it on every region.

Profiles

Most TTML is written to a profile: a subset of the language, with rules of its own. Subtitld reads each of them as TTML.

Profile Where it is used Its habits
DFXP TTML's first profile, and the extension .dfxp Older files in the namespace http://www.w3.org/2006/10/ttaf1
IMSC 1 Streaming over DASH, CMAF and HLS The W3C's profile for subtitles and captions online
EBU‑TT‑D European broadcasters' online players Elements often written with a prefix: <tt:p>
SMPTE‑TT American television's captions online SMPTE's additions, for captions carried over from broadcast
iTT (.itt) Deliveries to Apple's iTunes Store and Apple TV Times in frames (ttp:timeBase="smpte")

TTML in Subtitld

Kept in the .ttml
  • Every subtitle's text and line breaks
  • Italic, bold, underline, strikeout and colour
  • Where it sits on the screen
  • Speakers, as agents
  • Start and end, to the millisecond, in order
Nowhere to go
  • Fonts, sizes, backgrounds and outlines line by line
  • A region's exact size and place
  • Styles that change over time, ruby, image subtitles
  • Translations beside the original, dubs, speakers' faces

Save a .usfx project to keep what is Subtitld's.

Opening a TTML file

Subtitld opens .ttml, .dfxp, .itt and .xml, and:

  • reads TTML however it is written: in its namespace, in the old DFXP one, or with tt: before every element;
  • reads every form of time, each counted from the div and body it is in;
  • follows styles as TTML applies them, keeping italic, bold, underline, strikeout and any colour other than white;
  • puts each subtitle where its region shows it;
  • takes agents as speakers, ready for dubbing, and the file's xml:lang as the project's language;
  • reads the encoding the file declares, and HTML's entities such as &nbsp;.

A file that is not well-formed XML opens with a message giving the line and the column. A file that is not TTML at all says so.

Exporting TTML

Subtitld's export dialog with TTML chosen and the speakers written as agents

Export, then Subtitles and TTML or DFXP, offers:

  • TextThe original, a translation, or both, the translation below.
  • Speaker namesLeft out, before the text (Thom: …), or as agents (ttm:agent), TTML's own way.
  • FormattingKept, or removed.
  • Shift timesEvery subtitle earlier or later by the same amount.
  • LookWhite with a black outline, or as Subtitld's preview draws it: its font, colour and translucent box.

The file is TTML 1 in UTF-8. Times are written as 00:00:23.000, each place the subtitles sit as a region, formatting as spans, and line breaks as <br/>. Its xml:lang is the language of the text it holds. TTML and DFXP get the same file; only the extension differs.

TTML or WebVTT?

WebVTT for a <track> on a web page: browsers read it themselves. TTML for broadcasters, for streaming services that ask for it, and for players that read it, such as dash.js and Shaka Player. The WebVTT page has the rest.

Trivia

2010

TTML 1.0 became a W3C Recommendation in November 2010, after drafts named for its first profile: the Distribution Format Exchange Profile, DFXP.

ttaf1

The old namespace, http://www.w3.org/2006/10/ttaf1, is from the 2006 drafts, when TTML was the Timed Text Authoring Format. Files still carry it.

Emmy

In 2016 the W3C received a Technology & Engineering Emmy for TTML, beside HBO, Netflix, Telestream and SMPTE.

Related formats

Have a .ttml to fix?

Open it in Subtitld with the video and retime it on the waveform.

Download Subtitld