TTML / DFXP to VTT converter for Chromecast
Streaming services and broadcast tools often deliver subtitles as TTML or DFXP (.ttml, .dfxp, .xml). Chromecast's default player and most web players read WebVTT (.vtt). Open or drop the file. This page reads clock, frame and tick times, keeps italics, bold, underline and line breaks, checks every subtitle and saves a .vtt. Everything happens in this page; the file isn't uploaded.
What the TTML reader understands
- Times: clock times (
00:00:01.500), frames (00:00:01:12, usingttp:frameRate), ticks (15000000t, usingttp:tickRate) and offsets (1.5s,1500ms).durworks in place ofend, and times on a<div>or<body>offset the subtitles inside it. - Kept:
<br/>line breaks, italic, bold and underline from inline attributes or named styles, and subtitles aligned to the top. - Dropped: colours, fonts, backgrounds and exact regions. Image-based subtitles (SMPTE-TT with PNGs) have no text to convert.
What the converter fixes and checks
- Encoding. Many .srt files aren't UTF-8. Turkish, Polish, Russian, Greek, Arabic, Hebrew, Chinese, Japanese and Korean files are often saved in an older encoding, and the TV then shows broken letters. The page guesses the encoding from the bytes. If letters still look wrong, pick another one from the list. The .vtt is always saved as UTF-8.
- Tags. WebVTT keeps
<i>,<b>and<u>.<font>tags are removed, because WebVTT has no font tag. ASS position codes such as{\an8}become "show at the top"; other{\…}codes are removed. A bare&or<in the text is escaped so it doesn't break the file. - Cues. It reports blocks without a valid time line, cues that end before they start, empty cues, cues out of order (they're sorted) and overlapping cues (kept; that's allowed). Line numbers point to your original file.
- It doesn't translate, fix spelling or sync subtitles that drift slowly over the film.
Hosting the .vtt for Chromecast
The TV downloads the subtitle file itself, from its own player page on www.gstatic.com. Three things have to be right on the server that hosts the file:
- CORS: the response needs
Access-Control-Allow-Origin: *(or the receiver's origin). Without it the TV silently shows no subtitles. - Content type:
text/vttis the right type for WebVTT. Some players refuse files served astext/plainorapplication/octet-stream. - HTTPS: the TV's player page is https, so a subtitle file on plain http is blocked.
nginx
location ~* \.vtt$ {
types { text/vtt vtt; }
add_header Access-Control-Allow-Origin "*" always;
}Apache (.htaccess, needs mod_headers)
AddType text/vtt .vtt
<FilesMatch "\.vtt$">
Header set Access-Control-Allow-Origin "*"
</FilesMatch>Amazon S3
Bucket → Permissions → Cross-origin resource sharing (CORS):
[
{
"AllowedOrigins": ["*"],
"AllowedMethods": ["GET", "HEAD"],
"AllowedHeaders": ["*"],
"MaxAgeSeconds": 3000
}
]
Upload with the right type:
aws s3 cp subtitles.vtt s3://YOUR-BUCKET/subtitles.vtt --content-type text/vtt
Cloudflare R2
Bucket → Settings → CORS policy:
[
{
"AllowedOrigins": ["*"],
"AllowedMethods": ["GET", "HEAD"],
"AllowedHeaders": ["*"],
"MaxAgeSeconds": 3600
}
]
Upload with the right type:
npx wrangler r2 object put YOUR-BUCKET/subtitles.vtt --file subtitles.vtt --content-type text/vtt --remote
Cloudflare Pages (_headers file)
/*.vtt Access-Control-Allow-Origin: *
Pages already serves .vtt files as text/vtt.
Check a hosted .vtt
Paste the file's address. This page fetches it without cookies, from a different site than the one hosting it, the way the TV does, and checks the type and the content.
No file at hand? Check our sample file.
Have an .srt file? Use the SRT to VTT converter. Castmate for Chrome sends a page's subtitles to the TV and converts SRT automatically. For a whole stream, use the Chromecast stream checker. If subtitles still don't show, see subtitles not showing on the TV. Add Castmate to Chrome