TTML 字幕フォーマット
この形式が表現できること
- テキストのスタイル
- フォント、色、縁取り、影
- 画面内の位置指定
- 対応
- カラオケのタイミング
- 非対応
- 字幕ブロック内の改行
- 対応
- タイムライン
- 各字幕の開始と終了の時刻
- タイミングの精度
- 1 ms
- フレーム番号で保存されるタイミング
- 非対応
- 右から左に書く言語
- 対応
例
典型的な TTML ファイルと、そこから読み取れる内容
ファイル
<?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="en">
<head>
<styling>
<style xml:id="s1" tts:color="#FFFF00" tts:fontWeight="bold"/>
</styling>
<layout>
<region xml:id="bottom" tts:origin="10% 80%" tts:extent="80% 20%"/>
</layout>
</head>
<body>
<div>
<p begin="00:00:01.000" end="00:00:03.500" region="bottom" style="s1">Hello <span tts:fontStyle="italic">there</span>.</p>
<p begin="00:00:03.500" end="00:00:06.000" region="bottom">How are you?<br/>Fine, thanks.</p>
</div>
</body>
</tt>
ファイルの中身
2 cues, 3 lines of text
00:00:01.000 → 00:00:03.500
Hello there. [italic ×1]
[region="bottom" style="s1"]
00:00:03.500 → 00:00:06.000
How are you?
Fine, thanks.
[region="bottom"]
Outside the cues:
prolog an XML declaration and the namespace bindings, kept as they came in
styling 1 × <style> — "s1", the colour and weight a paragraph points at by name
layout 1 × <region> — "bottom", the origin and extent a paragraph points at by name
resolved the head is kept as it was written and is not applied here — a paragraph's style="s1" region="bottom" stays an attribute, not a colour or a screen position右側は変換後のファイルではありません。左側のファイルから本サイトが読み取った内容で、どの変換もここから始まります。
扱いにくい TTML ファイルでも読み取れる内容
ファイル
<?xml version="1.0" encoding="UTF-8"?>
<tt xmlns="http://www.w3.org/ns/ttml" xmlns:tts="http://www.w3.org/ns/ttml#styling">
<body>
<div begin="00:00:01.000" end="00:00:05.000">
<p>Inherits its timing from the div, which we do not resolve.</p>
<p begin="00:00:06.000" end="00:00:07.000">This one has its own timing.</p>
</div>
<!-- <p begin="00:00:08.000" end="00:00:09.000">commented out</p> -->
<div>
<p begin="00:00:10.000"/>
<p begin="00:00:11.000" end="00:00:12.000">Last one.</p>
</div>
</body>
</tt>
ファイルの中身
3 cues, 2 lines of text
00:00:06.000 → 00:00:07.000
This one has its own timing.
00:00:10.000 → 00:00:12.000
(no text)
00:00:11.000 → 00:00:12.000
Last one.
Outside the cues:
prolog an XML declaration and the namespace bindings, kept as they came in
head none — no <styling> and no <layout>, and no paragraph points at one either
comments the commented-out <p> stays a comment, in the place it was written
divs the timings on an enclosing <div> are not pushed down onto the paragraphs inside it
Reported while reading — repaired or skipped, never silently:
1 × paragraphs with no readable begin time of their own (they were skipped — see the note about timing inherited from an enclosing div)
1 × paragraphs with neither an end time nor a duration of their own (their end times were generated)実際のファイルには BOM、Windows の改行コード、タイムコード前の余分な行、まったく読めないタイムコードがあります。どれも例外にはならず、理解できない部分は黙って捨てずに報告されます。
TTML (Timed Text) を他の形式に変換
いずれもブラウザ内で完結します。ラベルには、その方向で何が失われるかが開く前に示されています。
- タイミング
- スタイル
- 位置
- 精度
- 形式固有の内容
- スタイル
- 位置
- フレームレート
- 形式固有の内容
- タイミング
- スタイル
- 位置
- 改行
- 形式固有の内容
この形式への変換
- SubRip (SRT) → TTML (Timed Text)
- WebVTT (VTT) → TTML (Timed Text)
- Advanced SubStation Alpha (ASS) → TTML (Timed Text)
- SubStation Alpha (SSA) → TTML (Timed Text)
- YouTube SBV → TTML (Timed Text)
- SAMI (SMI) → TTML (Timed Text)
- LRC Lyrics → TTML (Timed Text)
- MicroDVD → TTML (Timed Text)
- SubtitleMatrix JSON → TTML (Timed Text)
- Plain Text (TXT) → TTML (Timed Text)
- CSV Spreadsheet → TTML (Timed Text)
TTML(Timed Text)は本サイトが扱う字幕形式の 1 つです。このページはそのリファレンスで、何を保存でき、何を保存できず、どの形式へ変換できるかをまとめています。TTML は XML で書かれ、時刻はミリ秒まで指定でき、フレームレートや SMPTE のタイムコードによる指定も選べます。
上の表がすべてで、隠れた機能一覧はありません。「いいえ」の行は、TTML へ変換するときに失われるものそのものです。下に並ぶ各変換ページは、ファイルを開く前にそのことを示します。
変換はすべてブラウザ内で実行されます。ファイルはアップロードされず、登録も不要です。NDA の下にある素材、患者記録、放送前の素材では、この点が重要になります。
よくある質問
TTML ファイルとは何ですか?
.ttml は TTML(Timed Text)です。放送・配信業界が字幕を書くための XML 文書で、head が名前付きスタイルと領域を宣言し、p 要素が字幕本体になります。配信の字幕パイプラインで使われ、SMPTE-TT と IMSC プロファイルもこの上に作られています。
TTML はスタイルを保存できますか?
はい、他の形式より多く保存できます。フォント、サイズ、色、縁取り、余白のスタイル表に加え、本文内の区間指定により、名前付きスタイルなしでも 1 行を太字・着色・配置できます。カラオケのタイミングは保存しません。TTML が記録するのは cue の開始と終了で、音節がいつ光るかではありません。ここでは styling 要素が名前付きスタイル(tts:color、tts:fontWeight、tts:fontFamily)を、layout 要素が名前付き領域(tts:origin、tts:extent)を持ち、p 要素は style="s1" のように名前で参照します。
TTML の各 cue は開始と終了の両方を持ちますか?
はい。時刻は 00:00:04.126 のように書け、ミリ秒まで正確です。短い cue、長い cue、次の cue と重なる cue も、何も暗黙の前提なしで表現できます。フレームレート指定があるファイルでは 00:00:07:00 のようなフレーム表記も読めます。
TTML はどの形式に変換すればよいですか?
本サイトのどの形式も TTML のすべては受け取れないため、無料の方向はありません。各変換ページが独自の損失一覧を示します。よく見る形式かどうかではなく、どの損失なら受け入れられるかで選んでください。
TTML は cue の外に何を保存しますか?
XML 宣言と head 全体です。名前付きスタイルの styling 表、名前付き領域の layout 表、metadata が入り、各 p 要素は名前で参照します。1 か所を編集すれば全字幕の見た目を変えられます。これらの参照は cue モデルではなく段落に載るため、参照先を持たない形式への変換では損失として報告されます。