Skip to content
Free Subtitle Converter
Language
Color theme
Support us

XML subtitles explained: TTML, DFXP and IMSC

What TTML, DFXP and IMSC subtitle files are, how their timings work, and exactly what this site's converter reads from them and what it leaves out.

By Syed Peera Saheb · Published

The short answer

TTML, DFXP and IMSC are XML subtitle files built on the W3C's Timed Text Markup Language. DFXP is an earlier name for TTML, and IMSC is a profile of it used for streaming and broadcast delivery.

If you have a .ttml, .dfxp or .xml subtitle file and need SRT or VTT, the converter on this site can read its text, timings, line breaks and italic, bold and underline. It does not keep positions, colors or fonts, and it does not read every XML file that contains captions.

One family, several names

TTML is a W3C standard for timed text. While it was being written, it was called DFXP, the Distribution Format Exchange Profile, and the TTML 1 specification still notes that the older name survives in profile names and file extensions. In practice a .dfxp file and a .ttml file hold the same kind of document. TTML2 is the second version and adds more features.

Because TTML is large, industries define profiles: subsets that say which features a file may use. IMSC, the Internet Media Subtitles and Captions profile, is one of the most common. Its current versions define a text-only profile and an image-only profile. EBU-TT is a profile used by European broadcasters, and SMPTE-TT is used in American broadcasting. All of them start with a <tt> root element.

What a TTML file looks like

A TTML document has a head and a body. The head can define styles, such as a font or color, and regions, which are areas of the screen. The body holds paragraphs, <p> elements, each with a begin and end time and the caption text. A <br/> starts a new line, and <span> elements style or time parts of a line.

A short TTML file
<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling" xmlns:ttp="http://www.w3.org/ns/ttml#parameter" ttp:tickRate="10000000">
  <head>
    <styling><style xml:id="it" tts:fontStyle="italic" tts:color="yellow"/></styling>
    <layout><region xml:id="top" tts:origin="10% 5%" tts:extent="80% 20%"/></layout>
  </head>
  <body>
    <div>
      <p begin="12000000t" end="35000000t" region="top">Hello<br/><span style="it">there</span></p>
    </div>
  </body>
</tt>

How TTML timings work

TTML allows several ways of writing a time. Clock times look like 00:00:01.200, or 00:00:01:05 with a frame number at the end. Offset times are a number with a unit: 1.2s, 1200ms, 30f for frames, or 12000000t for ticks. Ticks are common in files from streaming services; the root element's tickRate says how many ticks make a second, so with a tick rate of 10,000,000, 12000000t is 1.2 seconds.

Times can also be relative. A div can have its own begin time that the paragraphs inside it add to, a paragraph can give a duration instead of an end time, and a paragraph without times can take them from its spans. This is why simple search-and-replace tools often get TTML timings wrong.

What this site reads

The converter recognizes TTML by its <tt> root element, whatever the file extension, so .ttml, .dfxp and .xml files all open. The example above becomes one caption from 1.2 to 3.5 seconds with two lines, the second in italics. In detail, it reads:

  • Clock times with fractions or frames, and offset times in hours, minutes, seconds, milliseconds, frames and ticks.
  • The frameRate, frameRateMultiplier, subFrameRate and tickRate settings on the root element. Without a tick rate, it derives one from the frame rate, or uses one tick per second, as the specification describes.
  • Begin, end and dur on paragraphs and spans, with begin times of the enclosing body and divs added up.
  • Line breaks written as <br/>.
  • Italic, bold and underline, whether they are set directly on an element or through a named style.
  • Elements with a namespace prefix, such as <tt:p> in EBU-TT and some IMSC files. Metadata, such as notes for editors, is skipped and never becomes caption text.

What it leaves out

The converter keeps the words and timings and drops presentation. Regions and positions, colors, fonts, sizes, backgrounds, outlines and text direction settings are not carried over. If a file shows two paragraphs at the same time in different regions, for example two speakers at the top and bottom, they become two overlapping captions; the subtitle checker will point them out.

Some XML caption files are not TTML at all, and the page says it does not recognize them as subtitles. That includes YouTube's own timedtext XML, whose root element is <timedtext> or <transcript> rather than <tt>. Image-based IMSC files, which store pictures of the text, contain no text to read. Unusual timing modes, such as SMPTE drop-frame timecodes, are not handled specially, so check a few captions near the end of the preview against the video.

What it writes

When you convert to TTML or DFXP, the converter writes a simple TTML 1 document: every caption becomes a paragraph with begin and end clock times in milliseconds, line breaks become <br/>, and italic, bold and underline become spans with the matching styling attribute. There is no head with styles or regions, so players use their default look. The DFXP option writes the same document with a .dfxp extension.

The language attribute on the root element is left empty, because the converter cannot know which language your subtitles are in. Some platforms require it. If yours does, open the file in a text editor and fill in xml:lang with a code such as en or es before you upload it.

The file the converter writes from the example
<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling" xml:lang="">
  <body>
    <div>
      <p begin="00:00:01.200" end="00:00:03.500">Hello<br/><span tts:fontStyle="italic">there</span></p>
    </div>
  </body>
</tt>

Converting TTML or DFXP to SRT or VTT

Converting takes a few seconds, and the file stays on your device.

  • Open the TTML to SRT or DFXP to SRT converter, or the main converter, and choose your .ttml, .dfxp or .xml file.
  • Check the summary. It tells you how many captions were found and whether any paragraphs had timings that could not be read.
  • Choose the output format, such as SRT or VTT, and look through the preview.
  • Play the result with your video and compare a caption near the start and one near the end, in case the file used a timing mode the converter does not handle.
  • Download the file. It is saved as UTF-8.

When to use TTML, and when not to

Use TTML or DFXP when a platform, streaming service or broadcaster asks for it; their delivery specifications usually name a profile, and a plain TTML 1 file may or may not meet it. For everyday use in players, editors and video platforms, SRT or WebVTT is simpler and more widely supported. If you receive a TTML file and only want to watch or edit it, convert it to SRT.

Keep the original file either way. Converting to SRT drops regions and styling for good, so if you later need to deliver TTML again with its original positions, you will want the source rather than a TTML file rebuilt from SRT.

Common questions

Is DFXP the same as TTML? For practical purposes, yes. DFXP was the name used while TTML was being drafted, and the converter treats both the same way.

Why does my .xml file say it is not a subtitle file? Either it is not TTML, for example YouTube timedtext XML, or it does not contain a <tt> root element. The converter does not read those files.

Will the converted SRT keep the position of each caption? No. SRT has no standard way to place captions, and the converter does not carry TTML regions into any format.

Open the subtitle converter
Buy me a coffee